blob: 6d4cd307f1ca64d1e30142c7b646ffbef64e1d5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis;
namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
{
internal class ParamKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
{
public ParamKeywordRecommender()
: base(SyntaxKind.ParamKeyword)
{
}
protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
{
var token = context.TargetToken;
if (token.Kind() == SyntaxKind.OpenBracketToken &&
token.Parent.IsKind(SyntaxKind.AttributeList))
{
if (token.GetAncestor<PropertyDeclarationSyntax>() != null ||
token.GetAncestor<EventDeclarationSyntax>() != null)
{
return true;
}
}
return false;
}
}
}
|