-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.CodeAnalysis.Editor.CSharp.SemanticSearch | ||
{ | ||
internal class SemanticSearchT | ||
{ | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.Editor; | ||
using Microsoft.CodeAnalysis.Editor.Shared.Utilities; | ||
using Microsoft.CodeAnalysis.Host; | ||
using Microsoft.CodeAnalysis.Options; | ||
using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
using Microsoft.CodeAnalysis.Text; | ||
using Microsoft.VisualStudio.Text; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.SemanticSearch; | ||
|
||
internal sealed class SemanticSearchEditorWorkspace( | ||
HostServices services, | ||
SemanticSearchProjectConfiguration config, | ||
IThreadingContext threadingContext, | ||
IAsynchronousOperationListenerProvider listenerProvider) | ||
: SemanticSearchWorkspace(services, config) | ||
{ | ||
private readonly IAsynchronousOperationListener _asyncListener = listenerProvider.GetListener(FeatureAttribute.SemanticSearch); | ||
|
||
private ITextBuffer? _queryTextBuffer; | ||
private DocumentId? _queryDocumentId; | ||
|
||
public async Task OpenQueryDocumentAsync(ITextBuffer buffer, CancellationToken cancellationToken) | ||
{ | ||
_queryTextBuffer = buffer; | ||
|
||
// initialize solution with default query, unless it has already been initialized: | ||
var queryDocument = await UpdateQueryDocumentAsync(query: null, cancellationToken).ConfigureAwait(false); | ||
|
||
_queryDocumentId = queryDocument.Id; | ||
|
||
OnDocumentOpened(queryDocument.Id, buffer.AsTextContainer()); | ||
} | ||
|
||
/// <summary> | ||
/// Used by code actions through <see cref="Workspace.TryApplyChanges(Solution)"/>. | ||
/// </summary> | ||
protected override void ApplyDocumentTextChanged(DocumentId documentId, SourceText newText) | ||
{ | ||
if (documentId == _queryDocumentId) | ||
{ | ||
ApplyQueryDocumentTextChanged(newText); | ||
} | ||
} | ||
|
||
protected override void ApplyQueryDocumentTextChanged(SourceText newText) | ||
{ | ||
Contract.ThrowIfNull(_queryTextBuffer); | ||
|
||
// update the buffer on UI thread: | ||
|
||
var completionToken = _asyncListener.BeginAsyncOperation(nameof(SemanticSearchEditorWorkspace) + "." + nameof(ApplyQueryDocumentTextChanged)); | ||
_ = UpdateTextAsync().ReportNonFatalErrorAsync().CompletesAsyncOperation(completionToken); | ||
|
||
async Task UpdateTextAsync() | ||
{ | ||
await threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(CancellationToken.None); | ||
TextEditApplication.UpdateText(newText, _queryTextBuffer, EditOptions.DefaultMinimalChange); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Composition; | ||
using Microsoft.CodeAnalysis.Editor.Shared; | ||
using Microsoft.CodeAnalysis.Host.Mef; | ||
using Microsoft.VisualStudio.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.SemanticSearch; | ||
|
||
[ExportWorkspaceService(typeof(ITextBufferSupportsFeatureService), WorkspaceKind.SemanticSearch), Shared] | ||
[method: ImportingConstructor] | ||
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
internal class SemanticSeatchTextBufferSupportsFeatureService() : ITextBufferSupportsFeatureService | ||
{ | ||
public bool SupportsCodeFixes(ITextBuffer textBuffer) | ||
=> true; | ||
|
||
public bool SupportsRefactorings(ITextBuffer textBuffer) | ||
=> true; | ||
|
||
public bool SupportsRename(ITextBuffer textBuffer) | ||
=> true; | ||
|
||
public bool SupportsNavigationToAnyPosition(ITextBuffer textBuffer) | ||
=> true; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.