diff options
author | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
commit | 95408b1a41b31b645f3a8c3323ab7d3ca4bff26b (patch) | |
tree | f8f137cddcb9a40499d303be95722fd2c6081bce /main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs | |
parent | b70e4e04b4e41b8ec28d7e4b220b401ecf467e7a (diff) | |
parent | de043d330a8bf5855d4d983c804cd36727cb2406 (diff) |
Merge remote-tracking branch 'origin/roslyn' into new-project-model
Diffstat (limited to 'main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs')
-rw-r--r-- | main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs index 260518ee9d..1479522a06 100644 --- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs +++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs @@ -32,6 +32,10 @@ using MonoDevelop.DesignerSupport; using MonoDevelop.TextTemplating.Parser; using MonoDevelop.Ide; using ICSharpCode.NRefactory.TypeSystem; +using MonoDevelop.Ide.Editor.Extension; +using MonoDevelop.Ide.Editor; +using System.Threading.Tasks; +using System.Threading; namespace MonoDevelop.TextTemplating.Gui { @@ -44,16 +48,16 @@ namespace MonoDevelop.TextTemplating.Gui { } - public override void Initialize () + protected override void Initialize () { base.Initialize (); - Document.DocumentParsed += HandleDocumentDocumentParsed; + DocumentContext.DocumentParsed += HandleDocumentDocumentParsed; HandleDocumentDocumentParsed (this, EventArgs.Empty); } void HandleDocumentDocumentParsed (object sender, EventArgs e) { - parsedDoc = (T4ParsedDocument)Document.ParsedDocument; + parsedDoc = (T4ParsedDocument)DocumentContext.ParsedDocument; if (parsedDoc != null) RefreshOutline (); } @@ -71,30 +75,21 @@ namespace MonoDevelop.TextTemplating.Gui protected T4ParsedDocument ParsedDoc { get { return parsedDoc; } } - - protected ITextBuffer Buffer { - get { - if (Document == null) - throw new InvalidOperationException ("Editor extension not yet initialized"); - return Document.GetContent<ITextBuffer> (); - } - } - - protected IEditableTextBuffer EditableBuffer { + + protected TextEditor EditableBuffer { get { - if (Document == null) + if (DocumentContext == null) throw new InvalidOperationException ("Editor extension not yet initialized"); - return Document.GetContent<IEditableTextBuffer> (); + return DocumentContext.GetContent<TextEditor> (); } } protected string GetBufferText (DomRegion region) { - MonoDevelop.Ide.Gui.Content.ITextBuffer buf = Buffer; - int start = buf.GetPositionFromLineColumn (region.BeginLine, region.BeginColumn); - int end = buf.GetPositionFromLineColumn (region.EndLine, region.EndColumn); + int start = Editor.LocationToOffset (region.BeginLine, region.BeginColumn); + int end = Editor.LocationToOffset (region.EndLine, region.EndColumn); if (end > start && start >= 0) - return buf.GetText (start, end); + return Editor.GetTextBetween (start, end); else return null; } @@ -108,23 +103,20 @@ namespace MonoDevelop.TextTemplating.Gui int pos = completionContext.TriggerOffset; if (pos <= 0) return null; - int triggerWordLength = 0; - return HandleCodeCompletion ((CodeCompletionContext) completionContext, true, ref triggerWordLength); + return HandleCodeCompletion ((CodeCompletionContext) completionContext, true); } - public override ICompletionDataList HandleCodeCompletion ( - CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength) + public override Task<ICompletionDataList> HandleCodeCompletionAsync (CodeCompletionContext completionContext, char completionChar, CancellationToken token = default(CancellationToken)) { int pos = completionContext.TriggerOffset; if (pos > 0 && Editor.GetCharAt (pos - 1) == completionChar) { - return HandleCodeCompletion ((CodeCompletionContext) completionContext, - false, ref triggerWordLength); + return Task.FromResult (HandleCodeCompletion ((CodeCompletionContext) completionContext, false)); } return null; } protected virtual ICompletionDataList HandleCodeCompletion ( - CodeCompletionContext completionContext, bool forced, ref int triggerWordLength) + CodeCompletionContext completionContext, bool forced) { //IEditableTextBuffer buf = this.EditableBuffer; return null; @@ -272,9 +264,9 @@ namespace MonoDevelop.TextTemplating.Gui void SelectSegment (Mono.TextTemplating.ISegment seg) { - int s = Editor.Document.LocationToOffset (seg.TagStartLocation.Line, seg.TagStartLocation.Column); + int s = Editor.LocationToOffset (seg.TagStartLocation.Line, seg.TagStartLocation.Column); if (s > -1) { - Editor.Caret.Offset = s; + Editor.CaretOffset = s; Editor.CenterTo (s); } } |