예제 #1
0
        private bool ShouldTriggerCompletion(CompletionTrigger trigger, SnapshotPoint triggerLocation)
        {
            if (triggerLocation == triggerLocation.Snapshot.Length)
            {
                return(false);
            }

            try
            {
                var currentToken     = _document.DocumentTokenizer.CurrentResult.GetToken(triggerLocation);
                var currentTokenType = _document.DocumentTokenizer.GetTokenType(currentToken.Type);
                if (currentTokenType == RadAsmTokenType.Comment)
                {
                    return(false);
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                // outdated parser results so you cannot get valid tokens for the trigger location
                return(false);
            }

            if (trigger.Reason == CompletionTriggerReason.Invoke ||
                trigger.Reason == CompletionTriggerReason.InvokeAndCommitIfUnique)
            {
                return(true);
            }

            if (trigger.Reason == CompletionTriggerReason.Insertion && (trigger.Character == '\n' || trigger.Character == '\t') ||
                trigger.Reason == CompletionTriggerReason.Deletion ||
                trigger.Reason == CompletionTriggerReason.Backspace)
            {
                return(false);
            }

            var extend = triggerLocation.GetExtent();

            if (extend.Span.Length < 3)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
 public CompletionStartData InitializeCompletion(CompletionTrigger trigger, SnapshotPoint triggerLocation, CancellationToken token) =>
 ShouldTriggerCompletion(trigger, triggerLocation)
         ? new CompletionStartData(CompletionParticipation.ProvidesItems, triggerLocation.GetExtent().Span)
         : CompletionStartData.DoesNotParticipateInCompletion;