Skip to main content



      Home
Home » Modeling » EMF » [XCORE] Hide attribute getter/setter from interface([XCORE] Hiding attribute getter/setter from interface disables XCore access to attribute)
[XCORE] Hide attribute getter/setter from interface [message #1395864] Mon, 07 July 2014 10:02 Go to next message
Eclipse UserFriend
Hi,

I'm trying to hide the generated attribute getter/setter methods from the interface using XCore.

Using the ECore editor to create a model with "suppressedGetVisibility" and "suppressedSetVisibility" annotations everything ist fine, the getXxx/setXxx methods are hidden in the interface and usable in body annotations.

Using the XCore editor has the same effect on the interface, but the attributes are not available to "op" operations in the .xcore.


Here my code snippet (a "test.xcore" in "./model" directory of a XCore-Project):

package test

class A
{
    // should hide attribute getter/setter methods from interface
    @GenModel(suppressedGetVisibility="true", suppressedSetVisibility="true")
    // only local/protected access expected
    String protectedText
    /* */
    op void clearProtectedText() {
        // test "attribute" setter
        protectedText = null // !error! protectedText(Object) not found
        protectedText = "" // !error! protectedText(String) not found

        // test "method" setter
        setProtectedText(null) // !error! setProtectedText(Object) not found
        setProtectedText("") // !error! setProtectedText(String) not found
    }
    /* */
    op String myProtectedText_1() {
        // do something with protectedText
        // ...
        // and return the modified value
        return protectedText  // !error!
    }
    /* */
    op String myProtectedText_2() {
        // do something with protectedText
        // ...
        // and return the modified value
        return getProtectedText()  // !error!
    }
}


I would expect that the declaring/derived classes have access to both, attribute and getter/setter methods.
Otherwise the attribute could not be used for any purpose ...


thx for help

Re: [XCORE] Hide attribute getter/setter from interface [message #1395927 is a reply to message #1395864] Mon, 07 July 2014 12:09 Go to previous messageGo to next message
Eclipse UserFriend
Xin,

Yes, it's kind of nasty. The bodies of expressions are Xbase-compiled
against the inferred interface (which matches the generated ones), so
when not present in the interface they won't be available. I'm not sure
how best to fix that. Ideally they'd be Xbase-compiled against the
inferred implementation, which would make other proper implementation
details available as well, but, because of multiple inheritance, the
same compiled body must function in any implementation and if the class
is marked as an interface, there is no obvious implementation to compile
relative to. Please open a bugzilla (though it's a long standing
problem without an obvious solution).


On 07/07/2014 4:02 PM, xjn Mising name wrote:
> Hi,
>
> I'm trying to hide the generated attribute getter/setter methods from
> the interface using XCore.
>
> Using the ECore editor to create a model with
> "suppressedGetVisibility" and "suppressedSetVisibility" annotations
> everything ist fine, the getXxx/setXxx methods are hidden in the
> interface and usable in body annotations.
>
> Using the XCore editor has the same effect on the interface, but the
> attributes are not available to "op" operations in the .xcore.
>
>
> Here my code snippet (a "test.xcore" in "./model" directory of a
> XCore-Project):
>
>
> package test
>
> class A
> {
> // should hide attribute getter/setter methods from interface
> @GenModel(suppressedGetVisibility="true",
> suppressedSetVisibility="true")
> // only local/protected access expected
> String protectedText
> /* */
> op void clearProtectedText() {
> // test "attribute" setter
> protectedText = null // !error! protectedText(Object) not found
> protectedText = "" // !error! protectedText(String) not found
>
> // test "method" setter
> setProtectedText(null) // !error! setProtectedText(Object) not
> found
> setProtectedText("") // !error! setProtectedText(String) not found
> }
> /* */
> op String myProtectedText_1() {
> // do something with protectedText
> // ...
> // and return the modified value
> return protectedText // !error!
> }
> /* */
> op String myProtectedText_2() {
> // do something with protectedText
> // ...
> // and return the modified value
> return getProtectedText() // !error!
> }
> }
>
>
> I would expect that the declaring/derived classes have access to both,
> attribute and getter/setter methods. Otherwise the attribute could not
> be used for any purpose ...
>
>
> thx for help
>
>
Re: [XCORE] Hide attribute getter/setter from interface [message #1398563 is a reply to message #1395927] Fri, 11 July 2014 04:48 Go to previous message
Eclipse UserFriend
Bugzilla :

https://bugs.eclipse.org/bugs/show_bug.cgi?id=439408
Previous Topic:EMF Reference Clearing Queue optional?
Next Topic:XMLResource.OPTION_FORMATTED is not working
Goto Forum:
  


Current Time: Wed Jul 23 13:58:19 EDT 2025

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

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

Back to the top