Editor Script – new functions

Lasă un comentariu

9 Iulie 2009 de liviustoica55


 

void comments_XmethodHeader(Editor e)
{
    UserInfo    tUserInfo;

    select firstonly tUserInfo index Id
                               where tUserInfo.Id == curuserid();
    e.gotoLine(1);
    e.gotoCol(1);

    e.insertLines(‘//––––––––––––––––––––\n’);
    e.insertLines(‘// System         : Name system         \n’);
    e.insertLines(‘// Description    :< What does the method do >                \n’);
    e.insertLines(‘// Parameters     :< Description of parameters >             \n’);
    e.insertLines(‘// Return value   :< Description of return value >           \n’);
    e.insertLines(‘// Exceptions     :< Exeptions the method could throw >      \n’);
    e.insertLines(‘// Pre-conditions :< Pre-Conditions such as values of global variables >\n’);
    e.insertLines(‘// Creator        : ‘+ tUserInfo.name+’ (‘+curUserId()+’)\n’);
    e.insertLines(‘// Date           : ‘+ date2str(today(),123,2,2,3,2,4)+’\n’);
    e.insertLines(‘//-Log–––––––––––––––––––\n’);
    e.insertLines(‘// \n’);
    e.insertLines(‘//––––––––––––––––––––\n’);
}

=================================================================

void comments_XComment(Editor e)
{
    UserInfo    tUserInfo;
    int startLine = e.selectionStartLine();
    int endLine   = e.selectionEndLine();
    ;

    select firstonly tUserInfo index Id
    where tUserInfo.Id == curuserid();

    e.unmark();
    e.gotoLine(startLine);
    e.gotoCol(1);
    e.insertLines(‘// X ‘ + date2str(today(),123,2,2,3,2,4) + ‘. ‘ + tUserInfo.name + ‘ – begin\n’);
    e.insertLines(‘// Description: \n’);
    e.gotoLine(endLine + 3);
    e.gotoCol(1);
    e.insertLines(‘// X ‘ + date2str(today(),123,2,2,3,2,4) + ‘. ‘ + tUserInfo.name + ‘ – end\n’);
}

================================================================

//Liviu Stoica –  deschide intr-o fereastra obiectul selectat
public void xTools_GoToSelectedObject(Editor e)
{
    #AOT
    TreeNode            treeNode = TreeNode::findNode(e.path());
    xRefTmpReferences   xRefTmpReferences;
    Column              nCol = e.columnNo() + 1;
    Line                nLine = e.currentLineNo() + 1;
    ;
    treeNode.AOTmakeXref(1);
    xRefTmpReferences = xRefCreate::makeTmp(infolog.lastxRef());

    select firstonly xRefTmpReferences
        order by Column desc
        where xRefTmpReferences.line == nLine &&
              xRefTmpReferences.Column <= nCol;

    if (!xRefTmpReferences)
        return;

    treeNode = TreeNode::findNode(xRefTmpReferences.path());

    if (treeNode)
        treeNode.AOTnewWindow();
}

 

====================================================================

public void xTools_ShowMACRO(Editor e)
{
    #AOT

    TreeNode            treeNode = TreeNode::findNode(e.path());
    Column              nCol = e.columnNo() + 1;
    Line                nLine = e.currentLineNo() + 1;
    str  nameMacroAOT;

    MemberFunction method;
    str sourceDeclaration,countChar;
    int blockStart;
    int ILine,nChar;
    ;

    nameMacroAOT = EditorScripts::getSelectedText(e);

    nameMacroAOT = strrtrim(strltrim(strReplace(nameMacroAOT, ‘\r\n’, ‘ ‘)));
//info(EditorScripts::getSelectedText(e));
//info(caleNameMacroAOT);

//if (TreeNode::isValidObjectName(nameMacroAOT))  //este macro AOT
    treeNode = TreeNode::findNode(strfmt(#MacroPath,nameMacroAOT));
    if (treeNode)
    {
       // treeNode.AOTnewWindow();
        treeNode.AOTedit(0,0);
    }
        else
    {
        nameMacroAOT = ‘#define.’+nameMacroAOT;

        treeNode = TreeNode::findNode(#MacrosPath);
       //   treeNode.AOTnewWindow();

        treeNode = treeNode.AOTfirstChild();

     do
     {
     treeNode = treeNode.AOTnextSibling();

     if(treeNode!= null)
     {

        {
            sourceDeclaration =”;
            sourceDeclaration = treeNode.AOTgetSource();

            blockStart = strscan(sourceDeclaration, nameMacroAOT, 1, strlen(sourceDeclaration));
            if(blockStart > 0)

            {

             for(ILine =0;ILine<200;ILine++)
             {
                countChar += strLine(sourceDeclaration,ILine);
                if(strlen(countChar) < blockStart)
                    nChar++;
                else
                ILine =200;
              }

                treeNode = TreeNode::findNode(treeNode.treeNodePath());
                if (treeNode)
                {
                   // treeNode.AOTnewWindow();
                    treeNode.AOTedit(nChar+1,0);
                }

                blockStart = 0;
             }
         }

       }

     } while (treeNode!= null);
    }

}

=====================================================================

/// <summary>
/// /// Navigate to the definition of a method that overrides the currently open method in a descendent class
/// </summary>
/// <param name="e">Currenty open editor</param>
//to do open metoda parinte
public void addIns_OpenOverriddenMethodInChildren(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();
    }
}

Lasă un răspuns

Completează mai jos detaliile despre tine sau dă clic pe un icon pentru autentificare:

Logo WordPress.com

Comentezi folosind contul tău WordPress.com. Dezautentificare / Schimbă )

Poză Twitter

Comentezi folosind contul tău Twitter. Dezautentificare / Schimbă )

Fotografie Facebook

Comentezi folosind contul tău Facebook. Dezautentificare / Schimbă )

Fotografie Google+

Comentezi folosind contul tău Google+. Dezautentificare / Schimbă )

Conectare la %s

%d blogeri au apreciat asta: