本文整理汇总了C#中EnumMemberDeclarationSyntax类的典型用法代码示例。如果您正苦于以下问题:C# EnumMemberDeclarationSyntax类的具体用法?C# EnumMemberDeclarationSyntax怎么用?C# EnumMemberDeclarationSyntax使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EnumMemberDeclarationSyntax类属于命名空间,在下文中一共展示了EnumMemberDeclarationSyntax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SourceEnumConstantSymbol
protected SourceEnumConstantSymbol(SourceMemberContainerTypeSymbol containingEnum, EnumMemberDeclarationSyntax syntax, DiagnosticBag diagnostics)
: base(containingEnum, syntax.Identifier.ValueText, syntax.GetReference(), syntax.Identifier.GetLocation())
{
if (this.Name == WellKnownMemberNames.EnumBackingFieldName)
{
diagnostics.Add(ErrorCode.ERR_ReservedEnumerator, this.Location, WellKnownMemberNames.EnumBackingFieldName);
}
}
示例2: CreateExplicitValuedConstant
public static SourceEnumConstantSymbol CreateExplicitValuedConstant(
SourceMemberContainerTypeSymbol containingEnum,
EnumMemberDeclarationSyntax syntax,
DiagnosticBag diagnostics)
{
var initializer = syntax.EqualsValue;
Debug.Assert(initializer != null);
return new ExplicitValuedEnumConstantSymbol(containingEnum, syntax, initializer, diagnostics);
}
示例3: VisitEnumMemberDeclaration
public override void VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node)
{
var symbol = model.GetDeclaredSymbol(node);
this.declaredItems.Add(new DeclaredItemDocument
{
Name = symbol.Name,
Location = this.model.SyntaxTree.GetLineSpan(node.Span, false).StartLinePosition.Line,
Identifier = symbol.ToDisplayString(),
Type = "EnumMember"
});
base.VisitEnumMemberDeclaration(node);
}
示例4: CreateImplicitValuedConstant
public static SourceEnumConstantSymbol CreateImplicitValuedConstant(
SourceMemberContainerTypeSymbol containingEnum,
EnumMemberDeclarationSyntax syntax,
SourceEnumConstantSymbol otherConstant,
int otherConstantOffset,
DiagnosticBag diagnostics)
{
if ((object)otherConstant == null)
{
Debug.Assert(otherConstantOffset == 0);
return new ZeroValuedEnumConstantSymbol(containingEnum, syntax, diagnostics);
}
else
{
Debug.Assert(otherConstantOffset > 0);
return new ImplicitValuedEnumConstantSymbol(containingEnum, syntax, otherConstant, (uint)otherConstantOffset, diagnostics);
}
}
示例5: VisitEnumMemberDeclaration
public override SyntaxNode VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node)
{
if (node.EqualsValue == null)
{
lastValue++;
return node.WithEqualsValue(Syntax.EqualsValueClause(Syntax.Token(SyntaxKind.EqualsToken),
Syntax.LiteralExpression(SyntaxKind.NumericLiteralExpression, Syntax.Literal(lastValue))
));
}
else
{
ExpressionSyntax expr = node.EqualsValue.Value;
if (expr.Kind == SyntaxKind.NumericLiteralExpression)
{
lastValue = int.Parse(expr.ToString());
return node;
}
throw new NotImplementedException("enum with non-literal explicit value");
}
return base.VisitEnumMemberDeclaration(node);
}
示例6: EnumMemberDeclarationTranslation
public EnumMemberDeclarationTranslation(EnumMemberDeclarationSyntax syntax, SyntaxTranslation parent) : base(syntax, parent)
{
}
示例7: VisitEnumMemberDeclaration
public override void VisitEnumMemberDeclaration (EnumMemberDeclarationSyntax node)
{
base.VisitEnumMemberDeclaration (node);
Append (node);
}
示例8: ClassifyUpdate
private void ClassifyUpdate(EnumMemberDeclarationSyntax oldNode, EnumMemberDeclarationSyntax newNode)
{
if (!SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier))
{
ReportError(RudeEditKind.Renamed);
return;
}
Debug.Assert(!SyntaxFactory.AreEquivalent(oldNode.EqualsValue, newNode.EqualsValue));
ReportError(RudeEditKind.InitializerUpdate);
}
示例9: VisitEnumMemberDeclaration
/// <summary>
/// Traverse AST node that represents enumeration constant declaration
/// </summary>
/// <param name="node">AST node.</param>
public override void VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node)
{
try
{
if (!node.Identifier.Span.IsEmpty)
{
var symbol = _sm.GetDeclaredSymbol(node);
if (!_defined.Contains(symbol))
{
_defined.Add(symbol);
var def = Def.For(symbol: symbol, type: "enum field", name: symbol.Name).At(_path, node.Identifier.Span);
def.Exported = true;
AddDef(def);
}
}
base.VisitEnumMemberDeclaration(node);
}
catch (Exception e)
{
}
}
示例10: GetDeclaredSymbol
public override IFieldSymbol GetDeclaredSymbol(EnumMemberDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
{
// Can't define member inside member.
return null;
}
示例11: GetDeclaredSymbol
/// <summary>
/// Given a enum member declaration, get the corresponding field symbol.
/// </summary>
/// <param name="declarationSyntax">The syntax node that declares an enum member.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The symbol that was declared.</returns>
public override IFieldSymbol GetDeclaredSymbol(EnumMemberDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
{
return (IFieldSymbol)GetDeclaredMemberSymbol(declarationSyntax);
}
示例12: ExplicitValuedEnumConstantSymbol
public ExplicitValuedEnumConstantSymbol(
SourceMemberContainerTypeSymbol containingEnum,
EnumMemberDeclarationSyntax syntax,
EqualsValueClauseSyntax initializer,
DiagnosticBag diagnostics) :
base(containingEnum, syntax, diagnostics)
{
this.equalsValueNodeRef = initializer.GetReference();
}
示例13: Add
public void Add(EnumMemberDeclarationSyntax node)
{
/* // Summary:
// Gets the attribute declaration list.
public SyntaxList<AttributeListSyntax> AttributeLists { get; }
public EqualsValueClauseSyntax EqualsValue { get; }
//
// Summary:
// Gets the identifier.
public SyntaxToken Identifier { get; }
*/
// add field info
TypeExtraInfo tei = Chunk.AddTypeExtraInfo(this.Class,Model);
tei.AddEnumMember(node.Identifier.ToString(), node.EqualsValue != null ? node.EqualsValue.Value : null);
/*
// Summary:
// Gets the attribute declaration list.
public override SyntaxList<AttributeListSyntax> AttributeLists { get; }
public override VariableDeclarationSyntax Declaration { get; }
//
// Summary:
// Gets the modifier list.
public override SyntaxTokenList Modifiers { get; }
public override SyntaxToken SemicolonToken { get; }
*/
// add to metadata for runtime type building
FlatArrayBuilder fab = new FlatArrayBuilder();
fab.Add(FlatValue.Int32((int)ClassMemberType.StaticField));
//TypeInfo ti = Chunk.Model.GetTypeInfo(node..Type);
fab.Add(FlatValue.String(Class.GetFullyQualifiedName()));
{
FlatArrayBuilder varList = new FlatArrayBuilder();
varList.Add(FlatValue.String(node.Identifier.ToString()));
fab.Add(varList.GetFlatValue());
}
{
FlatArrayBuilder valueList = new FlatArrayBuilder();
if (node.EqualsValue != null)
{
if (node.EqualsValue.Value.Kind == SyntaxKind.NumericLiteralExpression)
{
valueList.Add(FlatValue.Int32(int.Parse(node.EqualsValue.Value.ToString())));
}
else
{
throw new NotImplementedException("Enum member without numeric literal expression");
}
}
else
{
throw new NotImplementedException("Enum member without numeric literal expression");
}
fab.Add(valueList.GetFlatValue());
}
Members.Add(fab.GetFlatValue());
}
示例14: ZeroValuedEnumConstantSymbol
public ZeroValuedEnumConstantSymbol(
SourceMemberContainerTypeSymbol containingEnum,
EnumMemberDeclarationSyntax syntax,
DiagnosticBag diagnostics)
: base(containingEnum, syntax, diagnostics)
{
}
示例15: EnumMemberDeclaration
/// <summary>
/// Initializes a new instance of the <see cref="EnumMemberDeclaration"/> class.
/// </summary>
/// <param name="enumMemberDeclarationNode"></param>
/// <param name="semanticModel"></param>
public EnumMemberDeclaration(EnumMemberDeclarationSyntax enumMemberDeclarationNode, SemanticModel semanticModel)
: base(enumMemberDeclarationNode, semanticModel)
{
}