diff options
| author | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-12-20 23:01:54 +0900 |
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2020-12-22 11:50:09 +0900 |
| commit | 112ca8677b9b024de5529712e559c968da40a67a (patch) | |
| tree | a8e93a0b05d61aeaab1dab3288c5fc518cdd05c6 /debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_oc_decl_colon.cpp | |
| parent | b37f44d6c7444ca20c48a07fdcaf7b2a812db5bd (diff) | |
| download | extra-dependencies-112ca8677b9b024de5529712e559c968da40a67a.tar.gz extra-dependencies-112ca8677b9b024de5529712e559c968da40a67a.zip | |
DEB uncrustify: added first version of uncrustify-trinity. This is basically the upstream 0.72.0 version of uncrustify, repackaged.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_oc_decl_colon.cpp')
| -rw-r--r-- | debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_oc_decl_colon.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_oc_decl_colon.cpp b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_oc_decl_colon.cpp new file mode 100644 index 00000000..d0d4eed9 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_oc_decl_colon.cpp @@ -0,0 +1,90 @@ +/** + * @file align_oc_decl_colon.cpp + * + * @author Guy Maurel + * split from align.cpp + * @author Ben Gardner + * @license GPL v2+ + */ + +#include "align_oc_decl_colon.h" + +#include "align_oc_msg_colons.h" +#include "align_stack.h" +#include "chunk_list.h" + + +using namespace uncrustify; + + +void align_oc_decl_colon(void) +{ + LOG_FUNC_ENTRY(); + + bool did_line; + AlignStack cas; // for the colons + AlignStack nas; // for the parameter label + + cas.Start(4); + nas.Start(4); + nas.m_right_align = !options::align_on_tabstop(); + + chunk_t *pc = chunk_get_head(); + + while (pc != nullptr) + { + if (chunk_is_not_token(pc, CT_OC_SCOPE)) + { + pc = chunk_get_next(pc); + continue; + } + nas.Reset(); + cas.Reset(); + + size_t level = pc->level; + pc = chunk_get_next_ncnl(pc, scope_e::PREPROC); + + did_line = false; + + while (pc != nullptr && pc->level >= level) + { + // The declaration ends with an open brace or semicolon + if ( chunk_is_token(pc, CT_BRACE_OPEN) + || chunk_is_semicolon(pc)) + { + break; + } + + if (chunk_is_newline(pc)) + { + nas.NewLines(pc->nl_count); + cas.NewLines(pc->nl_count); + did_line = false; + } + else if ( !did_line + && chunk_is_token(pc, CT_OC_COLON)) + { + cas.Add(pc); + + chunk_t *tmp = chunk_get_prev(pc, scope_e::PREPROC); + chunk_t *tmp2 = chunk_get_prev_ncnl(tmp, scope_e::PREPROC); + + // Check for an un-labeled parameter + if ( ( chunk_is_token(tmp, CT_WORD) + || chunk_is_token(tmp, CT_TYPE) + || chunk_is_token(tmp, CT_OC_MSG_DECL) + || chunk_is_token(tmp, CT_OC_MSG_SPEC)) + && ( chunk_is_token(tmp2, CT_WORD) + || chunk_is_token(tmp2, CT_TYPE) + || chunk_is_token(tmp2, CT_PAREN_CLOSE))) + { + nas.Add(tmp); + } + did_line = true; + } + pc = chunk_get_next(pc, scope_e::PREPROC); + } + nas.End(); + cas.End(); + } +} // align_oc_decl_colon |
