?? variableresolver.cs
字號:
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision: 915 $</version>
// </file>
using System;
using System.Collections;
using System.Collections.Generic;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
namespace NRefactoryToBooConverter
{
/// <summary>
/// This class tries to find out the type of an identifier by looking at the NRefactory AST.
/// The possibilities inside the parser are very limited, we can only
/// search for local variables and fields.
/// </summary>
public class VariableResolver
{
StringComparer nameComparer;
public VariableResolver(StringComparer nameComparer)
{
this.nameComparer = nameComparer;
}
public TypeReference FindType(string name, Statement currentStatement)
{
INode node = currentStatement;
while ((node = node.Parent) != null) {
foreach (INode childNode in node.Children) {
LocalVariableDeclaration varDecl = childNode as LocalVariableDeclaration;
if (varDecl != null) {
foreach (VariableDeclaration var in varDecl.Variables) {
if (nameComparer.Equals(var.Name, name))
return var.TypeReference;
}
}
}
}
return null;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -