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
{ProductShortName} supports three types of conditions: `provider`, `and`, and `or`.
230
230
231
-
==== Provider conditions
231
+
[id="yaml-provider-conditions_{context}"]
232
+
== Provider conditions
232
233
233
234
The Application Analyzer detects the programming languages, frameworks, and tools used to build an application, and it generates default rulesets for each supported provider using the Language Server Protocol (LSP) accordingly.
234
235
Each supported provider has a ruleset defined by default and is run independently in a separate container.
@@ -273,7 +274,8 @@ a|
273
274
* Node.js
274
275
|===
275
276
276
-
===== `builtin` provider
277
+
[id="yaml-builtin-provider_{context}"]
278
+
=== `builtin` provider
277
279
278
280
`builtin` is an internal provider that can analyze various files and internal metadata generated by the engine.
279
281
@@ -350,15 +352,19 @@ when:
350
352
----
351
353
<1> When more than one tag is given, a logical AND is implied.
352
354
353
-
===== `java` provider
355
+
[id="yaml-java-provider_{context}"]
356
+
=== `java` provider
354
357
355
-
The `java` provider analyzes Java source code.
358
+
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
359
357
360
This provider has the following capabilities:
358
361
359
362
* `referenced`
360
363
* `dependency`
361
364
365
+
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)`.
366
+
367
+
362
368
.`referenced`
363
369
364
370
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 +377,151 @@ when:
371
377
location: "<location>" <2>
372
378
annotated: "<annotated>" <3>
373
379
----
374
-
<1> A regular expression pattern to match, for example, `org.kubernetes.*`.
380
+
<1> A regular expression pattern to match, for example, `org.kubernetes*`.
375
381
<2> Specifies the exact location where the pattern needs to be matched, for example, `IMPORT`.
376
382
<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.
383
+
384
+
385
+
.Examples
386
+
387
+
* Search for any class under the `javax.xml` package, occurring in any
388
+
location:
377
389
+
378
-
[source,terminal]
390
+
[source,yaml]
379
391
----
380
-
annotated:
381
-
pattern: org.framework.Bean
382
-
elements:
383
-
- name: url
384
-
value: "http://www.example.com"
392
+
java.referenced:
393
+
pattern: javax.xml*
385
394
----
395
+
+
396
+
[WARNING]
397
+
====
398
+
If you want to match using an asterisk `*` wildcard for a wider range of results, it is recommended to place it directly after the package, not after the dot:
386
399
387
-
The supported locations are the following:
400
+
For example:
388
401
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`
402
+
* `pattern: javax.xml*`
403
+
+
404
+
and not:
401
405
402
-
.`dependency`
406
+
* `pattern: javax.xml.*`
407
+
====
403
408
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.
409
+
* Search for method declarations that return `java.lang.String`:
410
+
+
411
+
[source,yaml]
412
+
----
413
+
java.referenced:
414
+
location: METHOD
415
+
pattern: '* java.lang.String'
416
+
----
405
417
406
-
[source,terminal]
418
+
* Search for a method named "`method`" declared on `org.konveyor.MyClass`
419
+
that returns a `List` of a type that extends `java.lang.String`:
* Search for a class that implements `java.util.List`:
429
+
+
430
+
[source,yaml]
431
+
----
432
+
java.referenced:
433
+
location: IMPLEMENTS_TYPE
434
+
pattern: java.util.List
435
+
----
436
+
437
+
[id="yaml-java-locations_{context}"]
438
+
==== `java` locations
439
+
440
+
The Java provider allows scoping down the search to certain source code locations. You can scope down Java searches from any one of the following search locations:
441
+
442
+
* *IMPORT*: IMPORT allows for searches on class imports. It can either be used with a fully qualified domain name (FQDN) or an asterisk as a wildcard to allow for wider matches:
443
+
+
444
+
For example:
445
+
+
446
+
[source,yaml]
447
+
----
448
+
java.referenced:
449
+
pattern: org.apache.lucene.search*
450
+
location: IMPORT
451
+
----
452
+
453
+
+
454
+
This scope would match on each of these imports:
455
+
+
456
+
[source,java]
457
+
----
458
+
import org.apache.lucene.search.Query;
459
+
import org.apache.lucene.search.Sort;
460
+
import org.apache.lucene.search.SortField;
461
+
----
462
+
+
463
+
If you want to match using an asterisk `*` wildcard for a wider range of results, it is recommended to place it directly after the package, not after the dot:
464
+
465
+
** Use: `org.apache.lucene.search*`
466
+
467
+
** Do not use: `org.apache.lucene.search.*`
468
+
469
+
470
+
* *PACKAGE*: PACKAGE allows for searches on any usage of a package, be it in an import or used as part of a FQDN in the code:
471
+
+
472
+
[source,yaml]
473
+
----
474
+
java.referenced:
475
+
pattern: org.apache.lucene.search*
476
+
location: PACKAGE
477
+
----
478
+
+
479
+
This scope would match on both the import and the fully qualified usage:
480
+
+
481
+
[source,java]
482
+
----
483
+
import org.apache.lucene.search.*;
484
+
----
485
+
+
486
+
[source,java]
487
+
----
488
+
public class Test {
489
+
private org.apache.lucene.search.Query query;
490
+
}
491
+
----
492
+
+
493
+
If you want to match using an asterisk `*` wildcard for a wider range of results, it is recommended to place it directly after the package, not after the dot.
494
+
495
+
496
+
* *CONSTRUCTOR_CALL* and *METHOD_CALL*: for matching constructors and methods, respectively. The pattern possibilities are varied, and it is possible to match against specific return types, arguments, and so on.
497
+
+
498
+
For instance, looking for a method named `method` declared in the `org.konveyor.MyClass` that returns a `List` of a type that extends `java.lang.String` and accepts a single parameter:
More information about the possibilities of these patterns can be found in the link:[Class SearchPattern section] of the Eclipse documentation, which contain all the required information for building these patterns.
508
+
509
+
[WARNING]
510
+
====
511
+
In the current release of {ProductShortName}, fully qualified static method matching does not function as expected.
512
+
====
513
+
514
+
* *TYPE*: matches against types in general, appearing anywhere.
515
+
* *INHERITANCE*: matches against a class inheriting from a given type.
516
+
* *ANNOTATION*: matches against annotations.
517
+
* *IMPLEMENTS_TYPE*: matches against any type implementing the given type.
518
+
* *ENUM_CONSTANT*: matches against `enum` constants.
519
+
* *RETURN_TYPE*: matches against a type being returned by a method.
520
+
* *VARIABLE_DECLARATION*: matches against a type being declared as a variable.
521
+
* *FIELD* (declaration): matches against a type appearing in a field declaration. It can be coupled with an annotation match, this being an annotation happening on the field.
522
+
* *METHOD*: matches against a given method declaration. It can be coupled with an annotation match.
523
+
* *CLASS* (declaration): matches against a given method declaration. It can be coupled with an annotation match.
0 commit comments