Changeset 12655 for stable/HeuristicLab.CodeEditor/3.4
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12646,12653-12654
- Property svn:mergeinfo changed
-
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CSharp/CSharpCodeCompletionStrategy.cs
r12009 r12655 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 26 25 using ICSharpCode.NRefactory.CSharp; 27 26 using ICSharpCode.NRefactory.CSharp.Completion; 28 using ICSharpCode.NRefactory.Editor;29 27 using ICSharpCode.NRefactory.TypeSystem; 30 28 … … 112 110 113 111 protected override void DoParseStep() { 114 var document = (IDocument)codeEditor.Invoke( 115 (Func<IDocument>)(() => { 116 var doc = codeEditor.TextEditor.Document; 117 return new ReadOnlyDocument(doc, doc.FileName); 118 }) 119 ); 120 112 if (document == null) return; 121 113 var unresolvedFile = CSharpParsingHelpers.CreateCSharpUnresolvedFile(document); 122 114 projectContent = projectContent.AddOrUpdateFiles(unresolvedFile); -
stable/HeuristicLab.CodeEditor/3.4/LanguageFeatures/CodeCompletion/CodeCompletionStrategy.cs
r12009 r12655 20 20 #endregion 21 21 22 using System; 22 23 using System.Linq; 23 using System.Threading;24 24 using System.Threading.Tasks; 25 25 using ICSharpCode.AvalonEdit.CodeCompletion; 26 using ICSharpCode.NRefactory.Editor; 27 using Timer = System.Timers.Timer; 26 28 27 29 namespace HeuristicLab.CodeEditor { 28 30 internal abstract class CodeCompletionStrategy : ICodeCompletionStrategy { 29 31 protected readonly CodeEditor codeEditor; 30 protected readonly Task backgroundParser; 32 protected readonly Timer parserTimer; 33 protected IDocument document; 31 34 32 35 protected CodeCompletionStrategy(CodeEditor codeEditor) { 33 36 this.codeEditor = codeEditor; 34 backgroundParser = new Task(DoBackgroundParsing); 37 this.codeEditor.TextEditorTextChanged += codeEditor_TextEditorTextChanged; 38 parserTimer = new Timer(1000); 39 parserTimer.Elapsed += (sender, args) => Task.Run(() => { 40 DoParseStep(); 41 if (codeEditor.IsDisposed && parserTimer.Enabled) { 42 parserTimer.Stop(); 43 parserTimer.Dispose(); 44 } 45 }); 35 46 } 36 47 … … 41 52 42 53 public virtual void Initialize() { 43 if (backgroundParser.Status == TaskStatus.Created) 44 backgroundParser.Start(); 54 parserTimer.Enabled = true; 45 55 } 46 56 … … 89 99 } 90 100 91 protected virtual void DoBackgroundParsing() { 92 while (!codeEditor.IsDisposed) { 93 DoParseStep(); 94 Thread.Sleep(1000); 95 } 101 private void codeEditor_TextEditorTextChanged(object sender, EventArgs e) { 102 var doc = codeEditor.TextEditor.Document; 103 document = new ReadOnlyDocument(doc, doc.FileName); 96 104 } 97 105 }
Note: See TracChangeset
for help on using the changeset viewer.