@@ -91,6 +91,9 @@ sealed partial class VsProjectAnalyzer : IDisposable {
9191
9292 private readonly TaskProvider _defaultTaskProvider = CreateDefaultTaskProvider ( ) ;
9393
94+ internal static readonly string [ ] _emptyCompletionContextKeywords = new string [ ] {
95+ "var" , "function" , "const" , "let"
96+ } ;
9497#if FALSE
9598 private readonly UnresolvedImportSquiggleProvider _unresolvedSquiggles ;
9699#endif
@@ -156,9 +159,9 @@ private void CreateNewAnalyzer(AnalysisLimits limits) {
156159 _fullyLoaded = true ;
157160 }
158161
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+ }
162165
163166 #region Public API
164167
@@ -257,7 +260,7 @@ public void RemoveBuffer(ITextBuffer buffer) {
257260 }
258261
259262 BufferParser bufferParser ;
260- if ( ! buffer . Properties . TryGetProperty < BufferParser > ( typeof ( BufferParser ) , out bufferParser ) ) {
263+ if ( ! buffer . Properties . TryGetProperty < BufferParser > ( typeof ( BufferParser ) , out bufferParser ) ) {
261264 return ;
262265 }
263266
@@ -323,7 +326,7 @@ private void AnalyzeFile(string path, bool reportErrors, ProjectItem originating
323326 if ( ! reportErrors ) {
324327 TaskProvider . Clear ( item . Entry , ParserTaskMoniker ) ;
325328 }
326-
329+
327330 if ( ( _reparseDateTime != null && new FileInfo ( path ) . LastWriteTime > _reparseDateTime . Value )
328331 || ( reportErrors && ! item . ReportErrors ) ||
329332 ( item . Entry . Module == null || item . Entry . Unit == null ) ) {
@@ -378,21 +381,21 @@ public void AddPackageJson(string packageJsonPath) {
378381 AddPackageJson ( packageJsonPath , ( string ) mainFile , dependencyList ) ;
379382 }
380383 }
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+
396399 public void AddPackageJson ( string path , string mainFile , List < string > dependencies ) {
397400 if ( ! _fullyLoaded ) {
398401 lock ( _loadingDeltas ) {
@@ -1191,17 +1194,17 @@ private static CompletionAnalysis TrySpecialCompletions(ITextSnapshot snapshot,
11911194 if ( range != null ) {
11921195 start = range . Value . Start ;
11931196 }
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,
12051208 // so snapSpan.Start will occur at the current cursor position.
12061209 var tokens = classifier . GetClassificationSpans ( new SnapshotSpan ( start . GetContainingLine ( ) . Start , snapSpan . Start ) ) ;
12071210 if ( tokens . Count > 0 ) {
@@ -1210,8 +1213,9 @@ private static CompletionAnalysis TrySpecialCompletions(ITextSnapshot snapshot,
12101213
12111214 if ( lastClass . ClassificationType == classifier . Provider . Comment ||
12121215 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.
12151219 return CompletionAnalysis . EmptyCompletionContext ;
12161220 }
12171221 return null ;
@@ -1288,7 +1292,7 @@ private void OnErrorRemoved(string path) {
12881292 private void ClearParserTasks ( IProjectEntry entry ) {
12891293 if ( entry != null ) {
12901294 TaskProvider . Clear ( entry , ParserTaskMoniker ) ;
1291-
1295+
12921296 bool changed ;
12931297 lock ( _hasParseErrors ) {
12941298 changed = _hasParseErrors . Remove ( entry ) ;
0 commit comments