本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.IndexerDeclarationSyntax类的典型用法代码示例。如果您正苦于以下问题:C# IndexerDeclarationSyntax类的具体用法?C# IndexerDeclarationSyntax怎么用?C# IndexerDeclarationSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexerDeclarationSyntax类属于Microsoft.CodeAnalysis.CSharp.Syntax命名空间,在下文中一共展示了IndexerDeclarationSyntax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitIndexerDeclaration
public override void VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
CheckXmlDocForErrors(node, semanticModel.GetDeclaredSymbol(node));
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:4,代码来源:XmlDocAnalyzer.cs
示例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);
}
开发者ID:nileshjagtap,项目名称:roslyn,代码行数:10,代码来源:SyntaxTreeSemanticModel.cs
示例3: VisitIndexerDeclaration
public override void VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
base.VisitIndexerDeclaration(node);
Chunk.AddFunction(node, Model);
}
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:5,代码来源:MethodCollector.cs
示例4: VisitIndexerDeclaration
public override SyntaxNode VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
this.AppendCompileIssue(node, IssueType.Error, IssueId.IndexerNotSupport);
return node;
}
开发者ID:rexzh,项目名称:SharpJs,代码行数:5,代码来源:Rewriter_BasicStructure.cs
示例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();
}
开发者ID:Romanx,项目名称:StyleCopAnalyzers,代码行数:14,代码来源:SA1400CodeFixProvider.cs
示例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);
}
开发者ID:isse-augsburg,项目名称:ssharp,代码行数:24,代码来源:ExpressionBodyNormalizer.cs
示例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);
}
开发者ID:asthomas,项目名称:TypescriptSyntaxPaste,代码行数:4,代码来源:IndexerDeclarationTranslation.cs
示例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);
}
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:13,代码来源:SyntaxTreeSemanticModel.cs
示例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);
开发者ID:jkotas,项目名称:roslyn,代码行数:8,代码来源:LookupPosition.cs
示例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);
}
开发者ID:jmarolf,项目名称:CSharpEssentials,代码行数:24,代码来源:ExpandExpressionBodiedMemberRefactoring.cs
示例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);
}
开发者ID:andry-tino,项目名称:Rosetta,代码行数:9,代码来源:ASTWalkerNodeTypeOperationExecutor.cs
示例13: VisitIndexerDeclaration
/// <summary>
///
/// </summary>
/// <param name="node"></param>
public override sealed void VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
this.OnNodeVisited(node);
if (!this.traverseRootOnly) base.VisitIndexerDeclaration(node);
}
开发者ID:andry-tino,项目名称:Rosetta,代码行数:9,代码来源:MultiPurposeASTWalker.cs
示例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());
}
}
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:80,代码来源:TypeExtraInfo.cs
示例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);
}
/**/
}
开发者ID:LaxLacks,项目名称:ls2csc,代码行数:27,代码来源:Chunk.cs
示例16: VisitIndexerDeclaration
public override SyntaxNode VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
if (node == null)
return null;
var symbol = m_model.GetDeclaredSymbol(node);
node = (IndexerDeclarationSyntax)base.VisitIndexerDeclaration(node);
if (!IsPrivateOrInternal(symbol.DeclaredAccessibility))
node = (IndexerDeclarationSyntax)ApplyDocComment(node, symbol.GetDocumentationCommentId());
return node;
}
开发者ID:dotnet,项目名称:import-comments,代码行数:10,代码来源:Rewriter.cs
示例17: GetTransformedDocumentForIndexerDeclaration
private static Document GetTransformedDocumentForIndexerDeclaration(Document document, Diagnostic diagnostic, SyntaxNode root, SemanticModel semanticModel, IndexerDeclarationSyntax indexerDeclaration, CancellationToken cancellationToken)
{
if (indexerDeclaration.ExplicitInterfaceSpecifier == null && !indexerDeclaration.Modifiers.Any(SyntaxKind.OverrideKeyword))
{
ISymbol declaredSymbol = semanticModel.GetDeclaredSymbol(indexerDeclaration, cancellationToken);
if (declaredSymbol == null || !NamedTypeHelpers.IsImplementingAnInterfaceMember(declaredSymbol))
{
return document;
}
}
return InsertInheritdocComment(document, diagnostic, root, indexerDeclaration, cancellationToken);
}
开发者ID:hvanbakel,项目名称:StyleCopAnalyzers,代码行数:13,代码来源:InheritdocCodeFixProvider.cs
示例18: UseExpressionBodyIfDesired
private static IndexerDeclarationSyntax UseExpressionBodyIfDesired(
Workspace workspace, IndexerDeclarationSyntax declaration, ParseOptions options)
{
if (declaration.ExpressionBody == null)
{
var preferExpressionBody = workspace.Options.GetOption(CSharpCodeStyleOptions.PreferExpressionBodiedIndexers).Value;
if (preferExpressionBody)
{
var expressionBody = TryGetExpressionBody(declaration.AccessorList, options);
if (expressionBody != null)
{
declaration = declaration.WithAccessorList(null)
.WithExpressionBody(expressionBody)
.WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken));
}
}
}
return declaration;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:20,代码来源:PropertyGenerator.cs
示例19: Go
public static void Go(OutputWriter writer, IndexerDeclarationSyntax property, bool isProxy = false)
{
WriteProperty.Go(writer, property, isProxy);
}
开发者ID:mortezabarzkar,项目名称:SharpNative,代码行数:4,代码来源:WriteIndexer.cs
示例20: GetDeclaredSymbol
public override IPropertySymbol GetDeclaredSymbol(IndexerDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
{
// Can't define indexer inside member.
return null;
}
开发者ID:orthoxerox,项目名称:roslyn,代码行数:5,代码来源:MemberSemanticModel.cs
注:本文中的Microsoft.CodeAnalysis.CSharp.Syntax.IndexerDeclarationSyntax类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论