public void InitializeCodeCompletion(char ch) { int caretOffset = Document.Editor.Caret.Offset; int start = caretOffset - Tracker.Engine.CurrentStateLength; if (Document.Editor.GetCharAt(start) == '=') { start++; } string sourceText = Document.Editor.GetTextBetween(start, caretOffset); if (ch != '\0') { sourceText += ch; } string textAfterCaret = Document.Editor.GetTextBetween(caretOffset, Math.Min(Document.Editor.Length, Math.Max(caretOffset, Tracker.Engine.Position + Tracker.Engine.CurrentStateLength - 2))); var loc = new MonoDevelop.AspNet.Parser.Internal.Location(); var docLoc = Document.Editor.Document.OffsetToLocation(start); loc.EndLine = loc.BeginLine = docLoc.Line; loc.EndColumn = loc.BeginColumn = docLoc.Column; if (documentBuilder == null) { localDocumentInfo = null; return; } localDocumentInfo = documentBuilder.BuildLocalDocument(documentInfo, Editor, sourceText, textAfterCaret, true); var viewContent = new MonoDevelop.Ide.Gui.HiddenTextEditorViewContent(); viewContent.Project = Document.Project; viewContent.ContentName = localDocumentInfo.ParsedLocalDocument.FileName; viewContent.Text = localDocumentInfo.LocalDocument; viewContent.GetTextEditorData().Caret.Offset = localDocumentInfo.CaretPosition; var workbenchWindow = new MonoDevelop.Ide.Gui.HiddenWorkbenchWindow(); workbenchWindow.ViewContent = viewContent; localDocumentInfo.HiddenDocument = new MonoDevelop.Ide.Gui.Document(workbenchWindow) { ParsedDocument = localDocumentInfo.ParsedLocalDocument, Dom = domWrapper }; }
public void InitializeCodeCompletion() { int caretOffset = Document.TextEditorData.Caret.Offset; int start = caretOffset - Tracker.Engine.CurrentStateLength; if (Document.TextEditor.GetCharAt(start) == '=') { start++; } string sourceText = Document.TextEditor.GetText(start, caretOffset); string textAfterCaret = Document.TextEditor.GetText(caretOffset, Tracker.Engine.Position + Tracker.Engine.CurrentStateLength - start); var loc = new MonoDevelop.AspNet.Parser.Internal.Location(); var docLoc = Document.TextEditorData.Document.OffsetToLocation(start); loc.EndLine = loc.BeginLine = docLoc.Line; loc.EndColumn = loc.BeginColumn = docLoc.Column; localDocumentInfo = documentBuilder.BuildLocalDocument(documentInfo, TextEditorData, sourceText, textAfterCaret, true); var viewContent = new MonoDevelop.Ide.Gui.HiddenTextEditorViewContent(); viewContent.Project = Document.Project; viewContent.ContentName = localDocumentInfo.ParsedLocalDocument.FileName; viewContent.Text = localDocumentInfo.LocalDocument; viewContent.GetTextEditorData().Caret.Offset = localDocumentInfo.CaretPosition; var workbenchWindow = new MonoDevelop.Ide.Gui.HiddenWorkbenchWindow(); workbenchWindow.ViewContent = viewContent; hiddenDocument = new MonoDevelop.Ide.Gui.Document(workbenchWindow); hiddenDocument.ParsedDocument = localDocumentInfo.ParsedLocalDocument; }