// this is primarily used to pass info from GetCompletionContextAsync to GetDocumentationAsync // but also reuses the values calculated for expression completion in GetCompletionContextAsync // if it's determined not be be expression completion but actually ends up // in GetElementCompletionsAsync or GetAttributeCompletionsAsync async Task <MSBuildCompletionSessionContext> GetSessionContext(IAsyncCompletionSession session, SnapshotPoint triggerLocation, CancellationToken token) { if (session.Properties.TryGetProperty <MSBuildCompletionSessionContext> (typeof(MSBuildCompletionSessionContext), out var context)) { return(context); } var parser = GetParser(); var parseResult = await parser.GetOrParseAsync((ITextSnapshot2)triggerLocation.Snapshot, token); var doc = parseResult.MSBuildDocument ?? MSBuildRootDocument.Empty; var spine = parser.GetSpineParser(triggerLocation); var rr = MSBuildResolver.Resolve(GetSpineParser(triggerLocation), triggerLocation.Snapshot.GetTextSource(), doc, provider.FunctionTypeProvider); context = new MSBuildCompletionSessionContext { doc = doc, rr = rr, spine = spine }; session.Properties.AddProperty(typeof(MSBuildCompletionSessionContext), context); return(context); }
// this is primarily used to pass info from GetCompletionContextAsync to GetDocumentationAsync // but also reuses the values calculated for expression completion in GetCompletionContextAsync // if it's determined not be be expression completion but actually ends up // in GetElementCompletionsAsync or GetAttributeCompletionsAsync async Task <MSBuildCompletionSessionContext> GetSessionContext(IAsyncCompletionSession session, SnapshotPoint triggerLocation, CancellationToken token) { if (session.Properties.TryGetProperty <MSBuildCompletionSessionContext> (typeof(MSBuildCompletionSessionContext), out var context)) { return(context); } MSBuildParseResult parseResult = parser.LastOutput ?? await parser.GetOrProcessAsync(triggerLocation.Snapshot, token); var doc = parseResult.MSBuildDocument ?? MSBuildRootDocument.Empty; var spine = XmlParser.GetSpineParser(triggerLocation); // clone the spine because the resolver alters it var rr = MSBuildResolver.Resolve(spine.Clone(), triggerLocation.Snapshot.GetTextSource(), doc, provider.FunctionTypeProvider, token); context = new MSBuildCompletionSessionContext { doc = doc, rr = rr, spine = spine }; session.Properties.AddProperty(typeof(MSBuildCompletionSessionContext), context); return(context); }