forked from microsoft/azure-tools-for-java
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #742 from JetBrains/develop.ra/trigger-description
Azure Functions: Inlay Hints with Timer Trigger Cron description
- Loading branch information
Showing
6 changed files
with
146 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...Azure/Azure.Daemon/FunctionApp/InlayHints/TimerTriggerCronExpressionAdornmentDataModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2018-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using JetBrains.Application.UI.Controls.BulbMenu.Items; | ||
using JetBrains.Application.UI.Controls.Utils; | ||
using JetBrains.Application.UI.PopupLayout; | ||
using JetBrains.TextControl.DocumentMarkup.Adornments; | ||
using JetBrains.Util; | ||
|
||
namespace JetBrains.ReSharper.Azure.Daemon.FunctionApp.InlayHints; | ||
|
||
public class TimerTriggerCronExpressionAdornmentDataModel(string description) : IAdornmentDataModel | ||
{ | ||
public void ExecuteNavigation(PopupWindowContextSource popupWindowContextSource) | ||
{ | ||
MessageBox.ShowInfo($"{nameof(TimerTriggerCronExpressionAdornmentDataModel)}.{nameof(ExecuteNavigation)}", | ||
"ReSharper SDK"); | ||
} | ||
|
||
public AdornmentData Data { get; } = new AdornmentData() | ||
.WithText($"({description})") | ||
.WithFlags(AdornmentFlags.IsNavigable) | ||
.WithMode(PushToHintMode.Always); | ||
|
||
public IPresentableItem? ContextMenuTitle => null; | ||
public IEnumerable<BulbMenuItem>? ContextMenuItems => null; | ||
public TextRange? SelectionRange => null; | ||
} |
23 changes: 23 additions & 0 deletions
23
....Azure/Azure.Daemon/FunctionApp/InlayHints/TimerTriggerCronExpressionAdornmentProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2018-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the MIT license. | ||
|
||
using JetBrains.ProjectModel; | ||
using JetBrains.TextControl.DocumentMarkup; | ||
using JetBrains.TextControl.DocumentMarkup.Adornments; | ||
|
||
namespace JetBrains.ReSharper.Azure.Daemon.FunctionApp.InlayHints; | ||
|
||
[SolutionComponent] | ||
public class TimerTriggerCronExpressionAdornmentProvider : IHighlighterAdornmentProvider | ||
{ | ||
public bool IsValid(IHighlighter highlighter) | ||
{ | ||
return highlighter.UserData is TimerTriggerCronExpressionHint; | ||
} | ||
|
||
public IAdornmentDataModel? CreateDataModel(IHighlighter highlighter) | ||
{ | ||
return highlighter.UserData is TimerTriggerCronExpressionHint hint | ||
? new TimerTriggerCronExpressionAdornmentDataModel(hint.ToolTip) | ||
: null; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...net/ReSharper.Azure/Azure.Daemon/FunctionApp/InlayHints/TimerTriggerCronExpressionHint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2018-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the MIT license. | ||
|
||
using JetBrains.DocumentModel; | ||
using JetBrains.ReSharper.Daemon; | ||
using JetBrains.ReSharper.Feature.Services.Daemon; | ||
using JetBrains.ReSharper.Feature.Services.InlayHints; | ||
using JetBrains.ReSharper.Psi.Tree; | ||
using JetBrains.TextControl.DocumentMarkup; | ||
using JetBrains.TextControl.DocumentMarkup.VisualStudio; | ||
using JetBrains.UI.RichText; | ||
|
||
namespace JetBrains.ReSharper.Azure.Daemon.FunctionApp.InlayHints; | ||
|
||
[RegisterHighlighter( | ||
HighlightAttributeId, | ||
ForegroundColor = "#707070", | ||
BackgroundColor = "#EBEBEB", | ||
DarkForegroundColor = "#787878", | ||
DarkBackgroundColor = "#3B3B3C", | ||
EffectType = EffectType.INTRA_TEXT_ADORNMENT, | ||
Layer = HighlighterLayer.ADDITIONAL_SYNTAX, | ||
VsGenerateClassificationDefinition = VsGenerateDefinition.VisibleClassification, | ||
VsBaseClassificationType = VsPredefinedClassificationType.Text, | ||
TransmitUpdates = true)] | ||
[DaemonAdornmentProvider(typeof(TimerTriggerCronExpressionAdornmentProvider))] | ||
[DaemonTooltipProvider(typeof(InlayHintTooltipProvider))] | ||
[StaticSeverityHighlighting(Severity.INFO, typeof(HighlightingGroupIds.CodeInsights), AttributeId = HighlightAttributeId)] | ||
public class TimerTriggerCronExpressionHint(string description, ITreeNode node, DocumentOffset offset) | ||
: IInlayHintWithDescriptionHighlighting | ||
{ | ||
private const string HighlightAttributeId = nameof(TimerTriggerCronExpressionHint); | ||
|
||
public RichText Description => description; | ||
|
||
public string ToolTip => description; | ||
|
||
public string ErrorStripeToolTip => description; | ||
|
||
public bool IsValid() => node.IsValid(); | ||
|
||
public DocumentRange CalculateRange() => new(offset); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters