-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Proposal: Refactor extract class AssignmentStatementAnalyzer from SemanticAnalyzer #2198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On principle I'm uncomfortable with refactoring proposals from new
contributors (even very knowledgeable ones). The code will still be there,
and there will be some uneasy back-and-forth between the two classes (e.g.
for errors).
|
Okay then I won't volunteer to take this task on myself at the present time.
Indeed there will be some. For any potential implementors who may be reading, one detail I left out is that that a small number of private trampoline methods will need to be added to _AssignmentStatementAnalyzer to assist in forwarding requests to the original SemanticAnalyzer that aren't handled internally by _AssignmentStatementAnalyzer. If there are no other immediate implementor volunteers then I suggest closing this issue. |
This refactoring is needed, although it's not exactly about AssignmentStatement (a nametuple might be a base class expression). Personally I'd move everything to a different module, not just a class - and perhaps no class is needed at all. This is of course related to #699. Note that there are two independent tasks here: the parsing of "external" language constructs, and the semantic analysis of these constructs. The first task should IMO done before semantic analysis, as a pre-parsing phase. |
I want to propose a refactoring that I will volunteer to execute. Before spending time on it, I would like to see if there are any high-level objections.
Implementation Proposal
(1) The following tree of methods will be extracted from SemanticAnalyzer and moved to a new class _AssignmentStatementAnalyzer that is used internally by SemanticAnalyzer.
All methods in the new _AssignmentStatementAnalyzer class except visit_assignment_stmt() will be prefixed with underscore to indicate that they are private to the class.
(2) SemanticAnalyzer.visit_assignment_stmt() will be altered to delegate to _AssignmentStatementAnalyzer.visit_assignment_stmt().
Benefits
I believe that this change will significantly improve the readability of SemanticAnalyzer for future readers.
The text was updated successfully, but these errors were encountered: