mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 04:17:34 +00:00
Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
This commit is contained in:
parent
6e19ab2bbc
commit
57dc179b1f
597 changed files with 1973 additions and 1972 deletions
|
@ -630,7 +630,7 @@ void BarewordLiteral::highlight_in_editor(Line::Editor& editor, Shell& shell, Hi
|
|||
auto name = shell.help_path_for({}, *runnable);
|
||||
if (name.has_value()) {
|
||||
auto url = URL::create_with_help_scheme(name.release_value(), shell.hostname);
|
||||
style = bold.unified_with(Line::Style::Hyperlink(url.to_string()));
|
||||
style = bold.unified_with(Line::Style::Hyperlink(url.to_deprecated_string()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -662,7 +662,7 @@ void BarewordLiteral::highlight_in_editor(Line::Editor& editor, Shell& shell, Hi
|
|||
auto realpath = shell.resolve_path(m_text);
|
||||
auto url = URL::create_with_file_scheme(realpath);
|
||||
url.set_host(shell.hostname);
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Hyperlink(url.to_string()) });
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Hyperlink(url.to_deprecated_string()) });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -966,7 +966,7 @@ RefPtr<Value> DoubleQuotedString::run(RefPtr<Shell> shell)
|
|||
|
||||
builder.join(""sv, values);
|
||||
|
||||
return make_ref_counted<StringValue>(builder.to_string());
|
||||
return make_ref_counted<StringValue>(builder.to_deprecated_string());
|
||||
}
|
||||
|
||||
void DoubleQuotedString::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetadata metadata)
|
||||
|
@ -1397,7 +1397,7 @@ RefPtr<Value> Heredoc::run(RefPtr<Shell> shell)
|
|||
builder.append('\n');
|
||||
}
|
||||
|
||||
return make_ref_counted<StringValue>(builder.to_string());
|
||||
return make_ref_counted<StringValue>(builder.to_deprecated_string());
|
||||
}
|
||||
|
||||
void Heredoc::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetadata metadata)
|
||||
|
@ -2171,7 +2171,7 @@ RefPtr<Value> MatchExpr::run(RefPtr<Shell> shell)
|
|||
spans.ensure_capacity(match.n_capture_groups);
|
||||
for (size_t i = 0; i < match.n_capture_groups; ++i) {
|
||||
auto& capture = match.capture_group_matches[0][i];
|
||||
spans.append(capture.view.to_string());
|
||||
spans.append(capture.view.to_deprecated_string());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
|
@ -2498,7 +2498,7 @@ void PathRedirectionNode::highlight_in_editor(Line::Editor& editor, Shell& shell
|
|||
path = DeprecatedString::formatted("{}/{}", shell.cwd, path);
|
||||
auto url = URL::create_with_file_scheme(path);
|
||||
url.set_host(shell.hostname);
|
||||
editor.stylize({ position.start_offset, position.end_offset }, { Line::Style::Hyperlink(url.to_string()) });
|
||||
editor.stylize({ position.start_offset, position.end_offset }, { Line::Style::Hyperlink(url.to_deprecated_string()) });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2558,12 +2558,12 @@ RefPtr<Value> Range::run(RefPtr<Shell> shell)
|
|||
for (u32 code_point = start_code_point; code_point != end_code_point; code_point += step) {
|
||||
builder.clear();
|
||||
builder.append_code_point(code_point);
|
||||
values.append(make_ref_counted<StringValue>(builder.to_string()));
|
||||
values.append(make_ref_counted<StringValue>(builder.to_deprecated_string()));
|
||||
}
|
||||
// Append the ending code point too, most shells treat this as inclusive.
|
||||
builder.clear();
|
||||
builder.append_code_point(end_code_point);
|
||||
values.append(make_ref_counted<StringValue>(builder.to_string()));
|
||||
values.append(make_ref_counted<StringValue>(builder.to_deprecated_string()));
|
||||
} else {
|
||||
// Could be two numbers?
|
||||
auto start_int = start_str.to_int();
|
||||
|
@ -2667,7 +2667,7 @@ RefPtr<Value> ReadRedirection::run(RefPtr<Shell> shell)
|
|||
StringBuilder builder;
|
||||
builder.join(' ', path_segments);
|
||||
|
||||
command.redirections.append(PathRedirection::create(builder.to_string(), m_fd, PathRedirection::Read));
|
||||
command.redirections.append(PathRedirection::create(builder.to_deprecated_string(), m_fd, PathRedirection::Read));
|
||||
return make_ref_counted<CommandValue>(move(command));
|
||||
}
|
||||
|
||||
|
@ -2697,7 +2697,7 @@ RefPtr<Value> ReadWriteRedirection::run(RefPtr<Shell> shell)
|
|||
StringBuilder builder;
|
||||
builder.join(' ', path_segments);
|
||||
|
||||
command.redirections.append(PathRedirection::create(builder.to_string(), m_fd, PathRedirection::ReadWrite));
|
||||
command.redirections.append(PathRedirection::create(builder.to_deprecated_string(), m_fd, PathRedirection::ReadWrite));
|
||||
return make_ref_counted<CommandValue>(move(command));
|
||||
}
|
||||
|
||||
|
@ -3016,7 +3016,7 @@ RefPtr<Value> Juxtaposition::run(RefPtr<Shell> shell)
|
|||
builder.append(left[0]);
|
||||
builder.append(right[0]);
|
||||
|
||||
return make_ref_counted<StringValue>(builder.to_string());
|
||||
return make_ref_counted<StringValue>(builder.to_deprecated_string());
|
||||
}
|
||||
|
||||
// Otherwise, treat them as lists and create a list product.
|
||||
|
@ -3031,7 +3031,7 @@ RefPtr<Value> Juxtaposition::run(RefPtr<Shell> shell)
|
|||
for (auto& right_element : right) {
|
||||
builder.append(left_element);
|
||||
builder.append(right_element);
|
||||
result.append(builder.to_string());
|
||||
result.append(builder.to_deprecated_string());
|
||||
builder.clear();
|
||||
}
|
||||
}
|
||||
|
@ -3054,13 +3054,13 @@ void Juxtaposition::highlight_in_editor(Line::Editor& editor, Shell& shell, High
|
|||
path_builder.append(tilde_value);
|
||||
path_builder.append('/');
|
||||
path_builder.append(bareword_value);
|
||||
auto path = path_builder.to_string();
|
||||
auto path = path_builder.to_deprecated_string();
|
||||
|
||||
if (Core::File::exists(path)) {
|
||||
auto realpath = shell.resolve_path(path);
|
||||
auto url = URL::create_with_file_scheme(realpath);
|
||||
url.set_host(shell.hostname);
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Hyperlink(url.to_string()) });
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Hyperlink(url.to_deprecated_string()) });
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -3186,7 +3186,7 @@ RefPtr<Value> StringPartCompose::run(RefPtr<Shell> shell)
|
|||
builder.join(' ', left);
|
||||
builder.join(' ', right);
|
||||
|
||||
return make_ref_counted<StringValue>(builder.to_string());
|
||||
return make_ref_counted<StringValue>(builder.to_deprecated_string());
|
||||
}
|
||||
|
||||
void StringPartCompose::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetadata metadata)
|
||||
|
@ -3319,7 +3319,7 @@ DeprecatedString Tilde::text() const
|
|||
StringBuilder builder;
|
||||
builder.append('~');
|
||||
builder.append(m_username);
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
Tilde::Tilde(Position position, DeprecatedString username)
|
||||
|
@ -3349,7 +3349,7 @@ RefPtr<Value> WriteAppendRedirection::run(RefPtr<Shell> shell)
|
|||
StringBuilder builder;
|
||||
builder.join(' ', path_segments);
|
||||
|
||||
command.redirections.append(PathRedirection::create(builder.to_string(), m_fd, PathRedirection::WriteAppend));
|
||||
command.redirections.append(PathRedirection::create(builder.to_deprecated_string(), m_fd, PathRedirection::WriteAppend));
|
||||
return make_ref_counted<CommandValue>(move(command));
|
||||
}
|
||||
|
||||
|
@ -3379,7 +3379,7 @@ RefPtr<Value> WriteRedirection::run(RefPtr<Shell> shell)
|
|||
StringBuilder builder;
|
||||
builder.join(' ', path_segments);
|
||||
|
||||
command.redirections.append(PathRedirection::create(builder.to_string(), m_fd, PathRedirection::Write));
|
||||
command.redirections.append(PathRedirection::create(builder.to_deprecated_string(), m_fd, PathRedirection::Write));
|
||||
return make_ref_counted<CommandValue>(move(command));
|
||||
}
|
||||
|
||||
|
@ -3728,9 +3728,9 @@ Vector<DeprecatedString> TildeValue::resolve_as_list(RefPtr<Shell> shell)
|
|||
builder.append(m_username);
|
||||
|
||||
if (!shell)
|
||||
return { resolve_slices(shell, builder.to_string(), m_slices) };
|
||||
return { resolve_slices(shell, builder.to_deprecated_string(), m_slices) };
|
||||
|
||||
return { resolve_slices(shell, shell->expand_tilde(builder.to_string()), m_slices) };
|
||||
return { resolve_slices(shell, shell->expand_tilde(builder.to_deprecated_string()), m_slices) };
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Rewiring>> CloseRedirection::apply() const
|
||||
|
|
|
@ -449,7 +449,7 @@ int Shell::builtin_export(int argc, char const** argv)
|
|||
auto values = value->resolve_as_list(*this);
|
||||
StringBuilder builder;
|
||||
builder.join(' ', values);
|
||||
parts.append(builder.to_string());
|
||||
parts.append(builder.to_deprecated_string());
|
||||
} else {
|
||||
// Ignore the export.
|
||||
continue;
|
||||
|
@ -745,7 +745,7 @@ int Shell::builtin_pushd(int argc, char const** argv)
|
|||
}
|
||||
}
|
||||
|
||||
auto real_path = LexicalPath::canonicalized_path(path_builder.to_string());
|
||||
auto real_path = LexicalPath::canonicalized_path(path_builder.to_deprecated_string());
|
||||
|
||||
struct stat st;
|
||||
int rc = stat(real_path.characters(), &st);
|
||||
|
|
|
@ -44,7 +44,7 @@ DeprecatedString Formatter::format()
|
|||
if (!string.ends_with(' '))
|
||||
current_builder().append(m_trivia);
|
||||
|
||||
return current_builder().to_string();
|
||||
return current_builder().to_deprecated_string();
|
||||
}
|
||||
|
||||
void Formatter::with_added_indent(int indent, Function<void()> callback)
|
||||
|
@ -70,7 +70,7 @@ DeprecatedString Formatter::in_new_builder(Function<void()> callback, StringBuil
|
|||
{
|
||||
m_builders.append(move(new_builder));
|
||||
callback();
|
||||
return m_builders.take_last().to_string();
|
||||
return m_builders.take_last().to_deprecated_string();
|
||||
}
|
||||
|
||||
void Formatter::test_and_update_output_cursor(const AST::Node* node)
|
||||
|
|
|
@ -450,7 +450,7 @@ RefPtr<AST::Node> Shell::immediate_join(AST::ImmediateExpression& invoking_node,
|
|||
StringBuilder builder;
|
||||
builder.join(delimiter_str, value->resolve_as_list(*this));
|
||||
|
||||
return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), builder.to_string(), AST::StringLiteral::EnclosureType::None);
|
||||
return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), builder.to_deprecated_string(), AST::StringLiteral::EnclosureType::None);
|
||||
}
|
||||
|
||||
RefPtr<AST::Node> Shell::run_immediate_function(StringView str, AST::ImmediateExpression& invoking_node, NonnullRefPtrVector<AST::Node> const& arguments)
|
||||
|
|
|
@ -1459,7 +1459,7 @@ RefPtr<AST::Node> Parser::parse_string_inner(StringEndCondition condition)
|
|||
continue;
|
||||
}
|
||||
if (peek() == '$') {
|
||||
auto string_literal = create<AST::StringLiteral>(builder.to_string(), AST::StringLiteral::EnclosureType::DoubleQuotes); // String Literal
|
||||
auto string_literal = create<AST::StringLiteral>(builder.to_deprecated_string(), AST::StringLiteral::EnclosureType::DoubleQuotes); // String Literal
|
||||
auto read_concat = [&](auto&& node) {
|
||||
auto inner = create<AST::StringPartCompose>(
|
||||
move(string_literal),
|
||||
|
@ -1485,7 +1485,7 @@ RefPtr<AST::Node> Parser::parse_string_inner(StringEndCondition condition)
|
|||
builder.append(consume());
|
||||
}
|
||||
|
||||
return create<AST::StringLiteral>(builder.to_string(), AST::StringLiteral::EnclosureType::DoubleQuotes); // String Literal
|
||||
return create<AST::StringLiteral>(builder.to_deprecated_string(), AST::StringLiteral::EnclosureType::DoubleQuotes); // String Literal
|
||||
}
|
||||
|
||||
RefPtr<AST::Node> Parser::parse_variable()
|
||||
|
@ -1895,7 +1895,7 @@ RefPtr<AST::Node> Parser::parse_bareword()
|
|||
|
||||
auto current_end = m_offset;
|
||||
auto current_line = line();
|
||||
auto string = builder.to_string();
|
||||
auto string = builder.to_deprecated_string();
|
||||
if (string.starts_with('~')) {
|
||||
DeprecatedString username;
|
||||
RefPtr<AST::Node> tilde, text;
|
||||
|
@ -1988,7 +1988,7 @@ RefPtr<AST::Node> Parser::parse_glob()
|
|||
}
|
||||
}
|
||||
|
||||
return create<AST::Glob>(textbuilder.to_string()); // Glob
|
||||
return create<AST::Glob>(textbuilder.to_deprecated_string()); // Glob
|
||||
}
|
||||
|
||||
return bareword_part;
|
||||
|
|
|
@ -87,7 +87,7 @@ DeprecatedString Shell::prompt() const
|
|||
StringBuilder builder;
|
||||
builder.appendff("\033]0;{}@{}:{}\007", username, hostname, cwd);
|
||||
builder.appendff("\033[31;1m{}\033[0m@\033[37;1m{}\033[0m:\033[32;1m{}\033[0m$> ", username, hostname, cwd);
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
StringBuilder builder;
|
||||
|
@ -130,7 +130,7 @@ DeprecatedString Shell::prompt() const
|
|||
}
|
||||
builder.append(*ptr);
|
||||
}
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
};
|
||||
|
||||
return build_prompt();
|
||||
|
@ -159,17 +159,17 @@ DeprecatedString Shell::expand_tilde(StringView expression)
|
|||
if (!home) {
|
||||
auto passwd = getpwuid(getuid());
|
||||
VERIFY(passwd && passwd->pw_dir);
|
||||
return DeprecatedString::formatted("{}/{}", passwd->pw_dir, path.to_string());
|
||||
return DeprecatedString::formatted("{}/{}", passwd->pw_dir, path.to_deprecated_string());
|
||||
}
|
||||
return DeprecatedString::formatted("{}/{}", home, path.to_string());
|
||||
return DeprecatedString::formatted("{}/{}", home, path.to_deprecated_string());
|
||||
}
|
||||
|
||||
auto passwd = getpwnam(login_name.to_string().characters());
|
||||
auto passwd = getpwnam(login_name.to_deprecated_string().characters());
|
||||
if (!passwd)
|
||||
return expression;
|
||||
VERIFY(passwd->pw_dir);
|
||||
|
||||
return DeprecatedString::formatted("{}/{}", passwd->pw_dir, path.to_string());
|
||||
return DeprecatedString::formatted("{}/{}", passwd->pw_dir, path.to_deprecated_string());
|
||||
}
|
||||
|
||||
bool Shell::is_glob(StringView s)
|
||||
|
@ -391,7 +391,7 @@ DeprecatedString Shell::local_variable_or(StringView name, DeprecatedString cons
|
|||
if (value) {
|
||||
StringBuilder builder;
|
||||
builder.join(' ', value->resolve_as_list(*this));
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
return replacement;
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ DeprecatedString Shell::resolve_alias(StringView name) const
|
|||
Optional<Shell::RunnablePath> Shell::runnable_path_for(StringView name)
|
||||
{
|
||||
auto parts = name.split_view('/');
|
||||
auto path = name.to_string();
|
||||
auto path = name.to_deprecated_string();
|
||||
if (parts.size() > 1) {
|
||||
auto file = Core::File::open(path.characters(), Core::OpenMode::ReadOnly);
|
||||
if (!file.is_error() && !file.value()->is_directory() && access(path.characters(), X_OK) == 0)
|
||||
|
@ -914,7 +914,7 @@ void Shell::execute_process(Vector<char const*>&& argv)
|
|||
if (!line.starts_with("#!"sv))
|
||||
break;
|
||||
GenericLexer shebang_lexer { line.substring_view(2) };
|
||||
auto shebang = shebang_lexer.consume_until(is_any_of("\n\r"sv)).to_string();
|
||||
auto shebang = shebang_lexer.consume_until(is_any_of("\n\r"sv)).to_deprecated_string();
|
||||
argv.prepend(shebang.characters());
|
||||
int rc = execvp(argv[0], const_cast<char* const*>(argv.data()));
|
||||
if (rc < 0) {
|
||||
|
@ -1911,7 +1911,7 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s
|
|||
dbgln("LibLine: Unhandled completion kind: {}", kind);
|
||||
}
|
||||
} else {
|
||||
suggestions.append(parsed.to_string());
|
||||
suggestions.append(parsed.to_deprecated_string());
|
||||
}
|
||||
|
||||
return IterationDecision::Continue;
|
||||
|
@ -2172,7 +2172,7 @@ Shell::Shell()
|
|||
if (path.length())
|
||||
path.append(":"sv);
|
||||
path.append(DEFAULT_PATH_SV);
|
||||
setenv("PATH", path.to_string().characters(), true);
|
||||
setenv("PATH", path.to_deprecated_string().characters(), true);
|
||||
}
|
||||
|
||||
cache_path();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue