Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:02 Go to next message
xjn Mising nameFriend
Messages: 20
Registered: May 2010
Junior Member
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



br
xjn
Re: [XCORE] Hide attribute getter/setter from interface [message #1395927 is a reply to message #1395864] Mon, 07 July 2014 16:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
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
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [XCORE] Hide attribute getter/setter from interface [message #1398563 is a reply to message #1395927] Fri, 11 July 2014 08:48 Go to previous message
xjn Mising nameFriend
Messages: 20
Registered: May 2010
Junior Member
Bugzilla :

https://bugs.eclipse.org/bugs/show_bug.cgi?id=439408


br
xjn
Previous Topic:EMF Reference Clearing Queue optional?
Next Topic:XMLResource.OPTION_FORMATTED is not working
Goto Forum:
  


Current Time: Fri Apr 19 14:29:05 GMT 2024

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

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

Back to the top