Skip to content

Instantly share code, notes, and snippets.

@saga
Created August 3, 2010 03:55
Show Gist options
  • Save saga/505800 to your computer and use it in GitHub Desktop.
Save saga/505800 to your computer and use it in GitHub Desktop.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Module1
Sub BeginMe()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "// *********************william test*************"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "TCHAR bufferWill[512];"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "_stprintf(bufferWill, TEXT("" [%s] BEGIN ##[%p]L%d\n""), TEXT(__FUNCTION__),"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = " this, __LINE__); "
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "::OutputDebugString(bufferWill); "
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "// **********************************************"
End Sub
Sub EndMe()
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "// *********************william test*************"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "_stprintf(bufferWill, TEXT("" [%s] END ##[%p]L%d\n""), TEXT(__FUNCTION__),"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "this, __LINE__); "
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "::OutputDebugString(bufferWill); "
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "// **********************************************"
End Sub
Sub FunctionHeader()
Dim objEditPt As EditPoint
Dim currentLine As Integer
Dim endline As Integer
Dim findString As String
Dim findString2 As String
Dim firstPosition As Integer
Dim voidPosition As Integer
Dim BoolPosition As Integer
Dim PtrPosition As Integer
Dim lastPosition As Integer
objEditPt = DTE.ActiveDocument.Selection.ActivePoint.CreateEditPoint
currentLine = objEditPt.Line
objEditPt.EndOfDocument()
endLine = objEditPt.Line
If (endLine > currentLine + 50) Then
endLine = currentLine + 50
End If
findString = objEditPt.GetLines(currentLine, endLine)
'get params with "(" and ")"
findString2 = ""
Dim strList As New System.Collections.ArrayList
Dim findVoid As Boolean = False
Dim findBool As Boolean = False
Dim findPtr As Boolean = False
firstPosition = InStr(findString, "(")
voidPosition = InStr(findString, "void")
BoolPosition = InStr(findString, "BOOL ")
PtrPosition = InStr(findString, "* ")
If (firstPosition >= 1) Then
If (voidPosition >= 1 And voidPosition < firstPosition) Then
findVoid = True
End If
If (PtrPosition >= 1 And PtrPosition < firstPosition) Then
findPtr = True
End If
If (BoolPosition >= 1 And BoolPosition < firstPosition) Then
findBool = True
End If
lastPosition = InStr(firstPosition, findString, ")")
If (lastPosition >= firstPosition) Then
findString2 = Mid(findString, firstPosition + 1, lastPosition - firstPosition - 1)
strList.AddRange(findString2.Split(","c))
End If
End If
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "/**"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "* "
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "* "
DTE.ActiveDocument.Selection.NewLine()
Dim listCount As Integer
Dim newString As String
listCount = strList.Count
For Each stringElement In strList
stringElement = Replace(stringElement, vbCr, "")
stringElement = Replace(stringElement, vbLf, "")
stringElement = Replace(stringElement, vbTab, " ")
stringElement = Trim(stringElement)
If stringElement.Length <= 0 Then
Continue For
End If
Dim bAsIn = "[in] "
If InStr(stringElement, "*") Then
bAsIn = "[out] "
End If
newString = "* @param " + bAsIn + stringElement + " : "
DTE.ActiveDocument.Selection.Text = newString
DTE.ActiveDocument.Selection.NewLine()
Next
DTE.ActiveDocument.Selection.Text = "* "
DTE.ActiveDocument.Selection.NewLine()
If findVoid Then
DTE.ActiveDocument.Selection.Text = "* @return void."
DTE.ActiveDocument.Selection.NewLine()
ElseIf findBool Then
DTE.ActiveDocument.Selection.Text = "* @return True success;"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = " False, failed;"
DTE.ActiveDocument.Selection.NewLine()
ElseIf findPtr Then
DTE.ActiveDocument.Selection.Text = "* @return valid pointer; or NULL."
DTE.ActiveDocument.Selection.NewLine()
Else
DTE.ActiveDocument.Selection.Text = "* @return S_OK : the processing completed successfully;"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "* E_POINTER : a NULL pointer parameter was passed;"
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "* E_FAIL : Some other failure occurred;"
DTE.ActiveDocument.Selection.NewLine()
End If
DTE.ActiveDocument.Selection.Text = "* "
DTE.ActiveDocument.Selection.NewLine()
DTE.ActiveDocument.Selection.Text = "*/"
End Sub
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment