summaryrefslogtreecommitdiffstats
path: root/debian/uncrustify-trinity/uncrustify-trinity-0.73.0/src/align_eigen_comma_init.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2021-05-19 16:22:10 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2021-05-19 19:14:52 +0900
commit71fb4a139179e9d27070f7f3e98971e3e029697f (patch)
tree92fbf03f1e546b3c99e6e06e98100b6ef8e4e2c6 /debian/uncrustify-trinity/uncrustify-trinity-0.73.0/src/align_eigen_comma_init.cpp
parent6eae1a16a1001287ef5129db86f4ef2145ace3ca (diff)
downloadextra-dependencies-71fb4a139179e9d27070f7f3e98971e3e029697f.tar.gz
extra-dependencies-71fb4a139179e9d27070f7f3e98971e3e029697f.zip
uncrustify: updated to version 0.73
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'debian/uncrustify-trinity/uncrustify-trinity-0.73.0/src/align_eigen_comma_init.cpp')
-rw-r--r--debian/uncrustify-trinity/uncrustify-trinity-0.73.0/src/align_eigen_comma_init.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.73.0/src/align_eigen_comma_init.cpp b/debian/uncrustify-trinity/uncrustify-trinity-0.73.0/src/align_eigen_comma_init.cpp
new file mode 100644
index 00000000..c659c214
--- /dev/null
+++ b/debian/uncrustify-trinity/uncrustify-trinity-0.73.0/src/align_eigen_comma_init.cpp
@@ -0,0 +1,121 @@
+/**
+ * @file align_eigen_comma_init.cpp
+ *
+ * @author Matthew Woehlke
+ * copied/adapted from align_left_shift.cpp
+ * @author Guy Maurel
+ * @author Ben Gardner
+ * @license GPL v2+
+ */
+
+#include "align_eigen_comma_init.h"
+
+#include "align_stack.h"
+#include "indent.h"
+#include "log_rules.h"
+
+constexpr static auto LCURRENT = LALIGN;
+
+using namespace uncrustify;
+
+
+void align_eigen_comma_init(void)
+{
+ LOG_FUNC_ENTRY();
+
+ chunk_t *start = nullptr;
+ AlignStack as;
+
+ as.Start(255);
+
+ auto *pc = chunk_get_head();
+
+ while (pc != nullptr)
+ {
+ if (chunk_is_newline(pc))
+ {
+ LOG_FMT(LALIGN, "%s(%d): orig_line is %zu, <Newline>\n", __func__, __LINE__, pc->orig_line);
+ }
+ else
+ {
+ LOG_FMT(LALIGN, "%s(%d): orig_line is %zu, orig_col is %zu, pc->text() '%s'\n",
+ __func__, __LINE__, pc->orig_line, pc->orig_col, pc->text());
+ }
+
+ if ( start != nullptr
+ && ((pc->flags & PCF_IN_PREPROC) != (start->flags & PCF_IN_PREPROC)))
+ {
+ // a change in preproc status restarts the aligning
+ as.Flush();
+ start = nullptr;
+ }
+ else if (chunk_is_newline(pc))
+ {
+ as.NewLines(pc->nl_count);
+ }
+ else if ( start != nullptr
+ && pc->level < start->level)
+ {
+ // A drop in level restarts the aligning
+ as.Flush();
+ start = nullptr;
+ }
+ else if ( start != nullptr
+ && pc->level > start->level)
+ {
+ // Ignore any deeper levels when aligning
+ }
+ else if (chunk_is_token(pc, CT_SEMICOLON))
+ {
+ // A semicolon at the same level flushes
+ as.Flush();
+ start = nullptr;
+ }
+ else if ( !pc->flags.test(PCF_IN_ENUM)
+ && !pc->flags.test(PCF_IN_TYPEDEF)
+ && chunk_is_str(pc, "<<", 2))
+ {
+ if (get_chunk_parent_type(pc) == CT_OPERATOR)
+ {
+ // Ignore operator<<
+ }
+ else
+ {
+ /*
+ * check if the first one is actually on a blank line and then
+ * indent it. Eg:
+ *
+ * cout
+ * << "something";
+ */
+ chunk_t *prev = chunk_get_prev(pc);
+
+ if ( prev != nullptr
+ && chunk_is_newline(prev))
+ {
+ log_rule_B("indent_columns");
+ indent_to_column(pc, pc->column_indent + options::indent_columns());
+ pc->column_indent = pc->column;
+ chunk_flags_set(pc, PCF_DONT_INDENT);
+ }
+ // Restart alignment
+ as.Flush();
+ as.Add(chunk_get_next(pc));
+ start = pc;
+ }
+ }
+ else if (!as.m_aligned.Empty())
+ {
+ auto *const prev = chunk_get_prev(pc);
+
+ if ( chunk_is_newline(prev)
+ && chunk_is_token(chunk_get_prev_ncnnl(pc), CT_COMMA))
+ {
+ log_rule_B("align_eigen_comma_init");
+ as.Add(pc);
+ }
+ }
+ pc = chunk_get_next(pc);
+ }
+ as.End();
+} // align_left_shift