1) Moved net.sourceforge.phpeclipse.ui\src\net\sourceforge\phpdt back to net.sourcefo...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / IMethod.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  * Represents a method (or constructor) declared in a type.
15  * <p>
16  * This interface is not intended to be implemented by clients.
17  * </p>
18  */
19 public interface IMethod extends IMember {
20         /**
21          * Returns the simple name of this method. For a constructor, this returns
22          * the simple name of the declaring type. Note: This holds whether the
23          * constructor appears in a source or binary type (even though class files
24          * internally define constructor names to be <code>"&lt;init&gt;"</code>).
25          * For the class initialization methods in binary types, this returns the
26          * special name <code>"&lt;clinit&gt;"</code>. This is a handle-only
27          * method.
28          */
29         String getElementName();
30
31         /**
32          * Returns the type signatures of the exceptions this method throws, in the
33          * order declared in the source. Returns an empty array if this method
34          * throws no exceptions.
35          * 
36          * <p>
37          * For example, a source method declaring <code>"throws IOException"</code>,
38          * would return the array <code>{"QIOException;"}</code>.
39          * 
40          * @exception JavaModelException
41          *                if this element does not exist or if an exception occurs
42          *                while accessing its corresponding resource.
43          * @return the type signatures of the exceptions this method throws, in the
44          *         order declared in the source, an empty array if this method
45          *         throws no exceptions
46          * @see Signature
47          */
48         String[] getExceptionTypes() throws JavaModelException;
49
50         /**
51          * Returns the number of parameters of this method. This is a handle-only
52          * method.
53          * 
54          * @return the number of parameters of this method
55          */
56         int getNumberOfParameters();
57
58         /**
59          * Returns the names of parameters in this method. For binary types, these
60          * names are invented as "arg"+i, where i starts at 1 (even if source is
61          * associated with the binary). Returns an empty array if this method has no
62          * parameters.
63          * 
64          * <p>
65          * For example, a method declared as
66          * <code>public void foo(String text, int length)</code> would return the
67          * array <code>{"text","length"}</code>.
68          * 
69          * @exception JavaModelException
70          *                if this element does not exist or if an exception occurs
71          *                while accessing its corresponding resource.
72          * @return the names of parameters in this method, an empty array if this
73          *         method has no parameters
74          */
75         String[] getParameterNames() throws JavaModelException;
76
77         /**
78          * Returns the type signatures for the parameters of this method. Returns an
79          * empty array if this method has no parameters. This is a handle-only
80          * method.
81          * 
82          * <p>
83          * For example, a source method declared as
84          * <code>public void foo(String text, int length)</code> would return the
85          * array <code>{"QString;","I"}</code>.
86          * 
87          * @return the type signatures for the parameters of this method, an empty
88          *         array if this method has no parameters
89          * @see Signature
90          */
91         String[] getParameterTypes();
92
93         /**
94          * Returns the type signature of the return value of this method. For
95          * constructors, this returns the signature for void.
96          * 
97          * <p>
98          * For example, a source method declared as
99          * <code>public String getName()</code> would return
100          * <code>"QString;"</code>.
101          * 
102          * @exception JavaModelException
103          *                if this element does not exist or if an exception occurs
104          *                while accessing its corresponding resource.
105          * @return the type signature of the return value of this method, void for
106          *         constructors
107          * @see Signature
108          */
109         String getReturnType() throws JavaModelException;
110
111         /**
112          * Returns the signature of the method. This includes the signatures for the
113          * parameter types and return type, but does not include the method name or
114          * exception types.
115          * 
116          * <p>
117          * For example, a source method declared as
118          * <code>public void foo(String text, int length)</code> would return
119          * <code>"(QString;I)V"</code>.
120          * 
121          * @exception JavaModelException
122          *                if this element does not exist or if an exception occurs
123          *                while accessing its corresponding resource.
124          * 
125          * @see Signature
126          */
127         String getSignature() throws JavaModelException;
128
129         /**
130          * Returns whether this method is a constructor.
131          * 
132          * @exception JavaModelException
133          *                if this element does not exist or if an exception occurs
134          *                while accessing its corresponding resource.
135          * 
136          * @return true if this method is a constructor, false otherwise
137          */
138         boolean isConstructor() throws JavaModelException;
139
140         /**
141          * Returns whether this method is a main method. It is a main method if:
142          * <ul>
143          * <li>its name is equal to <code>"main"</code></li>
144          * <li>its return type is <code>void</code></li>
145          * <li>it is <code>static</code> and <code>public</code></li>
146          * <li>it defines one parameter whose type's simple name is </code>String[]</code></li>
147          * </ul>
148          * 
149          * @exception JavaModelException
150          *                if this element does not exist or if an exception occurs
151          *                while accessing its corresponding resource.
152          * @since 2.0
153          * @return true if this method is a main method, false otherwise
154          */
155         boolean isMainMethod() throws JavaModelException;
156
157         /**
158          * Returns whether this method is similar to the given method. Two methods
159          * are similar if:
160          * <ul>
161          * <li>their element names are equal</li>
162          * <li>they have the same number of parameters</li>
163          * <li>the simple names of their parameter types are equal</li>
164          * </ul>
165          * This is a handle-only method.
166          * 
167          * @param method
168          *            the given method
169          * @return true if this method is similar to the given method.
170          * @see Signature#getSimpleName
171          * @since 2.0
172          */
173         boolean isSimilar(IMethod method);
174 }