How can I get the infomations I need from my code string?

SyntaxEditor .NET Languages Add-on for Windows Forms Forum

Posted 7 years ago by Wang Jian
Version: 16.1.0330

For example,I have code like below.

Dim tblDtl As Table = e.Form.Controls("tblDtl").Table

 When I move the cursor to the word 'AddNew',then get the Quickinfo like 'Function Table.AddNew(ByVal i As Integer) As Row(+1 overload)'.

Now I can get the Quickinfo by code already,but I need to know how can I get the specific type of 'Function','Table.AddNew' and 'Row' directly.

[Modified 7 years ago]

Comments (2)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA


In the older WinForms SyntaxEditor design, the DotNetSyntaxLanguage class defines a protected GetContext method you can call to get a DotNetContext.  Quick info calls it like:

DotNetContext context = this.GetContext(syntaxEditor, offset, false, false);

That will have some contextual information about what is at the offset.

In the newer WPF SyntaxEditor design, we have implemented a much better system for getting full resolver result details about an offset.  Our WPF SyntaxEditor's quick info provider effectively does this sort of thing:

// 'offset' is the desired offset of the identifier
var dotNetContext = new VBContextFactory().CreateContext(new TextSnapshotOffset(editor.Document.CurrentSnapshot, offset));
if ((dotNetContext != null) && (dotNetContext.InitializationSnapshotRange.HasValue)) {
  var resultSet = dotNetContext.Resolve();
  if ((resultSet != null) && (resultSet.Results != null) && (resultSet.Results.Count > 0)) {
    // Results are sorted by best match and could be an INamespaceResolverResult,
    //   ITypeResolverResult, ITypeMemberResolverResult, IParameterResolverResult,
    //   or IVariableResolverResult... examine the results for type info

Actipro Software Support

Posted 7 years ago by Wang Jian

Thanks for your help.

Follow your code I check the product documentation again,then I find the property 'itmes' of  DotNetContext is what i need.

The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.