Documentation

Std.Tactic.TryThis

"Try this" support #

This implements a mechanism for tactics to print a message saying Try this: , where is a link to a replacement tactic. Users can either click on the link in the suggestion (provided by a widget), or use a code action which applies the suggestion.

This is a widget which is placed by TryThis.addSuggestion; it says Try this: where is a link which will perform the replacement.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    This is a code action provider that looks for TryThisInfo nodes and supplies a code action to apply the replacement.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Replace subexpressions like ?m.1234 with ?_ so it can be copy-pasted.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Delaborate e into an expression suitable for use in refine.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          def Std.Tactic.TryThis.addSuggestion (ref : Lean.Syntax) {kind : Lean.Name} (suggestion : Lean.TSyntax kind) (suggestionForMessage? : optParam (Option Lean.MessageData) none) (origSpan? : optParam (Option Lean.Syntax) none) (extraMsg : optParam String "") :

          Add a "try this" suggestion. This has three effects:

          • An info diagnostic is displayed saying Try this:
          • A widget is registered, saying Try this: with a link on to apply the suggestion
          • A code action Apply 'Try this' is added, which will apply the suggestion.

          The parameters are:

          • ref: the span of the info diagnostic
          • suggestion: the replacement syntax
          • suggestionForMessage?: the message to display in the info diagnostic (only). The widget message uses only suggestion. If not provided, suggestion is used in both places.
          • origSpan?: a syntax object whose span is the actual text to be replaced by suggestion. If not provided it defaults to ref.
          • extraMsg: an extra piece of message text to apply to the widget message (only).
          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Add a exact e or refine e suggestion.

            The parameters are:

            • ref: the span of the info diagnostic
            • e: the replacement expression
            • origSpan?: a syntax object whose span is the actual text to be replaced by suggestion. If not provided it defaults to ref.
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Add a term suggestion.

              The parameters are:

              • ref: the span of the info diagnostic
              • e: the replacement expression
              • origSpan?: a syntax object whose span is the actual text to be replaced by suggestion. If not provided it defaults to ref.
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For