public Task<ICompletionDataList> HandleCompletion (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context,	CodeCompletionContext completionContext,
			UnderlyingDocumentInfo docInfo, char currentChar, CancellationToken token)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc);
			return completion.HandleCodeCompletionAsync (completionContext, currentChar, token);
		}
		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 CreateCompletionAndUpdate (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo,
			out CodeCompletionContext codeCompletionContext)
		{
			var completion = CreateCompletion (editor, context, docInfo, out codeCompletionContext);
			completion.UpdateParsedDocument ();
			return completion;
		}
Beispiel #4
0
        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
            };

            // completion window needs this
            hiddenInfo.UnderlyingDocument.Editor.Parent = Editor.Parent;

            currentMappings = razorDocument.PageInfo.GeneratorResults.DesignTimeLineMappings;
            codeFragment    = null;
        }
		CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (Document realDocument, UnderlyingDocumentInfo docInfo,
			out CodeCompletionContext codeCompletionContext)
		{
			var completion = CreateCompletion (realDocument, docInfo, out codeCompletionContext);
			completion.UpdateParsedDocument ();
			return completion;
		}
		CSharpCompletionTextEditorExtension CreateCompletion (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, 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 (editor, context, docInfo)
			};
		}
		public Task<ICompletionDataList> HandlePopupCompletion (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc);
			return completion.CodeCompletionCommand (ccc);
		}
		public ICompletionWidget CreateCompletionWidget (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context,	UnderlyingDocumentInfo docInfo)
		{
			return new RazorCompletionWidget (editor, context, docInfo);
		}
		public RazorCompletionWidget (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo)
		{
			this.realEditor = editor;
			this.realDocumentContext = context;
			this.docInfo = docInfo;
		}
		public RazorCompletionWidget (Document realDocument, UnderlyingDocumentInfo docInfo)
		{
			this.realDocument = realDocument;
			this.docInfo = docInfo;
		}
		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 ParameterDataProvider 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 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 Task<ParameterHintingResult> HandleParameterCompletion (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context,	CodeCompletionContext completionContext,
			UnderlyingDocumentInfo docInfo, char completionChar)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc);
			return completion.HandleParameterCompletionAsync (completionContext, completionChar);
		}
//		public bool GetParameterCompletionCommandOffset (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context,	UnderlyingDocumentInfo docInfo, out int cpos)
//		{
//			CodeCompletionContext ccc;
//			var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc);
//			return completion.GetParameterCompletionCommandOffset (out cpos);
//		}

		public int GetCurrentParameterIndex (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo, int startOffset)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc);
			return completion.GetCurrentParameterIndex (startOffset);
		}
		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
			};

			// completion window needs this
			hiddenInfo.UnderlyingDocument.Editor.Parent = Editor.Parent;

			currentMappings = razorDocument.PageInfo.GeneratorResults.DesignTimeLineMappings;
			codeFragment = null;
		}
		public int GetCurrentParameterIndex (Document realDocument, UnderlyingDocumentInfo docInfo, int startOffset)
		{
			CodeCompletionContext ccc;
			var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc);
			return completion.GetCurrentParameterIndex (startOffset);
		}