summaryrefslogtreecommitdiffstats
path: root/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_left_shift.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-12-20 23:01:54 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-12-22 11:50:09 +0900
commit112ca8677b9b024de5529712e559c968da40a67a (patch)
treea8e93a0b05d61aeaab1dab3288c5fc518cdd05c6 /debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_left_shift.cpp
parentb37f44d6c7444ca20c48a07fdcaf7b2a812db5bd (diff)
downloadextra-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_left_shift.cpp')
-rw-r--r--debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_left_shift.cpp130
1 files changed, 130 insertions, 0 deletions
diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_left_shift.cpp b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_left_shift.cpp
new file mode 100644
index 00000000..d01f6b99
--- /dev/null
+++ b/debian/uncrustify-trinity/uncrustify-trinity-0.72.0/src/align_left_shift.cpp
@@ -0,0 +1,130 @@
+/**
+ * @file align_left_shift.cpp
+ *
+ * @author Guy Maurel
+ * split from align.cpp
+ * @author Ben Gardner
+ * @license GPL v2+
+ */
+
+#include "align_left_shift.h"
+
+#include "align_stack.h"
+#include "chunk_list.h"
+#include "ChunkStack.h"
+#include "indent.h"
+#include "log_rules.h"
+#include "uncrustify.h"
+
+using namespace uncrustify;
+
+
+void align_left_shift(void)
+{
+ LOG_FUNC_ENTRY();
+
+ chunk_t *start = nullptr;
+ AlignStack as;
+
+ as.Start(255);
+
+ chunk_t *pc = chunk_get_head();
+
+ while (pc != nullptr)
+ {
+ if (chunk_is_newline(pc))
+ {
+ LOG_FMT(LAVDB, "%s(%d): orig_line is %zu, <Newline>\n", __func__, __LINE__, pc->orig_line);
+ }
+ else
+ {
+ LOG_FMT(LAVDB, "%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 if (as.m_aligned.Empty())
+ {
+ /*
+ * 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);
+ }
+ // first one can be anywhere
+ as.Add(pc);
+ start = pc;
+ }
+ else if (chunk_is_newline(chunk_get_prev(pc)))
+ {
+ // subsequent ones must be after a newline
+ as.Add(pc);
+ }
+ }
+ else if (!as.m_aligned.Empty())
+ {
+ /*
+ * check if the given statement is on a line of its own, immediately following <<
+ * and then 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);
+ }
+ }
+ pc = chunk_get_next(pc);
+ }
+ as.End();
+} // align_left_shift