Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 314eb758983129917125c04bd188ee92105f1deb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*******************************************************************************
 * Copyright (c) 2004, 2006 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 Software Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.core.browser;

import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;

/**
 * Type information.
 */
public interface ITypeInfo extends Comparable {

	public static final int KNOWN_TYPES[] = {
		ICElement.C_NAMESPACE,
		ICElement.C_CLASS,
		ICElement.C_STRUCT,
		ICElement.C_UNION,
		ICElement.C_ENUMERATION,
		ICElement.C_TYPEDEF
	};
		
	/**
	 * Gets the CElement type.
	 * @return ICElement.C_NAMESPACE, C_CLASS, C_STRUCT, C_UNION, C_ENUMERATION, or C_TYPEDEF,
	 * or zero if unknown type.
	 */
	public int getCElementType();

	/**
	 * Sets the CElement type.
	 */
	public void setCElementType(int type);

	/**
	 * Gets the type name.
	 */
	public String getName();

	/**
	 * Gets the qualified type name.
	 */
	public IQualifiedTypeName getQualifiedTypeName();

	/**
	 * Returns true if the type exists.
	 */
	public boolean exists();

	/**
	 * Returns true if the element type is unknown.
	 */
	public boolean isUndefinedType();
	
	/**
	 * Returns true if this type is enclosed by other types,
	 * i.e. declared an inside another namespace or class.
	 */
	public boolean isEnclosedType();

	/** Gets the enclosing type, i.e. the outer class or namespace which contains this type.
	 * @return the enclosing type, or <code>null</code> if not found.
	 */
	public ITypeInfo getEnclosingType();

	/** Gets the enclosing namespace for this type.
	 * @return the enclosing namespace, or <code>null</code> if none exists.
	 */
	public ITypeInfo getEnclosingNamespace(boolean includeGlobalNamespace);

	/** Gets the first enclosing type which matches one of the given kinds.
	 * @param kinds Array containing CElement types: C_NAMESPACE, C_CLASS, C_STRUCT
	 * @return the enclosing type, or <code>null</code> if not found.
	 */
	public ITypeInfo getEnclosingType(int[] kinds);

	/** Gets the root namespace, i.e. the outermost namespace
	 * which contains this type.
	 * @param includeGlobalNamespace <code>true</code> if the global (default) namespace should be returned
	 * @return the namespace, or <code>null</code> if not found.
	 */
	public ITypeInfo getRootNamespace(boolean includeGlobalNamespace);
	
	/**
	 * Returns true if this type is capable of enclosing other types,
	 * i.e. it is a namespace, class, or struct.
	 */
	public boolean isEnclosingType();

	/**
	 * Returns true if this type encloses other types, i.e. contains
	 * inner classes or namespaces.
	 */
	public boolean hasEnclosedTypes();

	/**
	 * Returns true if this type encloses the given type.
	 */
	public boolean encloses(ITypeInfo info);
	
	/**
	 * Returns true if this type is enclosed by the given type.
	 */
	public boolean isEnclosed(ITypeInfo info);
	
	/** Gets the enclosed types, i.e. inner classes or classes inside this namespace.
	 * @return array of inner types, or empty array if not found.
	 */
	public ITypeInfo[] getEnclosedTypes();
	
	/** Gets the enclosed types, i.e. inner classes or classes inside this namespace.
	 * @param kinds Array containing CElement types: C_NAMESPACE, C_CLASS, C_STRUCT,
	 *              C_UNION, C_ENUMERATION, C_TYPEDEF
	 * @return array of inner types, or empty array if not found.
	 */
	public ITypeInfo[] getEnclosedTypes(int kinds[]);

	/**
	 * Gets the enclosing project.
	 */
	public ICProject getEnclosingProject();
	
	/**
	 * Returns true if type is enclosed in the given scope.
	 */
	public boolean isEnclosed(ITypeSearchScope scope);
	
	/**
	 * Adds a source reference.
	 */
	public void addReference(ITypeReference location);

	/** Gets the originating locations where this type was declared.
	 * @return all known source references, or an empty
	 * array if none found.
	 */
	public ITypeReference[] getReferences();

	/** Gets the real location where type was declared.
	 * @return the parsed source reference (with offset and length),
	 * or <code>null</code> if not found.
	 */
	public ITypeReference getResolvedReference();
	
	/**
	 * Returns true if the type can be substituted.
	 */
	public boolean canSubstituteFor(ITypeInfo info);

	/**
	 * Returns true if other types extend this type.
	 */
	public boolean hasSubTypes();
	
	/** Gets all types which extend this type.
	 * @return array of types, or <code>null</code> if none found.
	 */
	public ITypeInfo[] getSubTypes();
	
	/**
	 * Returns true if this type has base classes.
	 */
	public boolean hasSuperTypes();
	
	/** Gets the base classes.
	 * @return array of types, or <code>null</code> if none found.
	 */
	public ITypeInfo[] getSuperTypes();
	
	/**
	 * Gets the base class access visibility (PRIVATE, PROTECTED, PUBLIC)
	 */
	public ASTAccessVisibility getSuperTypeAccess(ITypeInfo subType);

	/**
	 * Adds a derived class reference, i.e. this type is used as
	 * a base class at the given location.
	 */
	public void addDerivedReference(ITypeReference location);

	/** Gets the originating locations where this type was
	 * used as a base class.
	 * @return all known source references, or an empty
	 * array if none found.
	 */
	public ITypeReference[] getDerivedReferences();
	
	/**
	 * Returns true if the type is a class or struct.
	 */
	public boolean isClass();

	/**
	 * Returns true if type is referenced in the given scope.
	 */
	public boolean isReferenced(ITypeSearchScope scope);
}

Back to the top