1717 */
1818
1919public class Scratch.Services.ValaSymbolOutline : Scratch .Services .SymbolOutline {
20- public const int PARSE_TIME_MAX_MSEC = 1000 ;
20+ public const int PARSE_TIME_MAX_MSEC = 5000 ;
2121 private Code . Plugins . ValaSymbolResolver resolver;
2222 private Vala . Parser parser;
2323 private GLib . Cancellable cancellable;
@@ -159,13 +159,15 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline
159159 parent.remove (item );
160160 }
161161
162+ // Called from separate thread
162163 private Code . Widgets . SourceList . ExpandableItem construct_tree (GLib . Cancellable cancellable) {
163164 var fields = resolver. get_properties_fields ();
164165 var symbols = resolver. get_symbols ();
165166 // Remove fake fields created by the vala parser.
166167 symbols. remove_all (fields);
167168
168169 var new_root = new Code .Widgets .SourceList .ExpandableItem (_(" Symbols" ));
170+ new_root. tooltip = _(" Vala symbols found in %s " ). printf (doc. file. get_basename ());
169171 foreach (var symbol in symbols) {
170172 if (cancellable. is_cancelled ())
171173 break ;
@@ -175,12 +177,18 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline
175177 continue ;
176178
177179 construct_child (symbol, new_root, cancellable);
180+ Thread . yield ();
178181 }
179182
180183 return new_root;
181184 }
182185
183- private ValaSymbolItem construct_child (Vala . Symbol symbol, Code . Widgets . SourceList . ExpandableItem given_parent, GLib . Cancellable cancellable) {
186+ private ValaSymbolItem construct_child (
187+ Vala . Symbol symbol,
188+ Code . Widgets . SourceList . ExpandableItem given_parent,
189+ GLib . Cancellable cancellable
190+ ) {
191+
184192 Code . Widgets . SourceList . ExpandableItem parent;
185193 if (symbol. scope. parent_scope. owner. name == null )
186194 parent = given_parent;
@@ -191,69 +199,20 @@ public class Scratch.Services.ValaSymbolOutline : Scratch.Services.SymbolOutline
191199 parent = construct_child (symbol. scope. parent_scope. owner, given_parent, cancellable);
192200 }
193201
194- var tree_child = new ValaSymbolItem (symbol);
195- if (symbol is Vala . Struct ) {
196- tree_child. icon = new ThemedIcon (" lang-struct" );
197- tree_child. symbol_type = SymbolType . STRUCT ;
198- } else if (symbol is Vala . Class ) {
199- if (((Vala . Class ) symbol). is_abstract) {
200- tree_child. icon = new ThemedIcon (" lang-class-abstract" );
201- } else {
202- tree_child. icon = new ThemedIcon (" lang-class" );
203- }
204-
205- tree_child. symbol_type = SymbolType . CLASS ;
206- } else if (symbol is Vala . Constant ) {
207- tree_child. icon = new ThemedIcon (" lang-constant" );
208- tree_child. symbol_type = SymbolType . CONSTANT ;
209- } else if (symbol is Vala . Enum ) {
210- tree_child. icon = new ThemedIcon (" lang-enum" );
211- tree_child. symbol_type = SymbolType . ENUM ;
212- } else if (symbol is Vala . Field ) {
213- tree_child. icon = new ThemedIcon (" lang-property" );
214- tree_child. symbol_type = SymbolType . PROPERTY ;
215- } else if (symbol is Vala . Interface ) {
216- tree_child. icon = new ThemedIcon (" lang-interface" );
217- tree_child. symbol_type = SymbolType . INTERFACE ;
218- } else if (symbol is Vala . Property ) {
219- if (((Vala . Property ) symbol). is_abstract) {
220- tree_child. icon = new ThemedIcon (" lang-property-abstract" );
221- } else if (((Vala . Property ) symbol). is_virtual) {
222- tree_child. icon = new ThemedIcon (" lang-property-virtual" );
223- } else {
224- tree_child. icon = new ThemedIcon (" lang-property" );
225- }
226-
227- tree_child. symbol_type = SymbolType . PROPERTY ;
228- } else if (symbol is Vala . Signal ) {
229- tree_child. icon = new ThemedIcon (" lang-signal" );
230- tree_child. symbol_type = SymbolType . SIGNAL ;
231- } else if (symbol is Vala . CreationMethod ) {
232- tree_child. icon = new ThemedIcon (" lang-constructor" );
233- tree_child. symbol_type = SymbolType . CONSTRUCTOR ;
234- } else if (symbol is Vala . Method ) {
235- if (((Vala . Method ) symbol). is_abstract) {
236- tree_child. icon = new ThemedIcon (" lang-method-abstract" );
237- } else if (((Vala . Method ) symbol). is_virtual) {
238- tree_child. icon = new ThemedIcon (" lang-method-virtual" );
239- } else if (((Vala . Method ) symbol). binding == Vala . MemberBinding . STATIC ) {
240- tree_child. icon = new ThemedIcon (" lang-method-static" );
241- } else {
242- tree_child. icon = new ThemedIcon (" lang-method" );
243- }
244-
245- tree_child. symbol_type = SymbolType . METHOD ;
246- } else if (symbol is Vala . Namespace ) {
247- tree_child. icon = new ThemedIcon (" lang-namespace" );
248- tree_child. symbol_type = SymbolType . NAMESPACE ;
249- } else if (symbol is Vala . ErrorDomain ) {
250- tree_child. icon = new ThemedIcon (" lang-errordomain" );
251- } else if (symbol is Vala . Delegate ) {
252- tree_child. icon = new ThemedIcon (" lang-delegate" );
253- } else {
254- warning (symbol. type_name);
255- }
202+ var tooltip = " %s%s " . printf (
203+ doc. get_slice (
204+ symbol. source_reference. begin. line,
205+ symbol. source_reference. begin. column,
206+ symbol. source_reference. end. line,
207+ symbol. source_reference. end. column
208+ ),
209+ symbol. comment != null ? " \n " + symbol. comment. content : " "
210+ );
256211
212+ var tree_child = new ValaSymbolItem (
213+ symbol,
214+ tooltip
215+ );
257216 parent. add (tree_child);
258217 return tree_child;
259218 }
0 commit comments