Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
DedSec256 committed Nov 13, 2024
1 parent 7a38cc7 commit c0c0ad2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@ open JetBrains.Application.UI.Components
open JetBrains.Application.UI.PopupLayout
open JetBrains.Application.UI.Tooltips
open JetBrains.RdBackend.Common.Features.Services
open JetBrains.ReSharper.Feature.Services.Daemon
open JetBrains.ReSharper.Plugins.FSharp.Psi.Daemon.Resources
open JetBrains.ReSharper.Resources.Shell
open JetBrains.TextControl.DocumentMarkup

let copyToClipboard text (highlighting: IHighlighting) highlighterKey =
let copyToClipboard text (highlighter: IHighlighter) =
let shell = Shell.Instance
shell.GetComponent<Clipboard>().SetText(text)
let documentMarkupManager = shell.GetComponent<IDocumentMarkupManager>();
shell.GetComponent<ITooltipManager>().Show(Strings.InferredTypeCodeVisionProvider_TypeCopied_TooltipText, PopupWindowContextSource(fun _ ->
let documentMarkup = documentMarkupManager.TryGetMarkupModel(highlighting.CalculateRange().Document)
if isNull documentMarkup then null else

documentMarkup.GetFilteredHighlighters(highlighterKey, fun h -> highlighting.Equals(h.GetHighlighting()))
|> Seq.tryHead
|> Option.map RiderEditorOffsetPopupWindowContext
|> Option.defaultValue null :> _
if highlighter.IsValid then RiderEditorOffsetPopupWindowContext highlighter
else null
))
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ type TypeHintHighlighting(typeNameString: string, range: DocumentRange, pushToHi
and [<SolutionComponent(Instantiation.DemandAnyThreadSafe)>]
TypeHintAdornmentProvider(settingsStore: ISettingsStore) =

let createCopyToClipboardBulbItem (highlighting: TypeHintHighlighting) highlighterKey =
let createCopyToClipboardBulbItem (highlighting: TypeHintHighlighting) highlighter =
let text = highlighting.TypeText
BulbMenuItem(ExecutableItem(fun () -> copyToClipboard text highlighting highlighterKey),
BulbMenuItem(ExecutableItem(fun () -> copyToClipboard text highlighter),
Strings.FSharpInferredTypeHighlighting_TooltipText, null, BulbMenuAnchors.FirstClassContextItems)

interface IHighlighterAdornmentProvider with
Expand All @@ -71,7 +71,7 @@ and [<SolutionComponent(Instantiation.DemandAnyThreadSafe)>]
override x.ContextMenuTitle = null
override x.ContextMenuItems =
[|
yield createCopyToClipboardBulbItem thh highlighter.Key
yield createCopyToClipboardBulbItem thh highlighter

if isNotNull actionsProvider then
yield! actionsProvider.CreateChangeVisibilityBulbMenuItems(settingsStore, thh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type InferredTypeCodeVisionProvider() =
let entry = codeInsightsHighlighting.Entry.As<TextCodeVisionEntry>()
if isNull entry then () else

copyToClipboard entry.Text codeInsightsHighlighting highlighting.Highlighter.Key
copyToClipboard entry.Text highlighting.Highlighter

member x.OnExtraActionClick(_, _, _) = ()

Expand Down

0 comments on commit c0c0ad2

Please sign in to comment.