Skip to content
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

Comma separated values in after/before statements don't execute properly #682

Closed
Shikib opened this Issue Jan 15, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@Shikib
Copy link
Member

commented Jan 15, 2016

I think there is an issue with how the after/before pattern matching code is handling comma separated operations. The issue can be observed with the examples on the following page: http://cruise.eecs.uottawa.ca/umple/CodeInjectionPatternMatching.html.

Consider the following Umple code:

class Student
{
  const Boolean DEBUG = true;
  firstName;
  lastName;
  cityOfBirth;
  before get*,!getCityOfBirth { 
    if ( DEBUG) { System.out.println("accessing the name"); }
  }
}

The expected output would be to have everything that starts with get AND is not getCityOfBirth have the code injected. However, in actuality the code was injected into getCityOfBirth as well.

It seems that only the first operation in the comma separated list is being looked at. If I switch the order of the commands:

class Student
{
  const Boolean DEBUG = true;
  firstName;
  lastName;
  cityOfBirth;
  before !getCityOfBirth,get* { 
    if ( DEBUG) { System.out.println("accessing the name"); }
  }
}

I now see everything that isn't getCityOfBirth having the code inserted, including the set methods. The second operation (select only things that start with get) is completely ignored.

@TimLethbridge

This comment has been minimized.

Copy link
Member

commented Feb 10, 2016

The above issue has been partly dealt with. I notice that when
class Student
{
const Boolean DEBUG = true;
firstName;
lastName;
cityOfBirth;
before get*,!getCityOfBirth {
if ( DEBUG) { System.out.println("accessing the name"); }
}
}

Is entered, the code injection now omits getCityOfBirth

However an important new problem has been introduced

Warning on line 7 : Method '!getCityOfBirth' cannot be found. Injection was ignored.. More information (1012)

@a3994288

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2017

The original problem seems to be resolved. I think the issue we are having now is the parser will somehow treat "!getCityOfBirth" as a method name so it will raise the warning (instead of checking the method name getCityOfBirth). Here are some tests I have tried.

class Student
{
  const Boolean DEBUG = true;
  firstName;
  lastName;
  cityOfBirth;
  before set*, get* { 
    if ( DEBUG) { System.out.println("accessing the name"); }
  }
} 

This is working fine, which prove that the original problem with comma has be resolved.

class Student
{
  const Boolean DEBUG = true;
  firstName;
  lastName;
  cityOfBirth;
  before !getCityOfBirth { 
    if ( DEBUG) { System.out.println("accessing the name"); }
  }
} 

The code injection will omit getCityOfBirth and inject code in all other method. So the injection is working fine.
However, it also raises the warning:

Warning on line 7 : Method '!getCityOfBirth' cannot be found. Injection was ignored.. More information (1012)

I believe there is something need to be fixed in the compiler so that when it sees an exclamation mark(!), it should only check the name without the exclamation mark(!)

I will do more investigation of this issue

@a3994288

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2017

I am able to locate the issue and fix it, here is my question about the design.

consider the code below, should I raise a warning for "!getCityOfSomething" because the method "getCityOfSomething" does not exist? I do not think we need to because if "getCityOfSomething" does not exist, it just means select all other methods.
If I am right, I will just stop matching the method name if the operation starts with an exclamation mark(!), and the following code should be compiled with no problem.
If I am wrong, the following code should generate a warning.

class Student
{
  const Boolean DEBUG = true;
  firstName;
  lastName;
  cityOfBirth;
  before !getCityOfSomething { 
    if ( DEBUG) { System.out.println("accessing the name"); }
  }
} 
@TimLethbridge

This comment has been minimized.

Copy link
Member

commented Jan 23, 2017

The actual message of the warning is clearly wrong ... the injection must not be ignored. But when something is negated like this, there is the expectation that the programmer was expecting to find it and simply didn't want the injection to occur. So the warning in that case should be

Excluded method getCityOfBirth was not found. This exclusion was ignored.

@a3994288

This comment has been minimized.

Copy link
Contributor

commented Jan 27, 2017

Solution
added a warning:

1014: 3, "http://cruise.eecs.uottawa.ca/umple/PageBeingDeveloped.html", Excluded method '{0}' cannot be found. The exclusion was ignored. ;

This will raise when there is an exclusion method like "!getMyBirth", and getMyBirth method does not exist.

@a3994288

This comment has been minimized.

Copy link
Contributor

commented Feb 20, 2017

Can we close this? this PR was merged. @vahdat-ab

@vahdat-ab vahdat-ab closed this Feb 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.