IsCaretInLibraryStatement() public static method

public static IsCaretInLibraryStatement ( ITextView textView ) : bool
textView ITextView
return bool
Example #1
0
        /// <summary>
        /// Should this key press trigger a completion session?
        /// </summary>
        public override bool IsTriggerChar(char typedCharacter)
        {
            if (!HasActiveCompletionSession)
            {
                switch (typedCharacter)
                {
                case '$':
                case '@':
                    return(true);

                case ':':
                    return(RCompletionContext.IsCaretInNamespace(TextView));

                case '(':
                    return(RCompletionContext.IsCaretInLibraryStatement(TextView));

                default:
                    if (REditorSettings.ShowCompletionOnFirstChar)
                    {
                        return(Char.IsLetter(typedCharacter) || typedCharacter == '.');
                    }
                    break;
                }
            }

            return(false);
        }
Example #2
0
        /// <summary>
        /// Should this key press trigger a completion session?
        /// </summary>
        public override bool IsTriggerChar(char typedCharacter)
        {
            if (!HasActiveCompletionSession)
            {
                switch (typedCharacter)
                {
                case '$':
                case '@':
                    return(true);

                case ':':
                    return(RCompletionContext.IsCaretInNamespace(TextView));

                case '(':
                    return(RCompletionContext.IsCaretInLibraryStatement(TextView));

                default:
                    if (REditorSettings.ShowCompletionOnFirstChar)
                    {
                        SnapshotPoint?position = REditorDocument.MapCaretPositionFromView(TextView);
                        if (position.HasValue)
                        {
                            int pos      = position.Value;
                            var snapshot = position.Value.Snapshot;
                            // Trigger on first character
                            if (RTokenizer.IsIdentifierCharacter(typedCharacter) && !char.IsDigit(typedCharacter))
                            {
                                // Ignore if this is not the first character
                                return(pos <= 1 || (pos > 1 && !RTokenizer.IsIdentifierCharacter(snapshot[pos - 2])));
                            }
                        }
                    }
                    break;
                }
            }
            return(false);
        }