本文整理汇总了C#中SyntaxKind类的典型用法代码示例。如果您正苦于以下问题:C# SyntaxKind类的具体用法?C# SyntaxKind怎么用?C# SyntaxKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyntaxKind类属于命名空间,在下文中一共展示了SyntaxKind类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LexSyntaxToken
private SyntaxToken LexSyntaxToken()
{
_diagnostics.Clear();
_leadingTrivia.Clear();
_start = _charReader.Position;
if (_kind == SyntaxKind.CgProgramKeyword || _kind == SyntaxKind.CgIncludeKeyword)
ReadCgTrivia(_leadingTrivia);
ReadTrivia(_leadingTrivia, isTrailing: false);
var leadingTrivia = _leadingTrivia.ToImmutableArray();
_kind = SyntaxKind.BadToken;
_contextualKind = SyntaxKind.None;
_value = null;
_diagnostics.Clear();
_start = _charReader.Position;
ReadToken();
var end = _charReader.Position;
var kind = _kind;
var span = TextSpan.FromBounds(Text, _start, end);
var text = Text.GetText(span);
var diagnostics = _diagnostics.ToImmutableArray();
_trailingTrivia.Clear();
_diagnostics.Clear();
_start = _charReader.Position;
ReadTrivia(_trailingTrivia, isTrailing: true);
var trailingTrivia = _trailingTrivia.ToImmutableArray();
return new SyntaxToken(kind, _contextualKind, false, span, text, _value, leadingTrivia, trailingTrivia, diagnostics);
}
开发者ID:tgjones,项目名称:HlslTools,代码行数:32,代码来源:UnityLexer.cs
示例2: MatchBraces
private static BraceMatchingResult MatchBraces(SyntaxToken token, SourceLocation position, SyntaxKind leftKind, SyntaxKind rightKind)
{
var isLeft = token.Kind == leftKind &&
position == token.SourceRange.Start;
var isRight = token.Kind == rightKind &&
position == token.SourceRange.End;
if (isLeft)
{
var left = token.Span;
TextSpan right;
if (FindMatchingBrace(position, 1, token.Parent, rightKind, out right))
return MapResultToFile(left, right);
}
else if (isRight)
{
TextSpan left;
var right = token.Span;
if (FindMatchingBrace(position, -1, token.Parent, leftKind, out left))
return MapResultToFile(left, right);
}
return BraceMatchingResult.None;
}
开发者ID:tgjones,项目名称:HlslTools,代码行数:25,代码来源:BraceMatcher.cs
示例3: GetAssignmentOperator
static SyntaxKind GetAssignmentOperator(SyntaxKind op)
{
switch (op)
{
case SyntaxKind.AndAssignmentExpression:
return SyntaxKind.BitwiseAndExpression;
case SyntaxKind.OrAssignmentExpression:
return SyntaxKind.BitwiseOrExpression;
case SyntaxKind.ExclusiveOrAssignmentExpression:
return SyntaxKind.ExclusiveOrExpression;
case SyntaxKind.AddAssignmentExpression:
return SyntaxKind.AddExpression;
case SyntaxKind.SubtractAssignmentExpression:
return SyntaxKind.SubtractExpression;
case SyntaxKind.MultiplyAssignmentExpression:
return SyntaxKind.MultiplyExpression;
case SyntaxKind.DivideAssignmentExpression:
return SyntaxKind.DivideExpression;
case SyntaxKind.ModuloAssignmentExpression:
return SyntaxKind.ModuloExpression;
case SyntaxKind.LeftShiftAssignmentExpression:
return SyntaxKind.LeftShiftExpression;
case SyntaxKind.RightShiftAssignmentExpression:
return SyntaxKind.RightShiftExpression;
default:
return SyntaxKind.None;
}
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:28,代码来源:ReplaceOperatorAssignmentWithAssignmentCodeRefactoringProvider.cs
示例4: SyntaxTrivia
internal SyntaxTrivia(SyntaxKind kind, string text)
: this()
{
_kind = kind;
_start = 0;
_text = text;
}
开发者ID:jpobst,项目名称:Mokii,代码行数:7,代码来源:SyntaxTrivia.cs
示例5: XmlCommentSyntax
public XmlCommentSyntax(SyntaxKind kind, PunctuationSyntax beginComment, SyntaxNode node, PunctuationSyntax endComment) : base(kind)
{
this.BeginComment = beginComment;
this.Content = node;
this.EndComment = endComment;
SlotCount = 3;
}
开发者ID:akrisiun,项目名称:Microsoft.Language.Xml,代码行数:7,代码来源:XmlCommentSyntax.cs
示例6: WhenGettingDocumentationForPropertyThenReadsFromPropertyDefinition
public async Task WhenGettingDocumentationForPropertyThenReadsFromPropertyDefinition(string code, string summary, SyntaxKind kind)
{
var codeFile = string.Format(
@"namespace TestNs
{{
public class DocClass
{{
/// <summary>{0}</summary>
{1}
}}
}}",
summary,
code);
var solution = CreateSolution(codeFile);
var project = solution.Projects.First();
var document = project.Documents.First();
var model = await document.GetSemanticModelAsync();
var docRoot = await document.GetSyntaxRootAsync();
var node = docRoot.DescendantNodes().First(x => x.Kind() == kind);
var symbol = model.GetDeclaredSymbol(node);
var documentation = await _sut.Create(symbol, CancellationToken.None);
Assert.AreEqual(summary, documentation.Summary);
}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:25,代码来源:MemberDocumentationFactoryTests.cs
示例7: AbstractSpecialTypePreselectingKeywordRecommender
public AbstractSpecialTypePreselectingKeywordRecommender(
SyntaxKind keywordKind,
bool isValidInPreprocessorContext = false,
bool shouldFormatOnCommit = false)
: base(keywordKind, isValidInPreprocessorContext, shouldFormatOnCommit)
{
}
开发者ID:vslsnap,项目名称:roslyn,代码行数:7,代码来源:AbstractSpecialTypePreselectingKeywordRecommender.cs
示例8: FindType
private static BlockType FindType(SyntaxKind kind)
{
switch (kind)
{
case SyntaxKind.ForEachStatement:
case SyntaxKind.ForStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.DoStatement:
return BlockType.Loop;
case SyntaxKind.IfStatement:
case SyntaxKind.ElseClause:
case SyntaxKind.SwitchStatement:
return BlockType.Conditional;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.StructDeclaration:
case SyntaxKind.EnumDeclaration:
return BlockType.Class;
case SyntaxKind.NamespaceDeclaration:
return BlockType.Namespace;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.GetAccessorDeclaration:
case SyntaxKind.SetAccessorDeclaration:
case SyntaxKind.ParenthesizedLambdaExpression:
return BlockType.Method;
case SyntaxKind.TryStatement:
case SyntaxKind.CatchClause:
case SyntaxKind.FinallyClause:
case SyntaxKind.LockStatement:
return BlockType.Other;
default:
return BlockType.Unknown;
}
}
开发者ID:xornand,项目名称:VS-PPT,代码行数:35,代码来源:CsharpParser.cs
示例9: TryFlip
static bool TryFlip(BinaryExpressionSyntax expr, out SyntaxKind flippedKind, out string operatorText)
{
switch (expr.Kind())
{
case SyntaxKind.LessThanExpression:
flippedKind = SyntaxKind.GreaterThanExpression;
operatorText = ">";
return true;
case SyntaxKind.LessThanOrEqualExpression:
flippedKind = SyntaxKind.GreaterThanOrEqualExpression;
operatorText = ">=";
return true;
case SyntaxKind.GreaterThanExpression:
flippedKind = SyntaxKind.LessThanExpression;
operatorText = "<";
return true;
case SyntaxKind.GreaterThanOrEqualExpression:
flippedKind = SyntaxKind.LessThanOrEqualExpression;
operatorText = "<=";
return true;
}
flippedKind = SyntaxKind.None;
operatorText = null;
return false;
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:25,代码来源:FlipRelationalOperatorArgumentsCodeRefactoringProvider.cs
示例10: FindMatchingBrace
private static bool FindMatchingBrace(SourceLocation position, int direction, SyntaxNode parent, SyntaxKind syntaxKind, out TextSpan right)
{
var tokens = parent.ChildNodes.Where(t => t.Kind == syntaxKind);
var relevantTokens = (direction < 0)
? from t in tokens
where t.SourceRange.End <= position
select t
: from t in tokens
where position < t.SourceRange.Start
select t;
right = new TextSpan();
var found = false;
foreach (var token in relevantTokens.Cast<SyntaxToken>())
{
if (!found)
{
right = token.Span;
found = true;
}
else
return false;
}
return found;
}
开发者ID:tgjones,项目名称:HlslTools,代码行数:27,代码来源:BraceMatcher.cs
示例11: MissingToken
public static SyntaxToken MissingToken(SyntaxKind kind, SyntaxList<SyntaxNode> precedingTrivia = default(SyntaxList<SyntaxNode>))
{
switch (kind)
{
case SyntaxKind.LessThanQuestionToken:
case SyntaxKind.XmlKeyword:
case SyntaxKind.LessThanToken:
case SyntaxKind.LessThanGreaterThanToken:
case SyntaxKind.LessThanSlashToken:
case SyntaxKind.BeginCDataToken:
case SyntaxKind.LessThanExclamationMinusMinusToken:
case SyntaxKind.LessThanPercentEqualsToken:
case SyntaxKind.SlashToken:
case SyntaxKind.GreaterThanToken:
case SyntaxKind.EqualsToken:
case SyntaxKind.SingleQuoteToken:
case SyntaxKind.DoubleQuoteToken:
case SyntaxKind.QuestionGreaterThanToken:
case SyntaxKind.OpenParenToken:
case SyntaxKind.CloseParenToken:
case SyntaxKind.ColonToken:
case SyntaxKind.SlashGreaterThanToken:
case SyntaxKind.EndCDataToken:
case SyntaxKind.MinusMinusGreaterThanToken:
return MissingPunctuation(kind, precedingTrivia.Node);
case SyntaxKind.XmlNameToken:
return SyntaxFactory.XmlNameToken("", null, null);
default:
break;
}
throw new InvalidOperationException();
}
开发者ID:akrisiun,项目名称:Microsoft.Language.Xml,代码行数:33,代码来源:SyntaxFactory.cs
示例12: IsPreprocessorKeyword
public static bool IsPreprocessorKeyword(SyntaxKind kind)
{
switch (kind)
{
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
case SyntaxKind.DefaultKeyword:
case SyntaxKind.IfKeyword:
case SyntaxKind.ElseKeyword:
case SyntaxKind.ElifKeyword:
case SyntaxKind.EndIfKeyword:
case SyntaxKind.RegionKeyword:
case SyntaxKind.EndRegionKeyword:
case SyntaxKind.DefineKeyword:
case SyntaxKind.UndefKeyword:
case SyntaxKind.WarningKeyword:
case SyntaxKind.ErrorKeyword:
case SyntaxKind.LineKeyword:
case SyntaxKind.PragmaKeyword:
case SyntaxKind.HiddenKeyword:
case SyntaxKind.ChecksumKeyword:
case SyntaxKind.DisableKeyword:
case SyntaxKind.RestoreKeyword:
case SyntaxKind.ReferenceKeyword:
case SyntaxKind.LoadKeyword:
return true;
default:
return false;
}
}
开发者ID:Daniel-Svensson,项目名称:roslyn,代码行数:30,代码来源:SyntaxKindFacts.cs
示例13: XmlElementEndTagSyntax
public XmlElementEndTagSyntax(SyntaxKind kind, PunctuationSyntax lessThanSlashToken, XmlNameSyntax name, PunctuationSyntax greaterThanToken) : base(kind)
{
this.LessThanSlashToken = lessThanSlashToken;
this.NameNode = name;
this.GreaterThanToken = greaterThanToken;
this.SlotCount = 3;
}
开发者ID:akrisiun,项目名称:Microsoft.Language.Xml,代码行数:7,代码来源:XmlElementEndTagSyntax.cs
示例14: M
protected SyntaxNodeOrToken M(SyntaxKind kind)
{
Assert.True(_treeEnumerator.MoveNext());
SyntaxNodeOrToken current = _treeEnumerator.Current;
Assert.Equal(kind, current.Kind());
Assert.True(current.IsMissing);
return current;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:ParsingTests.cs
示例15: LiteralKindFromSyntaxKind
public static LiteralKind LiteralKindFromSyntaxKind(SyntaxKind kind)
{
foreach (var tuple in LiteralKindMap)
{
if (tuple.Item1 == kind) { return tuple.Item3; }
}
throw new InvalidOperationException();
}
开发者ID:KathleenDollard,项目名称:RoslynDOM,代码行数:8,代码来源:Mappings.cs
示例16: KeywordSyntax
public KeywordSyntax(
SyntaxKind kind,
string text,
SyntaxNode leadingTrivia,
SyntaxNode trailingTrivia)
: base(kind, text, leadingTrivia, trailingTrivia)
{
}
开发者ID:akrisiun,项目名称:Microsoft.Language.Xml,代码行数:8,代码来源:KeywordSyntax.cs
示例17: HandleDefaultModifier
static void HandleDefaultModifier(SyntaxNodeAnalysisContext context, SyntaxTokenList modifiers, SyntaxKind defaultModifier)
{
var index = modifiers.IndexOf(defaultModifier);
if (index != -1)
{
context.ReportDiagnostic(Diagnostic.Create(Rule, modifiers[index].GetLocation()));
}
}
开发者ID:cincuranet,项目名称:ExplicitDefaultAccessModifiersAnalyzer,代码行数:8,代码来源:DiagnosticAnalyzer.cs
示例18: AddAccessorNode
private void AddAccessorNode(AccessorListSyntax accessorList, SyntaxKind filter)
{
var accessor = accessorList.Accessors.FirstOrDefault(x => x.IsKind(filter));
if (accessor != null)
{
_members.Add(accessor);
}
}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:8,代码来源:MemberCollector.cs
示例19: XmlStringSyntax
public XmlStringSyntax(SyntaxKind kind, PunctuationSyntax startQuoteToken, SyntaxList<SyntaxNode> textTokens, PunctuationSyntax endQuoteToken)
: base(kind)
{
this.StartQuoteToken = startQuoteToken;
this.TextTokens = textTokens;
this.EndQuoteToken = endQuoteToken;
this.SlotCount = 3;
}
开发者ID:akrisiun,项目名称:Microsoft.Language.Xml,代码行数:8,代码来源:XmlStringSyntax.cs
示例20: PunctuationSyntax
public PunctuationSyntax(
SyntaxKind kind,
string text,
SyntaxNode leadingTrivia,
SyntaxNode trailingTrivia)
: base(kind, text, leadingTrivia, trailingTrivia)
{
}
开发者ID:akrisiun,项目名称:Microsoft.Language.Xml,代码行数:8,代码来源:PunctuationSyntax.cs
注:本文中的SyntaxKind类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论