1
+ using JetBrains . Application . Settings ;
2
+ using JetBrains . Application . UI . Options ;
3
+ using JetBrains . Application . UI . Options . OptionsDialog ;
4
+ using JetBrains . DataFlow ;
5
+ using JetBrains . IDE . UI . Options ;
6
+ using JetBrains . Lifetimes ;
7
+
8
+ namespace ReSharper . Exceptional . Options
9
+ {
10
+ [ OptionsPage ( Pid , Name , typeof ( UnnamedThemedIcons . ExceptionalSettings ) , ParentId = ExceptionalOptionsPage . Pid , Sequence = 0.0 ) ]
11
+ public class GeneralOptionsPage : BeSimpleOptionsPage
12
+ {
13
+ public const string Pid = "Exceptional::General" ;
14
+ public const string Name = "General" ;
15
+
16
+ public GeneralOptionsPage ( Lifetime lifetime , OptionsPageContext optionsPageContext , OptionsSettingsSmartContext optionsSettingsSmartContext , bool wrapInScrollablePanel = false ) : base ( lifetime , optionsPageContext , optionsSettingsSmartContext , wrapInScrollablePanel )
17
+ {
18
+ CreateCheckboxInspectPublic ( lifetime , optionsSettingsSmartContext . StoreOptionsTransactionContext ) ;
19
+
20
+ CreateDocumentationSection ( lifetime , optionsSettingsSmartContext . StoreOptionsTransactionContext ) ;
21
+ }
22
+
23
+ private void CreateCheckboxInspectPublic ( Lifetime lifetime , IContextBoundSettingsStoreLive storeOptionsTransactionContext )
24
+ {
25
+ IProperty < bool > property = new Property < bool > ( lifetime , "Exceptional::General::DelegateInvocationsMayThrowSystemException" ) ;
26
+ property . SetValue ( storeOptionsTransactionContext . GetValue ( ( Settings . ExceptionalSettings key ) => key . DelegateInvocationsMayThrowExceptions ) ) ;
27
+
28
+ property . Change . Advise ( lifetime , a =>
29
+ {
30
+ if ( ! a . HasNew ) return ;
31
+
32
+ storeOptionsTransactionContext . SetValue ( ( Settings . ExceptionalSettings key ) => key . DelegateInvocationsMayThrowExceptions , a . New ) ;
33
+ } ) ;
34
+
35
+ AddBoolOption ( ( Settings . ExceptionalSettings key ) => key . DelegateInvocationsMayThrowExceptions , OptionsLabels . General . DelegateInvocationsMayThrowSystemException ) ;
36
+ }
37
+
38
+ private void CreateDocumentationSection ( Lifetime lifetime , IContextBoundSettingsStoreLive storeOptionsTransactionContext )
39
+ {
40
+ AddHeader ( OptionsLabels . General . DocumentationOfThrownExceptionsSubtypeHeader ) ;
41
+
42
+ CreateCheckboxIsDocumentationOfExceptionSubtypeSufficientForThrowStatements ( lifetime , storeOptionsTransactionContext ) ;
43
+ CreateCheckboxIsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions ( lifetime , storeOptionsTransactionContext ) ;
44
+ }
45
+
46
+ private void CreateCheckboxIsDocumentationOfExceptionSubtypeSufficientForThrowStatements ( Lifetime lifetime , IContextBoundSettingsStoreLive storeOptionsTransactionContext )
47
+ {
48
+ IProperty < bool > property = new Property < bool > ( lifetime , "Exceptional::General::IsDocumentationOfExceptionSubtypeSufficientForThrowStatements" ) ;
49
+ property . SetValue ( storeOptionsTransactionContext . GetValue ( ( Settings . ExceptionalSettings key ) => key . IsDocumentationOfExceptionSubtypeSufficientForThrowStatements ) ) ;
50
+
51
+ property . Change . Advise ( lifetime , a =>
52
+ {
53
+ if ( ! a . HasNew ) return ;
54
+
55
+ storeOptionsTransactionContext . SetValue ( ( Settings . ExceptionalSettings key ) => key . IsDocumentationOfExceptionSubtypeSufficientForThrowStatements , a . New ) ;
56
+ } ) ;
57
+
58
+ AddBoolOption ( ( Settings . ExceptionalSettings key ) => key . IsDocumentationOfExceptionSubtypeSufficientForThrowStatements , OptionsLabels . General . IsDocumentationOfExceptionSubtypeSufficientForThrowStatements ) ;
59
+ }
60
+
61
+ private void CreateCheckboxIsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions ( Lifetime lifetime , IContextBoundSettingsStoreLive storeOptionsTransactionContext )
62
+ {
63
+ IProperty < bool > property = new Property < bool > ( lifetime , "Exceptional::General::IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions" ) ;
64
+ property . SetValue ( storeOptionsTransactionContext . GetValue ( ( Settings . ExceptionalSettings key ) => key . IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions ) ) ;
65
+
66
+ property . Change . Advise ( lifetime , a =>
67
+ {
68
+ if ( ! a . HasNew ) return ;
69
+
70
+ storeOptionsTransactionContext . SetValue ( ( Settings . ExceptionalSettings key ) => key . IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions , a . New ) ;
71
+ } ) ;
72
+
73
+ AddBoolOption ( ( Settings . ExceptionalSettings key ) => key . IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions , OptionsLabels . General . IsDocumentationOfExceptionSubtypeSufficientForReferenceExpressions ) ;
74
+ }
75
+ }
76
+ }
0 commit comments