MathewWi / umple

Automatically exported from code.google.com/p/umple
0 stars 0 forks source link

Interface isA statements ignored if preceded by most statements #596

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Compile the following code:
interface A {
  //comment
  isA B;
}

The isA statement is ignored. This code is expected to give an error that "B" 
does not exist.

This appears to be caused by the analysis of an interface not properly handling 
any statement but a method declaration or a constant declaration. For example 
this code compiles and generates the proper Java:

interface A {
  boolean someMethod();
  isA B;
}

interface B {}

Generated Java code for interface A:
/*PLEASE DO NOT EDIT THIS CODE*/
/*This code was generated using the UMPLE 1.20.1.4071 modeling language!*/

public interface A extends B
{

  // ABSTRACT METHODS 

 public boolean someMethod();
}

Related issues:
issue 595
issue 442
issue 592 (comment 4)

Original issue reported on code.google.com by CraigBry...@gmail.com on 12 Jun 2014 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by PedroAug...@gmail.com on 17 Jun 2014 at 4:31

GoogleCodeExporter commented 9 years ago
Cause:

interface A {
  //comment
  isA B;
}

The above code is being parsed as:

[ROOT:][interfaceDefinition][name:A][interfaceMemberDeclaration][extraCode://com
ment isA B;]

This means that the grammar rules that define the structure of an interface 
body are not considering the situation when it constains comments. When this 
case occurs, any code after a comment is seem as extra code, consequently it is 
not parsable by Umple.

Solution:

By changing the grammar from 

interfaceMemberDeclaration : [[constantDeclaration]] | 
[[constantDeclarationDeprecated]] | [[abstractMethodDeclaration]] | 
[[position]] | [[displayColor]] | [[isA]] | [[extraCode]]

to

interfaceMemberDeclaration : [[comment]] | [[constantDeclaration]] | 
[[constantDeclarationDeprecated]] | [[abstractMethodDeclaration]] | 
[[position]] | [[displayColor]] | [[isA]] | [[extraCode]]

The parser will be able to, correctly, identify the comments inside an 
interface body and form a root token.

Original comment by PedroAug...@gmail.com on 19 Jun 2014 at 6:41

GoogleCodeExporter commented 9 years ago
Attached are the patch and issue summary.

Original comment by PedroAug...@gmail.com on 20 Jun 2014 at 4:56

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by TimothyCLethbridge on 5 Aug 2014 at 7:03