* Copyright (C) 2010 Robert Futrell
* robert_futrell at users.sourceforge.net
* http://fifesoft.com/rsyntaxtextarea
* This library is distributed under a modified BSD license. See the included
* RSTALanguageSupport.License.txt file for details.
package org.fife.rsta.ac.java;
import org.fife.rsta.ac.java.MemberCompletion.Data;
import org.fife.rsta.ac.java.rjc.ast.Method;
import org.fife.rsta.ac.java.rjc.ast.TypeDeclaration;
import org.fife.rsta.ac.java.rjc.lang.Modifiers;
import org.fife.rsta.ac.java.rjc.lang.Type;
* Metadata about a method as read from a Java source file. This class is
* used by instances of {@link MethodCompletion}.
class MethodData implements Data {
public MethodData(Method method) {
public String getEnclosingClassName(boolean fullyQualified) {
// NOTE: This check isn't really necessary, but is here just in case
// there's a bug in the parsing code.
TypeDeclaration td = method.getParentTypeDeclaration();
new Exception("No parent type declaration for: " + getSignature()).
return td.getName(fullyQualified);
public String getIcon() {
Modifiers mod = method.getModifiers();
key = IconFactory.METHOD_DEFAULT_ICON;
else if (mod.isPrivate()) {
key = IconFactory.METHOD_PRIVATE_ICON;
else if (mod.isProtected()) {
key = IconFactory.METHOD_PROTECTED_ICON;
else if (mod.isPublic()) {
key = IconFactory.METHOD_PUBLIC_ICON;
key = IconFactory.METHOD_DEFAULT_ICON;
public String getSignature() {
return method.getNameAndParameters();
public String getSummary() {
String docComment = method.getDocComment();
return docComment!=null ? docComment : method.toString();
public String getType() {
Type type = method.getType();
return type==null ? "void" : type.toString();
public boolean isAbstract() {
return method.getModifiers().isAbstract();
public boolean isConstructor() {
return method.isConstructor();
public boolean isDeprecated() {
return method.isDeprecated();
public boolean isFinal() {
return method.getModifiers().isFinal();
public boolean isStatic() {
return method.getModifiers().isStatic();