Skip to content

Commit

Permalink
Change attribute keys to reduce conflicts with @attr uses
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Feb 16, 2024
1 parent 958b913 commit 105e0b7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/PrettyPrinting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1407,8 +1407,8 @@ If `override` is `false`, the name is only set if there is no name already set.
This function errors if `obj` does not support attribute storage.
"""
function set_name!(obj, name::String; override::Bool=true)
override || isnothing(get_attribute(obj, :name)) || return
set_attribute!(obj, :name => name)
override || isnothing(get_attribute(obj, :_name)) || return
set_attribute!(obj, :_name => name)

Check warning on line 1411 in src/PrettyPrinting.jl

View check run for this annotation

Codecov / codecov/patch

src/PrettyPrinting.jl#L1410-L1411

Added lines #L1410 - L1411 were not covered by tests
end

"""
Expand All @@ -1422,7 +1422,7 @@ If `override` is `false`, the name is only set if there is no name already set.
This function errors if `obj` does not support attribute storage.
"""
function set_name!(obj; override::Bool=true)
override || isnothing(get_attribute(obj, :name)) || return
override || isnothing(get_attribute(obj, :_name)) || return

Check warning on line 1425 in src/PrettyPrinting.jl

View check run for this annotation

Codecov / codecov/patch

src/PrettyPrinting.jl#L1425

Added line #L1425 was not covered by tests
sy = find_name(obj)
isnothing(sy) && return
set_name!(obj, string(sy); override=true)
Expand Down Expand Up @@ -1457,7 +1457,7 @@ For this to work in doctests, one should call
function find_name(obj, M=Main; all::Bool=false)
AbstractAlgebra._is_attribute_storing_type(typeof(obj)) || return find_new_name(obj, M; all)

cached_name = get_attribute(obj, :cached_name)
cached_name = get_attribute(obj, :_cached_name)

Check warning on line 1460 in src/PrettyPrinting.jl

View check run for this annotation

Codecov / codecov/patch

src/PrettyPrinting.jl#L1460

Added line #L1460 was not covered by tests
if !isnothing(cached_name)
cached_name_sy = Symbol(cached_name)
if M === Main && get_current_module() != Main
Expand All @@ -1470,7 +1470,7 @@ function find_name(obj, M=Main; all::Bool=false)
end
end
name = find_new_name(obj, M; all)
set_attribute!(obj, :cached_name => name)
set_attribute!(obj, :_cached_name => name)

Check warning on line 1473 in src/PrettyPrinting.jl

View check run for this annotation

Codecov / codecov/patch

src/PrettyPrinting.jl#L1473

Added line #L1473 was not covered by tests
return name
end

Expand Down Expand Up @@ -1506,7 +1506,7 @@ This function tries to find a name in the following order:
"""
function get_name(obj)
if AbstractAlgebra._is_attribute_storing_type(typeof(obj))
name = get_attribute(obj, :name)
name = get_attribute(obj, :_name)

Check warning on line 1509 in src/PrettyPrinting.jl

View check run for this annotation

Codecov / codecov/patch

src/PrettyPrinting.jl#L1509

Added line #L1509 was not covered by tests
isnothing(name) || return name
end

Expand Down

0 comments on commit 105e0b7

Please sign in to comment.