Quick Query


The main body of the Quick Query window is a standard text editor for CodeQL queries. It is particularly useful for developing and testing new queries. If you want to edit CodeQL libraries or saved query files, you can use the QL editor.

Displaying the Quick Query window

To display the Quick Query window, click the Quick Query icon () in the Results view.

In the Quick Query window, there are two main areas of control:

  1. Top toolbar—defines the display name for any results of this query. It also includes three icons:
  2. Icon Action
    Run the query (equivalent to Ctrl+R).
    Save the query.
    Restore the previous query.
  3. Bottom toolbar—defines the initial display format for the query results. The buttons and display styles are the same as those described for the Results panel of the Results view.

Available actions

The Quick Query window supports the following options:

Command Description Access
Auto-complete Display auto-complete information in a pop-up window. This is normally triggered automatically as you type your query. You can also manually re-display the information (for example, after deleting a predicate).

Automatic or Ctrl+Space

Auto-format QL Format the currently open .ql or .qll file so that it follows the CodeQL Style Guide. Ctrl+Shift+F
QL entity info Show a description of the current QL entity including any QLDoc. This is displayed in a pop-up window when you hover over an entity with your mouse cursor. Hover over code
Find References

Find all QL references to the selected element in files and display the results in a Search window.

Find Subtypes

Available only for types: find QL types that directly extend the selected type and display the results in a Search window.

Multiline comments When you enter /* at the start of a multiline comment, CodeQL for Eclipse automatically inserts a closing */. Within a multiline comment, pressing Enter automatically creates a new line with appropriate whitespace and a * character.
You can enable or disable this using the CodeQL for Eclipse preferences page.
Open Declaration

Open the declaration of the selected predicate, type, or module in a QL file. This is the same as Jump to definition (F3).

Quick Evaluation

Evaluate the currently selected snippet of QL code and report the results in the Results view. Possible targets for quick evaluation include:

  • Selecting the name of a CodeQL entity (such as a class or predicate) to evaluate that entity.
  • Selecting a formula or expression with free variables to evaluate that formula or expression.

This is particularly useful when you are debugging a query and want to locate the part of the query that is wrong.

Spell check Check the spelling of text in comments using the tool built in to Eclipse. You can enable or disable it using the General > Editors > Text Editors > Spelling preferences page.  Automatic
Syntax check Underline any errors in red and highlight the line. The Run option is disabled until you have corrected the error. Hover the cursor over the error icon to display a tooltip describing the problem. Any warnings are underlined in orange. Automatic

You can close the Quick Query window at any time by pressing the keyboard Escape key.

Related Topics Link IconRelated Topics