Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 162217
Collapse All | Expand All

(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCEnumerator.java (-3 / +2 lines)
Lines 13-19 Link Here
13
13
14
import org.eclipse.cdt.core.CCorePlugin;
14
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.IASTName;
17
import org.eclipse.cdt.core.dom.ast.IEnumerator;
16
import org.eclipse.cdt.core.dom.ast.IEnumerator;
18
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.IType;
19
import org.eclipse.cdt.internal.core.pdom.PDOM;
18
import org.eclipse.cdt.internal.core.pdom.PDOM;
Lines 32-40 Link Here
32
	
31
	
33
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
32
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
34
	
33
	
35
	public PDOMCEnumerator(PDOM pdom, PDOMNode parent, IASTName name, PDOMCEnumeration enumeration)
34
	public PDOMCEnumerator(PDOM pdom, PDOMNode parent, IEnumerator enumerator, PDOMCEnumeration enumeration)
36
			throws CoreException {
35
			throws CoreException {
37
		super(pdom, parent, name);
36
		super(pdom, parent, enumerator.getNameCharArray());
38
		pdom.getDB().putInt(record + ENUMERATION, enumeration.getRecord());
37
		pdom.getDB().putInt(record + ENUMERATION, enumeration.getRecord());
39
		enumeration.addEnumerator(this);
38
		enumeration.addEnumerator(this);
40
	}
39
	}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java (-23 / +8 lines)
Lines 15-31 Link Here
15
15
16
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.DOMException;
18
import org.eclipse.cdt.core.dom.ast.IASTName;
19
import org.eclipse.cdt.core.dom.ast.IASTNode;
20
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
21
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
22
import org.eclipse.cdt.core.dom.ast.IBinding;
23
import org.eclipse.cdt.core.dom.ast.IFunction;
18
import org.eclipse.cdt.core.dom.ast.IFunction;
24
import org.eclipse.cdt.core.dom.ast.IFunctionType;
19
import org.eclipse.cdt.core.dom.ast.IFunctionType;
25
import org.eclipse.cdt.core.dom.ast.IParameter;
20
import org.eclipse.cdt.core.dom.ast.IParameter;
26
import org.eclipse.cdt.core.dom.ast.IScope;
21
import org.eclipse.cdt.core.dom.ast.IScope;
27
import org.eclipse.cdt.core.dom.ast.IType;
22
import org.eclipse.cdt.core.dom.ast.IType;
28
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
29
import org.eclipse.cdt.internal.core.Util;
23
import org.eclipse.cdt.internal.core.Util;
30
import org.eclipse.cdt.internal.core.pdom.PDOM;
24
import org.eclipse.cdt.internal.core.pdom.PDOM;
31
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
25
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
Lines 60-84 Link Here
60
	 */
54
	 */
61
	public static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9;
55
	public static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9;
62
	
56
	
63
	public PDOMCFunction(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
57
	public PDOMCFunction(PDOM pdom, PDOMNode parent, IFunction function) throws CoreException {
64
		super(pdom, parent, name);
58
		super(pdom, parent, function.getNameCharArray());
59
		
65
		try {
60
		try {
66
			IASTNode parentNode = name.getParent();
61
			IParameter[] params = function.getParameters();
67
			if (parentNode instanceof IASTStandardFunctionDeclarator) {
62
			pdom.getDB().putInt(record + NUM_PARAMS, params.length);
68
				IASTStandardFunctionDeclarator funcDecl = (IASTStandardFunctionDeclarator)parentNode;
63
			for (int i = 0; i < params.length; ++i) {
69
				IASTParameterDeclaration[] params = funcDecl.getParameters();
64
				setFirstParameter(new PDOMCParameter(pdom, this, params[i]));
70
				pdom.getDB().putInt(record + NUM_PARAMS, params.length);
71
				for (int i = 0; i < params.length; ++i) {
72
					IASTParameterDeclaration param = params[i];
73
					IASTName paramName = param.getDeclarator().getName();
74
					IBinding binding = paramName.resolveBinding();
75
					IParameter paramBinding = (IParameter)binding;
76
					setFirstParameter(new PDOMCParameter(pdom, this, paramName, paramBinding));
77
				}
78
			} else if(parentNode instanceof ICASTKnRFunctionDeclarator) {
79
				fail(); // aftodo
80
			}
65
			}
81
			pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(name.resolveBinding()));
66
			pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(function));
82
		} catch(DOMException e) {
67
		} catch(DOMException e) {
83
			throw new CoreException(Util.createStatus(e));
68
			throw new CoreException(Util.createStatus(e));
84
		}
69
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCParameter.java (-3 / +2 lines)
Lines 15-21 Link Here
15
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
17
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
18
import org.eclipse.cdt.core.dom.ast.IASTName;
19
import org.eclipse.cdt.core.dom.ast.IParameter;
18
import org.eclipse.cdt.core.dom.ast.IParameter;
20
import org.eclipse.cdt.core.dom.ast.IScope;
19
import org.eclipse.cdt.core.dom.ast.IScope;
21
import org.eclipse.cdt.core.dom.ast.IType;
20
import org.eclipse.cdt.core.dom.ast.IType;
Lines 44-52 Link Here
44
		super(pdom, record);
43
		super(pdom, record);
45
	}
44
	}
46
45
47
	public PDOMCParameter(PDOM pdom, PDOMNode parent, IASTName name, IParameter param)
46
	public PDOMCParameter(PDOM pdom, PDOMNode parent, IParameter param)
48
			throws CoreException {
47
			throws CoreException {
49
		super(pdom, parent, name.toCharArray());
48
		super(pdom, parent, param.getNameCharArray());
50
		
49
		
51
		Database db = pdom.getDB();
50
		Database db = pdom.getDB();
52
51
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java (-15 / +11 lines)
Lines 102-108 Link Here
102
		if (binding instanceof IParameter)
102
		if (binding instanceof IParameter)
103
			// skip parameters
103
			// skip parameters
104
			return null;
104
			return null;
105
105
		
106
		PDOMBinding pdomBinding = adaptBinding(binding);
106
		PDOMBinding pdomBinding = adaptBinding(binding);
107
		try {
107
		try {
108
			if (pdomBinding == null) {
108
			if (pdomBinding == null) {
Lines 114-155 Link Here
114
					return null; // skip parameters
114
					return null; // skip parameters
115
				else if (binding instanceof IField) { // must be before IVariable
115
				else if (binding instanceof IField) { // must be before IVariable
116
					if (parent instanceof IPDOMMemberOwner)
116
					if (parent instanceof IPDOMMemberOwner)
117
						pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, name);
117
						pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, (IField) binding);
118
				} else if (binding instanceof IVariable) {
118
				} else if (binding instanceof IVariable) {
119
					IVariable var= (IVariable) binding;
119
					IVariable var= (IVariable) binding;
120
					if (!var.isStatic()) {  // bug 161216
120
					if (!var.isStatic()) {  // bug 161216
121
						pdomBinding = new PDOMCVariable(pdom, parent, name);
121
						pdomBinding = new PDOMCVariable(pdom, parent, var);
122
					}
122
					}
123
				}
123
				} else if (binding instanceof IFunction) {
124
				else if (binding instanceof IFunction) {
125
					IFunction func= (IFunction) binding;
124
					IFunction func= (IFunction) binding;
126
					if (!func.isStatic()) {  // bug 161216
125
					if (!func.isStatic()) {  // bug 161216
127
						pdomBinding = new PDOMCFunction(pdom, parent, name);
126
						pdomBinding = new PDOMCFunction(pdom, parent, func);
128
					}
127
					}
129
				}
128
				} else if (binding instanceof ICompositeType)
130
				else if (binding instanceof ICompositeType)
129
					pdomBinding = new PDOMCStructure(pdom, parent, (ICompositeType) binding);
131
					pdomBinding = new PDOMCStructure(pdom, parent, name);
132
				else if (binding instanceof IEnumeration)
130
				else if (binding instanceof IEnumeration)
133
					pdomBinding = new PDOMCEnumeration(pdom, parent, name);
131
					pdomBinding = new PDOMCEnumeration(pdom, parent, (IEnumeration) binding);
134
				else if (binding instanceof IEnumerator) {
132
				else if (binding instanceof IEnumerator) {
135
					try {
133
					try {
136
						IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
134
						IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
137
						PDOMBinding pdomEnumeration = adaptBinding(enumeration);
135
						PDOMBinding pdomEnumeration = adaptBinding(enumeration);
138
						if (pdomEnumeration instanceof PDOMCEnumeration)
136
						if (pdomEnumeration instanceof PDOMCEnumeration)
139
							pdomBinding = new PDOMCEnumerator(pdom, parent, name,
137
							pdomBinding = new PDOMCEnumerator(pdom, parent, (IEnumerator) binding, (PDOMCEnumeration)pdomEnumeration);
140
									(PDOMCEnumeration)pdomEnumeration);
141
					} catch (DOMException e) {
138
					} catch (DOMException e) {
142
						throw new CoreException(Util.createStatus(e));
139
						throw new CoreException(Util.createStatus(e));
143
					}
140
					}
144
				} else if (binding instanceof ITypedef)
141
				} else if (binding instanceof ITypedef)
145
					pdomBinding = new PDOMCTypedef(pdom, parent, name, (ITypedef)binding);
142
					pdomBinding = new PDOMCTypedef(pdom, parent, (ITypedef)binding);
146
143
147
				if(pdomBinding!=null) {
144
				if(pdomBinding!=null) {
148
					parent.addChild(pdomBinding);
145
					parent.addChild(pdomBinding);
149
				}
146
				}
150
			}
147
			}
151
		}
148
		} catch (DOMException e) {
152
		catch (DOMException e) {
153
			throw new CoreException(Util.createStatus(e));
149
			throw new CoreException(Util.createStatus(e));
154
		}
150
		}
155
151
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotation.java (-6 / +9 lines)
Lines 15-21 Link Here
15
import org.eclipse.cdt.core.dom.ast.IBinding;
15
import org.eclipse.cdt.core.dom.ast.IBinding;
16
import org.eclipse.cdt.core.dom.ast.IFunction;
16
import org.eclipse.cdt.core.dom.ast.IFunction;
17
import org.eclipse.cdt.core.dom.ast.IVariable;
17
import org.eclipse.cdt.core.dom.ast.IVariable;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
19
19
20
/**
20
/**
21
 * A utility class for packing various annotations into bit fields.  This
21
 * A utility class for packing various annotations into bit fields.  This
Lines 67-80 Link Here
67
	
67
	
68
	/**
68
	/**
69
	 * Encodes CV qualifiers from a method declarator as a bit vector.
69
	 * Encodes CV qualifiers from a method declarator as a bit vector.
70
	 * @param declarator Method declarator.
70
	 * @param type the function type
71
	 * @return a bit vector of the CV qualifiers.
71
	 * @return a bit vector of the CV qualifiers.
72
	 */
72
	 */
73
	public static byte encodeCVQualifiers(ICPPASTFunctionDeclarator declarator) {
73
	/*
74
	 * aftodo - will we put CV information in C pdom bindings or should we
75
	 * move this to PDOMCPPAnnotation?
76
	 */
77
	public static byte encodeCVQualifiers(ICPPFunctionType type) {
74
		byte modifiers = 0;
78
		byte modifiers = 0;
75
		modifiers |= (declarator.isConst() ? 1 : 0) << CONST_OFFSET;
79
		modifiers |= (type.isConst() ? 1 : 0) << CONST_OFFSET;
76
		modifiers |= (declarator.isVolatile() ? 1 : 0) << VOLATILE_OFFSET;
80
		modifiers |= (type.isVolatile() ? 1 : 0) << VOLATILE_OFFSET;
77
		return modifiers;
81
		return modifiers;
78
	}
82
	}
79
80
}
83
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCTypedef.java (-3 / +2 lines)
Lines 14-20 Link Here
14
14
15
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.IType;
19
import org.eclipse.cdt.core.dom.ast.ITypedef;
18
import org.eclipse.cdt.core.dom.ast.ITypedef;
20
import org.eclipse.cdt.internal.core.Util;
19
import org.eclipse.cdt.internal.core.Util;
Lines 33-41 Link Here
33
	
32
	
34
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
33
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
35
	
34
	
36
	public PDOMCTypedef(PDOM pdom, PDOMNode parent, IASTName name, ITypedef typedef)
35
	public PDOMCTypedef(PDOM pdom, PDOMNode parent, ITypedef typedef)
37
			throws CoreException {
36
			throws CoreException {
38
		super(pdom, parent, name);
37
		super(pdom, parent, typedef.getNameCharArray());
39
		
38
		
40
		try {
39
		try {
41
			IType type = typedef.getType();
40
			IType type = typedef.getType();
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCStructure.java (-3 / +2 lines)
Lines 20-26 Link Here
20
import org.eclipse.cdt.core.dom.IPDOMNode;
20
import org.eclipse.cdt.core.dom.IPDOMNode;
21
import org.eclipse.cdt.core.dom.IPDOMVisitor;
21
import org.eclipse.cdt.core.dom.IPDOMVisitor;
22
import org.eclipse.cdt.core.dom.ast.DOMException;
22
import org.eclipse.cdt.core.dom.ast.DOMException;
23
import org.eclipse.cdt.core.dom.ast.IASTName;
24
import org.eclipse.cdt.core.dom.ast.ICompositeType;
23
import org.eclipse.cdt.core.dom.ast.ICompositeType;
25
import org.eclipse.cdt.core.dom.ast.IField;
24
import org.eclipse.cdt.core.dom.ast.IField;
26
import org.eclipse.cdt.core.dom.ast.IScope;
25
import org.eclipse.cdt.core.dom.ast.IScope;
Lines 42-49 Link Here
42
	private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE;
41
	private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE;
43
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
42
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
44
	
43
	
45
	public PDOMCStructure(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
44
	public PDOMCStructure(PDOM pdom, PDOMNode parent, ICompositeType compType) throws CoreException {
46
		super(pdom, parent, name);
45
		super(pdom, parent, compType.getNameCharArray());
47
		// linked list is initialized by malloc zeroing allocated storage
46
		// linked list is initialized by malloc zeroing allocated storage
48
	}
47
	}
49
48
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCEnumeration.java (-3 / +2 lines)
Lines 14-20 Link Here
14
14
15
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IEnumeration;
17
import org.eclipse.cdt.core.dom.ast.IEnumeration;
19
import org.eclipse.cdt.core.dom.ast.IEnumerator;
18
import org.eclipse.cdt.core.dom.ast.IEnumerator;
20
import org.eclipse.cdt.core.dom.ast.IType;
19
import org.eclipse.cdt.core.dom.ast.IType;
Lines 33-41 Link Here
33
	
32
	
34
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
33
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
35
	
34
	
36
	public PDOMCEnumeration(PDOM pdom, PDOMNode parent, IASTName name)
35
	public PDOMCEnumeration(PDOM pdom, PDOMNode parent, IEnumeration enumeration)
37
			throws CoreException {
36
			throws CoreException {
38
		super(pdom, parent, name);
37
		super(pdom, parent, enumeration.getNameCharArray());
39
	}
38
	}
40
39
41
	public PDOMCEnumeration(PDOM pdom, int record) {
40
	public PDOMCEnumeration(PDOM pdom, int record) {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCField.java (-3 / +2 lines)
Lines 13-19 Link Here
13
package org.eclipse.cdt.internal.core.pdom.dom.c;
13
package org.eclipse.cdt.internal.core.pdom.dom.c;
14
14
15
import org.eclipse.cdt.core.dom.ast.DOMException;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.IASTName;
17
import org.eclipse.cdt.core.dom.ast.IField;
16
import org.eclipse.cdt.core.dom.ast.IField;
18
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.IType;
19
import org.eclipse.cdt.internal.core.pdom.PDOM;
18
import org.eclipse.cdt.internal.core.pdom.PDOM;
Lines 28-35 Link Here
28
 */
27
 */
29
class PDOMCField extends PDOMBinding implements IField {
28
class PDOMCField extends PDOMBinding implements IField {
30
29
31
	public PDOMCField(PDOM pdom, IPDOMMemberOwner parent, IASTName name) throws CoreException {
30
	public PDOMCField(PDOM pdom, IPDOMMemberOwner parent, IField field) throws CoreException {
32
		super(pdom, (PDOMNode) parent, name);
31
		super(pdom, (PDOMNode) parent, field.getNameCharArray());
33
	}
32
	}
34
33
35
	public PDOMCField(PDOM pdom, int record) {
34
	public PDOMCField(PDOM pdom, int record) {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCVariable.java (-5 / +3 lines)
Lines 13-19 Link Here
13
package org.eclipse.cdt.internal.core.pdom.dom.c;
13
package org.eclipse.cdt.internal.core.pdom.dom.c;
14
14
15
import org.eclipse.cdt.core.dom.ast.DOMException;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.IASTName;
17
import org.eclipse.cdt.core.dom.ast.IType;
16
import org.eclipse.cdt.core.dom.ast.IType;
18
import org.eclipse.cdt.core.dom.ast.IVariable;
17
import org.eclipse.cdt.core.dom.ast.IVariable;
19
import org.eclipse.cdt.internal.core.Util;
18
import org.eclipse.cdt.internal.core.Util;
Lines 39-50 Link Here
39
	 */
38
	 */
40
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1;
39
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1;
41
	
40
	
42
	public PDOMCVariable(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
41
	public PDOMCVariable(PDOM pdom, PDOMNode parent, IVariable variable) throws CoreException {
43
		super(pdom, parent, name);
42
		super(pdom, parent, variable.getNameCharArray());
44
		IVariable binding = (IVariable)name.getBinding();
45
43
46
		try {
44
		try {
47
			pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(binding));
45
			pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(variable));
48
		} catch (DOMException e) {
46
		} catch (DOMException e) {
49
			throw new CoreException(Util.createStatus(e));
47
			throw new CoreException(Util.createStatus(e));
50
		}
48
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java (-23 / +9 lines)
Lines 14-32 Link Here
14
14
15
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IASTNode;
19
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
20
import org.eclipse.cdt.core.dom.ast.IBinding;
17
import org.eclipse.cdt.core.dom.ast.IBinding;
21
import org.eclipse.cdt.core.dom.ast.IFunctionType;
18
import org.eclipse.cdt.core.dom.ast.IFunctionType;
22
import org.eclipse.cdt.core.dom.ast.IParameter;
19
import org.eclipse.cdt.core.dom.ast.IParameter;
23
import org.eclipse.cdt.core.dom.ast.IScope;
20
import org.eclipse.cdt.core.dom.ast.IScope;
24
import org.eclipse.cdt.core.dom.ast.IType;
21
import org.eclipse.cdt.core.dom.ast.IType;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
28
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
29
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
30
import org.eclipse.cdt.internal.core.Util;
24
import org.eclipse.cdt.internal.core.Util;
31
import org.eclipse.cdt.internal.core.pdom.PDOM;
25
import org.eclipse.cdt.internal.core.pdom.PDOM;
32
import org.eclipse.cdt.internal.core.pdom.db.Database;
26
import org.eclipse.cdt.internal.core.pdom.db.Database;
Lines 65-90 Link Here
65
	 */
59
	 */
66
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9;
60
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9;
67
	
61
	
68
	public PDOMCPPFunction(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
62
	public PDOMCPPFunction(PDOM pdom, PDOMNode parent, ICPPFunction function) throws CoreException {
69
		super(pdom, parent, name);
63
		super(pdom, parent, function.getNameCharArray());
70
		IASTNode parentNode = name.getParent();
64
		
71
		Database db = pdom.getDB();
65
		Database db = pdom.getDB();
72
		if (parentNode instanceof ICPPASTFunctionDeclarator) {
66
		IBinding binding = function;
73
			ICPPASTFunctionDeclarator funcDecl = (ICPPASTFunctionDeclarator)parentNode;
67
		try {
74
			IASTParameterDeclaration[] params = funcDecl.getParameters();
68
			IParameter[] params = function.getParameters();
75
			db.putInt(record + NUM_PARAMS, params.length);
69
			db.putInt(record + NUM_PARAMS, params.length);
76
			for (int i = 0; i < params.length; ++i) {
70
			
77
				ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration)params[i];
71
			for (int i=0; i<params.length; ++i) {
78
				IASTName paramName = param.getDeclarator().getName();
72
				setFirstParameter(new PDOMCPPParameter(pdom, this, params[i]));
79
				IBinding binding = paramName.resolveBinding();
80
				if (!(binding instanceof ICPPParameter))
81
					continue;
82
				ICPPParameter paramBinding = (ICPPParameter)binding;
83
				setFirstParameter(new PDOMCPPParameter(pdom, this, paramName, paramBinding));
84
			}
73
			}
85
		}
86
		IBinding binding = name.resolveBinding();
87
		try {
88
			db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding));
74
			db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding));
89
		} catch (DOMException e) {
75
		} catch (DOMException e) {
90
			throw new CoreException(Util.createStatus(e));
76
			throw new CoreException(Util.createStatus(e));
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java (-2 / +1 lines)
Lines 16-22 Link Here
16
16
17
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.core.CCorePlugin;
18
import org.eclipse.cdt.core.dom.ast.DOMException;
18
import org.eclipse.cdt.core.dom.ast.DOMException;
19
import org.eclipse.cdt.core.dom.ast.IASTName;
20
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
21
import org.eclipse.cdt.internal.core.pdom.PDOM;
20
import org.eclipse.cdt.internal.core.pdom.PDOM;
22
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
21
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
Lines 31-37 Link Here
31
	public PDOMCPPBinding(PDOM pdom, int record) {
30
	public PDOMCPPBinding(PDOM pdom, int record) {
32
		super(pdom, record);
31
		super(pdom, record);
33
	}
32
	}
34
	public PDOMCPPBinding(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
33
	public PDOMCPPBinding(PDOM pdom, PDOMNode parent, char[] name) throws CoreException {
35
		super(pdom, parent, name);
34
		super(pdom, parent, name);
36
	}
35
	}
37
		
36
		
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPField.java (-6 / +3 lines)
Lines 14-21 Link Here
14
14
15
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IBinding;
19
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.IType;
20
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
21
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
Lines 44-56 Link Here
44
	 */
42
	 */
45
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1;
43
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1;
46
	
44
	
47
	public PDOMCPPField(PDOM pdom, PDOMCPPClassType parent, IASTName name)
45
	public PDOMCPPField(PDOM pdom, PDOMCPPClassType parent, ICPPField field)
48
			throws CoreException {
46
			throws CoreException {
49
		super(pdom, parent, name);
47
		super(pdom, parent, field.getNameCharArray());
50
		IBinding binding = name.resolveBinding();
51
		try {
48
		try {
52
			Database db = pdom.getDB();
49
			Database db = pdom.getDB();
53
			db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding));
50
			db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(field));
54
		} catch (DOMException e) {
51
		} catch (DOMException e) {
55
			throw new CoreException(Util.createStatus(e));
52
			throw new CoreException(Util.createStatus(e));
56
		}
53
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/CPPBindingIdentity.java (-1 / +1 lines)
Lines 102-108 Link Here
102
		}
102
		}
103
		
103
		
104
		public String toString() {
104
		public String toString() {
105
			return name+" "+type+" "+mangledExtendedType;
105
			return name+" "+type+" "+mangledExtendedType; //$NON-NLS-1$ //$NON-NLS-2$
106
		}
106
		}
107
		
107
		
108
		public char[] getNameCharArray() throws CoreException {
108
		public char[] getNameCharArray() throws CoreException {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumeration.java (-3 / +2 lines)
Lines 14-20 Link Here
14
14
15
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IEnumeration;
17
import org.eclipse.cdt.core.dom.ast.IEnumeration;
19
import org.eclipse.cdt.core.dom.ast.IEnumerator;
18
import org.eclipse.cdt.core.dom.ast.IEnumerator;
20
import org.eclipse.cdt.core.dom.ast.IType;
19
import org.eclipse.cdt.core.dom.ast.IType;
Lines 34-42 Link Here
34
	
33
	
35
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
34
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
36
	
35
	
37
	public PDOMCPPEnumeration(PDOM pdom, PDOMNode parent, IASTName name)
36
	public PDOMCPPEnumeration(PDOM pdom, PDOMNode parent, IEnumeration enumeration)
38
			throws CoreException {
37
			throws CoreException {
39
		super(pdom, parent, name);
38
		super(pdom, parent, enumeration.getNameCharArray());
40
	}
39
	}
41
40
42
	public PDOMCPPEnumeration(PDOM pdom, int record) {
41
	public PDOMCPPEnumeration(PDOM pdom, int record) {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPVariable.java (-16 / +8 lines)
Lines 15-27 Link Here
15
15
16
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.DOMException;
18
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
19
import org.eclipse.cdt.core.dom.ast.IASTName;
20
import org.eclipse.cdt.core.dom.ast.IASTNode;
21
import org.eclipse.cdt.core.dom.ast.IType;
18
import org.eclipse.cdt.core.dom.ast.IType;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
23
import org.eclipse.cdt.internal.core.Util;
20
import org.eclipse.cdt.internal.core.Util;
24
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
25
import org.eclipse.cdt.internal.core.pdom.PDOM;
21
import org.eclipse.cdt.internal.core.pdom.PDOM;
26
import org.eclipse.cdt.internal.core.pdom.db.Database;
22
import org.eclipse.cdt.internal.core.pdom.db.Database;
27
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
23
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
Lines 52-72 Link Here
52
	 */
48
	 */
53
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 5;
49
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 5;
54
	
50
	
55
	public PDOMCPPVariable(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
51
	public PDOMCPPVariable(PDOM pdom, PDOMNode parent, ICPPVariable variable) throws CoreException {
56
		super(pdom, parent, name);
52
		super(pdom, parent, variable.getNameCharArray());
57
		
53
		
58
		// Find the type record
54
		try {
59
		IASTNode nameParent = name.getParent();
55
			// Find the type record
60
		Database db = pdom.getDB();
56
			Database db = pdom.getDB();
61
		if (nameParent instanceof IASTDeclarator) {
57
			PDOMNode typeNode = parent.getLinkageImpl().addType(this, variable.getType());
62
			IASTDeclarator declarator = (IASTDeclarator)nameParent;
63
			IType type = CPPVisitor.createType(declarator);
64
			PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
65
			if (typeNode != null)
58
			if (typeNode != null)
66
				db.putInt(record + TYPE_OFFSET, typeNode.getRecord());
59
				db.putInt(record + TYPE_OFFSET, typeNode.getRecord());
67
		}
60
68
		try {
61
			db.putByte(record + ANNOTATIONS, PDOMCPPAnnotation.encodeAnnotation(variable));
69
			db.putByte(record + ANNOTATIONS, PDOMCPPAnnotation.encodeAnnotation(name.resolveBinding()));
70
		} catch (DOMException e) {
62
		} catch (DOMException e) {
71
			throw new CoreException(Util.createStatus(e));
63
			throw new CoreException(Util.createStatus(e));
72
		}
64
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespace.java (-2 / +2 lines)
Lines 49-56 Link Here
49
	
49
	
50
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
50
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
51
51
52
	public PDOMCPPNamespace(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
52
	public PDOMCPPNamespace(PDOM pdom, PDOMNode parent, ICPPNamespace namespace) throws CoreException {
53
		super(pdom, parent, name);
53
		super(pdom, parent, namespace.getNameCharArray());
54
	}
54
	}
55
55
56
	public PDOMCPPNamespace(PDOM pdom, int record) throws CoreException {
56
	public PDOMCPPNamespace(PDOM pdom, int record) throws CoreException {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPEnumerator.java (-3 / +2 lines)
Lines 13-19 Link Here
13
13
14
import org.eclipse.cdt.core.CCorePlugin;
14
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.IASTName;
17
import org.eclipse.cdt.core.dom.ast.IEnumerator;
16
import org.eclipse.cdt.core.dom.ast.IEnumerator;
18
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.IType;
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
Lines 33-41 Link Here
33
	
32
	
34
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
33
	protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
35
	
34
	
36
	public PDOMCPPEnumerator(PDOM pdom, PDOMNode parent, IASTName name, PDOMCPPEnumeration enumeration)
35
	public PDOMCPPEnumerator(PDOM pdom, PDOMNode parent, IEnumerator enumerator, PDOMCPPEnumeration enumeration)
37
			throws CoreException {
36
			throws CoreException {
38
		super(pdom, parent, name);
37
		super(pdom, parent, enumerator.getNameCharArray());
39
		pdom.getDB().putInt(record + ENUMERATION, enumeration.getRecord());
38
		pdom.getDB().putInt(record + ENUMERATION, enumeration.getRecord());
40
		enumeration.addEnumerator(this);
39
		enumeration.addEnumerator(this);
41
	}
40
	}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java (-27 / +15 lines)
Lines 15-34 Link Here
15
15
16
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.DOMException;
18
import org.eclipse.cdt.core.dom.ast.IASTName;
19
import org.eclipse.cdt.core.dom.ast.IASTNode;
20
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
21
import org.eclipse.cdt.core.dom.ast.IBinding;
22
import org.eclipse.cdt.core.dom.ast.IFunctionType;
18
import org.eclipse.cdt.core.dom.ast.IFunctionType;
23
import org.eclipse.cdt.core.dom.ast.IParameter;
19
import org.eclipse.cdt.core.dom.ast.IParameter;
24
import org.eclipse.cdt.core.dom.ast.IScope;
20
import org.eclipse.cdt.core.dom.ast.IScope;
25
import org.eclipse.cdt.core.dom.ast.IType;
21
import org.eclipse.cdt.core.dom.ast.IType;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
28
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
29
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
30
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
31
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
32
import org.eclipse.cdt.internal.core.Util;
25
import org.eclipse.cdt.internal.core.Util;
33
import org.eclipse.cdt.internal.core.pdom.PDOM;
26
import org.eclipse.cdt.internal.core.pdom.PDOM;
34
import org.eclipse.cdt.internal.core.pdom.db.Database;
27
import org.eclipse.cdt.internal.core.pdom.db.Database;
Lines 78-106 Link Here
78
	 */
71
	 */
79
	private static final int CV_OFFSET = 2;
72
	private static final int CV_OFFSET = 2;
80
73
81
	public PDOMCPPMethod(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
74
	public PDOMCPPMethod(PDOM pdom, PDOMNode parent, ICPPMethod method) throws CoreException {
82
		super(pdom, parent, name);
75
		super(pdom, parent, method.getNameCharArray());
83
		IASTNode parentNode = name.getParent();
76
		
84
		byte annotation = 0;
85
		Database db = pdom.getDB();
77
		Database db = pdom.getDB();
86
		if (parentNode instanceof ICPPASTFunctionDeclarator) {
78
		
87
			ICPPASTFunctionDeclarator funcDecl = (ICPPASTFunctionDeclarator)parentNode;
79
		try {
88
			IASTParameterDeclaration[] params = funcDecl.getParameters();
80
			IParameter[] params = method.getParameters();
89
			db.putInt(record + NUM_PARAMS, params.length);
81
			db.putInt(record + NUM_PARAMS, params.length);
90
			for (int i = 0; i < params.length; ++i) {
82
			
91
				ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration)params[i];
83
			for (int i=0; i<params.length; ++i) {
92
				IASTName paramName = param.getDeclarator().getName();
84
				setFirstParameter(new PDOMCPPParameter(pdom, this, params[i]));
93
				IBinding binding = paramName.resolveBinding();
94
				ICPPParameter paramBinding = (ICPPParameter)binding;
95
				setFirstParameter(new PDOMCPPParameter(pdom, this, paramName, paramBinding));
96
			}
85
			}
97
			annotation |= PDOMCAnnotation.encodeCVQualifiers(funcDecl) << CV_OFFSET;
86
			ICPPFunctionType type = (ICPPFunctionType) method.getType();
98
		}
87
			byte annotation = 0;
99
		try {
88
			annotation |= PDOMCAnnotation.encodeCVQualifiers(type) << CV_OFFSET;
100
			IBinding binding = name.resolveBinding();
89
			annotation |= PDOMCPPAnnotation.encodeExtraAnnotation(method);
101
			annotation |= PDOMCPPAnnotation.encodeExtraAnnotation(binding);
90
			db.putByte(record + ANNOTATION0, PDOMCPPAnnotation.encodeAnnotation(method));
102
			db.putByte(record + ANNOTATION0, PDOMCPPAnnotation.encodeAnnotation(binding));
91
			db.putByte(record + ANNOTATION1, annotation);			
103
			db.putByte(record + ANNOTATION1, annotation);
104
		} catch (DOMException e) {
92
		} catch (DOMException e) {
105
			throw new CoreException(Util.createStatus(e));
93
			throw new CoreException(Util.createStatus(e));
106
		}
94
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java (-8 / +3 lines)
Lines 23-29 Link Here
23
import org.eclipse.cdt.core.dom.IPDOMVisitor;
23
import org.eclipse.cdt.core.dom.IPDOMVisitor;
24
import org.eclipse.cdt.core.dom.ast.DOMException;
24
import org.eclipse.cdt.core.dom.ast.DOMException;
25
import org.eclipse.cdt.core.dom.ast.IASTName;
25
import org.eclipse.cdt.core.dom.ast.IASTName;
26
import org.eclipse.cdt.core.dom.ast.IASTNode;
27
import org.eclipse.cdt.core.dom.ast.IBinding;
26
import org.eclipse.cdt.core.dom.ast.IBinding;
28
import org.eclipse.cdt.core.dom.ast.IField;
27
import org.eclipse.cdt.core.dom.ast.IField;
29
import org.eclipse.cdt.core.dom.ast.IScope;
28
import org.eclipse.cdt.core.dom.ast.IScope;
Lines 61-76 Link Here
61
	
60
	
62
	protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12;
61
	protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12;
63
62
64
	public PDOMCPPClassType(PDOM pdom, PDOMNode parent, IASTName name)
63
	public PDOMCPPClassType(PDOM pdom, PDOMNode parent, ICPPClassType classType)
65
			throws CoreException {
64
			throws CoreException {
66
		super(pdom, parent, name);
65
		super(pdom, parent, classType.getName().toCharArray());
67
66
68
		IBinding binding = name.resolveBinding();
69
		try {
67
		try {
70
			int key = 0;
68
			pdom.getDB().putByte(record + KEY, (byte) classType.getKey());
71
			if (binding instanceof ICPPClassType) // not sure why it wouldn't
72
				key = ((ICPPClassType) binding).getKey();
73
			pdom.getDB().putByte(record + KEY, (byte) key);
74
		} catch (DOMException e) {
69
		} catch (DOMException e) {
75
			throw new CoreException(Util.createStatus(e));
70
			throw new CoreException(Util.createStatus(e));
76
		}
71
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java (-1 / +1 lines)
Lines 34-40 Link Here
34
	
34
	
35
	public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, IASTName name, ITypedef typedef)
35
	public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, IASTName name, ITypedef typedef)
36
			throws CoreException {
36
			throws CoreException {
37
		super(pdom, parent, name);
37
		super(pdom, parent, name.toCharArray());
38
		try {
38
		try {
39
			IType type = typedef.getType();
39
			IType type = typedef.getType();
40
			PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
40
			PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPParameter.java (-5 / +4 lines)
Lines 16-25 Link Here
16
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.DOMException;
18
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
18
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
19
import org.eclipse.cdt.core.dom.ast.IASTName;
19
import org.eclipse.cdt.core.dom.ast.IParameter;
20
import org.eclipse.cdt.core.dom.ast.IScope;
20
import org.eclipse.cdt.core.dom.ast.IScope;
21
import org.eclipse.cdt.core.dom.ast.IType;
21
import org.eclipse.cdt.core.dom.ast.IType;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
23
import org.eclipse.cdt.internal.core.Util;
22
import org.eclipse.cdt.internal.core.Util;
24
import org.eclipse.cdt.internal.core.pdom.PDOM;
23
import org.eclipse.cdt.internal.core.pdom.PDOM;
25
import org.eclipse.cdt.internal.core.pdom.db.Database;
24
import org.eclipse.cdt.internal.core.pdom.db.Database;
Lines 33-39 Link Here
33
 * 
32
 * 
34
 * @author Doug Schaefer
33
 * @author Doug Schaefer
35
 */
34
 */
36
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
35
class PDOMCPPParameter extends PDOMNamedNode implements IParameter {
37
36
38
	/**
37
	/**
39
	 * Offset of pointer to the next parameter (relative to the
38
	 * Offset of pointer to the next parameter (relative to the
Lines 56-64 Link Here
56
		super(pdom, record);
55
		super(pdom, record);
57
	}
56
	}
58
57
59
	public PDOMCPPParameter(PDOM pdom, PDOMNode parent, IASTName name, ICPPParameter param)
58
	public PDOMCPPParameter(PDOM pdom, PDOMNode parent, IParameter param)
60
			throws CoreException {
59
			throws CoreException {
61
		super(pdom, parent, name.toCharArray());
60
		super(pdom, parent, param.getNameCharArray());
62
		
61
		
63
		Database db = pdom.getDB();
62
		Database db = pdom.getDB();
64
63
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPNamespaceAlias.java (-4 / +3 lines)
Lines 12-18 Link Here
12
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
12
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
13
13
14
import org.eclipse.cdt.core.dom.ast.DOMException;
14
import org.eclipse.cdt.core.dom.ast.DOMException;
15
import org.eclipse.cdt.core.dom.ast.IASTName;
16
import org.eclipse.cdt.core.dom.ast.IBinding;
15
import org.eclipse.cdt.core.dom.ast.IBinding;
17
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
16
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
17
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
Lines 28-36 Link Here
28
class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements
27
class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements
29
		ICPPNamespaceAlias {
28
		ICPPNamespaceAlias {
30
29
31
	public PDOMCPPNamespaceAlias(PDOM pdom, PDOMNode parent,
30
	public PDOMCPPNamespaceAlias(PDOM pdom, PDOMNode parent, ICPPNamespaceAlias alias)
32
			IASTName name) throws CoreException {
31
	throws CoreException {
33
		super(pdom, parent, name);
32
		super(pdom, parent, alias.getNameCharArray());
34
	}
33
	}
35
34
36
	public PDOMCPPNamespaceAlias(PDOM pdom, int record) {
35
	public PDOMCPPNamespaceAlias(PDOM pdom, int record) {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java (-47 / +47 lines)
Lines 119-125 Link Here
119
			return null;
119
			return null;
120
120
121
		IBinding binding = name.resolveBinding();
121
		IBinding binding = name.resolveBinding();
122
122
		
123
		if (binding == null || binding instanceof IProblemBinding)
123
		if (binding == null || binding instanceof IProblemBinding)
124
			// Can't tell what it is
124
			// Can't tell what it is
125
			return null;
125
			return null;
Lines 132-181 Link Here
132
		try {
132
		try {
133
			if (pdomBinding == null) {
133
			if (pdomBinding == null) {
134
				PDOMNode parent = getAdaptedParent(binding);
134
				PDOMNode parent = getAdaptedParent(binding);
135
				if (parent != null) {
135
				if (parent == null)
136
					if (binding instanceof ICPPField && parent instanceof PDOMCPPClassType)
136
					return null;
137
						pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, name);
137
				
138
					else if (binding instanceof ICPPVariable) {
138
				if (binding instanceof ICPPField && parent instanceof PDOMCPPClassType)
139
						if (!(binding.getScope() instanceof CPPBlockScope)) {
139
					pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, (ICPPField) binding);
140
							ICPPVariable var= (ICPPVariable) binding;
140
				else if (binding instanceof ICPPVariable && !(binding.getScope() instanceof CPPBlockScope)) {
141
							if (!var.isStatic()) {  // bug 161216
141
					if (!(binding.getScope() instanceof CPPBlockScope)) {
142
								pdomBinding = new PDOMCPPVariable(pdom, parent, name);
142
						ICPPVariable var= (ICPPVariable) binding;
143
							}
143
						if (!var.isStatic()) {  // bug 161216
144
						}
144
							pdomBinding = new PDOMCPPVariable(pdom, parent, var);
145
					} else if (binding instanceof ICPPMethod && parent instanceof PDOMCPPClassType) {
146
						pdomBinding = new PDOMCPPMethod(pdom, parent, name);
147
					} else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
148
						if(!name.isReference()) {
149
							//because we got the implicit method off of an IASTName that is not a reference,
150
							//it is no longer completly implicit and it should be treated as a normal method.						
151
							pdomBinding = new PDOMCPPMethod(pdom, parent, name);
152
						}
145
						}
153
					} else if (binding instanceof ICPPFunction) {
154
						ICPPFunction func= (ICPPFunction) binding;
155
						if (!func.isStatic()) {  // bug 161216
156
							pdomBinding = new PDOMCPPFunction(pdom, parent, name);
157
						}
158
					} else if (binding instanceof ICPPClassType) {
159
						pdomBinding = new PDOMCPPClassType(pdom, parent, name);
160
					} else if (binding instanceof ICPPNamespaceAlias) {
161
						pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, name);
162
					} else if (binding instanceof ICPPNamespace) {
163
						pdomBinding = new PDOMCPPNamespace(pdom, parent, name);
164
					} else if (binding instanceof IEnumeration) {
165
						pdomBinding = new PDOMCPPEnumeration(pdom, parent, name);
166
					} else if (binding instanceof IEnumerator) {
167
						IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
168
						PDOMBinding pdomEnumeration = adaptBinding(enumeration);
169
						if (pdomEnumeration instanceof PDOMCPPEnumeration)
170
							pdomBinding = new PDOMCPPEnumerator(pdom, parent, name,
171
									(PDOMCPPEnumeration)pdomEnumeration);
172
					} else if (binding instanceof ITypedef) {
173
						pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
174
					}
146
					}
175
					
147
				} else if (parent instanceof PDOMCPPClassType && binding instanceof ICPPMethod) {
176
					if(pdomBinding!=null) {
148
					pdomBinding = new PDOMCPPMethod(pdom, parent, (ICPPMethod)binding);
177
						parent.addChild(pdomBinding);
149
				} else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
150
					if(!name.isReference()) {
151
						//because we got the implicit method off of an IASTName that is not a reference,
152
						//it is no longer completly implicit and it should be treated as a normal method.						
153
						pdomBinding = new PDOMCPPMethod(pdom, parent, (ICPPMethod)binding);
154
					}
155
				} else if (binding instanceof ICPPFunction) {
156
					ICPPFunction func= (ICPPFunction) binding;
157
					if (!func.isStatic()) {  // bug 161216
158
						pdomBinding = new PDOMCPPFunction(pdom, parent, func);
178
					}
159
					}
160
				} else if (binding instanceof ICPPClassType) {
161
					pdomBinding = new PDOMCPPClassType(pdom, parent, (ICPPClassType) binding);
162
				} else if (binding instanceof ICPPNamespaceAlias) {
163
					pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, (ICPPNamespaceAlias) binding);
164
				} else if (binding instanceof ICPPNamespace) {
165
					pdomBinding = new PDOMCPPNamespace(pdom, parent, (ICPPNamespace) binding);
166
				} else if (binding instanceof IEnumeration) {
167
					pdomBinding = new PDOMCPPEnumeration(pdom, parent, (IEnumeration) binding);
168
				} else if (binding instanceof IEnumerator) {
169
					IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
170
					PDOMBinding pdomEnumeration = adaptBinding(enumeration);
171
					if (pdomEnumeration instanceof PDOMCPPEnumeration)
172
						pdomBinding = new PDOMCPPEnumerator(pdom, parent, (IEnumerator) binding,
173
								(PDOMCPPEnumeration)pdomEnumeration);
174
				} else if (binding instanceof ITypedef) {
175
					pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
176
				}
177
178
				if(pdomBinding!=null) {
179
					parent.addChild(pdomBinding);
179
				}
180
				}
180
			}
181
			}
181
		} catch(DOMException e) {
182
		} catch(DOMException e) {
Lines 460-470 Link Here
460
		if (type instanceof ICPPBasicType) {
461
		if (type instanceof ICPPBasicType) {
461
			return new PDOMCPPBasicType(pdom, parent, (ICPPBasicType)type);
462
			return new PDOMCPPBasicType(pdom, parent, (ICPPBasicType)type);
462
		} else if (type instanceof ICPPClassType) {
463
		} else if (type instanceof ICPPClassType) {
463
			// aftodo: please review, the binding may be nested in a namespace bug 162011
464
			FindEquivalentBinding feb = new FindEquivalentBinding(this,(ICPPClassType)type);
464
			//   it might be necessary to create the binding for the class here.
465
			getIndex().accept(feb);
465
			PDOMBinding binding= adaptBinding((ICPPClassType) type);
466
			if(feb.getResult()!=null) {
466
			if (binding != null) {
467
				return feb.getResult();
467
				return binding;
468
			}
468
			}
469
		}
469
		}
470
		return super.addType(parent, type); 
470
		return super.addType(parent, type); 
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java (-5 lines)
Lines 14-20 Link Here
14
14
15
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IScope;
17
import org.eclipse.cdt.core.dom.ast.IScope;
19
import org.eclipse.cdt.core.index.IIndexBinding;
18
import org.eclipse.cdt.core.index.IIndexBinding;
20
import org.eclipse.cdt.internal.core.index.IIndexFragment;
19
import org.eclipse.cdt.internal.core.index.IIndexFragment;
Lines 35-44 Link Here
35
	
34
	
36
	protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 12;
35
	protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 12;
37
	
36
	
38
	protected PDOMBinding(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
39
		super(pdom, parent, name.toCharArray());
40
	}
41
	
42
	protected PDOMBinding(PDOM pdom, PDOMNode parent, char[] name) throws CoreException {
37
	protected PDOMBinding(PDOM pdom, PDOMNode parent, char[] name) throws CoreException {
43
		super(pdom, parent, name);
38
		super(pdom, parent, name);
44
	}
39
	}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java (-2 / +4 lines)
Lines 177-184 Link Here
177
	/**
177
	/**
178
	 * 
178
	 * 
179
	 * @param binding
179
	 * @param binding
180
	 * @return null for filescope for non-pdom bindings, this for filescope for pdom bindings
180
	 * @return <ul><li> null - skip this binding (don't add to pdom)
181
	 * or the parent binding in any other case
181
	 * <li>this - for filescope
182
	 * <li>a PDOMBinding instance - parent adapted binding
183
	 * </ul>
182
	 * @throws CoreException
184
	 * @throws CoreException
183
	 */
185
	 */
184
	public PDOMNode getAdaptedParent(IBinding binding) throws CoreException {
186
	public PDOMNode getAdaptedParent(IBinding binding) throws CoreException {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMNamedNode.java (-15 / +1 lines)
Lines 16-22 Link Here
16
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.internal.core.pdom.PDOM;
17
import org.eclipse.cdt.internal.core.pdom.PDOM;
18
import org.eclipse.cdt.internal.core.pdom.db.Database;
18
import org.eclipse.cdt.internal.core.pdom.db.Database;
19
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
20
import org.eclipse.cdt.internal.core.pdom.db.IString;
19
import org.eclipse.cdt.internal.core.pdom.db.IString;
21
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
22
21
Lines 47-55 Link Here
47
				name != null ? db.newString(name).getRecord() : 0);
46
				name != null ? db.newString(name).getRecord() : 0);
48
	}
47
	}
49
48
50
	protected int getRecordSize() {
49
	abstract protected int getRecordSize();
51
		return RECORD_SIZE;
52
	}
53
50
54
	public IString getDBName() throws CoreException {
51
	public IString getDBName() throws CoreException {
55
		Database db = pdom.getDB();
52
		Database db = pdom.getDB();
Lines 65-81 Link Here
65
		return getDBName().equals(name);
62
		return getDBName().equals(name);
66
	}
63
	}
67
64
68
	public IBTreeComparator getIndexComparator() {
69
		return new IBTreeComparator() {
70
			public int compare(int record1, int record2) throws CoreException {
71
				Database db = pdom.getDB();
72
				int string1 = db.getInt(record1 + NAME);
73
				int string2 = db.getInt(record2 + NAME);
74
				return db.getString(string1).compare(db.getString(string2));
75
			}
76
		};
77
	}
78
	
79
	/**
65
	/**
80
	 * Convenience method for fetching a byte from the database.
66
	 * Convenience method for fetching a byte from the database.
81
	 * @param offset Location of the byte.
67
	 * @param offset Location of the byte.

Return to bug 162217