[latexila] Have same coding style for for loops in Vala and C



commit 101d18fe38179b8a1d3e5dd794263e7846d5da11
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Feb 16 17:47:03 2018 +0100

    Have same coding style for for loops in Vala and C
    
    To make the life easier for contributors (and to myself too). Reduce the
    number of differences between the coding style in Vala and C.

 HACKING                                            |    9 ++++-----
 data/images/generate-symbols/generate_symbols.vala |   10 +++++-----
 src/build_tool_dialog.vala                         |    2 +-
 src/completion.vala                                |    6 +++---
 src/document.vala                                  |    4 ++--
 src/document_structure.vala                        |    4 ++--
 src/main_window.vala                               |    4 ++--
 src/main_window_documents.vala                     |    2 +-
 src/most_used_symbols.vala                         |    2 +-
 src/projects.vala                                  |    4 ++--
 src/search.vala                                    |    2 +-
 src/structure_model.vala                           |    4 ++--
 src/symbols.vala                                   |    2 +-
 src/utils.vala                                     |    4 ++--
 14 files changed, 29 insertions(+), 30 deletions(-)
---
diff --git a/HACKING b/HACKING
index f2e6f11..2f86c91 100644
--- a/HACKING
+++ b/HACKING
@@ -29,10 +29,10 @@ For Vala:
     - Curly braces are always on a separate line.
     - For one-line blocks (if, for, while, etc), no curly braces.
     - Some spaces almost everywhere:
-        - function (blah);                // not function(blah);
-        - int num = 5;                    // not int num=5;
-        - if (! foo)                      // not if (!foo)
-        - for (int i = 0 ; i < max ; i++) // not for(int i=0;i<max;i++)
+        - function (blah);              // not function(blah);
+        - int num = 5;                  // not int num=5;
+        - if (! foo)                    // not if (!foo)
+        - for (int i = 0; i < max; i++) // not for(int i=0;i<max;i++)
         - etc...
     - Do not use 'var' for declaring variables, unless the type is very long.
       The type of a variable is useful to understand the code, it is a form of
@@ -44,7 +44,6 @@ For C:
     - No maximum line length (but short lines are better).
     - Spacing differences with Vala:
        - if (!foo)
-       - for (int i = 0; i < max; i++)
     - Note that the GNU coding style was previously used, all the *.c files
       have been converted to the GtkSourceView coding style with the uncrustify
       config file (see the scripts/ directory in the GtkSourceView git
diff --git a/data/images/generate-symbols/generate_symbols.vala 
b/data/images/generate-symbols/generate_symbols.vala
index 5fdf510..b4b8c3f 100644
--- a/data/images/generate-symbols/generate_symbols.vala
+++ b/data/images/generate-symbols/generate_symbols.vala
@@ -76,7 +76,7 @@ private class GenerateSymbols : Object
                 break;
 
             case "documentclass":
-                for (int i = 0 ; i < attr_names.length ; i++)
+                for (int i = 0; i < attr_names.length; i++)
                 {
                     switch (attr_names[i])
                     {
@@ -91,7 +91,7 @@ private class GenerateSymbols : Object
                 break;
 
             case "preamble":
-                for (int i = 0 ; i < attr_names.length ; i++)
+                for (int i = 0; i < attr_names.length; i++)
                 {
                     switch (attr_names[i])
                     {
@@ -106,7 +106,7 @@ private class GenerateSymbols : Object
                 break;
 
             case "convert":
-                for (int i = 0 ; i < attr_names.length ; i++)
+                for (int i = 0; i < attr_names.length; i++)
                 {
                     switch (attr_names[i])
                     {
@@ -126,7 +126,7 @@ private class GenerateSymbols : Object
                 symbol.name = null;
                 symbol.math = false;
                 symbol.package = null;
-                for (int i = 0 ; i < attr_names.length ; i++)
+                for (int i = 0; i < attr_names.length; i++)
                 {
                     switch (attr_names[i])
                     {
@@ -153,7 +153,7 @@ private class GenerateSymbols : Object
                 break;
 
             case "document":
-                for (int i = 0 ; i < attr_names.length ; i++)
+                for (int i = 0; i < attr_names.length; i++)
                 {
                     switch (attr_names[i])
                     {
diff --git a/src/build_tool_dialog.vala b/src/build_tool_dialog.vala
index 2a6b73b..2bb91fd 100644
--- a/src/build_tool_dialog.vala
+++ b/src/build_tool_dialog.vala
@@ -206,7 +206,7 @@ public class BuildToolDialog : GLib.Object
             typeof (string) // the name of the post processor
         );
 
-        for (int type = 0 ; type < Latexila.PostProcessorType.NB_TYPES ; type++)
+        for (int type = 0; type < Latexila.PostProcessorType.NB_TYPES; type++)
         {
             unowned string name = Latexila.PostProcessor.get_name_from_type (
                 (Latexila.PostProcessorType) type);
diff --git a/src/completion.vala b/src/completion.vala
index ff5e50d..866d049 100644
--- a/src/completion.vala
+++ b/src/completion.vala
@@ -846,7 +846,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
         throws MarkupError
     {
         _current_command = CompletionCommand ();
-        for (int attr_num = 0 ; attr_num < attr_names.length ; attr_num++)
+        for (int attr_num = 0; attr_num < attr_names.length; attr_num++)
         {
             switch (attr_names[attr_num])
             {
@@ -875,7 +875,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
         _current_arg = CompletionArgument ();
         _current_arg.optional = false;
 
-        for (int attr_num = 0 ; attr_num < attr_names.length ; attr_num++)
+        for (int attr_num = 0; attr_num < attr_names.length; attr_num++)
         {
             switch (attr_names[attr_num])
             {
@@ -899,7 +899,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
     {
         _current_choice = CompletionChoice ();
 
-        for (int attr_num = 0 ; attr_num < attr_names.length ; attr_num++)
+        for (int attr_num = 0; attr_num < attr_names.length; attr_num++)
         {
             switch (attr_names[attr_num])
             {
diff --git a/src/document.vala b/src/document.vala
index 7dde60e..b2d8a56 100644
--- a/src/document.vala
+++ b/src/document.vala
@@ -355,7 +355,7 @@ public class Document : Tepl.Buffer
 
         begin_user_action ();
 
-        for (int line_num = start_line ; line_num <= end_line ; line_num++)
+        for (int line_num = start_line; line_num <= end_line; line_num++)
         {
             if (cur_iter.ends_line ())
                 // Don't insert a trailing space.
@@ -380,7 +380,7 @@ public class Document : Tepl.Buffer
 
         begin_user_action ();
 
-        for (int i = start_line ; i <= end_line ; i++)
+        for (int i = start_line; i <= end_line; i++)
         {
             get_iter_at_line (out start, i);
 
diff --git a/src/document_structure.vala b/src/document_structure.vala
index 3fde52e..5ea1ac7 100644
--- a/src/document_structure.vala
+++ b/src/document_structure.vala
@@ -603,7 +603,7 @@ public class DocumentStructure : GLib.Object
 
     private void clear_all_structure_marks ()
     {
-        for (int i = 0 ; i < _nb_marks ; i++)
+        for (int i = 0; i < _nb_marks; i++)
         {
             string mark_name = MARK_NAME_PREFIX + i.to_string ();
             TextMark? mark = _doc.get_mark (mark_name);
@@ -1106,7 +1106,7 @@ public class DocumentStructure : GLib.Object
 
         /* Do the same for all the children */
         int nb_children = _model.iter_n_children (tree_iter);
-        for (int child_num = 0 ; child_num < nb_children ; child_num++)
+        for (int child_num = 0; child_num < nb_children; child_num++)
         {
             TreeIter child_iter;
             bool child_iter_set = _model.iter_nth_child (out child_iter, tree_iter,
diff --git a/src/main_window.vala b/src/main_window.vala
index a9aad57..5ee1777 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -584,7 +584,7 @@ public class MainWindow : ApplicationWindow
     {
         Gee.List<Document> all_documents = new Gee.LinkedList<Document> ();
         int nb_documents = _documents_panel.get_n_pages ();
-        for (int i = 0 ; i < nb_documents ; i++)
+        for (int i = 0; i < nb_documents; i++)
         {
             DocumentTab tab = _documents_panel.get_nth_page (i) as DocumentTab;
             all_documents.add (tab.document);
@@ -614,7 +614,7 @@ public class MainWindow : ApplicationWindow
 
         int nb_documents = _documents_panel.get_n_pages ();
 
-        for (int i = 0 ; i < nb_documents ; i++)
+        for (int i = 0; i < nb_documents; i++)
         {
             DocumentTab tab = _documents_panel.get_nth_page (i) as DocumentTab;
             all_views.add (tab.document_view);
diff --git a/src/main_window_documents.vala b/src/main_window_documents.vala
index fa1c5c3..686e06c 100644
--- a/src/main_window_documents.vala
+++ b/src/main_window_documents.vala
@@ -129,7 +129,7 @@ public class MainWindowDocuments
 
         unowned SList<RadioAction> group = null;
 
-        for (int doc_num = 0 ; doc_num < nb_docs ; doc_num++)
+        for (int doc_num = 0; doc_num < nb_docs; doc_num++)
         {
             DocumentTab tab = _documents_panel.get_nth_page (doc_num) as DocumentTab;
             string action_name = get_list_action_name (doc_num);
diff --git a/src/most_used_symbols.vala b/src/most_used_symbols.vala
index a71f670..16b932c 100644
--- a/src/most_used_symbols.vala
+++ b/src/most_used_symbols.vala
@@ -169,7 +169,7 @@ public class MostUsedSymbols : GLib.Object
                 string id = null;
                 int num = 0;
 
-                for (int i = 0 ; i < attr_names.length ; i++)
+                for (int i = 0; i < attr_names.length; i++)
                 {
                     switch (attr_names[i])
                     {
diff --git a/src/projects.vala b/src/projects.vala
index 6f17d7d..541c271 100644
--- a/src/projects.vala
+++ b/src/projects.vala
@@ -186,7 +186,7 @@ public class Projects
             if (doc.location == null)
                 continue;
 
-            for (int i = 0 ; i < projects.size ; i++)
+            for (int i = 0; i < projects.size; i++)
             {
                 if (doc.location.has_prefix (projects[i].directory))
                 {
@@ -207,7 +207,7 @@ public class Projects
 
             case "project":
                 Project project = Project ();
-                for (int i = 0 ; i < attr_names.length ; i++)
+                for (int i = 0; i < attr_names.length; i++)
                 {
                     switch (attr_names[i])
                     {
diff --git a/src/search.vala b/src/search.vala
index 19b644f..8b29852 100644
--- a/src/search.vala
+++ b/src/search.vala
@@ -72,7 +72,7 @@ public class GotoLine : Grid
         string text = entry.get_text ();
 
         // check if all characters are digits
-        for (int i = 0 ; i < text.length ; i++)
+        for (int i = 0; i < text.length; i++)
         {
             unichar c = text[i];
             if (! c.isdigit ())
diff --git a/src/structure_model.vala b/src/structure_model.vala
index 18886ae..035be66 100644
--- a/src/structure_model.vala
+++ b/src/structure_model.vala
@@ -328,7 +328,7 @@ public class StructureModel : TreeModel, GLib.Object
         unowned int[] indices = path.get_indices ();
 
         unowned Node<StructData?> node = _tree;
-        for (int cur_depth = 0 ; cur_depth < depth ; cur_depth++)
+        for (int cur_depth = 0; cur_depth < depth; cur_depth++)
         {
             int indice = indices[cur_depth];
             if (indice < 0 || node.n_children () <= indice)
@@ -781,7 +781,7 @@ public class StructureModel : TreeModel, GLib.Object
         var list = get_list (node.data.type);
         return_val_if_fail (list != null, -1);
 
-        for (int num = 0 ; num < list.size ; num++)
+        for (int num = 0; num < list.size; num++)
         {
             if (list[num] == node)
                 return num;
diff --git a/src/symbols.vala b/src/symbols.vala
index 3df7686..35344d8 100644
--- a/src/symbols.vala
+++ b/src/symbols.vala
@@ -292,7 +292,7 @@ private class NormalSymbols : Gtk.ListStore
                 symbol.package_required = null;
                 string icon_file = null;
 
-                for (int i = 0 ; i < attr_names.length ; i++)
+                for (int i = 0; i < attr_names.length; i++)
                 {
                     switch (attr_names[i])
                     {
diff --git a/src/utils.vala b/src/utils.vala
index 4fecfd4..aec19e4 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -210,11 +210,11 @@ namespace Utils
 
         // go to the common dir
         uint nb_remaining_origin_dirs = origin_dirs.length () - nb_common_dirs;
-        for (uint i = 0 ; i < nb_remaining_origin_dirs ; i++)
+        for (uint i = 0; i < nb_remaining_origin_dirs; i++)
             relative_path += "../";
 
         // go to the target dir
-        for (uint i = nb_common_dirs ; i < target_dirs.length () ; i++)
+        for (uint i = nb_common_dirs; i < target_dirs.length (); i++)
         {
             File cur_target_dir = target_dirs.nth_data (i);
             relative_path += cur_target_dir.get_basename () + "/";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]