本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.IndexerDeclarationSyntax类的典型用法代码示例。如果您正苦于以下问题:C# IndexerDeclarationSyntax类的具体用法?C# IndexerDeclarationSyntax怎么用?C# IndexerDeclarationSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexerDeclarationSyntax类属于Microsoft.CodeAnalysis.CSharp.Syntax命名空间,在下文中一共展示了IndexerDeclarationSyntax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitIndexerDeclaration
public override void VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
CheckXmlDocForErrors(node, semanticModel.GetDeclaredSymbol(node));
}
示例2: GetDeclaredSymbol
/// <summary>
/// Given a syntax node that declares an indexer, get the corresponding declared symbol.
/// </summary>
/// <param name="declarationSyntax">The syntax node that declares an indexer.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The symbol that was declared.</returns>
public override IPropertySymbol GetDeclaredSymbol(IndexerDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
{
return (IPropertySymbol)GetDeclaredMemberSymbol(declarationSyntax);
}
示例3: VisitIndexerDeclaration
public override void VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
base.VisitIndexerDeclaration(node);
Chunk.AddFunction(node, Model);
}
示例4: VisitIndexerDeclaration
public override SyntaxNode VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
this.AppendCompileIssue(node, IssueType.Error, IssueId.IndexerNotSupport);
return node;
}
示例5: HandleIndexerDeclaration
private static SyntaxNode HandleIndexerDeclaration(IndexerDeclarationSyntax node)
{
TypeSyntax type = node.Type;
if (type == null || type.IsMissing)
{
return null;
}
SyntaxTokenList modifiers = DeclarationModifiersHelper.AddModifier(node.Modifiers, ref type, SyntaxKind.PrivateKeyword);
return node
.WithType(type)
.WithModifiers(modifiers)
.WithoutFormatting();
}
示例6: VisitIndexerDeclaration
/// <summary>
/// Normalizes the <paramref name="declaration" />.
/// </summary>
public override SyntaxNode VisitIndexerDeclaration(IndexerDeclarationSyntax declaration)
{
// Nothing to do here for properties without expression bodies
if (declaration.ExpressionBody == null)
return declaration;
// Nothing to do here for indexers not defined in fault effects or for indexers that are no overrides of some port
var propertySymbol = declaration.GetPropertySymbol(SemanticModel);
if (!propertySymbol.ContainingType.IsFaultEffect(SemanticModel) || !propertySymbol.IsOverride)
return declaration;
var originalDeclaration = declaration;
var statements = AsStatementBody(propertySymbol.GetMethod, declaration.ExpressionBody.Expression);
var getter = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration, statements);
var accessorList = SyntaxFactory.AccessorList(SyntaxFactory.SingletonList(getter));
declaration = declaration.WithAccessorList(accessorList);
declaration = declaration.WithExpressionBody(null).WithSemicolonToken(default(SyntaxToken));
return declaration.EnsureLineCount(originalDeclaration);
}
示例7: VisitIndexerDeclaration
public override void VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
base.VisitIndexerDeclaration(node);
if (node.Modifiers.Any(m => m.IsKind(SyntaxKind.ExternKeyword)))
{
// This method body is unable to be analysed, so may contain writer instances
CheckForRefParametersForExternMethod(node.ParameterList.Parameters);
}
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-codeformatter-dotnet,代码行数:10,代码来源:MarkReadonlyFieldsRule.cs
示例8: IndexerDeclarationTranslation
public IndexerDeclarationTranslation(IndexerDeclarationSyntax syntax, SyntaxTranslation parent) : base(syntax, parent)
{
ParameterList = syntax.ParameterList.Get<BracketedParameterListTranslation>(this);
}
示例9: GetDeclaredSymbol
/// <summary>
/// Given a syntax node that declares an indexer, get the corresponding declared symbol.
/// </summary>
/// <param name="declarationSyntax">The syntax node that declares an indexer.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The symbol that was declared.</returns>
public override IPropertySymbol GetDeclaredSymbol(IndexerDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
{
using (Logger.LogBlock(FunctionId.CSharp_SemanticModel_GetDeclaredSymbol, message: this.SyntaxTree.FilePath, cancellationToken: cancellationToken))
{
return (IPropertySymbol)GetDeclaredMemberSymbol(declarationSyntax);
}
}
示例10: IsInBody
/// <summary>
/// A position is inside a property body only if it is inside an expression body.
/// All block bodies for properties are part of the accessor declaration (a type
/// of BaseMethodDeclaration), not the property declaration.
/// </summary>
internal static bool IsInBody(int position,
IndexerDeclarationSyntax indexer)
=> IsInBody(position, default(BlockSyntax), indexer.GetExpressionBodySyntax(), indexer.SemicolonToken);
示例11: HandleIndexerDeclaration
private async Task<Document> HandleIndexerDeclaration(IndexerDeclarationSyntax declaration, Document document, CancellationToken cancellationToken)
{
var returnStatement = SyntaxFactory.ReturnStatement(
returnKeyword: SyntaxFactory.Token(SyntaxKind.ReturnKeyword),
expression: declaration.ExpressionBody.Expression,
semicolonToken: declaration.SemicolonToken);
var accessorDeclaration = SyntaxFactory.AccessorDeclaration(
kind: SyntaxKind.GetAccessorDeclaration,
body: SyntaxFactory.Block(returnStatement));
var newDeclaration = declaration
.WithAccessorList(
SyntaxFactory.AccessorList(
SyntaxFactory.SingletonList(accessorDeclaration)))
.WithExpressionBody(null)
.WithSemicolonToken(default(SyntaxToken))
.WithAdditionalAnnotations(Formatter.Annotation);
var oldRoot = await document.GetSyntaxRootAsync(cancellationToken);
var newRoot = oldRoot.ReplaceNode(declaration, newDeclaration);
return document.WithSyntaxRoot(newRoot);
}
示例12: VisitIndexerDeclaration
/// <summary>
///
/// </summary>
/// <param name="node"></param>
public override sealed void VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
this.OnNodeVisited(node, this.type.IsInstanceOfType(node));
base.VisitIndexerDeclaration(node);
}
示例13: VisitIndexerDeclaration
/// <summary>
///
/// </summary>
/// <param name="node"></param>
public override sealed void VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
this.OnNodeVisited(node);
if (!this.traverseRootOnly) base.VisitIndexerDeclaration(node);
}
示例14: Add
public void Add(IndexerDeclarationSyntax node)
{
if (IsLibrary)
return;
ISymbol s = Model.GetDeclaredSymbol(node);
Function fGet = null;
Function fSet = null;
string sGet = string.Empty;
string sSet = string.Empty;
IMethodSymbol msGet = null;
IMethodSymbol msSet = null;
foreach (AccessorDeclarationSyntax ads in node.AccessorList.Accessors)
{
switch (ads.Keyword.CSharpKind())
{
case SyntaxKind.GetKeyword:
{
msGet = Model.GetDeclaredSymbol(ads);
if (!Chunk.Functions.TryGetValue(msGet, out fGet))
{
throw new LS2ILMethodException("Method not found " + msGet.ToString());
}
sGet = /*"get_" +*/ msGet.GetFullyQualifiedName();
}
break;
case SyntaxKind.SetKeyword:
{
msSet = Model.GetDeclaredSymbol(ads);
if (!Chunk.Functions.TryGetValue(msSet, out fSet))
{
throw new LS2ILMethodException("Method not found " + msSet.ToString());
}
sSet = /*"set_" +*/ msSet.GetFullyQualifiedName();
}
break;
default:
throw new NotImplementedException("unhandled property accessor: " + ads.Keyword.CSharpKind().ToString());
break;
}
}
if (msGet != null)
{
FlatArrayBuilder fab = new FlatArrayBuilder();
fab.Add(FlatValue.Int32(s.IsStatic ? (int)ClassMemberType.StaticMethod : (int)ClassMemberType.Method));
fab.Add(FlatValue.String(sGet));
Function f;
if (!Chunk.Functions.TryGetValue(msGet, out f))
{
throw new LS2ILMethodException("Method not found " + msGet.ToString());
}
fab.Add(FlatValue.Int32(f.NumFunction));
fab.Add(GenerateInputDeclarations(msGet).GetFlatValue());
Members.Add(fab.GetFlatValue());
}
if (msSet != null)
{
FlatArrayBuilder fab = new FlatArrayBuilder();
fab.Add(FlatValue.Int32(s.IsStatic ? (int)ClassMemberType.StaticMethod : (int)ClassMemberType.Method));
fab.Add(FlatValue.String(sSet));
Function f;
if (!Chunk.Functions.TryGetValue(msSet, out f))
{
throw new LS2ILMethodException("Method not found " + msGet.ToString());
}
fab.Add(FlatValue.Int32(f.NumFunction));
fab.Add(GenerateInputDeclarations(msSet).GetFlatValue());
Members.Add(fab.GetFlatValue());
}
}
示例15: AddFunction
public void AddFunction(IndexerDeclarationSyntax node, SemanticModel Model)
{
IPropertySymbol ps = Model.GetDeclaredSymbol(node);
foreach(AccessorDeclarationSyntax ads in node.AccessorList.Accessors)
{
IMethodSymbol ms = Model.GetDeclaredSymbol(ads);
AddFunction(ms, Model);
}
/*
Function f;
if (Indexers.TryGetValue(ms, out f))
{
return;
}
int nFunction = FunctionsByNumber.Count;
f = new Function(this, nFunction, Model, ms);
Functions.Add(f.IMethodSymbol, f);
FunctionsByNumber.Add(f);
if (ms.IsImplicitlyDeclared)
{
TypeExtraInfo tei = AddTypeExtraInfo(ms.ContainingType, Model, false); // assuming isLibrary=false because we have a function representing it in the chunk.
tei.MetadataGenerator.Add(ms);
}
/**/
}