1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.core;
13 import org.eclipse.core.runtime.IPath;
16 * An entry on a Java project classpath identifying one or more package fragment
17 * roots. A classpath entry has a content kind (either source,
18 * <code>K_SOURCE</code>, or binary, <code>K_BINARY</code>), which is inherited
19 * by each package fragment root and package fragment associated with the entry.
21 * A classpath entry can refer to any of the following:<ul>
23 * <li>Source code in the current project. In this case, the entry identifies a
24 * root folder in the current project containing package fragments and
25 * <code>.java</code> source files. The root folder itself represents a default
26 * package, subfolders represent package fragments, and <code>.java</code> files
27 * represent compilation units. All compilation units will be compiled when
28 * the project is built. The classpath entry must specify the
29 * absolute path to the root folder. Entries of this kind are
30 * associated with the <code>CPE_SOURCE</code> constant.
31 * Source classpath entries can carry patterns to exclude selected files.
32 * Excluded <code>.java</code> source files do not appear as compilation
33 * units and are not compiled when the project is built.
36 * <li>A binary library in the current project, in another project, or in the external
37 * file system. In this case the entry identifies a JAR (or root folder) containing
38 * package fragments and <code>.class</code> files. The classpath entry
39 * must specify the absolute path to the JAR (or root folder), and in case it refers
40 * to an external JAR, then there is no associated resource in the workbench. Entries
41 * of this kind are associated with the <code>CPE_LIBRARY</code> constant.</li>
43 * <li>A required project. In this case the entry identifies another project in
44 * the workspace. The required project is used as a binary library when compiling
45 * (that is, the builder looks in the output location of the required project
46 * for required <code>.class</code> files when building). When performing other
47 * "development" operations - such as code assist, code resolve, type hierarchy
48 * creation, etc. - the source code of the project is referred to. Thus, development
49 * is performed against a required project's source code, and compilation is
50 * performed against a required project's last built state. The
51 * classpath entry must specify the absolute path to the
52 * project. Entries of this kind are associated with the <code>CPE_PROJECT</code>
54 * Note: referencing a required project with a classpath entry refers to the source
55 * code or associated <code>.class</code> files located in its output location.
56 * It will also automatically include any other libraries or projects that the required project's classpath
57 * refers to, iff the corresponding classpath entries are tagged as being exported
58 * (<code>IClasspathEntry#isExported</code>).
59 * Unless exporting some classpath entries, classpaths are not chained by default -
60 * each project must specify its own classpath in its entirety.</li>
62 * <li> A path beginning in a classpath variable defined globally to the workspace.
63 * Entries of this kind are associated with the <code>CPE_VARIABLE</code> constant.
64 * Classpath variables are created using <code>JavaCore#setClasspathVariable</code>,
65 * and gets resolved, to either a project or library entry, using
66 * <code>JavaCore#getResolvedClasspathVariable</code>.
67 * It is also possible to register an automatic initializer (<code>ClasspathVariableInitializer</code>),
68 * which will be invoked through the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
69 * After resolution, a classpath variable entry may either correspond to a project or a library entry. </li>
71 * <li> A named classpath container identified by its container path.
72 * A classpath container provides a way to indirectly reference a set of classpath entries through
73 * a classpath entry of kind <code>CPE_CONTAINER</code>. Typically, a classpath container can
74 * be used to describe a complex library composed of multiple JARs, projects or classpath variables,
75 * considering also that containers can be mapped differently on each project. Several projects can
76 * reference the same generic container path, but have each of them actually bound to a different
78 * The container path is a formed by a first ID segment followed with extra segments,
79 * which can be used as additional hints for resolving this container reference. If no container was ever
80 * recorded for this container path onto this project (using <code>setClasspathContainer</code>,
81 * then a <code>ClasspathContainerInitializer</code> will be activated if any was registered for this
82 * container ID onto the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
83 * A classpath container entry can be resolved explicitly using <code>JavaCore#getClasspathContainer</code>
84 * and the resulting container entries can contain any non-container entry. In particular, it may contain variable
85 * entries, which in turn needs to be resolved before being directly used.
86 * <br> Also note that the container resolution APIs include an IJavaProject argument, so as to allow the same
87 * container path to be interpreted in different ways for different projects. </li>
90 * The result of <code>IJavaProject#getResolvedClasspath</code> will have all entries of type
91 * <code>CPE_VARIABLE</code> and <code>CPE_CONTAINER</code> resolved to a set of
92 * <code>CPE_SOURCE</code>, <code>CPE_LIBRARY</code> or <code>CPE_PROJECT</code>
95 * Any classpath entry other than a source folder (kind <code>CPE_SOURCE</code>) can
96 * be marked as being exported. Exported entries are automatically contributed to
97 * dependent projects, along with the project's default output folder, which is
98 * implicitly exported, and any auxiliary output folders specified on source
99 * classpath entries. The project's output folder(s) are always listed first,
100 * followed by the any exported entries.
102 * This interface is not intended to be implemented by clients.
103 * Classpath entries can be created via methods on <code>JavaCore</code>.
106 * @see JavaCore#newLibraryEntry
107 * @see JavaCore#newProjectEntry
108 * @see JavaCore#newSourceEntry
109 * @see JavaCore#newVariableEntry
110 * @see JavaCore#newContainerEntry
111 * @see ClasspathVariableInitializer
112 * @see ClasspathContainerInitializer
114 public interface IClasspathEntry {
117 * Entry kind constant describing a classpath entry identifying a
118 * library. A library is a folder or JAR containing package
119 * fragments consisting of pre-compiled binaries.
124 * Entry kind constant describing a classpath entry identifying a
130 * Entry kind constant describing a classpath entry identifying a
131 * folder containing package fragments with source code
137 * Entry kind constant describing a classpath entry defined using
138 * a path that begins with a classpath variable reference.
140 int CPE_VARIABLE = 4;
143 * Entry kind constant describing a classpath entry representing
144 * a name classpath container.
148 int CPE_CONTAINER = 5;
151 * Returns the kind of files found in the package fragments identified by this
154 * @return <code>IPackageFragmentRoot.K_SOURCE</code> for files containing
155 * source code, and <code>IPackageFragmentRoot.K_BINARY</code> for binary
157 * There is no specified value for an entry denoting a variable (<code>CPE_VARIABLE</code>)
158 * or a classpath container (<code>CPE_CONTAINER</code>).
160 int getContentKind();
163 * Returns the kind of this classpath entry.
167 * <li><code>CPE_SOURCE</code> - this entry describes a source root in
169 * <li><code>CPE_LIBRARY</code> - this entry describes a folder or JAR
171 * <li><code>CPE_PROJECT</code> - this entry describes another project
173 * <li><code>CPE_VARIABLE</code> - this entry describes a project or library
174 * indirectly via a classpath variable in the first segment of the path
176 * <li><code>CPE_CONTAINER</code> - this entry describes set of entries
177 * referenced indirectly via a classpath container
183 * Returns the set of patterns used to exclude resources associated with
186 * Exclusion patterns allow specified portions of the resource tree rooted
187 * at this source entry's path to be filtered out. If no exclusion patterns
188 * are specified, this source entry includes all relevent files. Each path
189 * specified must be a relative path, and will be interpreted relative
190 * to this source entry's path. File patterns are case-sensitive. A file
191 * matched by one or more of these patterns is excluded from the
192 * corresponding package fragment root.
195 * Note that there is no need to supply a pattern to exclude ".class" files
196 * because a source entry filters these out automatically.
199 * The pattern mechanism is similar to Ant's. Each pattern is represented as
200 * a relative path. The path segments can be regular file or folder names or simple patterns
201 * involving standard wildcard characters.
204 * '*' matches 0 or more characters within a segment. So
205 * <code>*.java</code> matches <code>.java</code>, <code>a.java</code>
206 * and <code>Foo.java</code>, but not <code>Foo.properties</code>
207 * (does not end with <code>.java</code>).
210 * '?' matches 1 character within a segment. So <code>?.java</code>
211 * matches <code>a.java</code>, <code>A.java</code>,
212 * but not <code>.java</code> or <code>xyz.java</code> (neither have
213 * just one character before <code>.java</code>).
216 * Combinations of *'s and ?'s are allowed.
219 * The special pattern '**' matches zero or more segments. A path
220 * like <code>tests/</code> that ends in a trailing separator is interpreted
221 * as <code>tests/**</code>, and would match all files under the
222 * the folder named <code>tests</code>.
228 * <code>tests/**</code> (or simply <code>tests/</code>)
229 * matches all files under a root folder
230 * named <code>tests</code>. This includes <code>tests/Foo.java</code>
231 * and <code>tests/com/example/Foo.java</code>, but not
232 * <code>com/example/tests/Foo.java</code> (not under a root folder named
233 * <code>tests</code>).
236 * <code>tests/*</code> matches all files directly below a root
237 * folder named <code>tests</code>. This includes <code>tests/Foo.java</code>
238 * and <code>tests/FooHelp.java</code>
239 * but not <code>tests/com/example/Foo.java</code> (not directly under
240 * a folder named <code>tests</code>) or
241 * <code>com/Foo.java</code> (not under a folder named <code>tests</code>).
244 * <code>**/tests/**</code> matches all files under any
245 * folder named <code>tests</code>. This includes <code>tests/Foo.java</code>,
246 * <code>com/examples/tests/Foo.java</code>, and
247 * <code>com/examples/tests/unit/Foo.java</code>, but not
248 * <code>com/example/Foo.java</code> (not under a folder named
249 * <code>tests</code>).
254 * @return the possibly empty list of resource exclusion patterns
255 * associated with this source entry, and <code>null</code> for other
256 * kinds of classpath entries
259 IPath[] getExclusionPatterns();
262 * Returns the full path to the specific location where the builder writes
263 * <code>.class</code> files generated for this source entry
264 * (entry kind <code>CPE_SOURCE</code>).
266 * Source entries can optionally be associated with a specific output location.
267 * If none is provided, the source entry will be implicitly associated with its project
268 * default output location (see <code>IJavaProject#getOutputLocation</code>).
270 * NOTE: A specific output location cannot coincidate with another source/library entry.
273 * @return the full path to the specific location where the builder writes
274 * <code>.class</code> files for this source entry, or <code>null</code>
275 * if using default output folder
278 IPath getOutputLocation();
281 * Returns the path of this classpath entry.
283 * The meaning of the path of a classpath entry depends on its entry kind:<ul>
284 * <li>Source code in the current project (<code>CPE_SOURCE</code>) -
285 * The path associated with this entry is the absolute path to the root folder. </li>
286 * <li>A binary library in the current project (<code>CPE_LIBRARY</code>) - the path
287 * associated with this entry is the absolute path to the JAR (or root folder), and
288 * in case it refers to an external JAR, then there is no associated resource in
290 * <li>A required project (<code>CPE_PROJECT</code>) - the path of the entry denotes the
291 * path to the corresponding project resource.</li>
292 * <li>A variable entry (<code>CPE_VARIABLE</code>) - the first segment of the path
293 * is the name of a classpath variable. If this classpath variable
294 * is bound to the path <it>P</it>, the path of the corresponding classpath entry
295 * is computed by appending to <it>P</it> the segments of the returned
296 * path without the variable.</li>
297 * <li> A container entry (<code>CPE_CONTAINER</code>) - the path of the entry
298 * is the name of the classpath container, which can be bound indirectly to a set of classpath
299 * entries after resolution. The containerPath is a formed by a first ID segment followed with
300 * extra segments that can be used as additional hints for resolving this container
301 * reference (also see <code>IClasspathContainer</code>).
305 * @return the path of this classpath entry
310 * Returns the path to the source archive or folder associated with this
311 * classpath entry, or <code>null</code> if this classpath entry has no
314 * Only library and variable classpath entries may have source attachments.
315 * For library classpath entries, the result path (if present) locates a source
316 * archive or folder. This archive or folder can be located in a project of the
317 * workspace or outside thr workspace. For variable classpath entries, the
318 * result path (if present) has an analogous form and meaning as the
319 * variable path, namely the first segment is the name of a classpath variable.
322 * @return the path to the source archive or folder, or <code>null</code> if none
324 IPath getSourceAttachmentPath();
327 * Returns the path within the source archive or folder where package fragments
328 * are located. An empty path indicates that packages are located at
329 * the root of the source archive or folder. Returns a non-<code>null</code> value
330 * if and only if <code>getSourceAttachmentPath</code> returns
331 * a non-<code>null</code> value.
333 * @return the path within the source archive or folder, or <code>null</code> if
336 IPath getSourceAttachmentRootPath();
339 * Returns whether this entry is exported to dependent projects.
340 * Always returns <code>false</code> for source entries (kind
341 * <code>CPE_SOURCE</code>), which cannot be exported.
343 * @return <code>true</code> if exported, and <code>false</code> otherwise
346 boolean isExported();
349 * This is a helper method, which returns the resolved classpath entry denoted
350 * by an entry (if it is a variable entry). It is obtained by resolving the variable
351 * reference in the first segment. Returns <node>null</code> if unable to resolve using
352 * the following algorithm:
354 * <li> if variable segment cannot be resolved, returns <code>null</code></li>
355 * <li> finds a project, JAR or binary folder in the workspace at the resolved path location</li>
356 * <li> if none finds an external JAR file or folder outside the workspace at the resolved path location </li>
357 * <li> if none returns <code>null</code></li>
360 * Variable source attachment is also resolved and recorded in the resulting classpath entry.
362 * @return the resolved library or project classpath entry, or <code>null</code>
363 * if the given path could not be resolved to a classpath entry
365 * Note that this deprecated API doesn't handle CPE_CONTAINER entries.
367 * @deprecated - use JavaCore.getResolvedClasspathEntry(...)
369 IClasspathEntry getResolvedEntry();