Add "handle-as" hint provider

Replace the enum provider by a more general purpose provider that can
substitute the type of the property for the purpose of auto-completing
the values.

"handle-as" can be used for enums but for any type that the IDE
understands such as locale, charset, mime-type and Spring's resource
abstraction.

Closes gh-3457
This commit is contained in:
Stephane Nicoll 2015-07-10 14:28:11 +02:00
parent f6f74e1aef
commit 8ff8afec7c
2 changed files with 19 additions and 11 deletions

View File

@ -229,7 +229,7 @@
"name": "spring.jooq.sql-dialect", "name": "spring.jooq.sql-dialect",
"providers": [ "providers": [
{ {
"name": "enum", "name": "handle-as",
"parameters": { "parameters": {
"target": "org.jooq.SQLDialect" "target": "org.jooq.SQLDialect"
} }

View File

@ -351,8 +351,8 @@ The table below summarizes the list of supported providers:
|Auto-complete the classes available in the project. Usually constrained by a base |Auto-complete the classes available in the project. Usually constrained by a base
class that is specified via the `target` parameter. class that is specified via the `target` parameter.
|`enum` |`handle-as`
|Auto-complete the values of an enum given by the mandatory `target` parameter. |Handle the property as if it was defined by the type defined via the mandatory `target` parameter.
|`logger-name` |`logger-name`
|Auto-complete valid logger names. Typically, package and class names available in |Auto-complete valid logger names. Typically, package and class names available in
@ -453,9 +453,9 @@ property that defines the `JspServlet` class name to use:
===== Enum ===== Handle As
The **enum** provider auto-completes the values of the `Enum` class referenced via the The **handle-as** provider allows you to substitute the type of the property to a more
`target` parameter. This may be handy when the property has a `java.lang.String` type high-level type. This typically happens when the property has a `java.lang.String` type
because you don't want your configuration classes to rely on classes that may not be because you don't want your configuration classes to rely on classes that may not be
on the classpath. This provider supports these parameters: on the classpath. This provider supports these parameters:
@ -464,13 +464,21 @@ on the classpath. This provider supports these parameters:
|Parameter |Type |Default value |Description |Parameter |Type |Default value |Description
| **`target`** | **`target`**
| `String` (`Enum`) | `String` (`Class`)
|_none_ |_none_
|The fully qualified name of the `Enum` class. This parameter is mandatory. |The fully qualified name of the type to consider for the property. This parameter is mandatory.
|=== |===
TIP: By all means, try to define the property with the `Enum` type instead as The following types can be used:
no further hint should be required for the IDE to auto-complete the values.
* Any `java.lang.Enum` that list the possible values for the property (By all means, try to
define the property with the `Enum` type instead as no further hint should be required for
the IDE to auto-complete the values).
* `java.nio.charset.Charset`: auto-completion of charset/encoding values
* `java.util.Locale`: auto-completion of locales
* `org.springframework.util.MimeType`: auto-completion of content type values
* `org.springframework.core.io.Resource`: auto-completion of Springs Resource abstraction to
refer to a file on the filesystem or on the classpath.
The meta-data snippet below corresponds to the standard `spring.jooq.sql-dialect` The meta-data snippet below corresponds to the standard `spring.jooq.sql-dialect`
property that defines the `SQLDialect` class name to use: property that defines the `SQLDialect` class name to use:
@ -482,7 +490,7 @@ property that defines the `SQLDialect` class name to use:
"name": "spring.jooq.sql-dialect", "name": "spring.jooq.sql-dialect",
"providers": [ "providers": [
{ {
"name": "enum", "name": "handle-as",
"parameters": { "parameters": {
"target": "org.jooq.SQLDialect" "target": "org.jooq.SQLDialect"
} }