|
14.08.2008, 02:27 | #1 |
Участник
|
axaptapedia: Editor scripts OpenOverriddenMethodDef
Источник: http://www.axaptapedia.com/Editor_sc...iddenMethodDef
============== Summary: === Purpose === Navigate to the definition of a method that overrides the currently open method in a descendent class === Description === *This is a nice script that will be very helpful to AX developers often exploring the class heirarchy when debugging, etc. You will need to navigate to the AOT less, which, generally, speeds up things *In case there is more than one overridden method found, a listview with the possible choices is shown, where the developer can select the needed class. *2 versions of the code are provided, one of which uses cross references information, and the other - Dictionary class. The xRef version is generally faster. === Dynamics AX versions === Has been tested on Dynamics AX 3.0 SP3, Dynamics AX 4.0 SP1 and Dynamics AX 2009 === Code === Simply create a new method in class '''EditorScripts''' and paste the following code into it. (Check out the other 2 verions here: [[Talk:Editor_scripts_OpenOverriddenMethodDef]]) /// /// Editor_Scripts_OpenOverriddenMethodDef_ikash, 2008-08-12 /// Navigate to the definition of a method that overrides the currently open method in a descendent class /// /// Currenty open editor public void addIns_OpenOverriddenMethodDef(Editor e) { #define.AOTDelimiter('\\') #AOT TreeNode treeNode = TreeNode::findNode(e.path()); TreeNode treeNodeParent; ClassId classIdParent; TreeNodeName methodName = treeNode.treeNodeName(); Map descendents; MapEnumerator descendentsEnumerator; Counter descendentsCount; xRefTypeHierarchy xRefTypeHierarchy_find(Types _baseType, int _id) { xRefTypeHierarchy xRefTypeHierarchy; select firstonly xRefTypeHierarchy index BaseTypeIdIdx where xRefTypeHierarchy.BaseType == _baseType && xRefTypeHierarchy.Id == _id; return xRefTypeHierarchy; } xRefTypeHierarchy xRefTypeHierarchy_findOrCreate(Types _baseType, int _id) { xRefTypeHierarchy xRefTypeHierarchy = xRefTypeHierarchy_find(_baseType, _id); if (!xRefTypeHierarchy) { new xRefUpdateTypeHierarchy().run(); xRefTypeHierarchy = xRefTypeHierarchy_find(_baseType, _id); } return xRefTypeHierarchy; } void findDescendents(ClassId _parentId) { xRefTypeHierarchy typeHierarchy; TreeNode descendent; ; if (!xRefTypeHierarchy_findOrCreate(Types::Class, _parentId).Children) return; while select typeHierarchy where typeHierarchy.Parent == _parentId && typeHierarchy.BaseType == Types::Class { descendentsCount++; descendent = TreeNode::findNode(#ClassesPath + #AOTDelimiter + typeHierarchy.Name + #AOTDelimiter + methodName); if (descendent) descendents.insert(descendent.treeNodePath(), descendent.AOTparent().treeNodeName()); if (typeHierarchy.Children && typeHierarchy.Id) findDescendents(typeHierarchy.Id); } } ; if (subStr(treeNode.treeNodePath(), 1, strLen(#ClassesPath)) == #ClassesPath) { treeNodeParent = TreeNode::findNode(xUtilElements::getNodePathRough(xUtilElements::parentElement(xUtilElements::findTreeNode(treeNode)))); classIdParent = className2Id(treeNodeParent.treeNodeName()); descendents = new Map(Types::String, Types::String); findDescendents(classIdParent); switch (descendents.elements()) { case 0: info(strFmt(@"The method '%1' is not overridden in any of the %2 descendent classes", methodName, descendentsCount)); break; case 1: descendentsEnumerator = descendents.getEnumerator(); if (descendentsEnumerator.moveNext()) treeNode = TreeNode::findNode(descendentsEnumerator.currentKey()); break; default: treeNode = TreeNode::findNode(pickList(descendents, "@SYS24724", @"Pick required class to go to method definition")); } if (treeNode && SysTreeNode::hasSource(treeNode)) treeNode.AOTedit(); } } === Used in === [[Editor scripts]] === Externdal Links === [http://kashperuk.blogspot.com/2008/0...cript-for.html Original blog post about this script] [[Category:Development tools]] Источник: http://www.axaptapedia.com/Editor_sc...iddenMethodDef
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
Похожие темы | ||||
Тема | Ответов | |||
axaptapedia: Table Methods Generator | 0 | |||
axcoder: PowerShell + Ax | 1 | |||
axaptapedia: Load Web Documents | 1 | |||
axcoder: AxPath is supported by axaptapedia | 0 |
Опции темы | Поиск в этой теме |
Опции просмотра | |
|