public ReparsedPostfixExecutionContext([NotNull] Lifetime lifetime,
                                    [NotNull] CodeCompletionContext context,
                                    [NotNull] ReparsedCodeCompletionContext reparsedContext,
                                    [NotNull] string reparseString)
     : base(lifetime, context.Solution, context.TextControl,
      context.LookupItemsOwner, reparseString,
      context.CodeCompletionType == CodeCompletionType.AutomaticCompletion)
 {
     myReparsedContext = reparsedContext;
 }
        public PostfixTemplateAcceptanceContext([NotNull] ITreeNode reference,
      [NotNull] ICSharpExpression expression, DocumentRange replaceRange,
      bool forceMode, [NotNull] PostfixExecutionContext context)
        {
            myReparsedContext = context.ReparsedContext;
              myMostInnerExpression = expression;
              PostfixReferenceNode = reference;
              ForceMode = forceMode;
              PsiModule = context.PsiModule;
              LookupItemsOwner = context.LookupItemsOwner;
              MostInnerReplaceRange = replaceRange;

              if (!replaceRange.IsValid())
              {
            var referenceExpression = reference as IReferenceExpression;
            if (referenceExpression != null)
            {
              MostInnerReplaceRange =
            ToDocumentRange(referenceExpression.QualifierExpression.NotNull()).SetEndTo(
              ToDocumentRange(referenceExpression.Delimiter.NotNull()).TextRange.EndOffset);
            }

            var referenceName = reference as IReferenceName;
            if (referenceName != null)
            {
              MostInnerReplaceRange =
            ToDocumentRange(referenceName.Qualifier).SetEndTo(
              ToDocumentRange(referenceName.Delimiter).TextRange.EndOffset);
            }
              }

              // build expression contexts
              var expressionContexts = new List<PrefixExpressionContext>();
              var endOffset = Math.Max(
            MostInnerReplaceRange.TextRange.EndOffset,
            ToDocumentRange(reference).TextRange.EndOffset);

              for (ITreeNode node = expression; node != null; node = node.Parent)
              {
            if (node is ICSharpStatement) break;

            var expr = node as ICSharpExpression;
            if (expr == null || expr == reference) continue;

            var exprRange = myReparsedContext.ToDocumentRange(expr);
            if (!exprRange.IsValid())
              break; // stop when out of generated
            if (exprRange.TextRange.EndOffset > endOffset)
              break; // stop when 'a.var + b'

            // skip relational expressions like this: 'List<int.{here}>'
            if (CommonUtils.IsRelationalExpressionWithTypeOperand(expr)) continue;

            var expressionContext = new PrefixExpressionContext(this, expr);
            if (expressionContext.ReferencedElement is ITypeElement)
            {
              // skip types that are parts of 'List<T.>'-like expressions
              if (!CommonUtils.CanTypeBecameExpression(expression)) continue;
            }

            expressionContexts.Add(expressionContext);
            if (expressionContext.CanBeStatement) break;
              }

              Expressions = (expressionContexts.Count == 0)
            ? EmptyList<PrefixExpressionContext>.InstanceList
            : expressionContexts.AsReadOnly();
        }
        private static TextRange GetTextRange(ITreeNode node, ReparsedCodeCompletionContext context = null)
        {
            if (context == null)
            return node.GetDocumentRange().TextRange;

              return context.ToDocumentRange(node.GetTreeTextRange());
        }