General script for commenting added code

I've been playing with the most efficient way of doing commenting on the code you are adding / changing in standard code. This is what I have so far; in involves the developer setting the Startup project in their Tools -> Options. This code is meant to be written in the Classes \ EditorScripts

void comments_AddMyComments(Editor e)
{
    System.DateTime dt;
    UserInfo        userInfo;
    ProjName        projectName;
    int startLine = e.selectionStartLine();
    int endLine   = e.selectionEndLine();

    select firstonly Name from userInfo
        where userInfo.Id == curuserid();

    dt = System.DateTime::get_Now();

    projectName = userInfo.startupProject;
    if (projectName == '')
    {
        projectName = 'ReplaceProject';
    }

    e.unmark();

    e.gotoLine(startLine);
    e.gotoCol(1);
    e.insertLines(strFmt('// %1, %2, %3, %4', projectName, userInfo.name, CLRInterop::getAnyTypeForObject(dt.ToString('yyyy-MM-dd')), '-->\n'));
    e.gotoLine(endLine + 2);
    e.gotoCol(1);
    e.insertLines(strFmt('// %1, %2, %3, %4', projectName, userInfo.name, CLRInterop::getAnyTypeForObject(dt.ToString('yyyy-MM-dd')), '<--\n'));
}

No comments:

Post a Comment