Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: tools/gn/string_utils.h

Issue 1681363003: Add spell-checking to `gn help`. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to string_utils, add tests Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/gn/string_utils.h
diff --git a/tools/gn/string_utils.h b/tools/gn/string_utils.h
index 07be4c856e4708cda02b6a7fd5aa466f0dc3a03d..744714a754a35b674ffb6e432562774a4ac2b962 100644
--- a/tools/gn/string_utils.h
+++ b/tools/gn/string_utils.h
@@ -5,6 +5,8 @@
#ifndef TOOLS_GN_STRING_UTILS_H_
#define TOOLS_GN_STRING_UTILS_H_
+#include <vector>
+
#include "base/strings/string_piece.h"
class Err;
@@ -35,4 +37,17 @@ bool ExpandStringLiteral(Scope* scope,
Value* result,
Err* err);
+// Returns the minimum number of inserts, deleted, and replacements of
+// characters needed to transform s1 to s2, or max_edit_distance + 1 if
+// transforming s1 into s2 isn't possible in at most max_edit_distance steps.
+size_t EditDistance(const base::StringPiece& s1,
+ const base::StringPiece& s2,
+ size_t max_edit_distance);
+
+// Given a string |text| and a vector of correctly-spelled strings |words|,
+// returns the first string in |words| closest to |text|, or an empty
+// StringPiece if none of the strings in |words| is close.
+base::StringPiece SpellcheckString(const base::StringPiece& text,
+ const std::vector<base::StringPiece>& words);
+
#endif // TOOLS_GN_STRING_UTILS_H_

Powered by Google App Engine
This is Rietveld 408576698