Skip to content
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

feat: Improve Matching Algorithm with Matching Representation #61

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

jpedroh
Copy link
Owner

@jpedroh jpedroh commented Jul 18, 2024

This PR addresses a known issue in our matching algorithm, which previously employed naive early return logic based solely on node kinds. This approach led to incorrect matchings of nodes that should not trigger the matching algorithm, such as different method declarations.

The proposed solution introduces the concept of a "matching representation" for each node to improve the matching algorithm's accuracy. For example, in the case of method declarations, this representation uses the method signature to ensure that left and right both correspond to the same method declaration, early returning with empty matchings if not. However, since not all nodes might have a decent matching representation, for non-terminal nodes, the representation defaults to the node's kind, and for terminal nodes, it uses both the kind and value.

The pull request also adds a test scenario extracted from the GitHub-API project that failed before this change and will be used for checking future regressions. Another test was removed because the change made the scenario tested unreachable.

It's worth mentioning that the matching representation acts as an identifier for the node, which we already handle in the unique label matching. However, we still need to improve the node identifier extraction, which will be addressed in a future PR.

Copy link

codesandbox bot commented Jul 18, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@coveralls
Copy link

coveralls commented Jul 18, 2024

Coverage Status

coverage: 82.296% (+0.09%) from 82.209%
when pulling 87b196e on feat-matching-representation
into 9a51e76 on main.

@jpedroh jpedroh changed the title feat: Add matching representation initial work feat: Improve Matching Algorithm with Matching Representation Jul 19, 2024
@jpedroh jpedroh marked this pull request as ready for review July 19, 2024 12:51
@jpedroh jpedroh merged commit f6d66a5 into main Jul 19, 2024
10 checks passed
@jpedroh jpedroh deleted the feat-matching-representation branch July 19, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants