Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit d4cc86d

Browse files
reimplement CaretReferencesRenderer as IBackgroundRenderer
fix #368, fix #372
1 parent 69ce7df commit d4cc86d

7 files changed

Lines changed: 465 additions & 268 deletions

File tree

src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
</ItemGroup>
6969
<ItemGroup>
7070
<Compile Include="Configuration\AssemblyInfo.cs" />
71+
<Compile Include="Src\CaretReferenceHighlightRenderer.cs">
72+
<DependentUpon>CSharpSemanticHighlighter.cs</DependentUpon>
73+
</Compile>
7174
<Compile Include="Src\CodeManipulation.cs" />
7275
<Compile Include="Src\Completion\CSharpCompletionContext.cs" />
7376
<Compile Include="Src\Completion\CSharpInsightItem.cs" />
@@ -80,6 +83,9 @@
8083
<Compile Include="Src\Completion\SegmentTrackingOutputFormatter.cs" />
8184
<Compile Include="Src\Completion\TypeCompletionData.cs" />
8285
<Compile Include="Src\Completion\XmlDocCompletionData.cs" />
86+
<Compile Include="Src\CSharpSemanticHighlighterVisitor.cs">
87+
<DependentUpon>CSharpSemanticHighlighter.cs</DependentUpon>
88+
</Compile>
8389
<Compile Include="Src\FormattingStrategy\CSharpFormatter.cs" />
8490
<Compile Include="Src\FormsDesigner\CSharpDesignerGenerator.cs" />
8591
<Compile Include="Src\FormsDesigner\CSharpDesignerLoader.cs" />

src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpLanguageBinding.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)