New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After code injection injects code after any line that has "return" in it #1153

Closed
JoshuaMcManus opened this Issue Nov 19, 2017 · 1 comment

Comments

@JoshuaMcManus

JoshuaMcManus commented Nov 19, 2017

Brief Description

When using the after statement to inject code into an application, it is supposed to inject the code before any return statement. The program will instead look for any line that has "return" in it and inject the code before it.

Minimum Steps to Reproduce

Create an umple file with the following code:

class ReturnIssues
{
  String foo(int a) {

    if(a == 3) {
    	System.out.println("return");
        return "3";
    }
    
    // inject before return 
    return "";
  }

  after custom foo(int) {
    String b = "1";
    System.out.println("Returning from foo, a: " + String.valueOf(a) + ", b: " + b);
  }
}

Expected Result

// line 6 "../test.ump"
  public String foo(int a){
    if(a == 3) {
        System.out.println("return");        
        // line 16 "../test.ump"
        String b = "1";
        System.out.println("Returning from foo, a: " + String.valueOf(a) + ", b: " + b);
        // END OF UMPLE AFTER INJECTION
        return "3";
    }
    
    // inject before return    
    // line 16 "../test.ump"
    String b = "1";
    System.out.println("Returning from foo, a: " + String.valueOf(a) + ", b: " + b);
    // END OF UMPLE AFTER INJECTION
    return "";
  }

Actual Result

// line 6 "../test.ump"
  public String foo(int a){
    if(a == 3) {
    System.out.println("      
      // line 16 "../test.ump"
      String b = "1";
          System.out.println("Returning from foo, a: " + String.valueOf(a) + ", b: " + b);
      // END OF UMPLE AFTER INJECTION
      return ");        
        // line 16 "../test.ump"
        String b = "1";
            System.out.println("Returning from foo, a: " + String.valueOf(a) + ", b: " + b);
        // END OF UMPLE AFTER INJECTION
        return "3";
    }
    
   // inject before      
      // line 16 "../test.ump"
      String b = "1";
          System.out.println("Returning from foo, a: " + String.valueOf(a) + ", b: " + b);
      // END OF UMPLE AFTER INJECTION
      return    
    // line 16 "../test.ump"
    String b = "1";
        System.out.println("Returning from foo, a: " + String.valueOf(a) + ", b: " + b);
    // END OF UMPLE AFTER INJECTION
    return "";

  }

@TimLethbridge TimLethbridge added this to the April 2018 for release 1.28 milestone Dec 8, 2017

@TimLethbridge

This comment has been minimized.

Show comment
Hide comment
@TimLethbridge

TimLethbridge Mar 9, 2018

Member

If a comment has return as the first word, there is a crash

Member

TimLethbridge commented Mar 9, 2018

If a comment has return as the first word, there is a crash

@hugessen hugessen self-assigned this Apr 5, 2018

TimLethbridge added a commit that referenced this issue Apr 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment