Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions src/main/java/jp/naist/sd/kenja/factextractor/ast/ASTMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.Type;

/**
* A class which represents Method of Java for Historage.
*
*
* @author Kenji Fujiwara
*
*/
Expand All @@ -27,6 +28,11 @@ public class ASTMethod implements Treeable {
*/
private Blob parameters;

/**
* A Blob instance corresponding to method return type.
*/
private Blob returns;

/**
* root Tree of a Method.
*/
Expand All @@ -42,6 +48,11 @@ public class ASTMethod implements Treeable {
*/
private static final String PARAMETERS_BLOB_NAME = "parameters";

/**
* file name of method return type.
*/
private static final String RETURN_BLOB_NAME = "return";

/**
* True if method is a constructor.
*/
Expand All @@ -61,7 +72,7 @@ protected ASTMethod() {

/**
* Factory method of ASTMethod from MethodDeclaration of Eclipse AST.
*
*
* @param node
* MethodDeclaration of Eclipse AST
*/
Expand All @@ -72,11 +83,16 @@ protected ASTMethod(MethodDeclaration node) {
isConstructor = node.isConstructor();
setBody(node);
setParameters(node.parameters());

Type returnType = node.getReturnType2();
if (returnType != null) {
setReturnType(returnType);
}
}

/**
* Return root tree name.
*
*
* @param node
* MethodDeclaration of Eclipse AST
* @return name of root tree
Expand Down Expand Up @@ -104,7 +120,7 @@ private String getTreeName(MethodDeclaration node) {

/**
* Read and set method body to the Blob.
*
*
* @param node
* MethodDeclaration of Eclipse AST
*/
Expand All @@ -121,7 +137,7 @@ private void setBody(MethodDeclaration node) {

/**
* Read and set method parameters to the Blob.
*
*
* @param parametersList
* list of parameters
*/
Expand All @@ -142,9 +158,22 @@ private void setParameters(List parametersList) {
parameters.setBody(parameterBody);
}

/**
* Read and set method return type to the Blob.
*
* @param returnType
* type of return value
*/
private void setReturnType(Type returnType) {
returns = new Blob(RETURN_BLOB_NAME);
root.append(returns);

returns.setBody(returnType.toString() + "\n");
}

/**
* return directory name of the method.
*
*
* @return directory name of the method
*/
public String getName() {
Expand All @@ -153,7 +182,7 @@ public String getName() {

/**
* avoid conflicting blob name.
*
*
* @param number
* unique number of conflicted method
*/
Expand All @@ -167,7 +196,7 @@ public void conflict(int number) {

/**
* Return True if method is constructor.
*
*
* @return method is constructor or not.
*/
public boolean isConstructor() {
Expand All @@ -176,7 +205,7 @@ public boolean isConstructor() {

/**
* Factory method of ASTMethod.
*
*
* @param node
* MethodDeclaration of Eclipse AST
* @return ASTMethod instance created from MethodDeclaration
Expand Down