AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 13.08.2008, 07:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,477 / 846 (79) +++++++
Регистрация: 28.10.2006
axaptapedia: Editor scripts OpenOverriddenMethodDef
Источник: http://www.axaptapedia.com/Editor_sc...iddenMethodDef
==============

Summary: /* Externdal Links */

=== 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.

///
/// 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 Blog bot DAX Blogs 0 13.02.2009 02:05
axcoder: PowerShell + Ax Blog bot DAX Blogs 1 09.01.2009 18:05
axaptapedia: Load Web Documents Blog bot DAX Blogs 1 03.01.2009 23:50
axcoder: AxPath is supported by axaptapedia Blog bot DAX Blogs 0 11.05.2007 10:00

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:38.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.