Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 346163 - [wizard] creating bound role file causes havoc in refactoring.TypeContextChecker
Summary: [wizard] creating bound role file causes havoc in refactoring.TypeContextChecker
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTDT (show other bugs)
Version: 0.8   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.0 RC2   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-17 17:32 EDT by Stephan Herrmann CLA
Modified: 2011-06-02 11:14 EDT (History)
0 users

See Also:


Attachments
Fix (11.13 KB, patch)
2011-05-22 07:27 EDT, Stephan Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2011-05-17 17:32:28 EDT
Given a base class mypack.base.Base
Given a team class mypack.teams.MyTeam

I try to create a role file Role playedBy Base, but I get this exception:

java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:477)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
	at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1029)
	at org.eclipse.jdt.internal.ui.wizards.NewElementWizard.performFinish(NewElementWizard.java:134)
	at org.eclipse.objectteams.otdt.internal.ui.wizards.NewTypeCreationWizard.performFinish(NewTypeCreationWizard.java:54)
...
...
Caused by: java.lang.IllegalStateException
	at org.eclipse.jdt.internal.corext.refactoring.TypeContextChecker.resolveSuperClass(TypeContextChecker.java:756)
	at org.eclipse.objectteams.otdt.internal.ui.wizards.typecreation.RoleCreator.writeBaseClass(RoleCreator.java:72)
	at org.eclipse.objectteams.otdt.internal.ui.wizards.typecreation.RoleCreator.writeInheritanceRelations(RoleCreator.java:54)
	at org.eclipse.objectteams.otdt.internal.ui.wizards.typecreation.TypeCreator.constructTypeStub(TypeCreator.java:581)
	at org.eclipse.objectteams.otdt.internal.ui.wizards.typecreation.TypeCreator.createType(TypeCreator.java:187)
	at org.eclipse.objectteams.otdt.internal.ui.wizards.NewTypeCreationWizard.finishPage(NewTypeCreationWizard.java:70)
	at org.eclipse.jdt.internal.ui.wizards.NewElementWizard$2.run(NewElementWizard.java:118)
	at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4889)
	at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:106)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
Comment 1 Stephan Herrmann CLA 2011-05-22 07:27:49 EDT
Created attachment 196291 [details]
Fix

The root cause for trouble was:

The base class was resolved using a stub like:
  team class MyTeam { class MyRole extends mypack.base.Base {} }
Here the qualified name including a 'base' fragment caused a parse error
inside the team.

Fixed by using a different pattern for the stub when resolving the base class:
  public class MyTeam {}
  class MyRole extends mypack.base.Base { }
This avoids putting the scanner into OT/J mode.
I'm not sure if this could cause resolving to pick a wrong class, 
but I couldn't find any example for this.

The patch also fixes issues wrt base imports for a role file:
if "[ ] inlined" is unchecked maintain two compilation units and their 
import rewrites: one for the role file and one for the enclosing team.
Comment 2 Stephan Herrmann CLA 2011-05-22 07:30:35 EDT
Committed as r1618
Comment 3 Stephan Herrmann CLA 2011-06-02 11:14:51 EDT
Verified using build 201105311237