compute_gaps Function

public function compute_gaps(source, views, ws, comment_spacing) result(gap)

The gap wanted before each token (GAP_KEEP, GAP_MIN1 or a number of blanks).

Arguments

Type IntentOptional Attributes Name
type(source_t), intent(in) :: source

the source

type(statement_view_t), intent(in) :: views(:)

the view of each item (see statement_views)

type(whitespace_options_t), intent(in) :: ws

modes of the whitespace rules

integer, intent(in) :: comment_spacing

blanks before a trailing comment, or -1 to keep them

Return Value integer, allocatable, (:)


Calls

proc~~compute_gaps~~CallsGraph proc~compute_gaps compute_gaps proc~comment_gaps comment_gaps proc~compute_gaps->proc~comment_gaps proc~statement_gaps statement_gaps proc~compute_gaps->proc~statement_gaps proc~utf8_width utf8_width proc~comment_gaps->proc~utf8_width proc~is_chevron is_chevron proc~statement_gaps->proc~is_chevron proc~is_word is_word proc~statement_gaps->proc~is_word proc~view_kind_of statement_view_t%view_kind_of proc~statement_gaps->proc~view_kind_of proc~view_word statement_view_t%view_word proc~statement_gaps->proc~view_word

Called by

proc~~compute_gaps~~CalledByGraph proc~compute_gaps compute_gaps proc~format_pass format_pass proc~format_pass->proc~compute_gaps proc~format_text format_text proc~format_text->proc~format_pass proc~relayout relayout proc~format_text->proc~relayout proc~relayout->proc~format_pass proc~process_text process_text proc~process_text->proc~format_text proc~process_file process_file proc~process_file->proc~process_text proc~process_stdin process_stdin proc~process_stdin->proc~process_text proc~run run proc~run->proc~process_file proc~run->proc~process_stdin

Source Code

function compute_gaps(source, views, ws, comment_spacing) result(gap)
    !! The gap wanted before each token (`GAP_KEEP`, `GAP_MIN1` or a number of blanks).
    type(source_t), intent(in) :: source                !! the source
    type(statement_view_t), intent(in) :: views(:)      !! the view of each item (see [[statement_views]])
    type(whitespace_options_t), intent(in) :: ws        !! modes of the whitespace rules
    integer, intent(in) :: comment_spacing              !! blanks before a trailing comment, or -1 to keep them
    integer, allocatable :: gap(:)
    integer :: k

    allocate (gap(source%tokens%n))
    gap = GAP_KEEP
    do k = 1, source%stmts%n
        if (source%stmts%s(k)%kind == SK_CODE) call statement_gaps(source%text, source%tokens, views(k), ws, gap)
    end do
    if (comment_spacing >= 0) call comment_gaps(source, comment_spacing, gap)
end function compute_gaps