KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > apt > core > internal > declaration > ExecutableDeclarationImpl


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 BEA Systems, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * tyeung@bea.com - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.apt.core.internal.declaration;
13
14 import java.util.Collection JavaDoc;
15
16 import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
17 import org.eclipse.jdt.apt.core.internal.util.Factory;
18 import org.eclipse.jdt.core.dom.IMethodBinding;
19 import org.eclipse.jdt.core.dom.ITypeBinding;
20
21 import com.sun.mirror.declaration.ExecutableDeclaration;
22 import com.sun.mirror.declaration.ParameterDeclaration;
23 import com.sun.mirror.declaration.TypeDeclaration;
24 import com.sun.mirror.declaration.TypeParameterDeclaration;
25 import com.sun.mirror.type.ReferenceType;
26 import com.sun.mirror.util.DeclarationVisitor;
27
28 public abstract class ExecutableDeclarationImpl
29     extends MemberDeclarationImpl implements ExecutableDeclaration
30 {
31     public ExecutableDeclarationImpl(final IMethodBinding binding, final BaseProcessorEnv env)
32     {
33         super(binding, env);
34     }
35
36     public void accept(DeclarationVisitor visitor)
37     {
38         visitor.visitExecutableDeclaration(this);
39     }
40
41     public TypeDeclaration getDeclaringType()
42     {
43         final IMethodBinding methodBinding = getDeclarationBinding();
44         return Factory.createReferenceType(methodBinding.getDeclaringClass(), _env);
45     }
46
47     public Collection JavaDoc<TypeParameterDeclaration> getFormalTypeParameters()
48     {
49         return ExecutableUtil.getFormalTypeParameters(this, _env);
50     }
51     public Collection JavaDoc<ParameterDeclaration> getParameters()
52     {
53         return ExecutableUtil.getParameters(this, _env);
54     }
55
56     public Collection JavaDoc<ReferenceType> getThrownTypes()
57     {
58         return ExecutableUtil.getThrownTypes(this, _env);
59     }
60
61     public boolean isVarArgs()
62     {
63         return getDeclarationBinding().isVarargs();
64     }
65
66     public String JavaDoc getSimpleName()
67     {
68         return getDeclarationBinding().getName();
69     }
70
71     public IMethodBinding getDeclarationBinding()
72     {
73         return (IMethodBinding)_binding;
74     }
75
76     public boolean isFromSource()
77     {
78         final ITypeBinding type = getDeclarationBinding().getDeclaringClass();
79         return ( type != null && type.isFromSource() );
80     }
81 }
82
Popular Tags