我在C#中有这个变量,它是我正在创建的resharper插件的一部分,用于对所有引用的值(不仅仅是字符串)抛出一个警告。
var sourceFile = _process.SourceFile;
var file = sourceFile.GetPsiServices().Files.GetDominantPsiFile<CSharpLanguage>(sourceFile);
if (file != null)
{
var highlights = new List<HighlightingInfo>();
var stringHighlight = new RecursiveElementProcessor<IQuotedValue>(declaration =>
{
var docRange = declaration.GetDocumentRange();
highlights.Add(new HighlightingInfo(docRange, new MakeMethodVirtualSuggestion("Warning...")));
});
file.ProcessDescendants(stringHighlight);
commiter(new DaemonStageResult(highlights));
}它在使用IMethodDeclaration时可以工作,但无法理解如何获取IQuotedValue值。在这种情况下使用RecursiveElementProcessor是错误的吗?任何和所有的帮助都是非常感谢的,一直试图解决这个问题很多个小时了。提前谢谢。
发布于 2014-03-14 19:56:09
IQuotedValue是一个XAML元素-它不会在C#语法树中使用。最好的方法是查找ILiteralExpression或ICSharpLiteralExpression的元素,然后查看Literal属性以查看它是什么- true、false (数字、字符或字符串)。
https://stackoverflow.com/questions/22410844
复制相似问题