Use Levenshtein distance to display similar artifact names if given name is not found#2052
Merged
Use Levenshtein distance to display similar artifact names if given name is not found#2052
Conversation
🦋 Changeset detectedLatest commit: b62b5e3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
fvictorio
reviewed
Nov 15, 2021
fvictorio
reviewed
Nov 18, 2021
fvictorio
approved these changes
Nov 19, 2021
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Core feature goal: Implement an appropriate edit-distance algorithm (Levenshtein) to suggest similar artifacts if a requested artifact is not found (i.e. if a user made a typo in the name)
New functions:
Public:
formArtifactPathFromFullyQualifiedNamePrivate:
_trueCasePath_trueCasePathSync_getAllContractNamesFromFiles_getAllFullyQualifiedNamesSync_handleWrongArtifactForFullyQualifiedName_handleWrongArtifactForContractName_handleMultipleSimilarContractNames_getSimilarContractNamesfindDistance(Levenshtein logic)Added Error 703:
ERRORS.ARTIFACTS.TYPO_SUGGESTIONExample:
Some existing functions were edited such as moving the
true-case-pathlogic fromreadArtifactandreadArtifactSyncinto_getArtifactPathFromFullyQualifiedName(now called_getValidArtifactPathFromFullyQualifiedNamedue to needing to keep the old function for TypeChain).The reasoning behind moving this logic is that it was only needed when the user passed in a fully qualified name, so its placement in the top-level public function was misleading. Moving it fully into the dedicated "fully qualified name" code path is clearer and doesn't make additional, unnecessary file system calls when a contract name is given instead of an FQN.