Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1bf30c241f2bfafb73d00f0e92ca1674a57c0240 (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
206
207
208
209
210
package org.eclipse.jdt.internal.core.builder.impl;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */
import org.eclipse.core.runtime.IPath;

import org.eclipse.jdt.internal.core.builder.*;

public class ImageImpl
	extends NonStateSpecificHandleImpl 
	implements IImage {
		JavaDevelopmentContextImpl fDevelopmentContext;	

	/**
	 * Creates a new image
	 */
	public ImageImpl(JavaDevelopmentContextImpl dc) {
		fDevelopmentContext = dc;
	}
/**
 * Returns the Type representing the primitive type boolean.
 */
public IType booleanType() {
	return fDevelopmentContext.fBooleanType;
}
/**
 * Returns the Type representing the primitive type byte
 */
public org.eclipse.jdt.internal.core.builder.IType byteType() {
	return fDevelopmentContext.fByteType;
}
/**
 *Returns the Type representing the primitive type char
 */
public org.eclipse.jdt.internal.core.builder.IType charType() {
	return fDevelopmentContext.fCharType;
}
/**
 * Returns an Image Context consisting of all the given packages.
 * This object and the packages must all be non-state-specific.
 * This is a handle-only operation.  The packages need not
 *	be present in the image.
 */
public IImageContext createImageContext(IPackage[] packages) 
	throws StateSpecificException {
	// copy array and verify that the packages are non-state-specific
	IPackage[] pkgs = new IPackage[packages.length];
	for (int  i = 0; i < packages.length; i++) {
		if ((packages[i].kind() != K_JAVA_PACKAGE) ||
			(packages[i].isStateSpecific())) {
				throw new StateSpecificException();
		}
		pkgs[i] = packages[i];
	}
	// create the image context
	return new ImageContextImpl(fDevelopmentContext, pkgs);
}
/**
 * Returns the Type representing the primitive type double
 */
public org.eclipse.jdt.internal.core.builder.IType doubleType() {
	return fDevelopmentContext.fDoubleType;
}
	/**
	 * Compares this Image handle against the specified object.  Returns
	 *	true if the objects are the same.  Two Image handles are the same if
	 *	they belong to the same development context, and if they are both
	 *	non-state-specific or are both state-specific on the same state.
	 *	See Handle.equals() for more details.
	 */
	public boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof ImageImpl)) return false;

		ImageImpl image = (ImageImpl) o;
		return fDevelopmentContext.equals(image.fDevelopmentContext);
	}
/**
 * Returns the Type representing the primitive type float
 */
public org.eclipse.jdt.internal.core.builder.IType floatType() {
	return fDevelopmentContext.fFloatType;
}
/**
 * Returns an array containing Type objects representing all
 * classes and interfaces in the given ImageContext.
 * This includes public and default (package) access top-level 
 * classes, inner classes, and local inner classes.
 * The result is the intersection of all classes present in this image
 * and the classes in the ImageContext, so the resulting classes
 * are all present in the image.
 * The resulting Types are in no particular order.
 */
public IType[] getAllClasses(IImageContext context) {
	StateImpl state = (StateImpl) getDevelopmentContext().getCurrentState();
	IPackage[] pkgs = (context == null ? state.getPackageMap().getAllPackagesAsArray() : context.getPackages());
	java.util.Vector result = new java.util.Vector(pkgs.length * 25);
	for (int i = 0; i < pkgs.length; ++i) {
		TypeStructureEntry[] entries = state.getAllTypesForPackage(pkgs[i]);
		// entries is null if package is missing
		if (entries != null) {
			for (int j = 0, len = entries.length; j < len; ++j) {
				result.addElement(entries[j].getType());
			}
		}
	}
	// convert the Vector to an array
	IType[] types = new IType[result.size()];
	result.copyInto(types);
	return types;
}
	/**
	 * Returns an array of all packages present in the image.  Note that this
	 * method defies the concept of a potentially infinite image, and should only
	 * be used by clients that must operate over the entire image (search, code assist)
	 */
	public IPackage[] getAllPackages() {
		StateImpl state = (StateImpl)fDevelopmentContext.getCurrentState();
		return state.getPackageMap().getAllPackagesAsArray();
	}
	/**
	 * @see IImage
	 */
	public IType[] getBuiltClasses(IPath path) {
		return nonStateSpecific(((IImage) inCurrentState()).getBuiltClasses(path));
	}
/**
 * Return the internal representation of the development context that owns this object
 */
JavaDevelopmentContextImpl getInternalDC() {
	return fDevelopmentContext;
}
/**
 * Returns a handle representing the package with the given 
 * name.  For named packages, this is the fully qualified
 * name.  For unnamed packages, it is some internal identifying
 * string.
 * See <em>The Java Language Specification</em> section 7.4.1 and
 * 7.4.2 for more details.
 * This is a handle-only method; the specified package 
 * may or may not actually be present in the image.
 */
public IPackage getPackageHandle(String name, boolean isUnnamed) {
	return new PackageImpl(fDevelopmentContext, name, isUnnamed);
}
/**
 * Returns an array of Package objects representing all
 * packages contained in the given ImageContext.
 * The result is the intersection of the packages present in this image
 * and the packages in the ImageContext, so the resulting packages
 * are all present in the image.
 * The resulting Packages are in no particular order.
 */
public IPackage[] getPackages(IImageContext context) {
	if (context == null) {
		return ((StateImpl) fDevelopmentContext.getCurrentState()).getAllPackagesAsArray();
	}
	return nonStateSpecific(((IImage) inCurrentState()).getPackages(context));
}
	/**
	 * Returns a consistent hash code for this object
	 */
	public int hashCode() {
		return fDevelopmentContext.hashCode();
	}
/**
 * Returns the state wrapped handle
 */
public IHandle inState(IState state) {
	return state.getImage();
}
/**
 * Returns the Type representing the primitive type int
 */
public org.eclipse.jdt.internal.core.builder.IType intType() {
	return fDevelopmentContext.fIntType;
}
/**
 * kind method comment.
 */
public int kind() {
	return K_JAVA_IMAGE;
}
/**
 * Returns the Type representing the primitive type long
 */
public org.eclipse.jdt.internal.core.builder.IType longType() {
	return fDevelopmentContext.fLongType;
}
/**
 * Returns the Type representing the primitive type short
 */
public org.eclipse.jdt.internal.core.builder.IType shortType() {
	return fDevelopmentContext.fShortType;
}
	/**
	 * Returns a string representation of the image handle.	
	 */
	public String toString() {
		return "image"/*nonNLS*/;
	}
/**
 * Returns the Type representing the primitive type void
 */
public org.eclipse.jdt.internal.core.builder.IType voidType() {
	return fDevelopmentContext.fVoidType;
}
}

Back to the top