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;
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>.
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.
26 * Source reference elements may be working copies if they were created from a
27 * compilation unit that is a working copy.
30 * This interface is not intended to be implemented by clients.
33 * @see IPackageFragmentRoot#attachSource
35 public interface ISourceReference {
37 * Returns whether this element exists in the model.
39 * @return <code>true</code> if this element exists in the Java model
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>.
50 * For class files, this returns the source of the entire compilation unit
51 * associated with the class file (if there is one).
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
60 String getSource() throws JavaModelException;
63 * Returns the source range associated with this element.
65 * For class files, this returns the range of the entire compilation unit
66 * associated with the class file (if there is one).
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
75 ISourceRange getSourceRange() throws JavaModelException;