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
Next Next commit
Added more highlightings
  • Loading branch information
En3Tho committed Jun 9, 2020
commit 34ba41eb2f50785b34a25bb484bfcd0464e4cbb3
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public static string GetEntityHighlightingAttributeId([NotNull] this FSharpEntit
if (entity.IsFSharpRecord)
return FSharpHighlightingAttributeIdsModule.Record;

if (entity.IsMeasure)
return FSharpHighlightingAttributeIdsModule.Measure;

return entity.IsInterface
? FSharpHighlightingAttributeIdsModule.Interface
: FSharpHighlightingAttributeIdsModule.Class;
Expand All @@ -51,22 +54,35 @@ public static string GetMfvHighlightingAttributeId([NotNull] this FSharpMemberOr

var entity = mfv.DeclaringEntity;
if (mfv.IsModuleValueOrMember && (entity != null && !entity.Value.IsFSharpModule || mfv.IsExtensionMember))
return mfv.IsProperty || mfv.IsPropertyGetterMethod || mfv.IsPropertySetterMethod
? FSharpHighlightingAttributeIdsModule.Property
: FSharpHighlightingAttributeIdsModule.Method;
if (mfv.IsProperty || mfv.IsPropertyGetterMethod || mfv.IsPropertySetterMethod)
return mfv.IsExtensionMember
? FSharpHighlightingAttributeIdsModule.ExtensionProperty
: FSharpHighlightingAttributeIdsModule.Property;
else
return mfv.IsExtensionMember
? FSharpHighlightingAttributeIdsModule.ExtensionMethod
: FSharpHighlightingAttributeIdsModule.Method;

if (mfv.LiteralValue != null)
return FSharpHighlightingAttributeIdsModule.Literal;

if (mfv.IsActivePattern)
return FSharpHighlightingAttributeIdsModule.ActivePatternCase;

if (mfv.IsMutable || mfv.IsRefCell())
return FSharpHighlightingAttributeIdsModule.MutableValue;

if (IsMangledOpName(mfv.LogicalName))
return FSharpHighlightingAttributeIdsModule.Operator;

if (mfv.IsValCompiledAsMethod)
En3Tho marked this conversation as resolved.
Show resolved Hide resolved
return FSharpHighlightingAttributeIdsModule.Method;

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

if (mfv.IsMutable || mfv.IsRefCell())
return FSharpHighlightingAttributeIdsModule.MutableValue;

var fsType = mfv.FullType;
if (fsType.HasTypeDefinition && fsType.TypeDefinition is var mfvTypeEntity && mfvTypeEntity.IsByRef)
return FSharpHighlightingAttributeIdsModule.MutableValue;
Expand All @@ -82,6 +98,13 @@ 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
En3Tho marked this conversation as resolved.
Show resolved Hide resolved
if (parameter.FullName.Equals("new"))
En3Tho marked this conversation as resolved.
Show resolved Hide resolved
return FSharpHighlightingAttributeIdsModule.Keyword;
En3Tho marked this conversation as resolved.
Show resolved Hide resolved
return parameter.Type.GenericArguments.Count == 2 && parameter.Type.GenericArguments[0].IsUnit
En3Tho marked this conversation as resolved.
Show resolved Hide resolved
? 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 @@ -45,7 +45,7 @@ private void AddHighlightings(IEnumerable<FSharpResolvedSymbolUse> symbolsUses,

var highlightingId =
symbolUse.IsFromComputationExpression
? FSharpHighlightingAttributeIdsModule.Keyword
? FSharpHighlightingAttributeIdsModule.ComputationExpression
: symbol.GetHighlightingAttributeId();

if (symbolUse.IsFromDefinition && symbol is FSharpMemberOrFunctionOrValue mfv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ module FSharpHighlightingAttributeIds =
let [<Literal>] InterfaceExtension = "ReSharper F# Struct Extension Identifier" // todo: add setting

let [<Literal>] Value = "ReSharper F# Value Identifier"
let [<Literal>] MutableValue = "ReSharper F# Mutable 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>] Parameter = "ReSharper F# Parameter Identifier" // todo: add setting
let [<Literal>] Literal = "ReSharper F# Literal Identifier"

Expand All @@ -58,9 +61,11 @@ module FSharpHighlightingAttributeIds =
let [<Literal>] Event = "ReSharper F# Event Identifier"

let [<Literal>] Method = "ReSharper F# Method Identifier"
let [<Literal>] ExtensionMethod = "ReSharper F# Extension Method Identifier" // todo: add setting
let [<Literal>] ExtensionProperty = "ReSharper F# Extension Property Identifier" // todo: add setting

let [<Literal>] ExtensionMethod = "ReSharper F# Extension Method Identifier" // todo: tests
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

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

RegisterHighlighter(
FSharpHighlightingAttributeIds.Measure,
FallbackAttributeId = FSharpHighlightingAttributeIds.TypeParameter,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Syntax//Measure",
En3Tho marked this conversation as resolved.
Show resolved Hide resolved
Layer = HighlighterLayer.SYNTAX,
EffectType = EffectType.TEXT, ForegroundColor = "DarkBlue", DarkForegroundColor = "LightBlue");

RegisterHighlighter(
FSharpHighlightingAttributeIds.ComputationExpression,
FallbackAttributeId = FSharpHighlightingAttributeIds.Keyword,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Syntax//Computation expression",
En3Tho marked this conversation as resolved.
Show resolved Hide resolved
Layer = HighlighterLayer.SYNTAX,
EffectType = EffectType.TEXT, ForegroundColor = "#0000E0", DarkForegroundColor = "#569CD6");

RegisterHighlighter(
FSharpHighlightingAttributeIds.LineComment,
FallbackAttributeId = DefaultLanguageAttributeIds.LINE_COMMENT,
Expand Down Expand Up @@ -291,7 +312,7 @@ type FSharpSettingsNamesProvider() =
Layer = HighlighterLayer.SYNTAX,
VSPriority = VSPriority.IDENTIFIERS,
EffectType = EffectType.TEXT, ForegroundColor = "Purple", DarkForegroundColor = "Violet");

RegisterHighlighter(
FSharpHighlightingAttributeIds.Value,
FallbackAttributeId = DefaultLanguageAttributeIds.LOCAL_VARIABLE,
Expand All @@ -310,6 +331,24 @@ type FSharpSettingsNamesProvider() =
VSPriority = FSharpHighlightingAttributeIds.VsPriorityPlusOne,
EffectType = EffectType.TEXT,
FontStyle = FontStyle.Bold);

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

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

RegisterHighlighter(
FSharpHighlightingAttributeIds.Method,
Expand All @@ -336,7 +375,26 @@ type FSharpSettingsNamesProvider() =
RiderPresentableName = "Values//Active pattern case",
Layer = HighlighterLayer.SYNTAX,
VSPriority = VSPriority.IDENTIFIERS,
EffectType = EffectType.TEXT, ForegroundColor = "DarkCyan:Blue", DarkForegroundColor = "Cyan")>]
EffectType = EffectType.TEXT, ForegroundColor = "DarkCyan:Blue", DarkForegroundColor = "Cyan");

RegisterHighlighter(
FSharpHighlightingAttributeIds.ExtensionMethod,
FallbackAttributeId = FSharpHighlightingAttributeIds.Method,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Members//Extension method",
Layer = HighlighterLayer.SYNTAX,
VSPriority = VSPriority.IDENTIFIERS,
EffectType = EffectType.TEXT, ForegroundColor = "DarkCyan:Maroon", DarkForegroundColor = "Cyan");

RegisterHighlighter(
FSharpHighlightingAttributeIds.ExtensionProperty,
FallbackAttributeId = FSharpHighlightingAttributeIds.Property,
GroupId = FSharpHighlightingAttributeIds.GroupId,
RiderPresentableName = "Members//Extensions property",
Layer = HighlighterLayer.SYNTAX,
VSPriority = VSPriority.IDENTIFIERS,
EffectType = EffectType.TEXT, ForegroundColor = "Purple", DarkForegroundColor = "Violet")>]

type FSharpHighlightingAttributeIds() = class end

module MissingAssemblyReferenceWorkaround =
Expand Down