From 67c81d20589876178ab96161abcfe8881824429c Mon Sep 17 00:00:00 2001 From: Dominique Luna Date: Sun, 24 Dec 2023 22:36:01 +1000 Subject: [PATCH] rm @inline i dunno what this even does tbh --- src/JuliaFormatter.jl | 2 +- src/fst.jl | 76 ++++++++++++++++++------------------ src/state.jl | 8 ++-- src/styles/blue/nest.jl | 18 ++++----- src/styles/default/pretty.jl | 10 ++--- src/styles/yas/nest.jl | 32 +++++++-------- 6 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/JuliaFormatter.jl b/src/JuliaFormatter.jl index bd2bf82d8..5d6b35e97 100644 --- a/src/JuliaFormatter.jl +++ b/src/JuliaFormatter.jl @@ -51,7 +51,7 @@ end abstract type AbstractStyle end -@inline options(s::AbstractStyle) = NamedTuple() +options(s::AbstractStyle) = NamedTuple() struct NoopStyle <: AbstractStyle end diff --git a/src/fst.jl b/src/fst.jl index 9509d57bf..5426fec9c 100644 --- a/src/fst.jl +++ b/src/fst.jl @@ -174,17 +174,17 @@ function FST( ) end -@inline function Base.setindex!(fst::FST, node::FST, ind::Int) +function Base.setindex!(fst::FST, node::FST, ind::Int) nodes = fst.nodes::Vector{FST} fst.len -= nodes[ind].len nodes[ind] = node fst.len += node.len end -@inline Base.getindex(fst::FST, inds...) = (fst.nodes::Vector{FST})[inds...] -@inline Base.lastindex(fst::FST) = length(fst.nodes::Vector{FST}) -@inline Base.firstindex(fst::FST) = 1 -@inline Base.length(fst::FST) = fst.len -@inline function Base.iterate(fst::FST, state = 1) +Base.getindex(fst::FST, inds...) = (fst.nodes::Vector{FST})[inds...] +Base.lastindex(fst::FST) = length(fst.nodes::Vector{FST}) +Base.firstindex(fst::FST) = 1 +Base.length(fst::FST) = fst.len +function Base.iterate(fst::FST, state = 1) nodes = fst.nodes::Vector{FST} if state > length(nodes::Vector{FST}) return nothing @@ -192,21 +192,21 @@ end return nodes[state], state + 1 end -@inline function Base.insert!(fst::FST, ind::Int, node::FST) +function Base.insert!(fst::FST, ind::Int, node::FST) insert!(fst.nodes::Vector{FST}, ind, node) fst.len += node.len return end -@inline Newline(; length = 0, nest_behavior = AllowNest) = +Newline(; length = 0, nest_behavior = AllowNest) = FST(NEWLINE, -1, -1, 0, length, "\n", nothing, nothing, nest_behavior, 0, -1, nothing) -@inline Semicolon() = +Semicolon() = FST(SEMICOLON, -1, -1, 0, 1, ";", nothing, nothing, AllowNest, 0, -1, nothing) -@inline TrailingComma() = +TrailingComma() = FST(TRAILINGCOMMA, -1, -1, 0, 0, "", nothing, nothing, AllowNest, 0, -1, nothing) -@inline TrailingSemicolon() = +TrailingSemicolon() = FST(TRAILINGSEMICOLON, -1, -1, 0, 0, "", nothing, nothing, AllowNest, 0, -1, nothing) -@inline InverseTrailingSemicolon() = FST( +InverseTrailingSemicolon() = FST( INVERSETRAILINGSEMICOLON, -1, -1, @@ -220,36 +220,36 @@ end -1, nothing, ) -@inline Whitespace(n) = +Whitespace(n) = FST(WHITESPACE, -1, -1, 0, n, " "^n, nothing, nothing, AllowNest, 0, -1, nothing) -@inline Placeholder(n) = +Placeholder(n) = FST(PLACEHOLDER, -1, -1, 0, n, " "^n, nothing, nothing, AllowNest, 0, -1, nothing) -@inline Notcode(startline, endline) = +Notcode(startline, endline) = FST(NOTCODE, startline, endline, 0, 0, "", nothing, nothing, AllowNest, 0, -1, nothing) -@inline InlineComment(line) = +InlineComment(line) = FST(INLINECOMMENT, line, line, 0, 0, "", nothing, nothing, AllowNest, 0, -1, nothing) -@inline must_nest(fst::FST) = fst.nest_behavior === AlwaysNest -@inline cant_nest(fst::FST) = fst.nest_behavior === NeverNest -@inline can_nest(fst::FST) = fst.nest_behavior === AllowNest +must_nest(fst::FST) = fst.nest_behavior === AlwaysNest +cant_nest(fst::FST) = fst.nest_behavior === NeverNest +can_nest(fst::FST) = fst.nest_behavior === AllowNest -@inline is_leaf(cst::CSTParser.EXPR) = cst.args === nothing -@inline is_leaf(fst::FST) = fst.nodes === nothing +is_leaf(cst::CSTParser.EXPR) = cst.args === nothing +is_leaf(fst::FST) = fst.nodes === nothing -@inline is_punc(cst::CSTParser.EXPR) = CSTParser.ispunctuation(cst) -@inline is_punc(fst::FST) = fst.typ === PUNCTUATION +is_punc(cst::CSTParser.EXPR) = CSTParser.ispunctuation(cst) +is_punc(fst::FST) = fst.typ === PUNCTUATION -@inline is_end(x::CSTParser.EXPR) = x.head === :END && x.val == "end" -@inline is_end(x::FST) = x.typ === KEYWORD && x.val == "end" +is_end(x::CSTParser.EXPR) = x.head === :END && x.val == "end" +is_end(x::FST) = x.typ === KEYWORD && x.val == "end" -@inline is_colon(x::FST) = x.typ === OPERATOR && x.val == ":" +is_colon(x::FST) = x.typ === OPERATOR && x.val == ":" -@inline is_comma(fst::FST) = fst.typ === TRAILINGCOMMA || (is_punc(fst) && fst.val == ",") -@inline is_comment(fst::FST) = fst.typ === INLINECOMMENT || fst.typ === NOTCODE +is_comma(fst::FST) = fst.typ === TRAILINGCOMMA || (is_punc(fst) && fst.val == ",") +is_comment(fst::FST) = fst.typ === INLINECOMMENT || fst.typ === NOTCODE -@inline is_circumflex_accent(x::CSTParser.EXPR) = +is_circumflex_accent(x::CSTParser.EXPR) = CSTParser.isoperator(x) && endswith(CSTParser.valof(x)::String, "^") -@inline is_fwdfwd_slash(x::CSTParser.EXPR) = +is_fwdfwd_slash(x::CSTParser.EXPR) = CSTParser.isoperator(x) && endswith(CSTParser.valof(x)::String, "//") # TODO: fix this @@ -264,7 +264,7 @@ function is_multiline(fst::FST) ) end -@inline is_macrocall(fst::FST) = fst.typ === MacroCall || fst.typ === MacroBlock +is_macrocall(fst::FST) = fst.typ === MacroCall || fst.typ === MacroBlock function is_macrodoc(cst::CSTParser.EXPR) cst.head === :macrocall && @@ -430,7 +430,7 @@ function get_args(args::Nothing) return CSTParser.EXPR[] end -@inline n_args(x) = length(get_args(x)) +n_args(x) = length(get_args(x)) """ add_node!( @@ -693,7 +693,7 @@ function add_node!( nothing end -@inline function is_prev_newline(fst::FST) +function is_prev_newline(fst::FST) if fst.typ === NEWLINE return true elseif is_leaf(fst) || length(fst.nodes::Vector) == 0 @@ -707,7 +707,7 @@ end Returns the length to any node type in `ntyps` based off the `start` index. """ -@inline function length_to(fst::FST, ntyps; start::Int = 1) +function length_to(fst::FST, ntyps; start::Int = 1) fst.typ in ntyps && return 0, true is_leaf(fst) && return length(fst), false len = 0 @@ -720,14 +720,14 @@ Returns the length to any node type in `ntyps` based off the `start` index. return len, false end -@inline is_closer(fst::FST) = +is_closer(fst::FST) = fst.typ === PUNCTUATION && (fst.val == "}" || fst.val == ")" || fst.val == "]") -@inline is_closer(cst::CSTParser.EXPR) = +is_closer(cst::CSTParser.EXPR) = cst.head === :RBRACE || cst.head === :RPAREN || cst.head === :RSQUARE -@inline is_opener(fst::FST) = +is_opener(fst::FST) = fst.typ === PUNCTUATION && (fst.val == "{" || fst.val == "(" || fst.val == "[") -@inline is_opener(cst::CSTParser.EXPR) = +is_opener(cst::CSTParser.EXPR) = cst.head === :LBRACE || cst.head === :LPAREN || cst.head === :LSQUARE function is_iterable(x::CSTParser.EXPR) diff --git a/src/state.jl b/src/state.jl index e2a173a62..695b83079 100644 --- a/src/state.jl +++ b/src/state.jl @@ -11,8 +11,8 @@ mutable struct State end State(doc, opts) = State(doc, 0, 1, 0, true, opts) -@inline nspaces(s::State) = s.indent -@inline hascomment(d::Document, line::Integer) = haskey(d.comments, line) +nspaces(s::State) = s.indent +hascomment(d::Document, line::Integer) = haskey(d.comments, line) """ has_semicolon(d::Document, line::Integer) @@ -24,12 +24,12 @@ function has_semicolon(d::Document, line::Integer) return length(d.semicolons[line]) > 0 end -@inline function cursor_loc(s::State, offset::Integer) +function cursor_loc(s::State, offset::Integer) l = s.doc.range_to_line[offset:offset] r = s.doc.line_to_range[l] return (l, offset - first(r) + 1, length(r)) end -@inline cursor_loc(s::State) = cursor_loc(s, s.offset) +cursor_loc(s::State) = cursor_loc(s, s.offset) function on_same_line(s::State, offset1::Int, offset2::Int) l = s.doc.range_to_line[offset1:offset1] diff --git a/src/styles/blue/nest.jl b/src/styles/blue/nest.jl index 103c459cf..ce0a39c0d 100644 --- a/src/styles/blue/nest.jl +++ b/src/styles/blue/nest.jl @@ -131,15 +131,15 @@ function n_tuple!(bs::BlueStyle, fst::FST, s::State) nest!(style, nodes, s, fst.indent, extra_margin = extra_margin) end end -@inline n_call!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) -@inline n_curly!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) -@inline n_macrocall!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) -@inline n_ref!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) -@inline n_braces!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) -@inline n_vect!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) -@inline n_parameters!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) -@inline n_invisbrackets!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) -@inline n_bracescat!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) +n_call!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) +n_curly!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) +n_macrocall!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) +n_ref!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) +n_braces!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) +n_vect!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) +n_parameters!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) +n_invisbrackets!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) +n_bracescat!(bs::BlueStyle, fst::FST, s::State) = n_tuple!(bs, fst, s) function n_conditionalopcall!(bs::BlueStyle, fst::FST, s::State) style = getstyle(bs) diff --git a/src/styles/default/pretty.jl b/src/styles/default/pretty.jl index a5c25c170..5563dd45e 100644 --- a/src/styles/default/pretty.jl +++ b/src/styles/default/pretty.jl @@ -175,7 +175,7 @@ end p_file(style::S, cst::CSTParser.EXPR, s::State) where {S<:AbstractStyle} = p_file(DefaultStyle(style), cst, s) -@inline function p_nonstdidentifier(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) +function p_nonstdidentifier(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) style = getstyle(ds) t = FST(NonStdIdentifier, cst, nspaces(s)) for a in cst.args::Vector{CSTParser.EXPR} @@ -186,7 +186,7 @@ end p_nonstdidentifier(style::S, cst::CSTParser.EXPR, s::State) where {S<:AbstractStyle} = p_nonstdidentifier(DefaultStyle(style), cst, s) -@inline function p_identifier(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) +function p_identifier(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) loc = cursor_loc(s) s.offset += length(cst.val::AbstractString) + (cst.fullspan - cst.span) FST(IDENTIFIER, loc[2], loc[1], loc[1], cst.val::AbstractString) @@ -194,7 +194,7 @@ end p_identifier(style::S, cst::CSTParser.EXPR, s::State) where {S<:AbstractStyle} = p_identifier(DefaultStyle(style), cst, s) -@inline function p_operator(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) +function p_operator(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) loc = cursor_loc(s) s.offset += length(cst.val::AbstractString) + (cst.fullspan - cst.span) @@ -205,7 +205,7 @@ end p_operator(style::S, cst::CSTParser.EXPR, s::State) where {S<:AbstractStyle} = p_operator(DefaultStyle(style), cst, s) -@inline function p_keyword(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) +function p_keyword(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) loc = cursor_loc(s) s.offset += cst.fullspan FST(KEYWORD, loc[2], loc[1], loc[1], cst.val::AbstractString) @@ -213,7 +213,7 @@ end p_keyword(style::S, cst::CSTParser.EXPR, s::State) where {S<:AbstractStyle} = p_keyword(DefaultStyle(style), cst, s) -@inline function p_punctuation(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) +function p_punctuation(ds::DefaultStyle, cst::CSTParser.EXPR, s::State) loc = cursor_loc(s) s.offset += cst.fullspan val = if cst.val === nothing && cst.head === :DOT diff --git a/src/styles/yas/nest.jl b/src/styles/yas/nest.jl index 20f922e5e..7f0690a4f 100644 --- a/src/styles/yas/nest.jl +++ b/src/styles/yas/nest.jl @@ -53,11 +53,11 @@ function n_call!(ys::YASStyle, fst::FST, s::State) end end end -@inline n_curly!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) -@inline n_ref!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) -@inline n_macrocall!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) -@inline n_typedcomprehension!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) -@inline n_typedvcat!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) +n_curly!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) +n_ref!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) +n_macrocall!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) +n_typedcomprehension!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) +n_typedvcat!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s) function n_tuple!(ys::YASStyle, fst::FST, s::State) style = getstyle(ys) @@ -89,13 +89,13 @@ function n_tuple!(ys::YASStyle, fst::FST, s::State) end end end -@inline n_braces!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) -@inline n_vect!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) -@inline n_parameters!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) -@inline n_invisbrackets!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) -@inline n_comprehension!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) -@inline n_vcat!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) -@inline n_bracescat!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) +n_braces!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) +n_vect!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) +n_parameters!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) +n_invisbrackets!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) +n_comprehension!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) +n_vcat!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) +n_bracescat!(ys::YASStyle, fst::FST, s::State) = n_tuple!(ys, fst, s) function n_generator!(ys::YASStyle, fst::FST, s::State) style = getstyle(ys) @@ -123,8 +123,8 @@ function n_generator!(ys::YASStyle, fst::FST, s::State) end end end -@inline n_filter!(ys::YASStyle, fst::FST, s::State) = n_generator!(ys, fst, s) -@inline n_flatten!(ys::YASStyle, fst::FST, s::State) = n_generator!(ys, fst, s) +n_filter!(ys::YASStyle, fst::FST, s::State) = n_generator!(ys, fst, s) +n_flatten!(ys::YASStyle, fst::FST, s::State) = n_generator!(ys, fst, s) function n_whereopcall!(ys::YASStyle, fst::FST, s::State) style = getstyle(ys) @@ -173,8 +173,8 @@ function n_using!(ys::YASStyle, fst::FST, s::State) end end end -@inline n_export!(ys::YASStyle, fst::FST, s::State) = n_using!(ys, fst, s) -@inline n_import!(ys::YASStyle, fst::FST, s::State) = n_using!(ys, fst, s) +n_export!(ys::YASStyle, fst::FST, s::State) = n_using!(ys, fst, s) +n_import!(ys::YASStyle, fst::FST, s::State) = n_using!(ys, fst, s) function n_chainopcall!(ys::YASStyle, fst::FST, s::State) style = getstyle(ys)