提交 b18139a6 编写于 作者: B Balaji Krishnan

Insert traces for cases..

.. when completion can not have a session.
上级 dffda941
......@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Editor.Commands;
using Microsoft.CodeAnalysis.Editor.Options;
......@@ -146,6 +147,8 @@ private bool StartNewModelComputation(ICompletionService completionService, Comp
if (this.TextView.Selection.Mode == TextSelectionMode.Box)
{
Trace.WriteLine("Box selection, cannot have completion");
// No completion with multiple selection
return false;
}
......@@ -154,6 +157,8 @@ private bool StartNewModelComputation(ICompletionService completionService, Comp
var caret = TextView.GetCaretPoint(SubjectBuffer);
if (!caret.HasValue)
{
Trace.WriteLine("Caret is not mappable to subject buffer, cannot have completion");
return false;
}
......@@ -197,6 +202,7 @@ private ICompletionService GetCompletionService()
Workspace workspace;
if (!Workspace.TryGetWorkspace(this.SubjectBuffer.AsTextContainer(), out workspace))
{
Trace.WriteLine("Failed to get a workspace, cannot have a completion session.");
return null;
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using Microsoft.CodeAnalysis.Editor.Commands;
namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.Completion
......@@ -31,6 +32,7 @@ void ICommandHandler<InvokeCompletionListCommandArgs>.ExecuteCommand(InvokeCompl
var completionService = this.GetCompletionService();
if (completionService == null)
{
Trace.WriteLine("Failed to get completion service, cannot have a completion session.");
return;
}
......
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Editor.Commands;
......@@ -27,6 +28,8 @@ CommandState ICommandHandler<TypeCharCommandArgs>.GetCommandState(TypeCharComman
void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs args, Action nextHandler)
{
Trace.WriteLine("Entered completion command handler for typechar.");
AssertIsForeground();
var initialCaretPosition = GetCaretPointInViewBuffer();
......@@ -71,6 +74,8 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
// to proceed.
if (this.TextView.TypeCharWasHandledStrangely(this.SubjectBuffer, args.TypedChar))
{
Trace.WriteLine("typechar was handled by someone else, cannot have a completion session.");
if (sessionOpt != null)
{
// If we're on a seam (razor) with a computation, and the user types a character
......@@ -79,6 +84,8 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
// since the caret is no longer in our buffer.
if (isOnSeam && this.IsCommitCharacter(args.TypedChar))
{
Trace.WriteLine("typechar was on seam and a commit char, cannot have a completion session.");
this.CommitOnTypeChar(args.TypedChar);
return;
}
......@@ -86,6 +93,8 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
this.SubjectBuffer.GetOption(InternalFeatureOnOffOptions.AutomaticPairCompletion) &&
this.IsCommitCharacter(args.TypedChar))
{
Trace.WriteLine("typechar was brace completion char and a commit char, cannot have a completion session.");
// I don't think there is any better way than this. if typed char is one of auto brace completion char,
// we don't do multiple buffer change check
this.CommitOnTypeChar(args.TypedChar);
......@@ -93,6 +102,8 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
}
else
{
Trace.WriteLine("we stop model computation, cannot have a completion session.");
// If we were computing anything, we stop. We only want to process a typechar
// if it was a normal character.
this.StopModelComputation();
......@@ -105,6 +116,8 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
var completionService = this.GetCompletionService();
if (completionService == null)
{
Trace.WriteLine("handling typechar, completion service is null, cannot have a completion session.");
return;
}
......@@ -122,6 +135,8 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
// computation and start computing the model in the background.
if (isTextuallyTriggered)
{
Trace.WriteLine("no completion session yet and this is a trigger char, starting model computation.");
// First create the session that represents that we now have a potential
// completion list. Then tell it to start computing.
StartNewModelComputation(completionService, triggerInfo, filterItems: true);
......@@ -129,12 +144,16 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
}
else
{
Trace.WriteLine("no completion session yet and this is NOT a trigger char, we won't have completion.");
// No need to do anything. Just stay in the state where we have no session.
return;
}
}
else
{
Trace.WriteLine("we have a completion session.");
sessionOpt.UpdateModelTrackingSpan(initialCaretPosition);
// If the session is up, it may be in one of many states. It may know nothing
......@@ -147,6 +166,8 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
{
if (isTextuallyTriggered)
{
Trace.WriteLine("computing completion again and filtering...");
// The character typed was something like "a". It can both filter a list if
// we have computed one, or it can trigger a new list. Ask the computation
// to compute again. If nothing has been computed, then it will try to
......@@ -177,6 +198,8 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
// we have computed the list of completions.
if (this.IsFilterCharacter(args.TypedChar))
{
Trace.WriteLine("filtering the session...");
// Known to be a filter character for the currently selected item. So just
// filter the session.
sessionOpt.FilterModel(CompletionFilterReason.TypeChar);
......@@ -190,12 +213,16 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
// Now, commit if it was a commit character.
if (this.IsCommitCharacter(args.TypedChar))
{
Trace.WriteLine("committing the session...");
// Known to be a commit character for the currently selected item. So just
// commit the session.
this.CommitOnTypeChar(args.TypedChar);
}
else
{
Trace.WriteLine("dismissing the session...");
// Now dismiss the session.
this.StopModelComputation();
}
......@@ -205,6 +232,8 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
if (isTextuallyTriggered)
{
Trace.WriteLine("the char commit/dismiss -ed a session and is trigerring completion again. starting model computation.");
// First create the session that represents that we now have a potential
// completion list.
StartNewModelComputation(completionService, triggerInfo, filterItems: true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册