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

Commit51dac00

Browse files
forkiKevinRansom
authored andcommitted
Couple of cleanups in ErrorLogger (dotnet#4433)
1 parentf1e781c commit51dac00

File tree

1 file changed

+40
-41
lines changed

1 file changed

+40
-41
lines changed

‎src/fsharp/ErrorLogger.fs‎

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
modulepublicMicrosoft.FSharp.Compiler.ErrorLogger
44

5-
openInternal.Utilities
65
openMicrosoft.FSharp.Compiler
7-
openMicrosoft.FSharp.Compiler.AbstractIL.Diagnostics
8-
openMicrosoft.FSharp.Compiler.AbstractIL.Internal.Library
9-
openMicrosoft.FSharp.Compiler.Lib
106
openMicrosoft.FSharp.Compiler.Range
117
openSystem
128

@@ -109,23 +105,23 @@ exception ErrorWithSuggestions of (int * string) * range * string * Suggestions
109105
let inlineprotectAssemblyExploration dflt f=
110106
try
111107
f()
112-
with
113-
| UnresolvedPathReferenceNoRange_-> dflt
114-
|_-> reraise()
108+
with
109+
| UnresolvedPathReferenceNoRange_-> dflt
110+
|_-> reraise()
115111

116112
let inlineprotectAssemblyExplorationF dflt f=
117113
try
118114
f()
119-
with
120-
| UnresolvedPathReferenceNoRange(asmName, path)-> dflt(asmName, path)
121-
|_-> reraise()
115+
with
116+
| UnresolvedPathReferenceNoRange(asmName, path)-> dflt(asmName, path)
117+
|_-> reraise()
122118

123119
let inlineprotectAssemblyExplorationNoReraise dflt1 dflt2 f=
124120
try
125121
f()
126-
with
127-
| UnresolvedPathReferenceNoRange_-> dflt1
128-
|_-> dflt2
122+
with
123+
| UnresolvedPathReferenceNoRange_-> dflt1
124+
|_-> dflt2
129125

130126
// Attach a range if this is a range dual exception.
131127
let recAttachRange m(exn:exn)=
@@ -150,20 +146,22 @@ type Exiter =
150146

151147
letQuitProcessExiter=
152148
{new Exiterwith
153-
memberx.Exit(n)=
149+
member__.Exit(n)=
154150
try
155151
System.Environment.Exit(n)
156152
with_->
157153
()
158-
failwithf"%s"<| FSComp.SR.elSysEnvExitDidntExit()}
154+
FSComp.SR.elSysEnvExitDidntExit()
155+
|> failwith}
159156

160157
/// Closed enumeration of build phases.
158+
[<RequireQualifiedAccess>]
161159
typeBuildPhase=
162160
| DefaultPhase
163161
| Compile
164162
| Parameter| Parse| TypeCheck
165163
| CodeGen
166-
| Optimize|IlxGen|IlGen| Output
164+
| Optimize| IlxGen| IlGen| Output
167165
| Interactive// An error seen during interactive execution
168166

169167
/// Literal build phase subcategory strings.
@@ -212,17 +210,17 @@ type PhasedDiagnostic =
212210
///
213211
memberpe.Subcategory()=
214212
match pe.Phasewith
215-
| DefaultPhase-> BuildPhaseSubcategory.DefaultPhase
216-
| Compile-> BuildPhaseSubcategory.Compile
217-
| Parameter-> BuildPhaseSubcategory.Parameter
218-
| Parse-> BuildPhaseSubcategory.Parse
219-
| TypeCheck-> BuildPhaseSubcategory.TypeCheck
220-
| CodeGen-> BuildPhaseSubcategory.CodeGen
221-
| Optimize-> BuildPhaseSubcategory.Optimize
222-
| IlxGen-> BuildPhaseSubcategory.IlxGen
223-
| IlGen-> BuildPhaseSubcategory.IlGen
224-
| Output-> BuildPhaseSubcategory.Output
225-
| Interactive-> BuildPhaseSubcategory.Interactive
213+
|BuildPhase.DefaultPhase-> BuildPhaseSubcategory.DefaultPhase
214+
|BuildPhase.Compile-> BuildPhaseSubcategory.Compile
215+
|BuildPhase.Parameter-> BuildPhaseSubcategory.Parameter
216+
|BuildPhase.Parse-> BuildPhaseSubcategory.Parse
217+
|BuildPhase.TypeCheck-> BuildPhaseSubcategory.TypeCheck
218+
|BuildPhase.CodeGen-> BuildPhaseSubcategory.CodeGen
219+
|BuildPhase.Optimize-> BuildPhaseSubcategory.Optimize
220+
|BuildPhase.IlxGen-> BuildPhaseSubcategory.IlxGen
221+
|BuildPhase.IlGen-> BuildPhaseSubcategory.IlGen
222+
|BuildPhase.Output-> BuildPhaseSubcategory.Output
223+
|BuildPhase.Interactive-> BuildPhaseSubcategory.Interactive
226224

227225
/// Return true if the textual phase given is from the compile part of the build process.
228226
/// This set needs to be equal to the set of subcategories that the language service can produce.
@@ -256,7 +254,7 @@ type PhasedDiagnostic =
256254
memberpe.IsPhaseInCompile()=
257255
letisPhaseInCompile=
258256
match pe.Phasewith
259-
| Compile| Parameter| Parse| TypeCheck->true
257+
|BuildPhase.Compile|BuildPhase.Parameter|BuildPhase.Parse|BuildPhase.TypeCheck->true
260258
|_->false
261259
// Sanity check ensures that Phase matches Subcategory
262260
#if DEBUG
@@ -274,7 +272,7 @@ type ErrorLogger(nameForDebugging:string) =
274272
// The 'Impl' factoring enables a developer to place a breakpoint at the non-Impl
275273
// code just below and get a breakpoint for all error logger implementations.
276274
abstractDiagnosticSink: phasedError:PhasedDiagnostic* isError:bool->unit
277-
memberthis.DebugDisplay()= sprintf"ErrorLogger(%s)" nameForDebugging
275+
member__.DebugDisplay()= sprintf"ErrorLogger(%s)" nameForDebugging
278276

279277
letDiscardErrorsLogger=
280278
{new ErrorLogger("DiscardErrorsLogger")with
@@ -337,7 +335,7 @@ module ErrorLoggerExtensions =
337335
try
338336
letpreserveStackTrace= typeof<System.Exception>.GetMethod("InternalPreserveStackTrace", BindingFlags.Instance||| BindingFlags.NonPublic)
339337
preserveStackTrace.Invoke(exn,null)|> ignore
340-
withe->
338+
with_->
341339
// This is probably only the mono case.
342340
System.Diagnostics.Debug.Assert(false,"Could not preserve stack trace for watson exception.")
343341
()
@@ -411,7 +409,7 @@ module ErrorLoggerExtensions =
411409
x.ErrorR(AttachRange m exn)// may raise exceptions, e.g. an fsi error sink raises StopProcessing.
412410
ReraiseIfWatsonable(exn)
413411
with
414-
| ReportedError_| WrappedError(ReportedError_,_)->()
412+
| ReportedError_| WrappedError(ReportedError_,_)->()
415413

416414
memberx.StopProcessingRecovery(exn:exn)(m:range)=
417415
// Do standard error recovery.
@@ -421,10 +419,11 @@ module ErrorLoggerExtensions =
421419
match exnwith
422420
| StopProcessing| WrappedError(StopProcessing,_)->()// suppress, so skip error recovery.
423421
|_->
424-
try x.ErrorRecovery exn m
422+
try
423+
x.ErrorRecovery exn m
425424
with
426-
| StopProcessing| WrappedError(StopProcessing,_)->()// catch, e.g. raised by DiagnosticSink.
427-
| ReportedError_| WrappedError(ReportedError_,_)->()// catch, but not expected unless ErrorRecovery is changed.
425+
| StopProcessing| WrappedError(StopProcessing,_)->()// catch, e.g. raised by DiagnosticSink.
426+
| ReportedError_| WrappedError(ReportedError_,_)->()// catch, but not expected unless ErrorRecovery is changed.
428427

429428
memberx.ErrorRecoveryNoRange(exn:exn)=
430429
x.ErrorRecovery exn range0
@@ -445,13 +444,13 @@ let PushErrorLoggerPhaseUntilUnwind(errorLoggerTransformer : ErrorLogger -> #Err
445444
letnewInstalled= reftrue
446445
letnewIsInstalled()=if!newInstalledthen()else(assertfalse;();(*failwith "error logger used after unwind"*))// REVIEW: ok to throw?
447446
letchkErrorLogger={new ErrorLogger("PushErrorLoggerPhaseUntilUnwind")with
448-
memberx.DiagnosticSink(phasedError,isError)= newIsInstalled(); newErrorLogger.DiagnosticSink(phasedError, isError)
449-
memberx.ErrorCount= newIsInstalled(); newErrorLogger.ErrorCount}
447+
member__.DiagnosticSink(phasedError,isError)= newIsInstalled(); newErrorLogger.DiagnosticSink(phasedError, isError)
448+
member__.ErrorCount= newIsInstalled(); newErrorLogger.ErrorCount}
450449

451450
CompileThreadStatic.ErrorLogger<- chkErrorLogger
452451

453452
{new System.IDisposablewith
454-
memberx.Dispose()=
453+
member__.Dispose()=
455454
CompileThreadStatic.ErrorLogger<- oldErrorLogger
456455
newInstalled:= false}
457456

@@ -461,13 +460,13 @@ let SetThreadErrorLoggerNoUnwind(errorLogger) = CompileThreadStatic.ErrorLog
461460
// Global functions are still used by parser and TAST ops.
462461

463462
/// Raises an exception with error recovery and returns unit.
464-
leterrorRexn= CompileThreadStatic.ErrorLogger.ErrorR exn
463+
leterrorR exn= CompileThreadStatic.ErrorLogger.ErrorR exn
465464

466465
/// Raises a warning with error recovery and returns unit.
467466
letwarning exn= CompileThreadStatic.ErrorLogger.Warning exn
468467

469468
/// Raises a special exception and returns 'T - can be caught later at an errorRecovery point.
470-
leterrorexn= CompileThreadStatic.ErrorLogger.Error exn
469+
leterror exn= CompileThreadStatic.ErrorLogger.Error exn
471470

472471
/// Simulates an error. For test purposes only.
473472
letsimulateError(p:PhasedDiagnostic)= CompileThreadStatic.ErrorLogger.SimulateError p
@@ -497,8 +496,8 @@ let suppressErrorReporting f =
497496
try
498497
leterrorLogger=
499498
{new ErrorLogger("suppressErrorReporting")with
500-
memberx.DiagnosticSink(_phasedError,_isError)=()
501-
memberx.ErrorCount=0}
499+
member__.DiagnosticSink(_phasedError,_isError)=()
500+
member__.ErrorCount=0}
502501
SetThreadErrorLoggerNoUnwind(errorLogger)
503502
f()
504503
finally

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp