|
@@ -231,6 +231,7 @@ EditorHelpSearch::EditorHelpSearch() {
|
|
|
filter_combo->add_item(TTR("Methods Only"), SEARCH_METHODS);
|
|
|
filter_combo->add_item(TTR("Operators Only"), SEARCH_OPERATORS);
|
|
|
filter_combo->add_item(TTR("Signals Only"), SEARCH_SIGNALS);
|
|
|
+ filter_combo->add_item(TTR("Annotations Only"), SEARCH_ANNOTATIONS);
|
|
|
filter_combo->add_item(TTR("Constants Only"), SEARCH_CONSTANTS);
|
|
|
filter_combo->add_item(TTR("Properties Only"), SEARCH_PROPERTIES);
|
|
|
filter_combo->add_item(TTR("Theme Properties Only"), SEARCH_THEME_ITEMS);
|
|
@@ -339,8 +340,9 @@ bool EditorHelpSearch::Runner::_phase_match_classes() {
|
|
|
match.name = (term.is_empty() && (!class_doc.is_script_doc || class_doc.name[0] != '\"')) || _match_string(term, class_doc.name);
|
|
|
}
|
|
|
|
|
|
- // Match members if the term is long enough.
|
|
|
- if (term.length() > 1) {
|
|
|
+ // Match members only if the term is long enough, to avoid slow performance from building a large tree.
|
|
|
+ // Make an exception for annotations, since there are not that many of them.
|
|
|
+ if (term.length() > 1 || term == "@") {
|
|
|
if (search_flags & SEARCH_CONSTRUCTORS) {
|
|
|
for (int i = 0; i < class_doc.constructors.size(); i++) {
|
|
|
String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.constructors[i].name : class_doc.constructors[i].name.to_lower();
|
|
@@ -402,6 +404,13 @@ bool EditorHelpSearch::Runner::_phase_match_classes() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (search_flags & SEARCH_ANNOTATIONS) {
|
|
|
+ for (int i = 0; i < class_doc.annotations.size(); i++) {
|
|
|
+ if (_match_string(term, class_doc.annotations[i].name)) {
|
|
|
+ match.annotations.push_back(const_cast<DocData::MethodDoc *>(&class_doc.annotations[i]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
matches[class_doc.name] = match;
|
|
|
}
|
|
|
matches[class_doc.name] = match;
|
|
@@ -485,6 +494,10 @@ bool EditorHelpSearch::Runner::_phase_member_items() {
|
|
|
for (int i = 0; i < match.theme_properties.size(); i++) {
|
|
|
_create_theme_property_item(parent, match.doc, match.theme_properties[i]);
|
|
|
}
|
|
|
+ for (int i = 0; i < match.annotations.size(); i++) {
|
|
|
+ // Hide the redundant leading @ symbol.
|
|
|
+ _create_annotation_item(parent, match.doc, match.annotations[i]->name.substr(1), match.annotations[i]);
|
|
|
+ }
|
|
|
|
|
|
++iterator_match;
|
|
|
return !iterator_match;
|
|
@@ -523,6 +536,22 @@ void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_tex
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+String EditorHelpSearch::Runner::_build_method_tooltip(const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) const {
|
|
|
+ String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "(";
|
|
|
+ for (int i = 0; i < p_doc->arguments.size(); i++) {
|
|
|
+ const DocData::ArgumentDoc &arg = p_doc->arguments[i];
|
|
|
+ tooltip += arg.type + " " + arg.name;
|
|
|
+ if (!arg.default_value.is_empty()) {
|
|
|
+ tooltip += " = " + arg.default_value;
|
|
|
+ }
|
|
|
+ if (i < p_doc->arguments.size() - 1) {
|
|
|
+ tooltip += ", ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tooltip += ")";
|
|
|
+ return tooltip;
|
|
|
+}
|
|
|
+
|
|
|
TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_match) {
|
|
|
if (p_match.doc->name.is_empty()) {
|
|
|
return nullptr;
|
|
@@ -576,37 +605,20 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const
|
|
|
}
|
|
|
|
|
|
TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) {
|
|
|
- String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "(";
|
|
|
- for (int i = 0; i < p_doc->arguments.size(); i++) {
|
|
|
- const DocData::ArgumentDoc &arg = p_doc->arguments[i];
|
|
|
- tooltip += arg.type + " " + arg.name;
|
|
|
- if (!arg.default_value.is_empty()) {
|
|
|
- tooltip += " = " + arg.default_value;
|
|
|
- }
|
|
|
- if (i < p_doc->arguments.size() - 1) {
|
|
|
- tooltip += ", ";
|
|
|
- }
|
|
|
- }
|
|
|
- tooltip += ")";
|
|
|
+ String tooltip = _build_method_tooltip(p_class_doc, p_doc);
|
|
|
return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, p_text, TTRC("Method"), "method", tooltip);
|
|
|
}
|
|
|
|
|
|
TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) {
|
|
|
- String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "(";
|
|
|
- for (int i = 0; i < p_doc->arguments.size(); i++) {
|
|
|
- const DocData::ArgumentDoc &arg = p_doc->arguments[i];
|
|
|
- tooltip += arg.type + " " + arg.name;
|
|
|
- if (!arg.default_value.is_empty()) {
|
|
|
- tooltip += " = " + arg.default_value;
|
|
|
- }
|
|
|
- if (i < p_doc->arguments.size() - 1) {
|
|
|
- tooltip += ", ";
|
|
|
- }
|
|
|
- }
|
|
|
- tooltip += ")";
|
|
|
+ String tooltip = _build_method_tooltip(p_class_doc, p_doc);
|
|
|
return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, p_doc->name, TTRC("Signal"), "signal", tooltip);
|
|
|
}
|
|
|
|
|
|
+TreeItem *EditorHelpSearch::Runner::_create_annotation_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) {
|
|
|
+ String tooltip = _build_method_tooltip(p_class_doc, p_doc);
|
|
|
+ return _create_member_item(p_parent, p_class_doc->name, "MemberAnnotation", p_doc->name, p_text, TTRC("Annotation"), "annotation", tooltip);
|
|
|
+}
|
|
|
+
|
|
|
TreeItem *EditorHelpSearch::Runner::_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc) {
|
|
|
String tooltip = p_class_doc->name + "." + p_doc->name;
|
|
|
return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, p_doc->name, TTRC("Constant"), "constant", tooltip);
|