获取与EnvDte特定code元素的所有code语句 [英] Get all code statements in specific code element with EnvDte

查看:186
本文介绍了获取与EnvDte特定code元素的所有code语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过code语句,我的意思是code的最小独立元素。有没有得到一个EnvDTE。codeFunction体内code语句的结构形式的接口。

By code statement i mean smallest standalone element of code. Is there an interface to get code statements inside a EnvDTE.CodeFunction body in a structured form.

有可以检索EnvDTE。codeFunction机身以纯文本的方式,如果我要处理方法调用等我应该使用正则表达式,我认为是不是一个通用的解决方案。例如这两个说法都一样的:

There are ways that can retrieve body of EnvDTE.CodeFunction as plain text, and if i want to process method calls etc. i should use Regex which i think is not a general solution. For example both of these statements are same:

VAR值= @的,是qoutation商标;
VAR值=的\\是qoutation商标;

var value = @"the "" is qoutation mark"; var value = "the \" is qoutation mark";

但它是一个有点难以用正则表达式解析它们,更直接的方式应与EnvDTE可以存在,我认为!

but it is a little hard to parse them with regex, and a more straightforward way should be existed with EnvDTE I think!

推荐答案

文件code型(EnvDTE.File codeModel)不支持获取方法中的语句。对于2015年VS和更高您可以使用.NET编译器平台(原名罗斯林),这是C#/ VB.NET分析器,编译器等,接触到的Visual Studio扩展。请参阅: .NET编译器平台

The file code model (EnvDTE.FileCodeModel) doesn't support getting statements inside a method. For VS 2015 and higher you can use the .NET Compiler Platform (formerly "Roslyn") that is the C# / VB.NET parser, compiler, etc. exposed to extensions of Visual Studio. See: .NET Compiler Platform

这篇关于获取与EnvDte特定code元素的所有code语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆