elixir/templates/ident.html
Théo Lebrun e1bdface0c templates/ident: improve "Identifier not used" message
"Identifier not used" is weird, replace it by "unknown identifier" and
 give the search identifier name in the header.

Also improve the autocomplete comment. Make it human-friendly and
explain why people got autocompleted to a symbol that does not exist.
Also, only show it if the symbol actually exists. That way we only
tell "maybe autocomplete lead you here" only in cases where
autocomplete can actually lead you here.

To test this feature:
 - search for any random symbol, you'll see "Unknown identifier '...'"
 - search for a symbol that exists in another version as the selected
   one. For example __NR_epoll_pwait2 appeared in musl v1.2.5. You'll
   see the same header message plus a comment about how the symbol
   exists in another version.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-11-05 14:18:41 +01:00

70 lines
2.8 KiB
HTML

{% extends "layout.html" %}
{% block title %}
{{ searched_ident|e }} identifier - {{ current_project|capitalize }} source code {{ current_tag }} - Bootlin Elixir Cross Referencer
{% endblock %}
{% block description -%}
Elixir Cross Referencer - {{ searched_ident|e }} identifier references search for {{ current_project|capitalize }} {{ current_tag }}.
{%- for section in symbol_sections -%}
{%- if 'symbols' in section -%}
{%- for type, symbols in (section['symbols'].items()) -%}
{%- if (symbols|length) == 1 %}
{{ section['title'] }} {{- ' as a '+type if type != '_unknown' else '' }} in {{ symbols[0].path }}.
{%- else %}
{{ section['title'] }} in {{ symbols|length }} files {{- ' as a '+type if type != '_unknown' else '' -}}: {{ symbols[0].path }}...
{%- endif %}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{%- endblock -%}
{% block main %}
<div class="lxrident">
{% if symbol_sections|length != 0 %}
{% for section in symbol_sections %}
{% if 'symbols' in section %}
{% for type, symbols in section['symbols'].items() %}
<h2>{{ section['title'] }} in {{ symbols|length }} files
{{- ' as a '+type if type != '_unknown' else '' -}}:</h2>
<ul>
{% for symbol in symbols %}
<li>
<a href="{{ symbol.lines[0].url }}">
<strong>{{ symbol.path }}</strong>
{%- if symbol.lines|length == 1 %},
line {{ symbol.lines[0].lineno }}
{%- elif symbols|length > 100 %},
<em>{{ symbol.lines|length }} times</em>
{% endif %}
{% if symbol.type is not none %}
<em>(as a {{ symbol.type }})</em>
{% endif %}
</a>
{% if symbol.lines|length > 1 and symbols|length <= 100 %}
<ul>
{% for line, url in symbol.lines %}
<li><a href="{{ url }}">line {{ line }}</a>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
{% else %}
<h2>{{ section['message'] }}</h2>
{% endif %}
{% endfor %}
{% else %}
<h2>Unknown identifier '{{ searched_ident|e }}'</h2>
{% if symbol_exists %}
<div id="error-details">
The '{{ searched_ident|e }}' symbol is defined in another version.
Elixir cannot efficiently tell where.
</div>
{% endif %}
{% endif %}
</div>
{% endblock %}