.. _searchfox_context_menu:

============
Context Menu
============

Searchfox provides a custom context menu, which is opened on the primary button click (not the secondary button click, which is for the browser's built-in context menu).

Clicking symbols, such as function name or variable name shows a context menu for the clicked symbols.

.. image:: img/context-menu.png
    :class: border
    :alt: The context menu for symbols
    :width: 428px

Symbols
-------

Go to definition of ...
  Open the definition of given symbol.

  This is shown for the consumers of functions, variables.

Go to declaration of ...
  Open the forward declaration of given function.

Search for ...
  Open the search result of given symbol.

  The search result will include the definition, declaration, and uses.

Search for the substring ...
  Open the search result of given substring.

Sticky highlight
  Keep applying the highlight on the symbol.

  This is useful for example when you're scrolling through the function while highlighting one of the function arguments.

Structured Analysis
-------------------

For bindings generated by XPIDL and WebIDL, Searchfox generates structured analysis, which associates these C++ symbol, JavaScript symbol, generated binding, etc.

.. image:: img/context-menu-idl-1.png
    :class: border
    :alt: The context menu for WebIDL definitions
    :width: 678px

.. image:: img/context-menu-idl-2.png
    :class: border
    :alt: The context menu for WebIDL generated bindings
    :width: 538px

Go to IDL definition ...
  Open the definition inside the XPIDL/WebIDL file for given interface etc.

Go to definition of IDL C++ binding ...
  Open the auto-generated binding for given method or attribute.

Search for IDL JS ...
  Open the search result of given symbol in JS files.

Search for IDL C++ binding ...
  Open the search result of given auto-generated binding.

Search for IDL ...
  Open the search result of all symbols related to the IDL definition, including the JS symbol and C++ bindings.

Macro expansion
---------------

For preprocessor macros inside C/C++ code, Searchfox can show the expansion result, possibly for each compilation target.

.. image:: img/context-menu-macro-1.png
    :class: border
    :alt: The context menu for macros
    :width: 673px

Expansion on ...
  Open a macro expansion popup for given compilation target

  .. image:: img/context-menu-macro-2.png
      :class: border
      :alt: The macro expansion popup
      :width: 636px

Class field layout
------------------

For C++ classes, Searchfox can show the field layout table for each compilation target.

This is behind the alpha feature gate "Semantic Info Queries".

.. image:: img/context-menu-layout.png
    :class: border
    :alt: The context menu for classes
    :width: 448px

Class layout of ...
  Open the class field layout table of given class.

  This item is shown on the classes which has the class field layout information.

Diagrams
--------

For functions, classes, methods, and fields, Searchfox can show the diagram of how they're used, called, or related.

These items are behind the alpha feature gate "Diagramming".

Uses diagram of ...
  Open a diagram that shows how given field is used.

Calls diagram of ...
  Open a diagram that shows how given function is called.

Class diagram of ...
  Open a diagram that shows given class and its fields, the hierarchy, etc.

Inheritance diagram of ...
  Open a diagram that shows the class hierarchy of given class.

Go to use of ...
  Open the use site of the function shown as the edge in the diagram.

  This item is shown for the uses diagram's edge.

GC analysis
-----------

For functions that uses SpiderMonkey JSAPI, Searchfox can show which function can perform GC.
See the `Static Analysis for Rooting and Heap Write Hazards <https://firefox-source-docs.mozilla.org/js/HazardAnalysis/index.html>`__ document for more details how the analysis works.

This is behind the alpha feature gate "Semantic Info Queries".

Can GC/Cannot GC
  If a function can perform GC, "Can GC" item is shown.
  Clicking this shows a possible call path to the GC.

  If a function can never perform GC, "Cannot GC" item is shown.

  If the function is not found in the hazard analysis data, neither of these items are shown.
  This can happen if the function is not covered by the hazard analysis, or if the function symbol differs between GCC and Clang.
