Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » What is best way to get reference of JvmAnnotationType in inference?
What is best way to get reference of JvmAnnotationType in inference? [message #904208] Tue, 28 August 2012 02:19 Go to next message
Jeeeyul Lee is currently offline Jeeeyul LeeFriend
Messages: 117
Registered: July 2009
Location: Seoul
Senior Member

JvmTypesBuilder seems not to support JvmAnnotationType.

So I created it myself:
val annoType = createJvmAnnotationType =>[
	it.packageName = "java.lang"
	it.simpleName = "SuppressWarnings"
]

var annoTypeRef = createJvmAnnotationReference => [
	annotation = annoType
	values += createJvmStringAnnotationValue => [
		values += "all"
	]
]


It causes dangle problem, because this reference is not contained by resource.

I tried to inspect, but it seems to I am wandering so deep and internal mechanism.

Can anyone suggest best approach?
Re: What is best way to get reference of JvmAnnotationType in inference? [message #904286 is a reply to message #904208] Tue, 28 August 2012 07:05 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Did you try a clean build?

Am 8/28/12 4:19 AM, schrieb Jeeeyul Lee:
> JvmTypesBuilder seems not to support JvmAnnotationType.
>
> So I created it myself:
>
> val annoType = createJvmAnnotationType =>[
> it.packageName = "java.lang"
> it.simpleName = "SuppressWarnings"
> ]
>
> var annoTypeRef = createJvmAnnotationReference => [
> annotation = annoType
> values += createJvmStringAnnotationValue => [
> values += "all"
> ]
> ]
>
>
> It causes dangle problem, because this reference is not contained by
> resource.
>
> I tried to inspect, but it seems to I am wandering so deep and internal
> mechanism.
>
> Can anyone suggest best approach?


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: What is best way to get reference of JvmAnnotationType in inference? [message #904295 is a reply to message #904286] Tue, 28 August 2012 07:28 Go to previous messageGo to next message
Jeeeyul Lee is currently offline Jeeeyul LeeFriend
Messages: 117
Registered: July 2009
Location: Seoul
Senior Member

I think I did not explain my problem correctly.

I'm writing a JVM model inferrer,
I want to add an annotation(@SuppressWarning("all")) to my inferred type.

JvmTypesBuilder xtend extensions provides newTypeRef() method to create or reuse JvmTypeReference easily.
But it supports only against of JVMGenericType, not JvmAnnotationType.

So I tried to create JvmAnnotationReferernce by myself.

val annoType = createJvmAnnotationType =>[
	it.packageName = "java.lang"
	it.simpleName = "SuppressWarnings"
]

var annoTypeRef = createJvmAnnotationReference => [
	annotation = annoType
	values += createJvmStringAnnotationValue => [
		values += "all"
	]
]


in above code, annoTypeRef is not contained by any resource, because I didn't. (because I don't know which resource is appropriate)

So inferring causes an error log which reports isolated model from resourceset problem.

I tried to inspect JVMTypesBuilder and TypeReferences,
It's to complex to me,
So I think that I may going wrong way or too deep.
Re: What is best way to get reference of JvmAnnotationType in inference? [message #904299 is a reply to message #904295] Tue, 28 August 2012 07:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
It needs to be added to<code>
org.eclipse.xtext.common.types.JvmAnnotationTarget.getAnnotations()<br>
<br>
</code>
<div class="moz-cite-prefix">On 28/08/2012 9:28 AM, Jeeeyul Lee
wrote:<br>
</div>
<blockquote cite="mid:k1hrvq$4pt$1@xxxxxxxxe.org" type="cite">I
think I did not explain my problem correctly.
<br>
<br>
I'm writing a JVM model inferrer,
<br>
I want to add an annotation(@SuppressWarning("all")) to my
inferred type.
<br>
<br>
JvmTypesBuilder xtend extensions provides newTypeRef() method to
create or reuse JvmTypeReference easily.
<br>
But it supports only against of JVMGenericType, not
JvmAnnotationType.
<br>
<br>
So I tried to create JvmAnnotationReferernce by myself.
<br>
<br>
<br>
val annoType = createJvmAnnotationType =&gt;[
<br>
    it.packageName = "java.lang"
<br>
    it.simpleName = "SuppressWarnings"
<br>
]
<br>
<br>
var annoTypeRef = createJvmAnnotationReference =&gt; [
<br>
    annotation = annoType
<br>
    values += createJvmStringAnnotationValue =&gt; [
<br>
        values += "all"
<br>
    ]
<br>
]
<br>
<br>
<br>
in above code, annoTypeRef is not contained by any resource,
because I didn't. (because I don't know which resource is
appropriate)
<br>
<br>
So inferring causes an error log which reports isolated model from
resourceset problem.
<br>
<br>
I tried to inspect JVMTypesBuilder and TypeReferences, It's to
complex to me, So I think that I may going wrong way or too deep.
<br>
</blockquote>
<br>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: What is best way to get reference of JvmAnnotationType in inference? [message #904323 is a reply to message #904299] Tue, 28 August 2012 08:40 Go to previous messageGo to next message
Jeeeyul Lee is currently offline Jeeeyul LeeFriend
Messages: 117
Registered: July 2009
Location: Seoul
Senior Member

It was done by using TypeReferences

var rootType = root.toClass(typeName)[
	annotations += createJvmAnnotationReference => [
		it.annotation = references.findDeclaredType(typeof(SuppressWarnings), root) as JvmAnnotationType
		it.values += createJvmStringAnnotationValue => [
			values += "all"
		]
	]
]
Re: What is best way to get reference of JvmAnnotationType in inference? [message #1000853 is a reply to message #904323] Tue, 15 January 2013 14:46 Go to previous message
Alan Alberghini is currently offline Alan AlberghiniFriend
Messages: 19
Registered: January 2013
Junior Member
Thanks for the solution, I was looking for it!
However, I'm facing another similar issue with a JvmTypeReference: I need a "void"-kind JvmTypeReference for the return type of a method I'm inferring, but I keep getting various errors when testing the plugin.
Anyone has any insight?
Edit: for some strange reason one of my previous forum searches got stuck and I couldn't find other relevant posts.
Found the solution here.
Sorry for the inconvenience.

[Updated on: Sat, 26 January 2013 17:33]

Report message to a moderator

Previous Topic:Use xmi elements inside the dsl
Next Topic:xtext check annotation issue
Goto Forum:
  


Current Time: Wed Apr 24 16:49:42 GMT 2024

Powered by FUDForum. Page generated in 0.04218 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top