diff --git a/messages/6.5.0.rst b/messages/6.5.0.rst
index 4b62f00b..33552608 100644
--- a/messages/6.5.0.rst
+++ b/messages/6.5.0.rst
@@ -13,6 +13,7 @@ Improvements and bug fixes:
end, the picked file is committed to file.
- Details here:
https://niosus.github.io/EasyClangComplete/settings/#autocomplete_includes
+- Info popup now also shows references from open files.
- Get rid of a singleton in the thread pool. Use a single instance per
plugin.
diff --git a/plugin/error_vis/popups.py b/plugin/error_vis/popups.py
index d2aff850..9a05efc7 100644
--- a/plugin/error_vis/popups.py
+++ b/plugin/error_vis/popups.py
@@ -29,9 +29,16 @@
{type_declaration}
"""
-REFERENCES_TEMPLATE = \
+INDEX_REFERENCES_TEMPLATE = \
"""### References: (from sublime index)
-{type_references}
+
+{references}
+"""
+
+OPEN_FILES_REFERENCES_TEMPLATE = \
+ """### References: (from open files)
+
+{references}
"""
BRIEF_DOC_TEMPLATE = """### Brief documentation:
@@ -173,25 +180,8 @@ def info(cursor, cindex, settings):
type_declaration=markupsafe.escape(declaration_text))
if settings.show_index_references:
- index = sublime.active_window().lookup_symbol_in_index(
- cursor.spelling)
- index_references = []
- for location_tuple in index:
- location = IndexLocation(filename=location_tuple[0],
- line=location_tuple[2][0],
- column=location_tuple[2][1])
- index_references.append(
- "{reference}: `{file}:{line}:{col}`".format(
- reference=Popup.link_from_location(location,
- cursor.spelling),
- file=location.file.short_name,
- line=location.line,
- col=location.column))
- log.debug("references from index: %s", index_references)
- if index_references:
- popup.__text += REFERENCES_TEMPLATE.format(
- type_references=markupsafe.escape(
- "\n".join(index_references)))
+ popup.__text += Popup.__lookup_in_sublime_index(
+ sublime.active_window(), cursor.spelling)
# Doxygen comments
if cursor.brief_comment:
@@ -218,6 +208,33 @@ def info(cursor, cindex, settings):
content=CODE_TEMPLATE.format(lang="c++", code=body))
return popup
+ @staticmethod
+ def __lookup_in_sublime_index(window, spelling):
+ def lookup(lookup_function, spelling):
+ index = lookup_function(spelling)
+ references = []
+ for location_tuple in index:
+ location = IndexLocation(filename=location_tuple[0],
+ line=location_tuple[2][0],
+ column=location_tuple[2][1])
+ references.append(
+ "{reference}: `{file}:{line}:{col}`".format(
+ reference=Popup.link_from_location(location, spelling),
+ file=location.file.short_name,
+ line=location.line,
+ col=location.column))
+ return markupsafe.escape("\n - ".join(references))
+ index_references = lookup(window.lookup_symbol_in_index, spelling)
+ usage_references = lookup(window.lookup_symbol_in_open_files, spelling)
+ output_text = ""
+ if index_references:
+ output_text += INDEX_REFERENCES_TEMPLATE.format(
+ references=" - " + index_references)
+ if usage_references:
+ output_text += OPEN_FILES_REFERENCES_TEMPLATE.format(
+ references=" - " + usage_references)
+ return output_text
+
def info_objc(cursor, cindex, settings):
"""Provide information about Objective C cursors."""
popup = Popup((