@@ -61,15 +61,14 @@ public class CSharpTextEditorExtension : ITextEditorExtension
6161 IssueManager inspectionManager ;
6262 IList < IContextActionProvider > contextActionProviders ;
6363 CodeManipulation codeManipulation ;
64- CSharpSemanticHighlighter highlighter ;
65- CancellationTokenSource caretMovementTokenSource ;
64+ CaretReferenceHighlightRenderer renderer ;
6665
6766 public void Attach ( ITextEditor editor )
6867 {
6968 this . editor = editor ;
7069 inspectionManager = new IssueManager ( editor ) ;
7170 codeManipulation = new CodeManipulation ( editor ) ;
72- this . editor . Caret . LocationChanged += CaretLocationChanged ;
71+ renderer = new CaretReferenceHighlightRenderer ( editor ) ;
7372
7473 if ( ! editor . ContextActionProviders . IsReadOnly ) {
7574 contextActionProviders = AddInTree . BuildItems < IContextActionProvider > ( "/SharpDevelop/ViewContent/TextEditor/C#/ContextActions" , null ) ;
@@ -87,21 +86,8 @@ public void Detach()
8786 if ( contextActionProviders != null ) {
8887 editor . ContextActionProviders . RemoveAll ( contextActionProviders . Contains ) ;
8988 }
90- this . editor . Caret . LocationChanged -= CaretLocationChanged ;
89+ renderer . Dispose ( ) ;
9190 this . editor = null ;
9291 }
93-
94- void CaretLocationChanged ( object sender , EventArgs e )
95- {
96- if ( highlighter == null )
97- highlighter = editor . GetService < CSharpSemanticHighlighter > ( ) ;
98- if ( highlighter == null )
99- return ;
100- if ( caretMovementTokenSource != null )
101- caretMovementTokenSource . Cancel ( ) ;
102- caretMovementTokenSource = new CancellationTokenSource ( ) ;
103- var rr = SD . ParserService . Resolve ( editor . FileName , editor . Caret . Location , editor . Document , cancellationToken : caretMovementTokenSource . Token ) ;
104- highlighter . SetCurrentSymbol ( rr . GetSymbol ( ) ) ;
105- }
10692 }
10793}
0 commit comments