Example #1
0
 public LexCodeCompletionContext(CodeCompletionContext context, TextLookupRanges completionRanges, LexReparsedCompletionContext reparsedContext)
     :
     base(context)
 {
     ReparsedContext = reparsedContext;
     Ranges          = completionRanges;
 }
        public override ISpecificCodeCompletionContext GetCompletionContext(CodeCompletionContext context)
        {
            var unterminatedContext = new LexReparsedCompletionContext(context.File, context.SelectedTreeRange, "aa");

            unterminatedContext.Init();
            IReference referenceToComplete = unterminatedContext.Reference;
            ITreeNode  elementToComplete   = unterminatedContext.TreeNode;

            if (elementToComplete == null)
            {
                return(null);
            }
            TreeTextRange referenceRange = referenceToComplete != null?referenceToComplete.GetTreeTextRange() : GetElementRange(elementToComplete);

            TextRange referenceDocumentRange = unterminatedContext.ToDocumentRange(referenceRange);

            if (!referenceDocumentRange.IsValid)
            {
                return(null);
            }

            if (!referenceDocumentRange.Contains(context.CaretDocumentRange.TextRange))
            {
                return(null);
            }
            TextLookupRanges ranges = GetTextLookupRanges(context, referenceDocumentRange);

            return(new LexCodeCompletionContext(context, ranges, unterminatedContext));
        }