Exemplo n.º 1
0
		/// <summary>
		/// Generates the completion data.
		/// </summary>
		/// <param name="alreadyCheckedCompletionContext">Set to <c>false</c> if you already ensured that completion can occur in the current editing context.</param>
		public static bool GenerateCompletionData(IEditorData editor, 
			ICompletionDataGenerator completionDataGen, char triggerChar, bool alreadyCheckedCompletionContext = false)
		{
			if(!alreadyCheckedCompletionContext && !IsCompletionAllowed(editor, triggerChar))
				return false;

			IBlockNode _b = null;
			bool inNonCode;

			var sr = FindCurrentCaretContext(editor, ref _b, out inNonCode);

			if (inNonCode)
				return false;

			if (_b == null || editor.CaretLocation > _b.EndLocation) {
				_b = editor.SyntaxTree;
			}

			var complVis = new CompletionProviderVisitor (completionDataGen, editor, triggerChar) { scopedBlock = _b };
			if (sr is INode)
				(sr as INode).Accept (complVis);
			else if (sr is IStatement)
				(sr as IStatement).Accept (complVis);
			else if (sr is IExpression)
				(sr as IExpression).Accept (complVis);

			if (complVis.GeneratedProvider == null)
				return false;

			complVis.GeneratedProvider.BuildCompletionData(editor, triggerChar);

			return true;
		}
Exemplo n.º 2
0
        /// <summary>
        /// Generates the completion data.
        /// </summary>
        /// <param name="alreadyCheckedCompletionContext">Set to <c>false</c> if you already ensured that completion can occur in the current editing context.</param>
        public static bool GenerateCompletionData(IEditorData editor,
                                                  ICompletionDataGenerator completionDataGen, char triggerChar, bool alreadyCheckedCompletionContext = false)
        {
            if (!alreadyCheckedCompletionContext && !IsCompletionAllowed(editor, triggerChar))
            {
                return(false);
            }

            IBlockNode _b = null;
            IStatement _s;
            bool       inNonCode;

            var sr = FindCurrentCaretContext(editor, ref _b, out _s, out inNonCode);

            if (inNonCode)
            {
                return(false);
            }

            if (editor.CaretLocation > _b.EndLocation)
            {
                _b = editor.SyntaxTree;
                _s = null;
            }

            var complVis = new CompletionProviderVisitor(completionDataGen, triggerChar)
            {
                scopedBlock = _b, scopedStatement = _s
            };

            if (sr is INode)
            {
                (sr as INode).Accept(complVis);
            }
            else if (sr is IStatement)
            {
                (sr as IStatement).Accept(complVis);
            }
            else if (sr is IExpression)
            {
                (sr as IExpression).Accept(complVis);
            }

            if (complVis.GeneratedProvider == null)
            {
                return(false);
            }

            complVis.GeneratedProvider.BuildCompletionData(editor, triggerChar);

            return(true);
        }