Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add symbol filter to outline pane #1253

Merged
merged 32 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e08786e
Search symbol pane, first attempt
Jan 23, 2023
526b702
Implement filter tool in symbol pane
Jan 23, 2023
de7678f
Extend range of symbol types, classify symbols
Jan 24, 2023
d1205d4
Throttle refilter; refilter on check toggled
Jan 24, 2023
b3904a3
Simplify filter; expand_all after filter
Jan 24, 2023
fed7470
Handle Namespace type; Add ActionBar
Jan 24, 2023
d99f0a0
Merge branch 'master' into search-symbols
Jan 24, 2023
3f0b813
Fix regression in search entry filtering
Jan 24, 2023
84c4f6e
Delete debug warning
Jan 24, 2023
d6f7313
Merge branch 'master' into search-symbols
Jan 24, 2023
53b9d9c
Merge branch 'master' into search-symbols
Mar 21, 2023
9b18404
Inline namespace
Mar 21, 2023
413fccb
Space out filters, add header
Mar 21, 2023
f00a36e
Reduce nesting in schedule refilter
Mar 21, 2023
cfcf24b
Simplify and flatten filter func
Mar 21, 2023
c7d8f80
Merge branch 'master' into search-symbols
zeebok Mar 22, 2023
906fb5a
Merge branch 'master' into search-symbols
danirabbit Mar 24, 2023
1024dd2
Merge branch 'master' into search-symbols
zeebok Mar 27, 2023
2075dde
Merge branch 'master' into search-symbols
zeebok May 12, 2023
f9ce70a
Merge branch 'master' into search-symbols
May 12, 2023
a2c88f6
Merge branch 'master' into search-symbols
Jun 17, 2023
43c0b79
Merge branch 'master' into search-symbols
zeebok Jul 6, 2023
245f362
Merge branch 'master' into search-symbols
Aug 2, 2023
c6f86fe
Merge branch 'master' into search-symbols
jeremypw Jul 17, 2024
9419e6d
Change stray Granite.Widget to Code.Widget
jeremypw Jul 17, 2024
f7ec4ed
Change another stray Granite.Widgets.SourceList
jeremypw Jul 17, 2024
611f662
Add filter icon, fix styles
danirabbit Jul 24, 2024
00b2ad2
Merge branch 'master' into search-symbols
jeremypw Jul 27, 2024
15ff6e4
Merge branch 'master' into search-symbols
jeremypw Jul 30, 2024
96c2a22
Merge branch 'master' into search-symbols
jeremypw Aug 1, 2024
da1d045
Jeremypw/use simple menu (#1459)
jeremypw Aug 1, 2024
54dae83
Fix lint
jeremypw Aug 1, 2024
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
23 changes: 20 additions & 3 deletions src/SymbolPane/C/CtagsSymbol.vala
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,29 @@
*
*/

public class Scratch.Services.CtagsSymbol : Granite.Widgets.SourceList.ExpandableItem {
public class Scratch.Services.CtagsSymbol : Granite.Widgets.SourceList.ExpandableItem,
Scratch.Services.SymbolItem {

public Scratch.Services.Document doc { get; construct set; }
public SymbolType symbol_type { get; set; default = SymbolType.OTHER; }
public int line { get; construct set; }

public CtagsSymbol (Scratch.Services.Document doc, string name, int line, Icon? _icon) {
Object (doc: doc, name: name, line: line);
public CtagsSymbol (
Scratch.Services.Document doc,
string name,
int line,
Icon? _icon,
SymbolType? s_type = null) {

Object (
doc: doc,
name: name,
line: line
);

icon = _icon;
if (s_type != null) {
symbol_type = s_type;
}
}
}
18 changes: 16 additions & 2 deletions src/SymbolPane/C/CtagsSymbolIter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,22 @@ public class Scratch.Services.CtagsSymbolIter : Object {
public string parent { get; construct set; }
public int line { get; construct set; }
public Icon? icon { get; construct set; }
public SymbolType? symbol_type;

public CtagsSymbolIter (string name, string parent, int line, Icon? icon) {
Object (name: name, parent: parent, line: line, icon: icon);
public CtagsSymbolIter (
string name,
string parent,
int line,
Icon? icon,
SymbolType? s_type = SymbolType.OTHER) {

Object (
name: name,
parent: parent,
line: line,
icon: icon
);

symbol_type = s_type;
}
}
75 changes: 69 additions & 6 deletions src/SymbolPane/C/CtagsSymbolOutline.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ public class Scratch.Services.CtagsSymbolOutline : Scratch.Services.SymbolOutlin
);
}

static construct {
// Array of symbol types that could be assigned to a CtagsSymbol
// by parse output ()
filters = {
SymbolType.CLASS,
SymbolType.CONSTRUCTOR,
SymbolType.PROPERTY,
SymbolType.METHOD,
SymbolType.STRUCT,
SymbolType.ENUM,
SymbolType.CONSTANT
};
}
construct {
store.item_selected.connect ((selected) => {
doc.goto (((CtagsSymbol)selected).line);
Expand Down Expand Up @@ -74,66 +87,92 @@ public class Scratch.Services.CtagsSymbolOutline : Scratch.Services.SymbolOutlin
int line = int.parse (parts[4].offset ("line:".length));
string? parent = null;
GLib.Icon? parent_icon = null;
SymbolType? parent_s_type = null;
if (parts.length > 5 && parts[5] != null) {
if ("typeref:" in parts[5]) {
parent = parts[5].offset ("typeref:".length);
} else if ("class:" in parts[5]) {
parent = parts[5].offset ("class:".length);
parent_icon = new ThemedIcon ("lang-class");
parent_s_type = SymbolType.CLASS;
} else if ("struct:" in parts[5]) {
parent = parts[5].offset ("struct:".length);
parent_icon = new ThemedIcon ("lang-struct");
parent_s_type = SymbolType.STRUCT;
} else if ("enum:" in parts[5]) {
parent = parts[5].offset ("enum:".length);
parent_icon = new ThemedIcon ("lang-enum");
parent_s_type = SymbolType.ENUM;
}
}

Icon? icon = null;
SymbolType? s_type = null;
switch (type) {
case "class":
icon = new ThemedIcon ("lang-class");
s_type = SymbolType.CLASS;
break;
case "struct":
icon = new ThemedIcon ("lang-struct");
s_type = SymbolType.STRUCT;
break;
case "field":
case "member":
case "variable":
icon = new ThemedIcon ("lang-property");
s_type = SymbolType.PROPERTY;
break;
case "enum":
case "enumerator":
icon = new ThemedIcon ("lang-enum");
s_type = SymbolType.ENUM;
break;
case "macro":
case "constant":
case "typedef":
icon = new ThemedIcon ("lang-constant");
s_type = SymbolType.CONSTANT;
break;
case "constructor":
icon = new ThemedIcon ("lang-constructor");
s_type = SymbolType.CONSTRUCTOR;
break;
case "destructor":
case "method":
case "function":
icon = new ThemedIcon ("lang-method");
s_type = SymbolType.METHOD;
break;
case "namespace":
icon = new ThemedIcon ("lang-namespace");
s_type = SymbolType.NAMESPACE;
break;
case "package":
break;
case "property":
icon = new ThemedIcon ("lang-property");
s_type = SymbolType.PROPERTY;
break;
}

if (parent == null) {
var s = new CtagsSymbol (doc, name, line, icon);
var s = new CtagsSymbol (
doc,
name,
line,
icon,
s_type
);
new_root.add (s);
} else {
parent_dependent.add (new CtagsSymbolIter (name, parent, line, parent_icon));
parent_dependent.add (new CtagsSymbolIter (
name,
parent,
line,
parent_icon,
parent_s_type
));
}
}
} catch (Error e) {
Expand All @@ -152,7 +191,13 @@ public class Scratch.Services.CtagsSymbolOutline : Scratch.Services.SymbolOutlin
var parent = find_existing (i.parent, new_root);
if (parent != null) {
found_something = true;
parent.add (new CtagsSymbol (doc, i.name, i.line, i.icon));
parent.add (new CtagsSymbol (
doc,
i.name,
i.line,
i.icon,
i.symbol_type
));
iter.remove ();
} else {
if (":" in i.parent) {
Expand All @@ -177,10 +222,22 @@ public class Scratch.Services.CtagsSymbolOutline : Scratch.Services.SymbolOutlin
}
// anonymous enum
if (i.parent.has_prefix ("__anon")) {
var e = new CtagsSymbol (doc, i.parent, i.line - 1, new ThemedIcon ("lang-enum"));
var e = new CtagsSymbol (
doc,
i.parent,
i.line - 1,
new ThemedIcon ("lang-enum"),
SymbolType.ENUM
);
new_root.add (e);

e.add (new CtagsSymbol (doc, i.name, i.line, i.icon));
e.add (new CtagsSymbol (
doc,
i.name,
i.line,
i.icon,
i.symbol_type
));
iter.remove ();
}
}
Expand All @@ -189,7 +246,13 @@ public class Scratch.Services.CtagsSymbolOutline : Scratch.Services.SymbolOutlin

// just add the rest
foreach (var symbol in parent_dependent) {
new_root.add (new CtagsSymbol (doc, symbol.name, symbol.line, symbol.icon));
new_root.add (new CtagsSymbol (
doc,
symbol.name,
symbol.line,
symbol.icon,
symbol.symbol_type
));
}

Idle.add (() => {
Expand Down
Loading