After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 763271 - editor should support ctrl+click to open included header
editor should support ctrl+click to open included header
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: editor
unspecified
Other All
: Normal enhancement
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-03-07 22:44 UTC by Christian Hergert
Modified: 2016-03-25 18:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Working Path (5.45 KB, patch)
2016-03-22 12:07 UTC, Debarshi Dutta
none Details | Review
Picture describing the mismatch in alignment. (175.09 KB, image/png)
2016-03-22 12:13 UTC, Debarshi Dutta
  Details
Corrected Incorrect Alignment (5.48 KB, patch)
2016-03-22 12:32 UTC, Debarshi Dutta
none Details | Review
Updated Patch (6.21 KB, patch)
2016-03-22 19:20 UTC, Debarshi Dutta
none Details | Review
Changed g_object_unref to g_regex_unref (6.21 KB, patch)
2016-03-22 20:10 UTC, Debarshi Dutta
none Details | Review
Corrected Incorrect Alignment after changing to g_regex_unref (6.35 KB, patch)
2016-03-22 20:19 UTC, Debarshi Dutta
committed Details | Review

Description Christian Hergert 2016-03-07 22:44:50 UTC
when a C source or header has:

  #include "foo.h"

we should be able to ctrl+click on the foo.h to jump to that file.
Comment 1 Debarshi Dutta 2016-03-22 12:07:39 UTC
Created attachment 324533 [details] [review]
Working Path

I have added an initial Working patch.
There seems to be a strange problem, I am not getting a CXCursor_InclusionDirective when hovering over any headers specified by <> e.g. <stdio.h>. However, hovering on the corresponding  "#include" statement gives me the Correct CXCursor_InclusionDirective. This however works properly on any headers of the form #include "temp.h"
Comment 2 Debarshi Dutta 2016-03-22 12:13:12 UTC
Created attachment 324534 [details]
Picture describing the mismatch in alignment.

Well, I again have this mismatch in alignment. See the content of the file when I open it in Builder vs when I do a diff here.
Comment 3 Debarshi Dutta 2016-03-22 12:32:27 UTC
Created attachment 324535 [details] [review]
Corrected Incorrect Alignment

I have corrected the previous misalignment in this patch.
Comment 4 sébastien lafargue 2016-03-22 14:27:31 UTC
Review of attachment 324535 [details] [review]:

+ fix the coding style
+ when doing patches, look at build output warnings to be sure that you don't introduce new ones

::: libide/ide-source-view.c
@@ +183,3 @@
+
+  GRegex		      *include_regex;
+  GError		      *include_regex_err;

use spaces not tabs

@@ +2537,3 @@
    * are commonly used in the same word in code */
+  *word_start = *iter;
+  *word_end   = *iter;

we don't align parameters in function body, only in structs and function definition/declation

@@ +2541,1 @@
+    do

the 'do' is not aligned well

@@ -2558,3 +2562,3 @@
         }
     }
-
+    return (!gtk_text_iter_equal (word_start, word_end));

keep the empty line after a curly braced block and align the return well

@@ -2591,2 +2594,3 @@
     }
 
+  IdeSymbolKind kind = ide_symbol_get_kind (symbol);

please declare parameters at the top of its scope

@@ +2620,3 @@
+	  GtkTextIter line_end = word_end;
+	  gint line_number;
+	  g_autofree gchar* line_text;

set g_autofree and g_autoptr parameters to NULL
should be written :
 g_autofree gchar *line_text = NULL;

@@ +2621,3 @@
+	  gint line_number;
+	  g_autofree gchar* line_text;
+	  GMatchInfo *matchInfo;

use g_autoptr here

@@ +2627,3 @@
+	  gtk_text_iter_set_line (&line_start, line_number);
+	  gtk_text_iter_set_line (&line_end, line_number);
+	  gtk_text_iter_forward_to_line_end (&line_end);

just use:
 gtk_text_iter_set_line_offset (&line_start, 0);
 gtk_text_iter_forward_to_line_end (&line_end);

@@ -2612,0 +2617,31 @@
+      if (kind == IDE_SYMBOL_HEADER)
+	{
+	  GtkTextIter line_start = word_start;
... 28 more ...

use gtk_text_iter_set_line_index

@@ -2612,0 +2617,33 @@
+      if (kind == IDE_SYMBOL_HEADER)
+	{
+	  GtkTextIter line_start = word_start;
... 30 more ...

tabs everywhere to remove

@@ +6467,3 @@
 
+  priv->include_regex = g_regex_new (INCLUDE_STATEMENTS,
+				      0,

maybe use G_REGEX_OPTIMIZE GRegexCompileFlags

@@ +6469,3 @@
+				      0,
+				      0,
+				      &priv->include_regex_err);

we can use NULL instead of a GError here, should be stated in the GLib doc
( remove include_regex_err in the struct field too)

@@ -6429,0 +6468,5 @@
+  priv->include_regex = g_regex_new (INCLUDE_STATEMENTS,
+				      0,
+				      0,
... 2 more ...

free it in ide_source_view_finalize
Comment 5 Debarshi Dutta 2016-03-22 19:20:30 UTC
Created attachment 324554 [details] [review]
Updated Patch

Updated with the above suggested changes.
Comment 6 Debarshi Dutta 2016-03-22 20:10:31 UTC
Created attachment 324562 [details] [review]
Changed g_object_unref to g_regex_unref
Comment 7 Debarshi Dutta 2016-03-22 20:19:04 UTC
Created attachment 324563 [details] [review]
Corrected Incorrect Alignment after changing to g_regex_unref
Comment 8 sébastien lafargue 2016-03-25 18:29:44 UTC
thanks for your work