3
3
// See the LICENSE file in the project root for more information.
4
4
5
5
using System ;
6
- using System . Collections . Generic ;
7
6
using System . ComponentModel . Composition ;
8
- using System . Linq ;
9
- using System . Text ;
10
7
using System . Threading ;
11
8
using System . Threading . Tasks ;
12
9
using Microsoft . CodeAnalysis . Copilot ;
@@ -51,16 +48,16 @@ public void TriggerDocumentationCommentProposalGeneration(Document document,
51
48
52
49
private async Task GenerateDocumentationCommentProposalsAsync ( Document document , DocumentationCommentSnippet snippet , ITextSnapshot snapshot , VirtualSnapshotPoint caret , ITextView textView , CancellationToken cancellationToken )
53
50
{
54
- var generateDocumentationCommentProvider = await CreateProviderAsync ( document , textView , cancellationToken ) . ConfigureAwait ( false ) ;
51
+ var generateDocumentationCommentProvider = await CreateProviderAsync ( document , textView , snippet . MemberNode , cancellationToken ) . ConfigureAwait ( false ) ;
55
52
if ( generateDocumentationCommentProvider is not null )
56
53
{
57
54
await generateDocumentationCommentProvider . GenerateDocumentationProposalAsync ( snippet , snapshot , caret , cancellationToken ) . ConfigureAwait ( false ) ;
58
55
}
59
56
}
60
57
61
- private async Task < CopilotGenerateDocumentationCommentProvider ? > CreateProviderAsync ( Document document , ITextView textView , CancellationToken cancellationToken )
58
+ private async Task < CopilotGenerateDocumentationCommentProvider ? > CreateProviderAsync ( Document document , ITextView textView , SyntaxNode ? memberNode , CancellationToken cancellationToken )
62
59
{
63
- var copilotService = await IsGenerateDocumentationAvailableAsync ( document , cancellationToken ) . ConfigureAwait ( false ) ;
60
+ var copilotService = await IsGenerateDocumentationAvailableAsync ( document , memberNode , cancellationToken ) . ConfigureAwait ( false ) ;
64
61
65
62
if ( copilotService is null )
66
63
{
@@ -75,7 +72,7 @@ private async Task GenerateDocumentationCommentProposalsAsync(Document document,
75
72
return provider ;
76
73
}
77
74
78
- private static async Task < ICopilotCodeAnalysisService ? > IsGenerateDocumentationAvailableAsync ( Document document , CancellationToken cancellationToken )
75
+ private static async Task < ICopilotCodeAnalysisService ? > IsGenerateDocumentationAvailableAsync ( Document document , SyntaxNode ? memberNode , CancellationToken cancellationToken )
79
76
{
80
77
// Bailing out if copilot is not available or the option is not enabled.
81
78
if ( document . GetLanguageService < ICopilotOptionsService > ( ) is not { } copilotOptionService ||
@@ -90,6 +87,17 @@ await copilotService.IsAvailableAsync(cancellationToken).ConfigureAwait(false) i
90
87
return null ;
91
88
}
92
89
90
+ if ( memberNode is null )
91
+ {
92
+ return null ;
93
+ }
94
+
95
+ // Check to see if the file containing the member being documented has been excluded.
96
+ if ( await copilotService . IsFileExcludedAsync ( memberNode . SyntaxTree . FilePath , cancellationToken ) . ConfigureAwait ( false ) )
97
+ {
98
+ return null ;
99
+ }
100
+
93
101
return copilotService ;
94
102
}
95
103
}
0 commit comments