Archive for November 19th, 2009

JPA 2.0 Typesafe Criteria API and Annotation Processing Howto

Thursday, November 19th, 2009

Maia build subsystem now recognizes Java Annotation Processors. Most of JPA 2.0 implementations are expected to make use of the Pluggable Annotation Processing API to automatically generate static metamodel classes. Here is a list of steps required to generate JPA 2.0 metamodel and keep it up-to-date with Hibernate Static Metamodel Generator. For the simplicity in this sample project the processor jar file is added to the module dependencies.

  • Enable annotation processing
  • Select Obtain processors from project classpath option
  • Add a processor class name to the Processors list
  • Add a module with annotated classes to the list of modules to process
  • To output generated classes to a generated directory under module content root, set Generated Sources Directory Name to generated. Note that this directory will not be set as a source root automatically.

Now, Annotation processors will be run every time you invoke Make or Compile. Besides, there is a special menu item Process Annotations that does exactly what its name says. In this sample project I have added the generated directory to project sources to get completion in JPA 2.0 Typesafe Criteria API calls. Enjoy, Comment.

IntelliJ IDEA PSI Viewer

Thursday, November 19th, 2009

If you’re an IntelliJ IDEA plugin developer, you’re surely going to enjoy IntelliJ IDEA PSI Viewer (Tools -> View PSI Structure), which displays internal structure of various files, as they’re interpreted by IntelliJ IDEA. If you’re implementing a new language support, or trying to add some cool new features to what’s already supported — this viewer is what you’re gonna need a lot.

As you see, PSI Viewer is made up of of tree parts:

  • An editor with file content
  • PSI structure view with parent-child tree of its elements
  • Area that displays references of element selected in PSI structure view.

Note that references marked as red resolve to null.

Available since build 92.35

CDI (JSR-299) Run with me…

Thursday, November 19th, 2009

Contexts and Dependency Injection (JSR-299) support in Maia has been significantly improved.

  • Reworked tool window:

  • New code inspections:
    • Injection points inconsistency. Detects Injection Points with ambiguous and unsatisfied dependencies
    • @Typed annotation errors.

    • Unproxyable bean types inconsistency.

    • And more:
  • Improved Rename refactoring for @Named beans
  • Better navigation to @Typed beans
  • Enhanced dependencies diagram, and more.