Skip navigation links
org.netbeans.spi.java.hints 1.30.0 13

Java Hints SPI
Under Development

See: Description

Java Hints SPI 
Package Description
org.netbeans.spi.java.hints  
org.netbeans.spi.java.hints.support  

spi.java.hints SPI to create custom Java hints, including code smell warnings, productivity tips, etc. Please see the Use Cases section for a guide on how to use this SPI.

What is New (see all changes)?

Use Cases

Creating a new Java Hint
Simple way to create a new Java hint is as follows:
  • Create a new class, annotate it with the @Hint annotation to it.
  • Create a public static ErrorDescription hint(HintContext ctx) {} method in the class. Annotate the method either with the @TriggerPattern annotation (strongly recommended), or with the @TriggerTreeKind. This method will be called when for parts of the code that match the given pattern, of for trees of the specified kinds.
  • Perform whatever checks necessary to find out whether a warning should be produced at the given place, and produce the ErrorDescription if needed.

Tips:
  • Always use the java.hints' ErrorDescriptionFactory to produce the resulting ErrorDescription.
  • Never try to produce a custom suppress warnings "fix". Specify suppress warnings keys in the @Hint annotation.
  • If an automated transformation is to be prodived from your hint, subclass JavaFix and use its toEditorFix() method to get the Fix, if the transformation is going to be used inside Inspect&Transform.
  • The name of the method is arbitrary, one hint can consist of more that one "triggered" method.
Creating a new Java Hint Without a Class
For simple hints, it is possible to annotate the hint method with the @Hint annotation. The hint then consists of this sole method. Any number of such hints may be created in a single class.
Creating a Tests for the Newly Created Java Hint
Creating automated tests for the hints is simple: create a test class, and use HintTest to setup the test, run the hint and verify that its outcomes are correct. The tests automatically run with test branding, so create Bundle_test.properties, and add bundle keys into it for ErrorDescription and Fix display names, to isolate the test from changes in the production Bundle.properties.
Adding options to a Java Hint
To add a simple boolean option to your hint, use @BooleanOption.

Exported Interfaces

This table lists all of the module exported APIs with defined stability classifications. It is generated based on answers to questions about the architecture of the module. Read them all...
Group of java interfaces
Interface NameIn/OutStabilitySpecified in What Document?
spi.java.hintsExportedUnder Development

SPI to create custom Java hints, including code smell warnings, productivity tips, etc. Please see the Use Cases section for a guide on how to use this SPI.

Implementation Details

Where are the sources for the module?

The sources for the module are in the NetBeans Mercurial repositories.

What do other modules need to do to declare a dependency on this one, in addition to or instead of a plain module dependency?

XXX no answer for deploy-dependencies

Read more about the implementation in the answers to architecture questions.

Skip navigation links
org.netbeans.spi.java.hints 1.30.0 13

Built on September 25 2016.  |  Portions Copyright 1997-2016 Oracle. All rights reserved.