private void ScopeToCompletions(HashSet <Completion> completionList, Scope scope, IAst[] stack)
        {
            var symbols = scope.MakeCompletionList("");

            foreach (var symbol in symbols.Where(s => s != null))
            {
                if (symbol.IsNameValid && !symbol.IsAbstract() && !IsSpecialSymbol(symbol))
                {
                    completionList.Add(MyCompletion.FromSymbol(symbol, stack));
                }
            }
        }
예제 #2
0
        private void SmartComplete(MyCompletion completion, int positionBefore, int positionAfter, ITextBuffer buffer)
        {
            var completionType  = completion.CompletionType;
            var newLineText     = GetNewLineText(new SnapshotPoint(_textView.TextSnapshot, positionAfter));
            var currentSnapshot = buffer.CurrentSnapshot;

            var textAfterCaret = positionAfter < currentSnapshot.Length
                                 ? currentSnapshot.GetText(positionAfter, (currentSnapshot.Length - (positionAfter + 1)))
                                 : "";

            var textBeforeCaret = currentSnapshot.GetText(0, positionBefore);

            // Need to map to PrettyPrint output without comments and other insignificant trash
            var nextSymbol = textAfterCaret.FirstOrDefault(c => c != ' ' && c != '\r' && c != '\n');
            var prevSymbol = textBeforeCaret.Reverse().FirstOrDefault(c => c != ' ');

            var line     = _textView.Caret.ContainingTextViewLine;
            var lineText = line.Extent.GetText();
            var indent   = string.Join("", lineText.TakeWhile(c => char.IsWhiteSpace(c) || c == '\t'));

            if (completionType == CompletionType.Property && prevSymbol != ':' && nextSymbol != ':')
            {
                SmartCompleteProperty(positionAfter, buffer);
            }
            else if (completionType == CompletionType.Node && nextSymbol != '{' && !completion.IsPropertyValue)
            {
                SmartCompleteNode(positionAfter, buffer, newLineText, indent);
            }
            else if (completionType == CompletionType.ContentFunctionRef && nextSymbol != '(')
            {
                //SmartCompleteContentFunctionRef(positionAfter, buffer, newLineText, indent);
            }
            else if (completionType == CompletionType.TypeFunctionRef && nextSymbol != '(')
            {
                SmartCompleteTypeFunctionRef(positionAfter, buffer, newLineText, indent);
            }
            else if (completionType == CompletionType.ContentFunctionRefWithParams && nextSymbol != '(')
            {
                SmartCompleteContentFunctionRefWithParams(positionAfter, buffer, newLineText, indent);
            }
            else if (completionType == CompletionType.TypeFunctionRefWithParams && nextSymbol != '(')
            {
                SmartCompleteTypeFunctionRefWithParams(positionAfter, buffer, newLineText, indent);
            }
        }