public override async System.Threading.Tasks.Task <ICompletionDataList> HandleCodeCompletionAsync(CodeCompletionContext completionContext, CompletionTriggerInfo triggerInfo, System.Threading.CancellationToken token) { if (triggerInfo.CompletionTriggerReason == CompletionTriggerReason.CompletionCommand) { if (hiddenInfo != null && (isInCSharpContext || Tracker.Engine.CurrentState is RazorState) && !(Tracker.Engine.Nodes.Peek() is XElement)) { InitializeCodeCompletion(); return(await completionBuilder.HandlePopupCompletion(defaultEditor, defaultDocumentContext, hiddenInfo)); } } char previousChar = defaultEditor.CaretOffset > 1 ? defaultEditor.GetCharAt( defaultEditor.CaretOffset - 2) : ' '; if (triggerInfo.CompletionTriggerReason != CompletionTriggerReason.CharTyped) { return(null); } // Don't show completion window when directive's name is being typed var directive = Tracker.Engine.Nodes.Peek() as RazorDirective; if (directive != null && !directive.FirstBracket.HasValue) { return(null); } var completionChar = triggerInfo.TriggerCharacter.Value; if (hiddenInfo != null && isInCSharpContext) { var list = (CompletionDataList)await completionBuilder.HandleCompletion(defaultEditor, defaultDocumentContext, completionContext, hiddenInfo, completionChar, token); if (list != null) { //filter out the C# templates, many of them are not valid int oldCount = list.Count; list = FilterCSharpTemplates(list); int templates = list.Count - oldCount; if (previousChar == '@') { RazorCompletion.AddAllRazorSymbols(list, razorDocument.PageInfo.HostKind); } if (templates > 0) { AddFilteredRazorTemplates(list, previousChar == '@', true); } } return(list); } return(await base.HandleCodeCompletionAsync(completionContext, triggerInfo, token)); }
public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength) { // if (!EnableCodeCompletion) // return null; char previousChar = defaultDocument.Editor.Caret.Offset > 1 ? defaultDocument.Editor.GetCharAt( defaultDocument.Editor.Caret.Offset - 2) : ' '; // Don't show completion window when directive's name is being typed var directive = Tracker.Engine.Nodes.Peek() as RazorDirective; if (directive != null && !directive.FirstBracket.HasValue) { return(null); } if (hiddenInfo != null && isInCSharpContext) { var list = (CompletionDataList)completionBuilder.HandleCompletion(defaultDocument, completionContext, hiddenInfo, completionChar, ref triggerWordLength); if (list != null) { //filter out the C# templates, many of them are not valid int oldCount = list.Count; list = FilterCSharpTemplates(list); int templates = list.Count - oldCount; if (previousChar == '@') { RazorCompletion.AddAllRazorSymbols(list, razorDocument.PageInfo.HostKind); } if (templates > 0) { AddFilteredRazorTemplates(list, previousChar == '@', true); } } return(list); } return(base.HandleCodeCompletion(completionContext, completionChar, ref triggerWordLength)); }