You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/yaml-rule-structure-syntax.adoc
+76-32Lines changed: 76 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -352,13 +352,16 @@ when:
352
352
353
353
===== `java` provider
354
354
355
-
The `java` provider analyzes Java source code.
355
+
The Language Server used by the Java provider is Eclipse’s JDT Language Server (JDTLS). Internally, the JDTLS uses the Eclipse Java Development Toolkit, which includes utilities for searching code in projects.
356
356
357
357
This provider has the following capabilities:
358
358
359
359
* `referenced`
360
360
* `dependency`
361
361
362
+
In the `pattern` element of a `java.referenced` condition, you can search through application code by using these utilities. For more details, see link:https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2Fsearch%2FSearchPattern.html&anchor=createPattern[Class SearchPattern], which contains all the information for building these patterns for `createPattern(String, int, int, int)`.
363
+
364
+
362
365
.`referenced`
363
366
364
367
The `referenced` capability enables the provider to find references in the source code. This capability takes three input parameters: `pattern`, `location`, and `annotated`.
@@ -371,49 +374,90 @@ when:
371
374
location: "<location>" <2>
372
375
annotated: "<annotated>" <3>
373
376
----
374
-
<1> A regular expression pattern to match, for example, `org.kubernetes.*`.
377
+
<1> A regular expression pattern to match, for example, `org.kubernetes*`.
375
378
<2> Specifies the exact location where the pattern needs to be matched, for example, `IMPORT`.
376
379
<3> Checks for specific annotations and their elements, such as name and value in the Java code using a query. For example, the following query matches the Bean(url = “http://www.example.com”) annotation in the method.
380
+
381
+
382
+
.Examples
383
+
384
+
* Search for any class under the `javax.xml` package, occurring in any
385
+
location:
377
386
+
378
-
[source,terminal]
387
+
[source,yaml]
379
388
----
380
-
annotated:
381
-
pattern: org.framework.Bean
382
-
elements:
383
-
- name: url
384
-
value: "http://www.example.com"
389
+
java.referenced:
390
+
pattern: javax.xml*
385
391
----
392
+
+
393
+
[WARNING]
394
+
====
395
+
When matching against packages, as in the previous example, the asterisk must not be after a dot.
386
396
387
-
The supported locations are the following:
397
+
For example:
388
398
389
-
* `CONSTRUCTOR_CALL`
390
-
* `TYPE`
391
-
* `INHERITANCE`
392
-
* `METHOD_CALL`
393
-
* `ANNOTATION`
394
-
* `IMPLEMENTS_TYPE`
395
-
* `ENUM_CONSTANT`
396
-
* `RETURN_TYPE`
397
-
* `IMPORT`
398
-
* `VARIABLE_DECLARATION`
399
-
* `FIELD`
400
-
* `METHOD`
399
+
* `pattern: javax.xml*`
400
+
+
401
+
and not:
401
402
402
-
.`dependency`
403
+
* `pattern: javax.xml.*`
404
+
====
403
405
404
-
The `dependency` capability enables the provider to find dependencies for a given application. {ProductShortName} generates a list of the application's dependencies, and you can use this capability to query the list and check whether a certain dependency exists for the application within a given range of the dependency's versions.
406
+
* Search for method declarations that return `java.lang.String`:
407
+
+
408
+
[source,yaml]
409
+
----
410
+
java.referenced:
411
+
location: METHOD
412
+
pattern: '* java.lang.String'
413
+
----
405
414
406
-
[source,terminal]
415
+
* Search for a method named "`method`" declared on `org.konveyor.MyClass`
416
+
that returns a `List` of a type that extends `java.lang.String`:
* Search for a class that implements `java.util.List`:
426
+
+
427
+
[source,yaml]
428
+
----
429
+
java.referenced:
430
+
location: IMPLEMENTS_TYPE
431
+
pattern: java.util.List
432
+
----
433
+
434
+
// Module included in the following assemblies:
435
+
//
436
+
// * docs/rules-development-guide/master.adoc
437
+
438
+
:_mod-docs-content-type: REFERENCE
439
+
[id="yaml-custom-variables_{context}"]
440
+
= Custom variables
441
+
442
+
Provider conditions can have associated custom variables. You can use custom variables to capture relevant information from the matched line in the source code. The values of these variables are interpolated with data matched in the source code.
443
+
444
+
These values can be used to generate detailed template messages in a rule's action (see xref:yaml-rule-actions_{context}[Message actions]). They can be added to a rule in the `customVariables` field:
0 commit comments