Цитата:
Сообщение от
Kabardian
Найти (Find), самое ценное — вырезки из кода
А с перекрестных ссылок - еще один клик и ты в
самом коде на нужном месте. О других плюсах верно сказал mazzy: ложных срабатываний гораздо меньше и сразу видно где переменная объявлена, где присвоено значение и т.п.
Цитата:
Сообщение от
mazzy
Эх, еще бы и для потомков...
Ну вот для потомков набросал. Для корректной работы иерархия типов должна быть обновлена. Если иерархия не построена, то в AX2009 автоматом запустится ее обновление (в AX4 этого нет и надо убрать строчку).
X++:
//Show cross-references, complete or filtered by selection, for a class and its super and descendant classes
#TreeNodeSysNodeType
void addIns_CrossReferencesSelected(Editor e)
{
xRefUpdateTmpReferences xTmpReferences = new xRefUpdateTmpReferences();
TreeNode currentNode = TreeNode::findNode(e.path());
SysDictClass sysDictClass;
Args formRunArgs;
FormRun formRun;
FormDataSource fds;
xRefTmpReferences refTable;
xRefName selectedText;
xRefPath currentNodePath;
int startLine = e.selectionStartLine();
int startCol = e.selectionStartCol();
int endCol = e.selectionEndCol();
void findDescendants(classId _classId)
{
xRefTypeHierarchy typeHierarchy;
TreeNode descendantNode;
;
while select typeHierarchy
where typeHierarchy.BaseType == Types::Class &&
typeHierarchy.Parent == _classId
{
descendantNode = new SysDictClass(typeHierarchy.Id).treeNode();
xTmpReferences.fillTmpxRefReferences(descendantNode);
findDescendants(typeHierarchy.Id);
}
}
;
if (e.selectionStartLine() == e.selectionEndLine() && startCol != endCol)
{
e.firstSelectedLine();
selectedText = strLRTrim(subStr(e.getLine(), e.selectionStartCol(), endCol-startCol));
}
currentNodePath = currentNode.treeNodePath();
if (currentNode.applObjectType() != UtilElementType::ClassStaticMethod &&
currentNode.applObjectType() != UtilElementType::TableStaticMethod)
{
while(! currentNode.AOTObjectNode())
{
currentNode = currentNode.AOTparent();
}
}
xTmpReferences.fillTmpxRefReferences(currentNode);
if (xRefTypeHierarchy::findOrCreate(Types::Class, currentNode.applObjectId()).Children) //Remove for AX4
{
findDescendants(currentNode.applObjectId());
}
while (currentNode && currentNode.sysNodeType() == #NT_CLASS)
{
sysDictClass = new SysDictClass(new SysDictClass(currentNode.applObjectId()).extend());
currentNode = sysDictClass ? sysDictClass.treeNode() : null;
if (currentNode)
{
xTmpReferences.fillTmpxRefReferences(currentNode);
}
}
formRunArgs = new Args(formstr(xRefTmpReferences));
formRunArgs.parmObject(xTmpReferences);
formRun = classfactory.formRunClass(formRunArgs);
formRun.init();
if (selectedText)
{
refTable = xTmpReferences.allTmpxRefReferences();
select firstonly refTable
where refTable.line == startLine
&& refTable.Column == startCol
&& refTable.name == selectedText
&& refTable.Path == currentNodePath;
fds = formRun.dataSource();
fds.query().dataSourceNo(1).addRange(fieldNum(xRefTmpReferences, Kind)).value(queryValue(refTable.Kind));
fds.query().dataSourceNo(1).addRange(fieldNum(xRefTmpReferences, name)).value(queryValue(refTable.name));
fds.query().dataSourceNo(1).addRange(fieldNum(xRefTmpReferences, ParentName)).value(queryValue(refTable.ParentName));
formRun.design().caption(strfmt("Complete cross-reference for %1 '%2'", refTable.Kind, refTable.name));
}
SysUtil::editPathLogicalPos(currentNodePath, startLine, startCol); //attempt to workaround AX2009 behaviour. Remove for AX4
formRun.run();
formRun.detach();
}
Обнаружил пренеприятную особенность в AX2009 - при вызове xTmpReferences.fillTmpxRefReferences для какого-нибудь объекта, окно редактора с этим объектом принудительно закрывается. Пришлось тупо добавить открытие редактора в код. В AX4 это не нужно. Да и вообще есть ощущение, что этот код в AX2009 работает медленнее, чем в AX4.