public ICompletionDataList HandleCompletion (Document realDocument,	CodeCompletionContext completionContext,
			UnderlyingDocumentInfo docInfo, char currentChar, ref int triggerWordLength)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc);
			return completion.HandleCodeCompletion (completionContext, currentChar, ref triggerWordLength);
		}
        public int GetCurrentParameterIndex(Document realDocument, UnderlyingDocumentInfo docInfo, int startOffset)
        {
            CodeCompletionContext ccc;
            var completion = CreateCompletionAndUpdate(realDocument, docInfo, out ccc);

            return(completion.GetCurrentParameterIndex(startOffset));
        }
        public ICompletionDataList HandlePopupCompletion(Document realDocument, UnderlyingDocumentInfo docInfo)
        {
            CodeCompletionContext ccc;
            var completion = CreateCompletionAndUpdate(realDocument, docInfo, out ccc);

            return(completion.CodeCompletionCommand(ccc));
        }
		CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (Document realDocument, UnderlyingDocumentInfo docInfo,
			out CodeCompletionContext codeCompletionContext)
		{
			var completion = CreateCompletion (realDocument, docInfo, out codeCompletionContext);
			completion.UpdateParsedDocument ();
			return completion;
		}
        public bool GetParameterCompletionCommandOffset(Document realDocument, UnderlyingDocumentInfo docInfo, out int cpos)
        {
            CodeCompletionContext ccc;
            var completion = CreateCompletionAndUpdate(realDocument, docInfo, out ccc);

            return(completion.GetParameterCompletionCommandOffset(out cpos));
        }
        public IParameterDataProvider HandleParameterCompletion(Document realDocument, CodeCompletionContext completionContext,
                                                                UnderlyingDocumentInfo docInfo, char completionChar)
        {
            CodeCompletionContext ccc;
            var completion = CreateCompletionAndUpdate(realDocument, docInfo, out ccc);

            return(completion.HandleParameterCompletion(completionContext, completionChar));
        }
        public ICompletionDataList HandleCompletion(Document realDocument, CodeCompletionContext completionContext,
                                                    UnderlyingDocumentInfo docInfo, char currentChar, ref int triggerWordLength)
        {
            CodeCompletionContext ccc;
            var completion = CreateCompletionAndUpdate(realDocument, docInfo, out ccc);

            return(completion.HandleCodeCompletion(completionContext, currentChar, ref triggerWordLength));
        }
		CSharpCompletionTextEditorExtension CreateCompletion (Document realDocument, UnderlyingDocumentInfo docInfo,
			out CodeCompletionContext codeCompletionContext)
		{
			var documentLocation = docInfo.UnderlyingDocument.Editor.OffsetToLocation (docInfo.CaretPosition);

			codeCompletionContext = new CodeCompletionContext () {
				TriggerOffset = docInfo.CaretPosition,
				TriggerLine = documentLocation.Line,
				TriggerLineOffset = documentLocation.Column - 1
			};

			return new CSharpCompletionTextEditorExtension (docInfo.UnderlyingDocument) {
				CompletionWidget = CreateCompletionWidget (realDocument, docInfo)
			};
		}
        CSharpCompletionTextEditorExtension CreateCompletion(Document realDocument, UnderlyingDocumentInfo docInfo,
                                                             out CodeCompletionContext codeCompletionContext)
        {
            var documentLocation = docInfo.UnderlyingDocument.Editor.OffsetToLocation(docInfo.CaretPosition);

            codeCompletionContext = new CodeCompletionContext()
            {
                TriggerOffset     = docInfo.CaretPosition,
                TriggerLine       = documentLocation.Line,
                TriggerLineOffset = documentLocation.Column - 1
            };

            return(new CSharpCompletionTextEditorExtension(docInfo.UnderlyingDocument)
            {
                CompletionWidget = CreateCompletionWidget(realDocument, docInfo)
            });
        }
		public ICompletionDataList HandlePopupCompletion (Document realDocument, UnderlyingDocumentInfo docInfo)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc);
			return completion.CodeCompletionCommand (ccc);
		}
		public ICompletionWidget CreateCompletionWidget (Document realDocument,	UnderlyingDocumentInfo docInfo)
		{
			return new RazorCompletionWidget (realDocument, docInfo);
		}
 public RazorCompletionWidget(Document realDocument, UnderlyingDocumentInfo docInfo)
 {
     this.realDocument = realDocument;
     this.docInfo      = docInfo;
 }
		public RazorCompletionWidget (Document realDocument, UnderlyingDocumentInfo docInfo)
		{
			this.realDocument = realDocument;
			this.docInfo = docInfo;
		}
		public int GetCurrentParameterIndex (Document realDocument, UnderlyingDocumentInfo docInfo, int startOffset)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc);
			return completion.GetCurrentParameterIndex (startOffset);
		}
		public bool GetParameterCompletionCommandOffset (Document realDocument,	UnderlyingDocumentInfo docInfo, out int cpos)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc);
			return completion.GetParameterCompletionCommandOffset (out cpos);
		}
        CSharpCompletionTextEditorExtension CreateCompletionAndUpdate(Document realDocument, UnderlyingDocumentInfo docInfo,
                                                                      out CodeCompletionContext codeCompletionContext)
        {
            var completion = CreateCompletion(realDocument, docInfo, out codeCompletionContext);

            completion.UpdateParsedDocument();
            return(completion);
        }
 public ICompletionWidget CreateCompletionWidget(Document realDocument, UnderlyingDocumentInfo docInfo)
 {
     return(new RazorCompletionWidget(realDocument, docInfo));
 }
		public ParameterDataProvider HandleParameterCompletion (Document realDocument,	CodeCompletionContext completionContext,
			UnderlyingDocumentInfo docInfo, char completionChar)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc);
			return completion.HandleParameterCompletion (completionContext, completionChar);
		}
		void UpdateHiddenDocument (bool updateSourceCode = true)
		{
			if (!updateSourceCode && hiddenInfo != null) {
				hiddenInfo.UnderlyingDocument.HiddenParsedDocument = razorDocument.PageInfo.CSharpParsedFile;
				hiddenInfo.UnderlyingDocument.HiddenCompilation = razorDocument.PageInfo.Compilation;
				return;
			}

			hiddenInfo = new UnderlyingDocumentInfo ();

			var viewContent = new HiddenTextEditorViewContent ();
			viewContent.Project = Document.Project;
			viewContent.ContentName = "Generated.cs"; // Use a name with .cs extension to get csharp ambience
			viewContent.Text = razorDocument.PageInfo.CSharpCode;

			var workbenchWindow = new HiddenWorkbenchWindow ();
			workbenchWindow.ViewContent = viewContent;
			hiddenInfo.UnderlyingDocument = new UnderlyingDocument (workbenchWindow) {
				HiddenParsedDocument = razorDocument.PageInfo.CSharpParsedFile,
				HiddenCompilation = razorDocument.PageInfo.Compilation
			};

			currentMappings = razorDocument.PageInfo.GeneratorResults.DesignTimeLineMappings;
			codeFragment = null;
		}