Пример #1
0
        public static bool IsCompletionAllowed(IEditorData Editor, char enteredChar)
        {
            if (Editor.CaretOffset > 0)
            {
                if (Editor.CaretLocation.Line == 1 && Editor.ModuleCode.Length > 0 && Editor.ModuleCode[0] == '#')
                {
                    return(false);
                }

                if (enteredChar == '.' || enteredChar == '_')
                {
                    // Don't complete on a double/multi-dot
                    if (Editor.CaretOffset > 1 && Editor.ModuleCode[Editor.CaretOffset - 2] == enteredChar)
                    {
                        // ISSUE: When a dot was typed, off-1 is the dot position,
                        // if a letter was typed, off-1 is the char before the typed letter..
                        return(false);
                    }
                }
                // If typing a begun identifier, return immediately
                else if ((DTokens.IsIdentifierChar(enteredChar) || enteredChar == '\0') &&
                         DTokens.IsIdentifierChar(Editor.ModuleCode[Editor.CaretOffset - 1]))
                {
                    return(false);
                }

                return(!CaretContextAnalyzer.IsInCommentAreaOrString(Editor.ModuleCode, Editor.CaretOffset));
            }

            return(true);
        }
        static bool IsCompletionAllowed(IEditorData Editor, string EnteredText)
        {
            // If typing a begun identifier, return immediately
            if ((EnteredText != null &&
                 EnteredText.Length > 0 ? IsIdentifierChar(EnteredText[0]) : true) &&
                Editor.CaretOffset > 0 &&
                IsIdentifierChar(Editor.ModuleCode[Editor.CaretOffset - 1]))
            {
                return(false);
            }

            if (CaretContextAnalyzer.IsInCommentAreaOrString(Editor.ModuleCode, Editor.CaretOffset))
            {
                return(false);
            }

            return(true);
        }