2012-03-24 15 views
0

私はビジュアルスタジオアドインを作成しようとしています。次のコードは、Visual Studioコードウィンドウ内の選択したテキストのグローバル変数またはクラス名または関数名を表示するために使用されます。ただし、関数内で定義された変数は表示されません。ローカル変数を表示するには、これをどのように変更できますか?Visual Studioアドインからローカル変数にアクセス

'Call this function inside OnConnection event of the addin 

Sub displayCodeElementName() 

    ' Before running this example, open a code document from a project 
    ' and place the insertion point inside a variable definition. 
    Try 
     ' Retrieve the CodeVariable at the insertion point. 
     Dim sel As TextSelection = _ 
      CType(applicationObject.ActiveDocument.Selection, TextSelection) 
     Dim var As CodeVariable2 = CType(sel.ActivePoint.CodeElement(vsCMElement.vsCMElementVariable), CodeVariable2) 

     ' Display the code element name 

      MsgBox(var.Name & " is the name.") 

    Catch ex As Exception 
     MsgBox(ex.Message) 
    End Try 
End sub 

答えて

0

Microsoftが公開するAPIは公開されていないようです。私は研究を行いましたが、関数定義の中のコード要素にアクセスする方法は見つけられませんでした。

関連する問題