Skip to content

Commit 6fb5364

Browse files
authored
Daemon/Identifier Highlighting: add record struct (#1150)
1 parent 2b22162 commit 6fb5364

7 files changed

Lines changed: 29 additions & 1 deletion

File tree

ReSharper.FSharp/src/FSharp/FSharp.Common/src/Util/FSharpHighlightingAttributeIds.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,14 @@ type FSharpNonTailRecursionGutterMarkType() =
277277
Layer = HighlighterLayer.SYNTAX,
278278
EffectType = EffectType.TEXT, ForegroundColor = "DarkBlue", DarkForegroundColor = "LightBlue");
279279
280+
RegisterHighlighter(
281+
FSharpHighlightingAttributeIds.StructRecord,
282+
FallbackAttributeId = DefaultLanguageAttributeIds.STRUCT,
283+
GroupId = FSharpHighlightingAttributeIds.GroupId,
284+
RiderPresentableName = "Types//StructRecord",
285+
Layer = HighlighterLayer.SYNTAX,
286+
EffectType = EffectType.TEXT, ForegroundColor = "DarkBlue", DarkForegroundColor = "LightBlue");
287+
280288
RegisterHighlighter(
281289
FSharpHighlightingAttributeIds.Literal,
282290
FallbackAttributeId = DefaultLanguageAttributeIds.CONSTANT,

ReSharper.FSharp/src/FSharp/FSharp.Psi/src/Features/Daemon/FSharpSymbolHighlightingUtil.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public static string GetEntityHighlightingAttributeId([NotNull] this FSharpEntit
2828
return FSharpHighlightingAttributeIdsModule.Union;
2929

3030
if (entity.IsFSharpRecord)
31-
return FSharpHighlightingAttributeIdsModule.Record;
31+
return entity.IsValueType
32+
? FSharpHighlightingAttributeIdsModule.StructRecord
33+
: FSharpHighlightingAttributeIdsModule.Record;
3234

3335
if (entity.IsMeasure)
3436
return FSharpHighlightingAttributeIdsModule.UnitOfMeasure;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Record = { A: int }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type |Record|(0) = { |A|(1): |int|(2) }
2+
3+
---------------------------------------------------------
4+
(0): ReSharper F# Record Identifier:
5+
(1): ReSharper F# Field Identifier:
6+
(2): ReSharper F# Struct Identifier:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type [<Struct>] Record = { A: int }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type [<|Struct|(0)>] |Record|(1) = { |A|(2): |int|(3) }
2+
3+
---------------------------------------------------------
4+
(0): ReSharper F# Class Identifier:
5+
(1): ReSharper F# Struct Record Identifier:
6+
(2): ReSharper F# Field Identifier:
7+
(3): ReSharper F# Struct Identifier:

ReSharper.FSharp/test/src/FSharp.Intentions.Tests/src/Daemon/IdentifierHighlightingTest.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,6 @@ type IdentifierHighlightingTest() =
7777
[<Test>] member x.``Method - Application 01``() = x.DoNamedTest()
7878
[<Test>] member x.``Method - Parameters - Optional 01``() = x.DoNamedTest()
7979
[<Test>] member x.``Method - Parameters - Optional 02 - Private``() = x.DoNamedTest()
80+
81+
[<Test>] member x.``Record 01``() = x.DoNamedTest()
82+
[<Test>] member x.``Record 02 - Struct``() = x.DoNamedTest()

0 commit comments

Comments
 (0)