Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Split Generated Method
Split Generated Method [message #1450763] Wed, 22 October 2014 22:26 Go to next message
Jimmy Lu is currently offline Jimmy LuFriend
Messages: 11
Registered: October 2014
Junior Member
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 20:41 Go to previous messageGo to next message
Jimmy Lu is currently offline Jimmy LuFriend
Messages: 11
Registered: October 2014
Junior Member
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 10:21 Go to previous message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

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,


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Previous Topic:Application error java.lang.RuntimeException: Application "org.eclipse.ui.ide.workbench" c
Next Topic:Having customized forms or Adding Menus/Toolbars/Context Menus and etc. when running GMF as a plugin
Goto Forum:
  


Current Time: Sat Apr 27 20:12:24 GMT 2024

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

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

Back to the top