refactor(ast): unify AstVisitorBase Stmt.Expression handler name (#1250)#1252
Merged
Conversation
Rename VisitExpressionStmt -> VisitExpression in the analyzer-visitor
family so it matches the mechanical Visit + node-type-name convention
used everywhere else (Stmt.Var -> VisitVar, Expr.Binary -> VisitBinary).
Stmt.Expression was the one node whose handler name diverged between the
two dispatch families: AstVisitorBase's switch called VisitExpressionStmt
while the registry dispatch (Interpreter/TypeChecker via
NodeRegistry.AutoRegister's $"Visit{Name}") uses VisitExpression. This
removes the last exception to the uniform naming and the one wrinkle a
future source-generator-based dispatch would have to special-case.
Behavior-neutral: renames the AstVisitorBase switch case, the virtual
method, and the StringAccumulatorPromotionAnalyzer override + base call.
No collision with the existing Interpreter/TypeChecker VisitExpression
methods, which are not in the AstVisitorBase hierarchy.
Part of #1094.
Closes #1250
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Renames
VisitExpressionStmt→VisitExpressionin theAstVisitorBaseanalyzer-visitor family, so the handler forStmt.Expressionfollows the same mechanicalVisit+ node-type-name rule used everywhere else (Stmt.Var→VisitVar,Expr.Binary→VisitBinary, …).Stmt.Expressionwas the only node whose handler name diverged between the two dispatch families:Stmt.Expression(before)AstVisitorBase+ subclasses)VisitExpressionStmtInterpreter,TypeChecker, viaNodeRegistry.AutoRegister's$"Visit{Name}")VisitExpressionThis removes the last exception to the uniform naming and the one wrinkle a future source-generator-based dispatch (the road not taken in #1243) would have to special-case.
Changes (4 spots, behavior-neutral)
Parsing/Visitors/AstVisitorBase.cs— theStmt.Expressionswitch caseParsing/Visitors/AstVisitorBase.cs— the virtual method definitionCompilation/StringAccumulatorPromotionAnalyzer.cs— the overrideCompilation/StringAccumulatorPromotionAnalyzer.cs— thebase.VisitExpression(stmt)callNo collision with the existing
Interpreter.VisitExpression/TypeChecker.VisitExpressionmethods — those live on the registry-dispatch types, not in theAstVisitorBasehierarchy.Testing
dotnet build— 0 errorsAstDispatchTests, which guards theAstVisitorBaseswitch via aGetUninitializedObject+NotSupportedExceptionprobe)Pure internal C# method rename with no behavioral surface — the Test262/TSConf conformance suites exercise TypeScript semantics this change cannot affect.
Part of #1094.
Closes #1250