Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more highlightings #136

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed 2 broken tests.
Removed FSharpParameter processing due to unexpected behaviour
  • Loading branch information
En3Tho committed Jun 13, 2020
commit 7770ae09c6a2fb59e849c96e86085a831a5916b7
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static string GetEntityHighlightingAttributeId([NotNull] this FSharpEntit
return FSharpHighlightingAttributeIdsModule.Record;

if (entity.IsMeasure)
return FSharpHighlightingAttributeIdsModule.Measure;
return FSharpHighlightingAttributeIdsModule.UnitOfMeasure;

return entity.IsInterface
? FSharpHighlightingAttributeIdsModule.Interface
Expand Down Expand Up @@ -72,13 +72,10 @@ public static string GetMfvHighlightingAttributeId([NotNull] this FSharpMemberOr
if (IsMangledOpName(mfv.LogicalName))
return FSharpHighlightingAttributeIdsModule.Operator;

if (mfv.IsValCompiledAsMethod)
return FSharpHighlightingAttributeIdsModule.Method;

if (mfv.FullType.IsFunctionType)
return mfv.IsMutable
? FSharpHighlightingAttributeIdsModule.MutableValueFunction
: FSharpHighlightingAttributeIdsModule.ValueFunction;
? FSharpHighlightingAttributeIdsModule.MutableFunction
: FSharpHighlightingAttributeIdsModule.Function;

if (mfv.IsMutable || mfv.IsRefCell())
return FSharpHighlightingAttributeIdsModule.MutableValue;
Expand All @@ -98,13 +95,6 @@ public static string GetHighlightingAttributeId([NotNull] this FSharpSymbol symb
case FSharpEntity entity when !entity.IsUnresolved:
return GetEntityHighlightingAttributeId(entity);

case FSharpParameter parameter: // FSharpParameter is a static member in a generic constraint, not a method parameter
if (parameter.FullName.Equals("new"))
return FSharpHighlightingAttributeIdsModule.Keyword;
return parameter.Type.GenericArguments.Count == 2 && parameter.Type.GenericArguments[0].IsUnit
? FSharpHighlightingAttributeIdsModule.Property
: FSharpHighlightingAttributeIdsModule.Method;

case FSharpMemberOrFunctionOrValue mfv when !mfv.IsUnresolved:
return GetMfvHighlightingAttributeId(mfv.AccessorProperty?.Value ?? mfv);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ module FSharpHighlightingAttributeIds =

let [<Literal>] Value = "ReSharper F# Value Identifier"
let [<Literal>] MutableValue = "ReSharper F# Mutable Value Identifier"
let [<Literal>] ValueFunction = "ReSharper F# Value Function Identifier" // todo: tests
let [<Literal>] MutableValueFunction = "ReSharper F# Mutable Value Function Identifier" // todo: tests
let [<Literal>] Function = "ReSharper F# Function Identifier" // todo: tests
let [<Literal>] MutableFunction = "ReSharper F# Mutable Function Identifier" // todo: tests

let [<Literal>] Parameter = "ReSharper F# Parameter Identifier" // todo: add setting
let [<Literal>] Literal = "ReSharper F# Literal Identifier"
Expand All @@ -65,7 +65,7 @@ module FSharpHighlightingAttributeIds =
let [<Literal>] ExtensionProperty = "ReSharper F# Extension Property Identifier" // todo: tests

let [<Literal>] ComputationExpression = "ReSharper F# Computation Expression Identifier" // todo: tests
let [<Literal>] Measure = "ReSharper F# Measure Identifier" // todo: tests
let [<Literal>] UnitOfMeasure = "ReSharper F# Unit Of Measure Identifier" // todo: tests

type FSharpSettingsNamesProvider() =
inherit PrefixBasedSettingsNamesProvider("ReSharper F#", "FSHARP")
Expand Down Expand Up @@ -102,22 +102,6 @@ type FSharpSettingsNamesProvider() =
RiderPresentableName = "Syntax//Number",
Layer = HighlighterLayer.SYNTAX,
EffectType = EffectType.TEXT, ForegroundColor = "#000000", DarkForegroundColor = "#B5CEA8");

RegisterHighlighter(
FSharpHighlightingAttributeIds.Measure,
FallbackAttributeId = FSharpHighlightingAttributeIds.TypeParameter,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Syntax//Measure",
Layer = HighlighterLayer.SYNTAX,
EffectType = EffectType.TEXT, ForegroundColor = "DarkBlue", DarkForegroundColor = "LightBlue");

RegisterHighlighter(
FSharpHighlightingAttributeIds.ComputationExpression,
FallbackAttributeId = FSharpHighlightingAttributeIds.Keyword,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Syntax//Computation expression",
Layer = HighlighterLayer.SYNTAX,
EffectType = EffectType.TEXT, ForegroundColor = "#0000E0", DarkForegroundColor = "#569CD6");

RegisterHighlighter(
FSharpHighlightingAttributeIds.LineComment,
Expand Down Expand Up @@ -249,6 +233,14 @@ type FSharpSettingsNamesProvider() =
VSPriority = VSPriority.IDENTIFIERS,
EffectType = EffectType.TEXT, ForegroundColor = "DarkBlue", DarkForegroundColor = "LightBlue");

RegisterHighlighter(
FSharpHighlightingAttributeIds.UnitOfMeasure,
FallbackAttributeId = FSharpHighlightingAttributeIds.TypeParameter,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Types//Unit of measure",
Layer = HighlighterLayer.SYNTAX,
EffectType = EffectType.TEXT, ForegroundColor = "DarkBlue", DarkForegroundColor = "LightBlue");

RegisterHighlighter(
FSharpHighlightingAttributeIds.Union,
FallbackAttributeId = FSharpHighlightingAttributeIds.Enum,
Expand Down Expand Up @@ -333,23 +325,31 @@ type FSharpSettingsNamesProvider() =
FontStyle = FontStyle.Bold);

RegisterHighlighter(
FSharpHighlightingAttributeIds.ValueFunction,
FSharpHighlightingAttributeIds.Function,
FallbackAttributeId = FSharpHighlightingAttributeIds.Method,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Values//Value function",
RiderPresentableName = "Values//Function",
Layer = HighlighterLayer.SYNTAX,
VSPriority = VSPriority.IDENTIFIERS,
EffectType = EffectType.TEXT, ForegroundColor = "DarkCyan:Maroon", DarkForegroundColor = "Cyan");

RegisterHighlighter(
FSharpHighlightingAttributeIds.MutableValueFunction,
FSharpHighlightingAttributeIds.MutableFunction,
FallbackAttributeId = FSharpHighlightingAttributeIds.MutableValue,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Values//Mutable value function",
RiderPresentableName = "Values//Mutable function",
Layer = HighlighterLayer.SYNTAX,
VSPriority = VSPriority.IDENTIFIERS,
EffectType = EffectType.TEXT, ForegroundColor = "DarkCyan:Maroon", DarkForegroundColor = "Cyan");

RegisterHighlighter(
FSharpHighlightingAttributeIds.ComputationExpression,
FallbackAttributeId = FSharpHighlightingAttributeIds.Keyword,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Values//Computation expression",
Layer = HighlighterLayer.SYNTAX,
EffectType = EffectType.TEXT, ForegroundColor = "#0000E0", DarkForegroundColor = "#569CD6");

RegisterHighlighter(
FSharpHighlightingAttributeIds.Method,
FallbackAttributeId = DefaultLanguageAttributeIds.METHOD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let |hello|(1) (|name|(2): |byref|(3)<|string|(4)>) (|other|(5): |inref|(6)<|int

---------------------------------------------------------
(0): ReSharper F# Module Identifier:
(1): ReSharper F# Value Identifier:
(1): ReSharper F# Function Identifier:
(2): ReSharper F# Mutable Value Identifier:
(3): ReSharper F# Class Identifier:
(4): ReSharper F# Class Identifier:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ let _ =

---------------------------------------------------------
(0): ReSharper F# Module Identifier:
(1): ReSharper F# Keyword:
(1): ReSharper F# Computation Expression Identifier: