Skip to main content



      Home
Home » Modeling » OCL » Refactor OCL statement, PrettyPrinter ignores code formatting
Refactor OCL statement, PrettyPrinter ignores code formatting [message #1384860] Mon, 02 June 2014 11:16 Go to next message
Eclipse UserFriend
I want to re-factor OCL statement and i have done it using PrettyPrinter but the problem with prettyPrinter is that it ignores all code formatting (spaces, indentation, line breaks etc).

Then i am trying to use EssentialOCL to refactor OCL statement so code formatting should remain as it is.

What can be best solution for re-factoring OCL statement.


Cheers
Re: Refactor OCL statement, PrettyPrinter ignores code formatting [message #1384869 is a reply to message #1384860] Mon, 02 June 2014 12:25 Go to previous messageGo to next message
Eclipse UserFriend
Hi

In my earlier message I wrote

> I suggest that you start a new thread in which you clearly identify:

> The context of your problem: what model representations you have,
with a small example

you provide no model representations and no example

> The problem to solve: what changes you want in those model
representations, with a small example

you only hint at some kind of refactoring; no example

> Do not confuse the issue by assuming a particular technology or
approach.

you tell me me about a PrettyPrinting solution.

Why do you make it so hard for me to help you?

Regards

Ed Willink
Re: Refactor OCL statement, PrettyPrinter ignores code formatting [message #1385149 is a reply to message #1384869] Wed, 04 June 2014 11:28 Go to previous messageGo to next message
Eclipse UserFriend
I have attached a plugin project. Please run the project as eclipse application and console will show following :
----------with classic OCL------------------------------

--mycomment
if 1=1 then
2*(tNew + 1)
else
0
endif

---------------------------------------------------------
----------with Pivot OCL and Pretty Printer--------------

if 1 = 1 then 2 * (newT + 1) else 0 endif

---------------------------------------------------------
I am creating very simple ecore model at run time. It contains one class("TestClass") having two attributes ("t1", "t2"). Same Ecore model is also available in oclinecore format in "model" folder just to make sure you can easily understand the model.

I want to change the rename "t2" to "tNew" but before doing that i want to refactor OCL statement of "t1" to make sure it use "tNew" instead of "t2".
Please check ClassicOCL.java. It is very easy to do it in classic OCL. All the code formatting in OCL statement remains intact and i did not have to save Ecore model in File format, it remains in memory and it is very nice.

I want to do the same in Pivot OCL and i have used PrettyPrinter for this purpose.
Please check PivotAndPrettyPrinter.java. I have successfully refactored but the code formatting in OCL statement is gone. How to make sure all code formatting remain intact while refactoring? I am open to use other solutions to achieve this.

I hope i have explained the problem well.

Cheers,
Re: Refactor OCL statement, PrettyPrinter ignores code formatting [message #1385151 is a reply to message #1385149] Wed, 04 June 2014 11:41 Go to previous message
Eclipse UserFriend
Hi

Try reading my earlier email.

The obvious answer to your solution is not to create the wrong Ecore in
the first place.

Regards

Ed Willink



On 04/06/2014 16:28, ModelGeek Mising name wrote:
> I have attached a plugin project. Please run the project as eclipse application and console will show following :
> ----------with classic OCL------------------------------
>
> --mycomment
> if 1=1 then
> 2*(tNew + 1)
> else
> 0
> endif
>
> ---------------------------------------------------------
> ----------with Pivot OCL and Pretty Printer--------------
>
> if 1 = 1 then 2 * (newT + 1) else 0 endif
>
> ---------------------------------------------------------
> I am creating very simple ecore model at run time. It contains one class("TestClass") having two attributes ("t1", "t2"). Same Ecore model is also available in oclinecore format in "model" folder just to make sure you can easily understand the model.
>
> I want to change the rename "t2" to "tNew" but before doing that i want to refactor OCL statement of "t1" to make sure it use "tNew" instead of "t2".
> Please check ClassicOCL.java. It is very easy to do it in classic OCL. All the code formatting in OCL statement remains intact and i did not have to save Ecore model in File format, it remains in memory and it is very nice.
>
> I want to do the same in Pivot OCL and i have used PrettyPrinter for this purpose.
> Please check PivotAndPrettyPrinter.java. I have successfully refactored but the code formatting in OCL statement is gone. How to make sure all code formatting remain intact while refactoring? I am open to use other solutions to achieve this.
>
> I hope i have explained the problem well.
>
> Cheers,
Previous Topic:EssentialOCL creation, loading and parsing
Next Topic:Bug or correct behavior
Goto Forum:
  


Current Time: Mon Nov 03 09:37:06 EST 2025

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

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

Back to the top