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

Commita177ef9

Browse files
highlight disposable types
1 parent85d323d commita177ef9

File tree

7 files changed

+38
-4
lines changed

7 files changed

+38
-4
lines changed

‎src/fsharp/TcGlobals.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
942942
member valtcref_System_IComparable= findSysTyconRef sys"IComparable"
943943
member valtcref_System_IStructuralComparable= findSysTyconRef sysCollections"IStructuralComparable"
944944
member valtcref_System_IStructuralEquatable= findSysTyconRef sysCollections"IStructuralEquatable"
945+
member valtcref_System_IDisposable= findSysTyconRef sys"IDisposable"
945946

946947
member valtcref_LanguagePrimitives= mk_MFCore_tcref fslibCcu"LanguagePrimitives"
947948

‎src/fsharp/vs/Symbols.fs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
403403
letty= generalizedTyconRef entity
404404
Infos.ExistsHeadTypeInEntireHierarchy cenv.g cenv.amap range0 ty cenv.g.tcref_System_Attribute
405405

406+
memberx.IsDisposableType=
407+
if isUnresolved()thenfalseelse
408+
letty= generalizedTyconRef entity
409+
Infos.ExistsHeadTypeInEntireHierarchy cenv.g cenv.amap range0 ty cenv.g.tcref_System_IDisposable
410+
406411
memberx.BaseType=
407412
checkIsResolved()
408413
GetSuperTypeOfType cenv.g cenv.amap range0(generalizedTyconRef entity)

‎src/fsharp/vs/service.fs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ type SemanticClassificationType =
502502
| IntrinsicFunction
503503
| Enumeration
504504
| Interface
505+
| Disposable
505506

506507
// A scope represents everything we get back from the typecheck of a file.
507508
// It acts like an in-memory database about the file.
@@ -1461,6 +1462,9 @@ type TypeCheckInfo
14611462
| None->
14621463
sResolutions.CapturedNameResolutions:> seq<_>
14631464

1465+
letisDisposableTy(ty:TType)=
1466+
Infos.ExistsHeadTypeInEntireHierarchy g amap range0 ty g.tcref_System_IDisposable
1467+
14641468
resolutions
14651469
|> Seq.choose(fun cnr->
14661470
match cnrwith
@@ -1495,6 +1499,8 @@ type TypeCheckInfo
14951499
Some(m, SemanticClassificationType.Interface)
14961500
| CNR(_, Item.Types(_, types), LegitTypeOccurence,_,_,_, m)when types|> List.exists(isStructTy g)->
14971501
Some(m, SemanticClassificationType.ValueType)
1502+
| CNR(_, Item.Types(_, types), LegitTypeOccurence,_,_,_, m)when types|> List.exists isDisposableTy->
1503+
Some(m, SemanticClassificationType.Disposable)
14981504
| CNR(_, Item.Types_, LegitTypeOccurence,_,_,_, m)->
14991505
Some(m, SemanticClassificationType.ReferenceType)
15001506
| CNR(_,(Item.TypeVar_| Item.UnqualifiedType_| Item.CtorGroup_), LegitTypeOccurence,_,_,_, m)->

‎src/fsharp/vs/service.fsi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ type internal SemanticClassificationType =
163163
| IntrinsicFunction
164164
| Enumeration
165165
| Interface
166+
| Disposable
166167

167168
/// A handle to the results of CheckFileInProject.
168169
[<Sealed>]

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module internal FSharpClassificationTypes =
3131
let [<Literal>]Enum= ClassificationTypeNames.EnumName
3232
let [<Literal>]Property="FSharp.Property"
3333
let [<Literal>]Interface= ClassificationTypeNames.InterfaceName
34+
let [<Literal>]Disposable="FSharp.Disposable"
3435

3536
letgetClassificationTypeName=function
3637
| SemanticClassificationType.ReferenceType-> ReferenceType
@@ -46,6 +47,7 @@ module internal FSharpClassificationTypes =
4647
| SemanticClassificationType.Enumeration-> Enum
4748
| SemanticClassificationType.Property-> Property
4849
| SemanticClassificationType.Interface-> Interface
50+
| SemanticClassificationType.Disposable-> Disposable
4951

5052
moduleinternalClassificationDefinitions=
5153

@@ -67,11 +69,12 @@ module internal ClassificationDefinitions =
6769
letthemeService= serviceProvider.GetService(typeof<SVsColorThemeService>):?> IVsColorThemeService
6870
themeService.CurrentTheme.ThemeId
6971

70-
letcolorData=// name, (light, dark)
71-
[ FSharpClassificationTypes.Function,(Colors.Black, Color.FromRgb(220uy,220uy,220uy))
72-
FSharpClassificationTypes.MutableVar,(Color.FromRgb(160uy,128uy,0uy), Color.FromRgb(255uy,210uy,28uy))
72+
letcolorData=// name, (light,dark)
73+
[ FSharpClassificationTypes.Function,(Colors.Black,Color.FromRgb(220uy,220uy,220uy))
74+
FSharpClassificationTypes.MutableVar,(Color.FromRgb(160uy,128uy,0uy),Color.FromRgb(255uy,210uy,28uy))
7375
FSharpClassificationTypes.Printf,(Color.FromRgb(43uy,145uy,175uy), Color.FromRgb(78uy,220uy,176uy))
74-
FSharpClassificationTypes.Property,(Colors.Black, Color.FromRgb(220uy,220uy,220uy))]
76+
FSharpClassificationTypes.Property,(Colors.Black, Color.FromRgb(220uy,220uy,220uy))
77+
FSharpClassificationTypes.Disposable,(Color.FromRgb(43uy,145uy,175uy), Color.FromRgb(78uy,220uy,176uy))]
7578

7679
letsetColors _=
7780
letfontAndColorStorage= serviceProvider.GetService(typeof<SVsFontAndColorStorage>):?> IVsFontAndColorStorage
@@ -118,6 +121,9 @@ module internal ClassificationDefinitions =
118121
[<Export; Name(FSharpClassificationTypes.Property); BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)>]
119122
letFSharpPropertyClassificationType:ClassificationTypeDefinition=null
120123

124+
[<Export; Name(FSharpClassificationTypes.Disposable); BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)>]
125+
letFSharpDisposableClassificationType:ClassificationTypeDefinition=null
126+
121127
[<Export(typeof<EditorFormatDefinition>)>]
122128
[<ClassificationType(ClassificationTypeNames= FSharpClassificationTypes.Function)>]
123129
[<Name(FSharpClassificationTypes.Function)>]
@@ -161,3 +167,14 @@ module internal ClassificationDefinitions =
161167

162168
do self.DisplayName<- SR.FSharpPropertiesClassificationType.Value
163169
self.ForegroundColor<- theme.GetColor FSharpClassificationTypes.Property
170+
171+
[<Export(typeof<EditorFormatDefinition>)>]
172+
[<ClassificationType(ClassificationTypeNames= FSharpClassificationTypes.Disposable)>]
173+
[<Name(FSharpClassificationTypes.Disposable)>]
174+
[<UserVisible(true)>]
175+
[<Order(After= PredefinedClassificationTypeNames.Keyword)>]
176+
typeinternalFSharpDisposableFormat[<ImportingConstructor>](theme: ThemeColors)asself=
177+
inherit ClassificationFormatDefinition()
178+
179+
do self.DisplayName<- SR.FSharpDisposablesClassificationType.Value
180+
self.ForegroundColor<- theme.GetColor FSharpClassificationTypes.Disposable

‎vsintegration/src/FSharp.Editor/FSharp.Editor.resx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
<dataname="FSharpPropertiesClassificationType"xml:space="preserve">
151151
<value>F# Properties</value>
152152
</data>
153+
<dataname="FSharpDisposablesClassificationType"xml:space="preserve">
154+
<value>F# Disposable Types</value>
155+
</data>
153156
<dataname="RemoveUnusedOpens"xml:space="preserve">
154157
<value>Remove unused open declaration</value>
155158
</data>

‎vsintegration/src/FSharp.Editor/srFSharp.Editor.fs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ module SR =
2424
letFSharpMutableVarsClassificationType=lazy(GetString"FSharpMutableVarsClassificationType")
2525
letFSharpPrintfFormatClassificationType=lazy(GetString"FSharpPrintfFormatClassificationType")
2626
letFSharpPropertiesClassificationType=lazy(GetString"FSharpPropertiesClassificationType")
27+
letFSharpDisposablesClassificationType=lazy(GetString"FSharpDisposablesClassificationType")
2728
letRemoveUnusedOpens=lazy(GetString"RemoveUnusedOpens")
2829
letUnusedOpens=lazy(GetString"UnusedOpens")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp