Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6924fc5

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Highlight "raise", "reraise", "typeof", "typedefof", "sizeof", "nameof" as keywords (dotnet#2475)
* highlight "raise", "reraise", "typeof", "typedefof", "sizeof", "nameof" as keywords* fix compilation* colorize forgotten "int8" and "uint8" as keywords
1 parentdb4febf commit6924fc5

File tree

5 files changed

+49
-30
lines changed

5 files changed

+49
-30
lines changed

‎src/fsharp/vs/service.fs‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ type SemanticClassificationType =
499499
| Printf
500500
| ComputationExpression
501501
| IntrinsicType
502+
| IntrinsicFunction
502503
| Enumeration
503504
| Interface
504505

@@ -1441,6 +1442,17 @@ type TypeCheckInfo
14411442
| TType.TType_app(tref,_)when tref.Stamp= g.attrib_OptionalArgumentAttribute.TyconRef.Stamp-> Some()
14421443
|_-> None
14431444

1445+
let(|KeywordIntrinsicValue|_|)(vref:ValRef)=
1446+
if valRefEq g g.raise_vref vref||
1447+
valRefEq g g.reraise_vref vref||
1448+
valRefEq g g.typeof_vref vref||
1449+
valRefEq g g.typedefof_vref vref||
1450+
valRefEq g g.sizeof_vref vref
1451+
// TODO uncomment this after `nameof` operator is implemented
1452+
// || valRefEq g g.nameof_vref vref
1453+
then Some()
1454+
else None
1455+
14441456
letresolutions=
14451457
match rangewith
14461458
| Some range->
@@ -1455,7 +1467,8 @@ type TypeCheckInfo
14551467
// 'seq' in 'seq { ... }' gets colored as keywords
14561468
| CNR(_,(Item.Value vref), ItemOccurence.Use,_,_,_, m)when valRefEq g g.seq_vref vref->
14571469
Some(m, SemanticClassificationType.ComputationExpression)
1458-
1470+
| CNR(_, Item.Value KeywordIntrinsicValue, ItemOccurence.Use,_,_,_, m)->
1471+
Some(m, SemanticClassificationType.IntrinsicFunction)
14591472
| CNR(_,(Item.Value vref),_,_,_,_, m)when isFunction g vref.Type->
14601473
if vref.IsPropertyGetterMethod|| vref.IsPropertySetterMethodthen
14611474
Some(m, SemanticClassificationType.Property)

‎src/fsharp/vs/service.fsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ type internal SemanticClassificationType =
160160
| Printf
161161
| ComputationExpression
162162
| IntrinsicType
163+
| IntrinsicFunction
163164
| Enumeration
164165
| Interface
165166

‎src/utils/sformat.fs‎

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -194,35 +194,38 @@ namespace Microsoft.FSharp.Text.StructuredFormat
194194
moduleTaggedTextOps=
195195
#endif
196196
lettagAlias= TaggedText.Alias
197+
letkeywordFunctions= Set["raise";"reraise";"typeof";"typedefof";"sizeof";"nameof"]
197198
letkeywordTypes=
198199
[
199-
"array";
200-
"bigint";
201-
"bool";
202-
"byref";
203-
"byte";
204-
"char";
205-
"decimal";
206-
"double";
207-
"float";
208-
"float32";
209-
"int";
210-
"int16";
211-
"int32";
212-
"int64";
213-
"list";
214-
"nativeint";
215-
"obj";
216-
"sbyte";
217-
"seq";
218-
"single";
219-
"string";
220-
"unit";
221-
"uint";
222-
"uint16";
223-
"uint32";
224-
"uint64";
225-
"unativeint";
200+
"array"
201+
"bigint"
202+
"bool"
203+
"byref"
204+
"byte"
205+
"char"
206+
"decimal"
207+
"double"
208+
"float"
209+
"float32"
210+
"int"
211+
"int8"
212+
"int16"
213+
"int32"
214+
"int64"
215+
"list"
216+
"nativeint"
217+
"obj"
218+
"sbyte"
219+
"seq"
220+
"single"
221+
"string"
222+
"unit"
223+
"uint"
224+
"uint8"
225+
"uint16"
226+
"uint32"
227+
"uint64"
228+
"unativeint"
226229
]|> Set.ofList
227230
lettagClass name=if Set.contains name keywordTypesthen TaggedText.Keyword nameelse TaggedText.Class name
228231
lettagUnionCase= TaggedText.UnionCase
@@ -238,7 +241,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat
238241
lettagRecordField= TaggedText.RecordField
239242
lettagMethod= TaggedText.Method
240243
lettagModule= TaggedText.Module
241-
lettagModuleBinding=TaggedText.ModuleBinding
244+
lettagModuleBindingname=if keywordFunctions.Contains namethenTaggedText.Keyword nameelse TaggedText.ModuleBinding name
242245
lettagNamespace= TaggedText.Namespace
243246
lettagNumericLiteral= TaggedText.NumericLiteral
244247
lettagOperator= TaggedText.Operator

‎src/utils/sformat.fsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat
127127
#endif
128128
TaggedTextOps=
129129
valkeywordTypes:Set<string>
130+
valkeywordFunctions:Set<string>
130131
valtagAlias:string->TaggedText
131132
valtagClass:string->TaggedText
132133
valtagUnionCase:string->TaggedText

‎vsintegration/src/FSharp.Editor/Classification/ClassificationDefinitions.fs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ module internal FSharpClassificationTypes =
4040
| SemanticClassificationType.MutableVar-> MutableVar
4141
| SemanticClassificationType.Printf-> Printf
4242
| SemanticClassificationType.ComputationExpression
43-
| SemanticClassificationType.IntrinsicType-> Keyword
43+
| SemanticClassificationType.IntrinsicType
44+
| SemanticClassificationType.IntrinsicFunction-> Keyword
4445
| SemanticClassificationType.UnionCase
4546
| SemanticClassificationType.Enumeration-> Enum
4647
| SemanticClassificationType.Property-> Property

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp