<commit_before>/* 
 * Copyright 2012 <NAME> and other contributors
 * http://chirrup.org/
 * 
 * See the file LICENSE for copying permission.
 */

package edu.syr.pcpratts.rootbeer.util;

public class MethodSignatureUtil {

  public String classFromSig(String signature){
    String[] tokens = signature.split(":");
    String first = tokens[0].trim();
    return first.substring(1);
  }
  
  public String methodSubSig(String signature){
    String[] tokens = signature.split(":");
    String second = tokens[1].trim();
    String[] tokens2 = second.split("\\)");
    return tokens2[0].trim() + ")";
  }
  
  
  
  public static void main(String[] args){
    String sig = "<rootbeertest.GpuWorkItem: void <init>()>";
    MethodSignatureUtil util = new MethodSignatureUtil();
    System.out.println(util.classFromSig(sig));
    System.out.println(util.methodSubSig(sig));
  }
}<commit_msg>new MethodSignatureUtil parses entire signature<commit_after>/* 
 * Copyright 2012 <NAME> and other contributors
 * http://chirrup.org/
 * 
 * See the file LICENSE for copying permission.
 */

package edu.syr.pcpratts.rootbeer.util;

import java.util.ArrayList;
import java.util.List;

public class MethodSignatureUtil {

  private String m_className;
  private String m_returnType;
  private String m_methodName;
  private List<String> m_params;
  
  public void parse(String signature){
    String[] tokens0 = signature.split(":");
    String cls = tokens0[0].trim();
    m_className = cls.substring(1);
    
    String method_sub_sig = tokens0[1].trim();
    method_sub_sig = method_sub_sig.substring(0, method_sub_sig.length()-1);
    
    String[] tokens1 = method_sub_sig.split("\\(");
    String front = tokens1[0].trim();
    String back = tokens1[1].trim();
    
    String[] tokens2 = front.split(" ");
    m_returnType = tokens2[0].trim();
    m_methodName = tokens2[1].trim();
    
    String params = back.substring(0, back.length()-1);
    String[] param_tokens = params.split(",");
    m_params = new ArrayList<String>();
    
    for(String param : param_tokens){
      m_params.add(param.trim()); 
    }
  }
  
  private void print(){
    System.out.println("return_type: ["+m_returnType+"]");
    System.out.println("class_name: ["+m_className+"]");
    System.out.println("method_name: ["+m_methodName+"]");
    System.out.print("args: [");
    for(String arg : m_params){
      System.out.println("  {"+arg+"}");
    }
    System.out.println("]");
  }
  
  public String getClassName(){
    return m_className;
  }
  
  public void setClassName(String class_name){
    m_className = class_name; 
  }
  
  public String getReturnType(){
    return m_returnType;
  }
  
  public void setReturnType(String return_type){
    m_returnType = return_type; 
  }
  
  public String getMethodName(){
    return m_methodName;
  }
  
  public void setMethodName(String method_name){
    m_methodName = method_name; 
  }
  
  public List<String> getParameterTypes(){
    return m_params;
  }
  
  public void setParameterTypes(List<String> params){
    m_params = params; 
  }
  
  @Override
  public String toString(){
    StringBuilder ret = new StringBuilder();
    ret.append("<");
    ret.append(m_className);
    ret.append(": ");
    ret.append(m_returnType);
    ret.append(" ");
    ret.append(m_methodName);
    ret.append("(");
    for(int i = 0; i < m_params.size(); ++i){
      ret.append(m_params.get(i));
      if(i < m_params.size() - 1){
        ret.append(", "); 
      }
    }
    ret.append(")>");
    return ret.toString();
  }
  
  public static void main(String[] args){
    String sig = "<rootbeertest.GpuWorkItem: void <init>(java.lang.String, java.util.Random)>";
    MethodSignatureUtil util = new MethodSignatureUtil();
    util.parse(sig);
    util.print();
  }
}
{'fraction_non_alphanumeric': 0.14783526927138332, 'fraction_numerical': 0.009503695881731784, 'mean_word_length': 3.3652073732718892, 'pattern_counts': {'":': 4, '<': 16, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1370104', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1220, 'n_words': 257}