[gnome-builder] foundry: use path helpers to determine C/C++ file suffixes



commit cf441ddfb4ec92167348be7421ee11fb21431bcf
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 18 13:08:47 2019 -0700

    foundry: use path helpers to determine C/C++ file suffixes

 src/libide/foundry/ide-compile-commands.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
---
diff --git a/src/libide/foundry/ide-compile-commands.c b/src/libide/foundry/ide-compile-commands.c
index 3faf5f744..a380a4418 100644
--- a/src/libide/foundry/ide-compile-commands.c
+++ b/src/libide/foundry/ide-compile-commands.c
@@ -23,6 +23,7 @@
 #include "config.h"
 
 #include <json-glib/json-glib.h>
+#include <libide-io.h>
 #include <libide-threading.h>
 #include <string.h>
 
@@ -405,19 +406,6 @@ ide_compile_commands_load_finish (IdeCompileCommands  *self,
   IDE_RETURN (ret);
 }
 
-static gboolean
-suffix_is_c_like (const gchar *suffix)
-{
-  if (suffix == NULL)
-    return FALSE;
-
-  return !!strstr (suffix, ".c") || !!strstr (suffix, ".h") ||
-         !!strstr (suffix, ".cc") || !!strstr (suffix, ".hh") ||
-         !!strstr (suffix, ".c++") || !!strstr (suffix, ".h++") ||
-         !!strstr (suffix, ".cxx") || !!strstr (suffix, ".hxx") ||
-         !!strstr (suffix, ".cpp") || !!strstr (suffix, ".hpp");
-}
-
 static gboolean
 suffix_is_vala (const gchar *suffix)
 {
@@ -631,7 +619,7 @@ find_with_alternates (IdeCompileCommands *self,
         if (NULL != (info = g_hash_table_lookup (self->info_by_file, other)))
           return info;
       }
-    else if (suffix_is_c_like (dot))
+    else if (ide_path_is_c_like (dot) || ide_path_is_cpp_like (dot))
       {
         static const gchar *tries[] = { ".c", ".cc", ".cpp", ".cxx", ".c++" };
 
@@ -694,7 +682,7 @@ ide_compile_commands_lookup (IdeCompileCommands   *self,
       if (!g_shell_parse_argv (info->command, &argc, &argv, error))
         return NULL;
 
-      if (suffix_is_c_like (dot))
+      if (ide_path_is_c_like (dot) || ide_path_is_cpp_like (dot))
         ide_compile_commands_filter_c (self, info, system_includes, &argv);
       else if (suffix_is_vala (dot))
         ide_compile_commands_filter_vala (self, info, &argv);


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