Split Generated Method [message #1450763] |
Wed, 22 October 2014 18:26  |
Eclipse User |
|
|
|
I have a fairly large model from which I want to generate the diagram code. However, the generated code has one method (*NavigatorContentProvider#getViewChildren) that gives me "The code of method getViewChildren(View, Object) is exceeding the 65535 bytes limit" error.
Where can I specify some options so that the code generator can split up such big methods for me (I want to avoid splitting it up manually every time after regeneration)? If not possible I will need to raise a ticket to ask for that kind of functionality in code generator.
|
|
|
Re: Split Generated Method [message #1698178 is a reply to message #1450763] |
Thu, 11 June 2015 16:41   |
Eclipse User |
|
|
|
Fixed this by myself. Need to overwrite the buggy template using aspect aspects/xpt/navigator/NavigatorContentProvider.xpt:
«EXTENSION xpt::navigator::Utils»
«AROUND getViewChildren FOR gmfgen::GenNavigator-»
«EXPAND xpt::Common::generatedMemberComment»
private Object[] getViewChildren(org.eclipse.gmf.runtime.notation.View view, Object parentElement) {
switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(view)) {
«FOREACH getNavigatorContainerNodes(self) AS navigator-»
«EXPAND xpt::Common::caseVisualID FOR navigator» «EXPAND getViewChildrenNavigatorNodeMethodName FOR navigator»(view, parentElement);
«ENDFOREACH»
}
return EMPTY_ARRAY;
}
«EXPAND getViewChildrenNavigatorNode(self) FOREACH getNavigatorContainerNodes(self)»
«ENDAROUND»
«DEFINE getViewChildrenNavigatorNodeMethodName FOR gmfgen::GenCommonBase»getViewChildren_«EXPAND xpt::Common::disqualifiedClassName FOR getEditPartQualifiedClassName()»«ENDDEFINE»
«DEFINE getViewChildrenNavigatorNode(navigator : gmfgen::GenNavigator) FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
private Object[] «EXPAND getViewChildrenNavigatorNodeMethodName»(org.eclipse.gmf.runtime.notation.View view, Object parentElement) {
«EXPAND CodeStyle::newGenericInstance('result', 'java.util.LinkedList', navigator.getAbstractNavigatorItemQualifiedClassName())»();
«EXPAND xpt::navigator::NavigatorContentProvider::addForeignShortcuts FOR self-»
«EXPAND xpt::navigator::NavigatorContentProvider::_nailedDownVariable('sv', 'view')»
«LET getChildReferencesFrom(navigator, self) AS _references-»
«EXPAND xpt::navigator::NavigatorContentProvider::initGroupVariables(navigator, _references, 'parentElement', self) FOREACH getGroupNames(_references)-»
«IF _references->notEmpty() and _references->findConnectionPaths()->notEmpty()-»
«EXPAND CodeStyle::G('java.util.Collection', 'org.eclipse.gmf.runtime.notation.View')» connectedViews;
«FOREACH _references AS reference-»
«FOREACH reference.findConnectionPaths() AS path-»
«FOREACH path.segments->asSequence() AS segment ITERATOR segmentsIterator-»
connectedViews = «EXPAND xpt::navigator::NavigatorContentProvider::childrenMethodName(reference.referenceType, segment) FOR segment._from-»
(«IF segmentsIterator.isFirstIteration()»java.util.Collections.singleton(sv)«ELSE»connectedViews«ENDIF-»
, «EXPAND xpt::editor::VisualIDRegistry::typeMethodCall FOR segment.to»);
«ENDFOREACH-»
«EXPAND xpt::navigator::NavigatorContentProvider::addNavigatorItemsPrefix FOR reference»connectedViews«EXPAND xpt::navigator::NavigatorContentProvider::addNavigatorItemsSuffix('parentElement', reference.referenceType <> gmfgen::GenNavigatorReferenceType::children) FOR reference-»
«ENDFOREACH-»
«ENDFOREACH-»
«ENDIF-»
«EXPAND xpt::navigator::NavigatorContentProvider::addGroups(_references) FOREACH getGroupNames(_references)-»
«ENDLET-»
return result.toArray();
}
«ENDDEFINE»
|
|
|
Re: Split Generated Method [message #1703700 is a reply to message #1698178] |
Tue, 04 August 2015 06:21  |
Eclipse User |
|
|
|
Hi,
thanks for sharing your solution.
You should report a bug report to GMF Tooling project and if possible provide a patch (or a gerrit push) in order that everyone in the community can enjoy of your findings. It will also allow you not to maintain this custom templates over version upgrades.
Regards,
|
|
|
Powered by
FUDForum. Page generated in 0.03473 seconds