@@ -91,6 +91,9 @@ sealed partial class VsProjectAnalyzer : IDisposable {
91
91
92
92
private readonly TaskProvider _defaultTaskProvider = CreateDefaultTaskProvider ( ) ;
93
93
94
+ internal static readonly string [ ] _emptyCompletionContextKeywords = new string [ ] {
95
+ "var" , "function" , "const" , "let"
96
+ } ;
94
97
#if FALSE
95
98
private readonly UnresolvedImportSquiggleProvider _unresolvedSquiggles ;
96
99
#endif
@@ -156,9 +159,9 @@ private void CreateNewAnalyzer(AnalysisLimits limits) {
156
159
_fullyLoaded = true ;
157
160
}
158
161
159
- private bool ShouldEnqueue ( ) {
160
- return _analysisLevel != AnalysisLevel . None && _analysisLevel != AnalysisLevel . Preview ;
161
- }
162
+ private bool ShouldEnqueue ( ) {
163
+ return _analysisLevel != AnalysisLevel . None && _analysisLevel != AnalysisLevel . Preview ;
164
+ }
162
165
163
166
#region Public API
164
167
@@ -257,7 +260,7 @@ public void RemoveBuffer(ITextBuffer buffer) {
257
260
}
258
261
259
262
BufferParser bufferParser ;
260
- if ( ! buffer . Properties . TryGetProperty < BufferParser > ( typeof ( BufferParser ) , out bufferParser ) ) {
263
+ if ( ! buffer . Properties . TryGetProperty < BufferParser > ( typeof ( BufferParser ) , out bufferParser ) ) {
261
264
return ;
262
265
}
263
266
@@ -323,7 +326,7 @@ private void AnalyzeFile(string path, bool reportErrors, ProjectItem originating
323
326
if ( ! reportErrors ) {
324
327
TaskProvider . Clear ( item . Entry , ParserTaskMoniker ) ;
325
328
}
326
-
329
+
327
330
if ( ( _reparseDateTime != null && new FileInfo ( path ) . LastWriteTime > _reparseDateTime . Value )
328
331
|| ( reportErrors && ! item . ReportErrors ) ||
329
332
( item . Entry . Module == null || item . Entry . Unit == null ) ) {
@@ -378,21 +381,21 @@ public void AddPackageJson(string packageJsonPath) {
378
381
AddPackageJson ( packageJsonPath , ( string ) mainFile , dependencyList ) ;
379
382
}
380
383
}
381
- }
382
-
383
- private static List < string > GetDependencyListFromJson ( Dictionary < string , object > json , params string [ ] dependencyTypes ) {
384
- var allDependencies = new List < string > ( ) ;
385
- foreach ( var type in dependencyTypes ) {
386
- object dependencies ;
387
- json . TryGetValue ( type , out dependencies ) ;
388
- var dep = dependencies as Dictionary < string , object > ;
389
- if ( dep != null ) {
390
- allDependencies . AddRange ( dep . Keys . ToList ( ) ) ;
391
- }
392
- }
393
- return allDependencies ;
394
- }
395
-
384
+ }
385
+
386
+ private static List < string > GetDependencyListFromJson ( Dictionary < string , object > json , params string [ ] dependencyTypes ) {
387
+ var allDependencies = new List < string > ( ) ;
388
+ foreach ( var type in dependencyTypes ) {
389
+ object dependencies ;
390
+ json . TryGetValue ( type , out dependencies ) ;
391
+ var dep = dependencies as Dictionary < string , object > ;
392
+ if ( dep != null ) {
393
+ allDependencies . AddRange ( dep . Keys . ToList ( ) ) ;
394
+ }
395
+ }
396
+ return allDependencies ;
397
+ }
398
+
396
399
public void AddPackageJson ( string path , string mainFile , List < string > dependencies ) {
397
400
if ( ! _fullyLoaded ) {
398
401
lock ( _loadingDeltas ) {
@@ -1191,17 +1194,17 @@ private static CompletionAnalysis TrySpecialCompletions(ITextSnapshot snapshot,
1191
1194
if ( range != null ) {
1192
1195
start = range . Value . Start ;
1193
1196
}
1194
- }
1195
-
1196
- // Get the classifiers from beginning of the line to the beginning of snapSpan.
1197
- // The contents of snapSpan differ depending on what is determined in
1198
- // CompletionSource.GetApplicableSpan.
1199
- //
1200
- // In the case of:
1201
- // var myIdentifier<cursor>
1202
- // the applicable span will be "myIdentifier", so GetClassificationSpans will operate on "var "
1203
- //
1204
- // In the case of comments and string literals, the applicable span will be empty,
1197
+ }
1198
+
1199
+ // Get the classifiers from beginning of the line to the beginning of snapSpan.
1200
+ // The contents of snapSpan differ depending on what is determined in
1201
+ // CompletionSource.GetApplicableSpan.
1202
+ //
1203
+ // In the case of:
1204
+ // var myIdentifier<cursor>
1205
+ // the applicable span will be "myIdentifier", so GetClassificationSpans will operate on "var "
1206
+ //
1207
+ // In the case of comments and string literals, the applicable span will be empty,
1205
1208
// so snapSpan.Start will occur at the current cursor position.
1206
1209
var tokens = classifier . GetClassificationSpans ( new SnapshotSpan ( start . GetContainingLine ( ) . Start , snapSpan . Start ) ) ;
1207
1210
if ( tokens . Count > 0 ) {
@@ -1210,8 +1213,9 @@ private static CompletionAnalysis TrySpecialCompletions(ITextSnapshot snapshot,
1210
1213
1211
1214
if ( lastClass . ClassificationType == classifier . Provider . Comment ||
1212
1215
lastClass . ClassificationType == classifier . Provider . StringLiteral ||
1213
- ( lastClass . ClassificationType == classifier . Provider . Keyword && lastClass . Span . GetText ( ) == "var" ) ) {
1214
- // No completions in comments, strings, or directly after "var" keywords.
1216
+ ( lastClass . ClassificationType == classifier . Provider . Keyword &&
1217
+ _emptyCompletionContextKeywords . Contains ( lastClass . Span . GetText ( ) ) ) ) {
1218
+ // No completions in comments, strings, or directly after certain keywords.
1215
1219
return CompletionAnalysis . EmptyCompletionContext ;
1216
1220
}
1217
1221
return null ;
@@ -1288,7 +1292,7 @@ private void OnErrorRemoved(string path) {
1288
1292
private void ClearParserTasks ( IProjectEntry entry ) {
1289
1293
if ( entry != null ) {
1290
1294
TaskProvider . Clear ( entry , ParserTaskMoniker ) ;
1291
-
1295
+
1292
1296
bool changed ;
1293
1297
lock ( _hasParseErrors ) {
1294
1298
changed = _hasParseErrors . Remove ( entry ) ;
0 commit comments