Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SymbolPane/SymbolOutline.vala
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class Scratch.Services.SymbolOutline : Gtk.Box {
}

public virtual void parse_symbols () {}
public virtual void add_tooltips (Code.Widgets.SourceList.ExpandableItem root) {}

Gtk.MenuButton filter_button;

Expand Down
41 changes: 29 additions & 12 deletions src/SymbolPane/Vala/ValaSymbolOutline.vala
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline
}

store.root.expand_all ();
add_tooltips (store.root);
store.vadjustment.set_value (adjustment_value);

return false;
});
} else {
Expand All @@ -145,6 +145,30 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline
});
}

protected override void add_tooltips (Code.Widgets.SourceList.ExpandableItem root) {
foreach (var parent in root.children) {
add_tooltip ((Code.Widgets.SourceList.ExpandableItem) parent);
}
}

private void add_tooltip (Code.Widgets.SourceList.ExpandableItem parent) {
if (parent is ValaSymbolItem) {
var item = ((ValaSymbolItem)parent);
var symbol = item.symbol;
item.tooltip = "%s%s".printf (
doc.get_slice (
symbol.source_reference.begin.line,
symbol.source_reference.begin.column,
symbol.source_reference.end.line,
symbol.source_reference.end.column
),
symbol.comment != null ? "\n" + symbol.comment.content : ""
);
}

add_tooltips (parent);
}

private void destroy_all_children (Code.Widgets.SourceList.ExpandableItem parent) {
foreach (var child in parent.children) {
remove (child, parent);
Expand Down Expand Up @@ -177,7 +201,9 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline
continue;

construct_child (symbol, new_root, cancellable);
Thread.yield ();
if (!cancellable.is_cancelled ()) {
Thread.yield ();
}
}

return new_root;
Expand All @@ -199,19 +225,10 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline
parent = construct_child (symbol.scope.parent_scope.owner, given_parent, cancellable);
}

var tooltip = "%s%s".printf (
doc.get_slice (
symbol.source_reference.begin.line,
symbol.source_reference.begin.column,
symbol.source_reference.end.line,
symbol.source_reference.end.column
),
symbol.comment != null ? "\n" + symbol.comment.content : ""
);

var tree_child = new ValaSymbolItem (
symbol,
tooltip
""
);
parent.add (tree_child);
return tree_child;
Expand Down