A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / ISourceReference.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.core;
12
13 /**
14  * Common protocol for Java elements that have associated source code. This set
15  * consists of <code>IClassFile</code>, <code>ICompilationUnit</code>,
16  * <code>IPackageDeclaration</code>, <code>IImportDeclaration</code>,
17  * <code>IImportContainer</code>, <code>IType</code>, <code>IField</code>,
18  * <code>IMethod</code>, and <code>IInitializer</code>.
19  * </ul>
20  * <p>
21  * Note: For <code>IClassFile</code>, <code>IType</code> and other members
22  * derived from a binary type, the implementation returns source iff the element
23  * has attached source code.
24  * </p>
25  * <p>
26  * Source reference elements may be working copies if they were created from a
27  * compilation unit that is a working copy.
28  * </p>
29  * <p>
30  * This interface is not intended to be implemented by clients.
31  * </p>
32  * 
33  * @see IPackageFragmentRoot#attachSource
34  */
35 public interface ISourceReference {
36         /**
37          * Returns whether this element exists in the model.
38          * 
39          * @return <code>true</code> if this element exists in the Java model
40          * @since 2.0
41          */
42         boolean exists();
43
44         /**
45          * Returns the source code associated with this element. This extracts the
46          * substring from the source buffer containing this source element. This
47          * corresponds to the source range that would be returned by
48          * <code>getSourceRange</code>.
49          * <p>
50          * For class files, this returns the source of the entire compilation unit
51          * associated with the class file (if there is one).
52          * </p>
53          * 
54          * @return the source code, or <code>null</code> if this element has no
55          *         associated source code
56          * @exception JavaModelException
57          *                if this element does not exist or if an exception occurs
58          *                while accessing its corresponding resource
59          */
60         String getSource() throws JavaModelException;
61
62         /**
63          * Returns the source range associated with this element.
64          * <p>
65          * For class files, this returns the range of the entire compilation unit
66          * associated with the class file (if there is one).
67          * </p>
68          * 
69          * @return the source range, or <code>null</code> if this element has no
70          *         associated source code
71          * @exception JavaModelException
72          *                if this element does not exist or if an exception occurs
73          *                while accessing its corresponding resource
74          */
75         ISourceRange getSourceRange() throws JavaModelException;
76 }