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

Commit24e3547

Browse files
forkiKevinRansom
authored andcommitted
Breakpoints should be faster (dotnet#2247)
* Use List functions* Add additional position checks* We don't need to evaluate unrelated expressions
1 parent1c78f6a commit24e3547

File tree

1 file changed

+50
-38
lines changed

1 file changed

+50
-38
lines changed

‎src/fsharp/vs/ServiceUntypedParse.fs‎

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
107107
(fun _-> NavigationImpl.empty)
108108

109109
memberprivatescope.ValidateBreakpointLocationImpl(pos)=
110+
letisMatchRange m= rangeContainsPos m pos|| m.StartLine= pos.Line
110111

111-
112112
// Process let-binding
113113
letfindBreakPoints()=
114-
letcheckRange m=[ifrangeContainsPos m pos|| m.StartLine= pos.Linethenyield m]
114+
letcheckRange m=[ifisMatchRange mthenyield m]
115115
letwalkBindSeqPt sp=[match spwith SequencePointAtBinding m->yield! checkRange m|_->()]
116116
letwalkForSeqPt sp=[match spwith SequencePointAtForLoop m->yield! checkRange m|_->()]
117117
letwalkWhileSeqPt sp=[match spwith SequencePointAtWhileLoop m->yield! checkRange m|_->()]
@@ -131,22 +131,35 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
131131

132132
yield! walkExpr(isFunction||(match spInfowith SequencePointAtBinding_->false|_->true)) synExpr]
133133

134-
andwalkExprs es=[for ein esdoyield!walkExprfalse e]
135-
andwalkBinds es=[for ein esdoyield!walkBinde]
134+
andwalkExprs es=List.collect(walkExprfalse) es
135+
andwalkBinds es=List.collectwalkBindes
136136
andwalkMatchClauses cl=
137137
[for(Clause(_,whenExpr,e,_,_))in cldo
138-
match whenExprwith Some e->yield! walkExprfalse e|_->()
138+
match whenExprwith
139+
| Some e->yield! walkExprfalse e
140+
|_->()
139141
yield! walkExprtrue e]
140142

141143
andwalkExprOpt(spAlways:bool)eOpt=[match eOptwith Some e->yield! walkExpr spAlways e|_->()]
142144

145+
andIsBreakableExpression e=
146+
match ewith
147+
| SynExpr.Match_
148+
| SynExpr.IfThenElse_
149+
| SynExpr.For_
150+
| SynExpr.ForEach_
151+
| SynExpr.While_->true
152+
|_->not(IsControlFlowExpression e)
153+
143154
// Determine the breakpoint locations for an expression. spAlways indicates we always
144155
// emit a breakpoint location for the expression unless it is a syntactic control flow construct
145-
andwalkExpr(spAlways:bool)e=
146-
[if spAlways&&not(IsControlFlowExpression e)then
147-
yield! checkRange e.Range
148-
match ewith
156+
andwalkExpr(spAlways:bool)e=
157+
letm= e.Range
158+
ifnot(isMatchRange m)then[]else
159+
[if spAlways&& IsBreakableExpression ethen
160+
yield! checkRange m
149161

162+
match ewith
150163
| SynExpr.ArbitraryAfterError_
151164
| SynExpr.LongIdent_
152165
| SynExpr.LibraryOnlyILAssembly_
@@ -279,15 +292,17 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
279292
yield! walkExprtrue e2]
280293

281294
// Process a class declaration or F# type declaration
282-
let recwalkTycon(TypeDefn(ComponentInfo(_,_,_,_,_,_,_,_),repr,membDefns,_))=
283-
[for min membDefnsdoyield! walkMember m
295+
let recwalkTycon(TypeDefn(ComponentInfo(_,_,_,_,_,_,_,_),repr,membDefns,m))=
296+
ifnot(isMatchRange m)then[]else
297+
[for membin membDefnsdoyield! walkMember memb
284298
match reprwith
285299
| SynTypeDefnRepr.ObjectModel(_, membDefns,_)->
286-
formin membDefnsdoyield! walkMemberm
300+
formembin membDefnsdoyield! walkMembermemb
287301
|_->()]
288302

289303
// Returns class-members for the right dropdown
290-
andwalkMember memb=
304+
andwalkMember memb=
305+
ifnot(rangeContainsPos memb.Range pos)then[]else
291306
[match membwith
292307
| SynMemberDefn.LetBindings(binds,_,_,_)->yield! walkBinds binds
293308
| SynMemberDefn.AutoProperty(_attribs,_isStatic,_id,_tyOpt,_propKind,_,_xmlDoc,_access, synExpr,_,_)->yield! walkExprtrue synExpr
@@ -303,36 +318,30 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
303318
// (such as type declarations, nested modules etc.)
304319
let recwalkDecl decl=
305320
[match declwith
306-
| SynModuleDecl.Let(_, binds, m)->
307-
if rangeContainsPos m posthen
308-
yield! walkBinds binds
309-
| SynModuleDecl.DoExpr(spExpr,expr,_)->
321+
| SynModuleDecl.Let(_, binds, m)when isMatchRange m->
322+
yield! walkBinds binds
323+
| SynModuleDecl.DoExpr(spExpr,expr, m)when isMatchRange m->
310324
yield! walkBindSeqPt spExpr
311325
yield! walkExprfalse expr
312-
| SynModuleDecl.ModuleAbbrev_->
313-
()
314-
| SynModuleDecl.NestedModule(_,_isRec, decls,_, m)->
315-
if rangeContainsPos m posthen
316-
for din declsdoyield! walkDecl d
317-
| SynModuleDecl.Types(tydefs, m)->
318-
if rangeContainsPos m posthen
319-
for din tydefsdoyield! walkTycon d
320-
| SynModuleDecl.Exception(SynExceptionDefn(SynExceptionDefnRepr(_,_,_,_,_,_), membDefns,_), m)->
321-
if rangeContainsPos m posthen
322-
for min membDefnsdoyield! walkMember m
323-
|_->
324-
()]
326+
| SynModuleDecl.ModuleAbbrev_->()
327+
| SynModuleDecl.NestedModule(_,_isRec, decls,_, m)when isMatchRange m->
328+
for din declsdoyield! walkDecl d
329+
| SynModuleDecl.Types(tydefs, m)when isMatchRange m->
330+
for din tydefsdoyield! walkTycon d
331+
| SynModuleDecl.Exception(SynExceptionDefn(SynExceptionDefnRepr(_,_,_,_,_,_), membDefns,_), m)
332+
when isMatchRange m->
333+
for min membDefnsdoyield! walkMember m
334+
|_->()]
325335

326-
// Collect all the items
336+
// Collect all the itemsin a module
327337
letwalkModule(SynModuleOrNamespace(_,_,_,decls,_,_,_,m))=
328-
ifrangeContainsPos mposthen
329-
[for din declsdoyield!walkDecld]
338+
ifisMatchRange mthen
339+
List.collectwalkDecldecls
330340
else
331341
[]
332342

333343
/// Get information for implementation file
334-
letwalkImplFile(modules:SynModuleOrNamespace list)=
335-
[for xin modulesdoyield! walkModule x]
344+
letwalkImplFile(modules:SynModuleOrNamespace list)= List.collect walkModule modules
336345

337346
match inputwith
338347
| Some(ParsedInput.ImplFile(ParsedImplFileInput(_,_,_,_,_,modules,_)))-> walkImplFile modules
@@ -344,9 +353,12 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
344353
letlocations= findBreakPoints()
345354

346355
match locations|> List.filter(fun m-> rangeContainsPos m pos)with
347-
|[]-> Seq.tryHead locations
348-
| locations-> Seq.tryLast locations)
349-
(fun _msg-> None)
356+
|[]->
357+
match locations|> List.filter(fun m-> rangeBeforePos m pos|>not)with
358+
|[]-> Seq.tryHead locations
359+
| locationsAfterPos-> Seq.tryHead locationsAfterPos
360+
| coveringLocations-> Seq.tryLast coveringLocations)
361+
(fun _msg-> None)
350362

351363
/// When these files appear or disappear the configuration for the current project is invalidated.
352364
memberscope.DependencyFiles= dependencyFiles

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp