Bug 345533 - [Xtend/Xpand IDE Integration] Code generation for multiple projects got problem with default outlet ${project_loc}/gen
Summary: [Xtend/Xpand IDE Integration] Code generation for multiple projects got probl...
Status: CLOSED WONTFIX
Alias: None
Product: Sphinx
Classification: Automotive
Component: M2x IDE Integration (show other bugs)
Version: 0.7.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-12 03:18 EDT by Lan Phan CLA
Modified: 2024-05-07 00:51 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lan Phan CLA 2011-05-12 03:18:54 EDT
Build Identifier: Eclipse 3.6.2

Usecase: code generation supports user to generate code for multiple selections, and these selections belong to several projects (for ex: <project1> and <project2>)
List of outlets are determined before generating, and all XpandExecutionContextImpl use the same list
--> ${project_loc}/gen outlet is resolved to <project1>/gen, and all generated code (of both <project1> and <project2>) will be generated to same folder: NOT OK

Solution:
- Create separated list of outlets for each XpandEvaluationRequest (or, at least, separated list of outlets for each IProject)

Reproducible: Always
Comment 1 Stephan Eberle CLA 2011-05-12 05:10:51 EDT
(In reply to comment #0)
> --> ${project_loc}/gen outlet is resolved to <project1>/gen, and all generated
> code (of both <project1> and <project2>) will be generated to same folder: NOT
> OK

Agreed. Code for model element in project1 should go into project1/gen and code for model element in project2 should go into project2/gen.

> Solution:
> - Create separated list of outlets for each XpandEvaluationRequest (or, at
> least, separated list of outlets for each IProject)

Not quite. The outlets are declared as preferences for each project and therefore don't need to be added to the XpandEvaluationRequest (that would be redundant information). Instead I'd say that we need to tweak the resolution of the  ${project_loc}/gen expression such that it takes the project behind the target object in the XpandEvaluationRequest into account an the resolution is done relative to the same.

Could that be a solution for your problem?
Comment 2 Lan Phan CLA 2011-05-12 23:22:21 EDT
Not quite. The outlets are declared as preferences for each project and
therefore don't need to be added to the XpandEvaluationRequest (that would be
redundant information). Instead I'd say that we need to tweak the resolution of
the  ${project_loc}/gen expression such that it takes the project behind the
target object in the XpandEvaluationRequest into account an the resolution is
done relative to the same.

--> My first comment doesn't mean we'll add Outlet info into XpandEvaluationRequest. Please be noticed that ${project_loc} can be used in user-defined outlets too, and in order to resolve it to correct path, we should use:
new ExtendedOutlet(String name, String pathExpression, IProject proj)

My pseudo code for XpandJob.runInWorkspace() is:
1. install Resource loader
2. foreach XpandEvaluationRequest:
   a. Configure outlets using ExtendedOutlet(String name, String pathExpression, IProject proj), and create OutputImpl, XpandExecutionContextImpl
   b. Start transaction to execute XpandFacade

For my solution, I think getXpandEvaluationRequests() can be removed, or changed to: TransactionalEditingDomain getXpandEvaluationRequestTransaction(ExpandEvaluationRequest)
Comment 3 Stephan Eberle CLA 2011-05-13 04:52:10 EDT
(In reply to comment #2)
> --> My first comment doesn't mean we'll add Outlet info into
> XpandEvaluationRequest. 

I'm glad to read that ;)

> Please be noticed that ${project_loc} can be used in
> user-defined outlets too, and in order to resolve it to correct path, we should
> use:
> new ExtendedOutlet(String name, String pathExpression, IProject proj)

At which place exactly? Note that the outlets come from OutletsPreference and in there they are already created that way (see org.eclipse.sphinx.xtendxpand.preferences.OutletsPreference#toObject(IProject, String) for details).

> My pseudo code for XpandJob.runInWorkspace() is:
> 1. install Resource loader
> 2. foreach XpandEvaluationRequest:
>    a. Configure outlets using ExtendedOutlet(String name, String
> pathExpression, IProject proj), and create OutputImpl,
> XpandExecutionContextImpl
>    b. Start transaction to execute XpandFacade

How do you initialize the org.eclipse.sphinx.xtendxpand.jobs.XpandJob#getOutlets() list? How do you decide which of them need to be taken when setting up the OutputImpl for a given XpandEvaluationRequest? I'm wondering if we are not facing the problem of having multiple outlets with the same name and path expression but different target projects ending up in the same XpandJob#getOutlets() list. I agree that something needs to be done here to handle this more consistently but I'm not yet sure what and how exactly.

My proposal is that we start with providing an appropriate test case for the issue. We already have an org.eclipse.sphinx.tests.xtendxpand.integration.XpandJobTest that we can leverage and extend for that purpose. It is based on theorg.eclipse.sphinx.testutils.integration.referenceworkspace.xtendxpand reference workspace. Currently the latter has only one Xpand project but we can add a second one according to your use case. Once this is done we can add a new test method to XpandJobTest and invoke the XpandJob with multiple XpandEvaluationRequests referring to multiple projects.

Would you like to provide such a test?

> For my solution, I think getXpandEvaluationRequests() can be removed, or
> changed to: TransactionalEditingDomain
> getXpandEvaluationRequestTransaction(ExpandEvaluationRequest)

I don't think that it can be removed. It is there for sorting the XpandEvaluationRequests according to the editing domain in which they need to be executed and to make sure that all XpandEvaluationRequests with the same editing domain can be run in a single transaction (rather than creating one transaction for each XpandEvaluationRequest).
Comment 4 Balazs Grill CLA 2024-05-07 00:51:43 EDT
Closed stale issue before migration