umple icon indicating copy to clipboard operation
umple copied to clipboard

Umple parsing and output of annotations needs some more work

Open vahdat-ab opened this issue 9 years ago • 12 comments

Consider the following example:

class X{

 @SuppressWarnings("unchecked")
  public void analyzeToken(Token token)
  {
    analyze(token);
  }
public void analyze(Token token){}

public void analyze2(Token token){}
}

If we generate the code we won't see the method analyze while it has got the method analyze2. The issue comes to the place because of @SuppressWarnings. I think it should be related to the Umple grammar.

vahdat-ab avatar Sep 23 '16 19:09 vahdat-ab

The main issue is that Umple detects the method analyzeToken but not the one after it which is analyze. Then, it again can detect the other methods which in this case is the method analyze2.

vahdat-ab avatar Sep 23 '16 20:09 vahdat-ab

yes, of course. The Umple grammar expects all methods to follow a certain syntax. The presence of the @ breaks that syntax. To fix this we would have to allow parsing of the annotations. Maybe it is not worth bothering.

I assume analyzeToken has some old stuff in it. I assume we can't just get rid of that old stuff?

TimLethbridge avatar Sep 23 '16 20:09 TimLethbridge

I don't think this issue is worth fixing.

TimLethbridge avatar Sep 23 '16 20:09 TimLethbridge

The issue is not related to what is inside the method analyzeToken. This is not a big issue, we just wanted to get rid of those warnings in the build process.

vahdat-ab avatar Sep 23 '16 20:09 vahdat-ab

What about adding actual annotations? Then something similar to Xtend's Active Annotations could be added.

https://eclipse.org/xtend/documentation/204_activeannotations.html

Just a thought.

Nava2 avatar Sep 23 '16 20:09 Nava2

actually the method analyzeToken is not parsed. It's considered as extra code.

vahdat-ab avatar Sep 23 '16 20:09 vahdat-ab

I would be fine to have annotations pass through from methods to Java generated code if they are parsed, stored in the metamodel, and then output. But I have lowered the priority.

TimLethbridge avatar Jan 16 '17 14:01 TimLethbridge

One minor semnatics, which @TimLethbridge spoke of but I want to make more apparent is that it's not that "UmpleParser doesn't support Language Feature X", it's that "UmpleParser doesn't support Feature X".

Umple is it's own language, that yes draws heavily on Java, but it is not Java. Support for any syntactic feature should be thought of as a new feature, instead of simply porting support from language X.

Maybe the notion of annotations is worth adding to Umple, but maybe the syntax need not be identical to Java.

An example of such a decision to stray from the Java syntax was the decision to use namespace not package.

aforward avatar Jan 16 '17 14:01 aforward

Annotations (by other names) are a pretty common idiom in other languages, too. That being said, @aforward is right... just this case happens to also match the justification.

Nava2 avatar Jan 16 '17 15:01 Nava2

There is a growing need to support annotations, not just on methods, but on attributes and classes too. They should be treated as a special kind of comments and output right before the element in question.

TimLethbridge avatar Jun 21 '18 13:06 TimLethbridge

This issue is being re-opened, since it would be desirable for annotations (if not all comments) to be attached to the variables of all attributes, not just internal attributes.

TimLethbridge avatar Jun 27 '18 16:06 TimLethbridge

This should be done with #1984

TimLethbridge avatar Oct 27 '22 16:10 TimLethbridge