Skip to content

@TemplateExtension methods falsely reported as unused #1565

@dcucchietti

Description

@dcucchietti

Summary

Public static methods defined in a @TemplateExtension class are reported as "unused" by IntelliJ's code inspection, even though they are actively called from Qute templates. These methods render correctly at runtime — the warning is a false positive.


Environment

  • Quarkus version: 3.32.2
  • Qute version: bundled with Quarkus 3.x
  • IDE: IntelliJ IDEA with Quarkus plugin

Steps to Reproduce

A repository is available to reproduce the error : link

  1. Create a @TemplateExtension class with an extension method, see example
  @TemplateExtension
  public class GlobalExtension {

      public static String ellipsis(String value, int maxLength) {
          if (value == null || value.length() <= maxLength) {
              return value;
          }
          return value.substring(0, maxLength) + "…";
      }
  }
  1. Call it from a Qute template:
    <p>{description.ellipsis(20)}</p>
  1. Open GlobalExtension.java in IntelliJ and observe the inspection warning on ellipsis().
Image

Expected Behavior

No "unused" warning should be raised. The Quarkus plugin should recognize that public static methods in @TemplateExtension classes are callable as virtual methods on their first parameter type in Qute templates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions