本文整理汇总了C#中SyntaxNodeOrToken.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNodeOrToken.ToString方法的具体用法?C# SyntaxNodeOrToken.ToString怎么用?C# SyntaxNodeOrToken.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxNodeOrToken
的用法示例。
在下文中一共展示了SyntaxNodeOrToken.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SyntaxNodeOrTokenListItem
public SyntaxNodeOrTokenListItem(SyntaxNodeOrToken syntaxNodeOrToken)
{
_lineSpan = syntaxNodeOrToken.GetLocation().GetLineSpan();
Content = $"{_lineSpan}: {syntaxNodeOrToken.Kind()} {Truncate(syntaxNodeOrToken.ToString())}";
ToolTip = syntaxNodeOrToken.ToString();
}
示例2: SourceLabelSymbol
public SourceLabelSymbol(
MethodSymbol containingMethod,
SyntaxNodeOrToken identifierNodeOrToken,
ConstantValue switchCaseLabelConstant = null)
: base(identifierNodeOrToken.IsToken ? identifierNodeOrToken.AsToken().ValueText : identifierNodeOrToken.ToString())
{
this.containingMethod = containingMethod;
this.identifierNodeOrToken = identifierNodeOrToken;
this.switchCaseLabelConstant = switchCaseLabelConstant;
}
示例3: FindMatchingSwitchCaseLabels
private List<SourceLabelSymbol> FindMatchingSwitchCaseLabels(ConstantValue constantValue, SyntaxNodeOrToken labelSyntax = default(SyntaxNodeOrToken))
{
// SwitchLabelsMap: Dictionary for the switch case/default labels.
// Case labels with a non-null constant value are indexed on their ConstantValue.
// Invalid case labels with null constant value are indexed on the labelName.
object key;
if (constantValue != null)
{
key = constantValue;
}
else
{
key = labelSyntax.ToString();
}
return FindMatchingSwitchLabels(key);
}
示例4: GetSimilarity
private int GetSimilarity(SyntaxNodeOrToken node1, SyntaxNodeOrToken node2)
{
// count the characters in the common/identical nodes
int w = 0;
_nodeSimilaritySet.Clear();
_tokenTextSimilaritySet.Clear();
if (node1.IsToken && node2.IsToken)
{
var text1 = node1.ToString();
var text2 = node2.ToString();
if (text1 == text2)
{
// main text of token is the same
w += text1.Length;
}
foreach (var tr in node1.GetLeadingTrivia())
{
_nodeSimilaritySet.Add(tr.UnderlyingNode);
}
foreach (var tr in node1.GetTrailingTrivia())
{
_nodeSimilaritySet.Add(tr.UnderlyingNode);
}
foreach (var tr in node2.GetLeadingTrivia())
{
if (_nodeSimilaritySet.Contains(tr.UnderlyingNode))
{
w += tr.FullSpan.Length;
}
}
foreach (var tr in node2.GetTrailingTrivia())
{
if (_nodeSimilaritySet.Contains(tr.UnderlyingNode))
{
w += tr.FullSpan.Length;
}
}
}
else
{
foreach (var n1 in node1.ChildNodesAndTokens())
{
_nodeSimilaritySet.Add(n1.UnderlyingNode);
if (n1.IsToken)
{
_tokenTextSimilaritySet.Add(n1.ToString());
}
}
foreach (var n2 in node2.ChildNodesAndTokens())
{
if (_nodeSimilaritySet.Contains(n2.UnderlyingNode))
{
w += n2.FullSpan.Length;
}
else if (n2.IsToken)
{
var tokenText = n2.ToString();
if (_tokenTextSimilaritySet.Contains(tokenText))
{
w += tokenText.Length;
}
}
}
}
return w;
}
示例5: Print
private static void Print(SyntaxNodeOrToken node)
{
if (node.Kind() == SyntaxKind.IdentifierToken && !node.IsMissing)
{
Debug.WriteLine(@"N(SyntaxKind.{0}, ""{1}"");", node.Kind(), node.ToString());
}
else
{
Debug.WriteLine("{0}(SyntaxKind.{1});", node.IsMissing ? "M" : "N", node.Kind());
}
}
示例6: Print
private static void Print(SyntaxNodeOrToken node)
{
switch (node.Kind())
{
case SyntaxKind.IdentifierToken:
case SyntaxKind.NumericLiteralToken:
if (node.IsMissing)
{
goto default;
}
Debug.WriteLine(@"N(SyntaxKind.{0}, ""{1}"");", node.Kind(), node.ToString());
break;
default:
Debug.WriteLine("{0}(SyntaxKind.{1});", node.IsMissing ? "M" : "N", node.Kind());
break;
}
}