-
Notifications
You must be signed in to change notification settings - Fork 194
refactor(type): explicitly declare the MouseListenerSet interface #770
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
refactor(type): explicitly declare the MouseListenerSet interface #770
Conversation
Declare it on classes that must implement it. This prevents to implement wrong method signature or to miss a method.
WalkthroughThis update standardizes the implementation of mouse event handler interfaces across multiple classes in the codebase. Several classes now explicitly implement the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Graph
participant MouseListenerSet (Handler)
User->>Graph: Triggers mouse event (down/move/up)
Graph->>MouseListenerSet: Calls mouseDown/_Move/_Up(_sender, event)
MouseListenerSet-->>Graph: Handles event (parameter _sender may be unused)
Graph-->>User: Event processed
This diagram represents the standardized flow of mouse events from the user through the graph to the handlers implementing the Suggested labels
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
packages/core/src/editor/Editor.ts
(2 hunks)packages/core/src/view/GraphView.ts
(1 hunks)packages/core/src/view/cell/CellTracker.ts
(4 hunks)packages/core/src/view/handler/EdgeHandler.ts
(5 hunks)packages/core/src/view/handler/VertexHandler.ts
(5 hunks)packages/core/src/view/other/DragSource.ts
(7 hunks)packages/core/src/view/other/Outline.ts
(5 hunks)packages/core/src/view/other/PanningManager.ts
(1 hunks)packages/core/src/view/plugins/ConnectionHandler.ts
(5 hunks)packages/core/src/view/plugins/RubberBandHandler.ts
(5 hunks)packages/core/src/view/plugins/SelectionCellsHandler.ts
(2 hunks)packages/core/src/view/plugins/TooltipHandler.ts
(4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (8)
packages/core/src/view/plugins/SelectionCellsHandler.ts (1)
packages/core/src/types.ts (2)
GraphPlugin
(1109-1111)MouseListenerSet
(1135-1139)
packages/core/src/view/handler/EdgeHandler.ts (1)
packages/core/src/types.ts (1)
MouseListenerSet
(1135-1139)
packages/core/src/view/plugins/RubberBandHandler.ts (1)
packages/core/src/types.ts (2)
GraphPlugin
(1109-1111)MouseListenerSet
(1135-1139)
packages/core/src/view/cell/CellTracker.ts (1)
packages/core/src/types.ts (1)
MouseListenerSet
(1135-1139)
packages/core/src/view/other/Outline.ts (1)
packages/core/src/types.ts (1)
MouseListenerSet
(1135-1139)
packages/core/src/view/handler/VertexHandler.ts (1)
packages/core/src/types.ts (1)
MouseListenerSet
(1135-1139)
packages/core/src/view/plugins/ConnectionHandler.ts (1)
packages/core/src/types.ts (2)
GraphPlugin
(1109-1111)MouseListenerSet
(1135-1139)
packages/core/src/view/plugins/TooltipHandler.ts (1)
packages/core/src/types.ts (2)
GraphPlugin
(1109-1111)MouseListenerSet
(1135-1139)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build (windows-2022)
- GitHub Check: build (ubuntu-22.04)
🔇 Additional comments (37)
packages/core/src/view/plugins/SelectionCellsHandler.ts (2)
27-27
: Good addition of type-safe interface import.The explicit
type
import ofMouseListenerSet
prepares for the interface implementation, improving code organization and type safety.
51-51
: Excellent enhancement to class declaration.Explicitly implementing the
MouseListenerSet
interface alongsideGraphPlugin
provides stronger type checking and better documents the class's capabilities. This ensures the class correctly implements all required mouse handler methods with proper signatures, preventing potential runtime errors.packages/core/src/view/other/PanningManager.ts (1)
44-56
: Clean and effective parameter simplification.Removing unused parameters from the mouse event handlers improves code clarity while maintaining interface compatibility. This change makes it immediately clear that these methods don't use any event information. The implementation remains unchanged functionally but is now more maintainable and easier to understand.
packages/core/src/view/GraphView.ts (1)
2173-2177
: Simplified method signature improves clarity.Removing unused parameters from the
mouseDown
handler creates cleaner, more maintainable code by making it immediately obvious the method doesn't use any event parameters. This refactoring maintains interface compatibility while improving code readability.packages/core/src/editor/Editor.ts (1)
1628-1628
: Improved type safety and parameter naming convention.Changing the parameter type from
any
toEventSource
and renaming fromsender
to_sender
follows best practices for TypeScript interfaces. The underscore prefix clearly indicates the parameter is intentionally unused, while the explicit type ensures compatibility with theMouseListenerSet
interface and helps catch potential type errors.Also applies to: 1643-1643, 1649-1649
packages/core/src/view/other/DragSource.ts (4)
55-57
: Documentation improvements look good.The class documentation has been reformatted for better readability while maintaining the original content.
126-127
: Updated reference from mxGraph to Graph in documentation.The comment has been updated to use the current class name
Graph
instead of legacymxGraph
, which improves consistency.
141-142
: Updated references from mxGuide to Guide in comments.The comments have been updated to reference the current class name
Guide
instead of legacymxGuide
, maintaining consistency with the codebase.Also applies to: 146-147
294-299
: Documentation example code has been modernized.The code example in the comment has been improved:
- Changed variable declaration from
var
toconst
- Updated event utility references from
mxEvent
toEventUtils
This aligns with modern JavaScript practices and current naming in the codebase.
packages/core/src/view/plugins/ConnectionHandler.ts (3)
60-66
: Updated imports to include MouseListenerSet as a type import.The import statement now correctly includes the
MouseListenerSet
type, which is necessary for the interface implementation.
207-207
: Explicitly implementing MouseListenerSet interface.The ConnectionHandler class now explicitly implements the MouseListenerSet interface alongside GraphPlugin. This guarantees that the class implements all required mouse event handler methods with the correct signatures, improving type safety.
754-754
: Updated mouse event handler parameters to indicate unused parameters.The first parameter in mouse event handlers has been renamed from
sender
to_sender
to clearly indicate that it's unused within these methods. This follows TypeScript conventions for marking unused parameters.Also applies to: 1026-1026, 1491-1491
packages/core/src/view/plugins/TooltipHandler.ts (3)
28-28
: Added MouseListenerSet to import statement.The import statement now properly includes the MouseListenerSet type, which is necessary for the interface implementation.
40-40
: TooltipHandler now explicitly implements MouseListenerSet interface.Explicitly implementing the MouseListenerSet interface ensures that the class implements all required mouse event handler methods with the correct signatures, improving type safety and preventing potential errors.
177-178
: Updated mouse event handler parameters and documentation.The parameter naming has been updated from
sender
to_sender
to indicate it's unused in the method implementations, and some comment text has been improved. This follows TypeScript conventions for marking unused parameters.Also applies to: 185-185, 210-210
packages/core/src/view/handler/EdgeHandler.ts (3)
59-59
: Updated imports to include MouseListenerSet.The import statement now properly includes the MouseListenerSet type, which is necessary for the interface implementation.
77-77
: EdgeHandler now explicitly implements MouseListenerSet.The class now explicitly implements the MouseListenerSet interface, ensuring that it provides all required mouse event handler methods with the correct signatures. This improves type safety and enforces the interface contract.
787-787
: Updated mouse event handler parameters to indicate unused parameters.The first parameter in mouse event handlers has been renamed from
sender
to_sender
to clearly indicate that it's unused within these methods. This is a good practice in TypeScript to mark parameters that are part of an interface but not used in the implementation.Also applies to: 1311-1311, 1419-1419
packages/core/src/view/cell/CellTracker.ts (3)
24-24
: Looks good: Import of MouseListenerSet as type.The import has been correctly updated to import
MouseListenerSet
as a type from the types file.
79-79
: Good: Explicit implementation of MouseListenerSet interface.Explicitly implementing the
MouseListenerSet
interface helps ensure type safety and enforces the correct method signatures.
106-106
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.packages/core/src/view/handler/VertexHandler.ts (5)
33-34
: Looks good: Import of MouseListenerSet as type.The import has been correctly updated to import
MouseListenerSet
as a type from the types file.
49-49
: Good: Explicit implementation of MouseListenerSet interface.Explicitly implementing the
MouseListenerSet
interface helps ensure type safety and enforces the correct method signatures.
635-635
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.
834-834
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.
1210-1210
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.packages/core/src/view/plugins/RubberBandHandler.ts (5)
34-35
: Looks good: Import of MouseListenerSet and GraphPlugin as types.The imports have been correctly updated to import both
MouseListenerSet
andGraphPlugin
as types from the types file.
60-60
: Good: Explicit implementation of MouseListenerSet and GraphPlugin interfaces.Explicitly implementing both the
MouseListenerSet
andGraphPlugin
interfaces helps ensure type safety and enforces the correct method signatures.
180-180
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.
243-243
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.
300-300
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.packages/core/src/view/other/Outline.ts (6)
38-38
: Looks good: Import of MouseListenerSet as type and updating Listenable import.The imports have been correctly updated to import
MouseListenerSet
as a type and changeListenable
to a type import as well.
81-81
: Good: Explicit implementation of MouseListenerSet interface.Explicitly implementing the
MouseListenerSet
interface helps ensure type safety and enforces the correct method signatures.
82-87
: Clean constructor parameter simplification.Changed the constructor parameter
container
to be optional without a default value, which is cleaner and makes the optional nature of the parameter more explicit in the signature.
575-575
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.
607-607
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.
702-702
: Good: Renamed unused parameter to indicate it's not used.Renaming the
sender
parameter to_sender
clearly indicates that this parameter is not used in the method implementation, which is a good practice.
|
Declare it on classes that must implement it.
This avoids implementing the wrong method signature or omitting a method.
Summary by CodeRabbit