Skip to content

Excise JuliaHighighting, StyledStrings from stdlib and AnnotatedX from Base #58001

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions base/logging/ConsoleLogger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,8 @@ function handle_message(logger::ConsoleLogger, level::LogLevel, message, _module
# split into lines. This is specialised to improve type inference,
# and reduce the risk of resulting method invalidations.
message = string(message)
msglines = if Base._isannotated(message) && !isempty(Base.annotations(message))
message = Base.AnnotatedString(String(message), Base.annotations(message))
@NamedTuple{indent::Int, msg::Union{SubString{Base.AnnotatedString{String}}, SubString{String}}}[
(indent=0, msg=l) for l in split(chomp(message), '\n')]
else
[(indent=0, msg=l) for l in split(
chomp(convert(String, message)::String), '\n')]
end
msglines = [(indent=0, msg=l) for l in split(
chomp(convert(String, message)::String), '\n')]
stream::IO = logger.stream
if !(isopen(stream)::Bool)
stream = stderr
Expand Down
30 changes: 1 addition & 29 deletions base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -445,35 +445,9 @@ function match(re::Regex, str::Union{SubString{String}, String}, idx::Integer,
return result
end

function _annotatedmatch(m::RegexMatch{S}, str::AnnotatedString{S}) where {S<:AbstractString}
RegexMatch{AnnotatedString{S}}(
(@inbounds SubString{AnnotatedString{S}}(
str, m.match.offset, m.match.ncodeunits, Val(:noshift))),
Union{Nothing,SubString{AnnotatedString{S}}}[
if !isnothing(cap)
(@inbounds SubString{AnnotatedString{S}}(
str, cap.offset, cap.ncodeunits, Val(:noshift)))
end for cap in m.captures],
m.offset, m.offsets, m.regex)
end

function match(re::Regex, str::AnnotatedString)
m = match(re, str.string)
if !isnothing(m)
_annotatedmatch(m, str)
end
end

function match(re::Regex, str::AnnotatedString, idx::Integer, add_opts::UInt32=UInt32(0))
m = match(re, str.string, idx, add_opts)
if !isnothing(m)
_annotatedmatch(m, str)
end
end

match(r::Regex, s::AbstractString) = match(r, s, firstindex(s))
match(r::Regex, s::AbstractString, i::Integer) = throw(ArgumentError(
"regex matching is only available for the String and AnnotatedString types; use String(s) to convert"
"regex matching is only available for the String type; use String(s) to convert"
))

findnext(re::Regex, str::Union{String,SubString}, idx::Integer) = _findnext_re(re, str, idx, C_NULL)
Expand Down Expand Up @@ -726,8 +700,6 @@ struct RegexMatchIterator{S <: AbstractString}

RegexMatchIterator(regex::Regex, string::AbstractString, ovr::Bool=false) =
new{String}(regex, String(string), ovr)
RegexMatchIterator(regex::Regex, string::AnnotatedString, ovr::Bool=false) =
new{AnnotatedString{String}}(regex, AnnotatedString(String(string.string), string.annotations), ovr)
end
compile(itr::RegexMatchIterator) = (compile(itr.regex); itr)
eltype(::Type{<:RegexMatchIterator}) = RegexMatch
Expand Down
Loading