Skip to content

Commit 957d94d

Browse files
committed
add
Signed-off-by: A.Arnold <[email protected]>
1 parent 222f475 commit 957d94d

File tree

1 file changed

+90
-1
lines changed

1 file changed

+90
-1
lines changed

docs/topics/yaml-rule-structure-syntax.adoc

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ java.referenced:
392392
+
393393
[WARNING]
394394
====
395-
When matching against packages, as in the previous example, the asterisk must not be after a dot.
395+
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:
396396
397397
For example:
398398
@@ -431,6 +431,95 @@ java.referenced:
431431
pattern: java.util.List
432432
----
433433

434+
====== `java` locations
435+
436+
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:
437+
438+
* *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:
439+
+
440+
For example:
441+
+
442+
[source,yaml]
443+
----
444+
java.referenced:
445+
pattern: org.apache.lucene.search*
446+
location: IMPORT
447+
----
448+
449+
+
450+
This scope would match on each of these imports:
451+
+
452+
[source,java]
453+
----
454+
import org.apache.lucene.search.Query;
455+
import org.apache.lucene.search.Sort;
456+
import org.apache.lucene.search.SortField;
457+
----
458+
+
459+
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:
460+
461+
** Use: `org.apache.lucene.search*`
462+
463+
** Do not use: `org.apache.lucene.search.*`
464+
465+
466+
* *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:
467+
+
468+
[source,yaml]
469+
----
470+
java.referenced:
471+
pattern: org.apache.lucene.search*
472+
location: PACKAGE
473+
----
474+
+
475+
This scope would match on both the import and the fully qualified usage:
476+
+
477+
[source,java]
478+
----
479+
import org.apache.lucene.search.*;
480+
----
481+
+
482+
[source,java]
483+
----
484+
public class Test {
485+
private org.apache.lucene.search.Query query;
486+
}
487+
----
488+
+
489+
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.
490+
491+
492+
* *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.
493+
+
494+
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:
495+
+
496+
[source,yaml]
497+
----
498+
java.referenced:
499+
location: METHOD
500+
pattern: 'org.konveyor.Myclass.method(*) java.util.List<? extends java.lang.String>'
501+
----
502+
503+
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.
504+
505+
[WARNING]
506+
====
507+
In the current release of {ProductShortName}, fully qualified static method matching does not function as expected.
508+
====
509+
510+
* *TYPE*: matches against types in general, appearing anywhere.
511+
* *INHERITANCE*: matches against a class inheriting from a given type.
512+
* *ANNOTATION*: matches against annotations.
513+
* *IMPLEMENTS_TYPE*: matches against any type implementing the given type.
514+
* *ENUM_CONSTANT*: matches against enum constants.
515+
* *RETURN_TYPE*: matches against a type being returned by a method.
516+
* *VARIABLE_DECLARATION*: matches against a type being declared as a variable.
517+
* *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.
518+
* *METHOD*: matches against a given method declaration. It can be coupled with an annotation match.
519+
* *CLASS* (declaration): matches against a given method declaration. It can be coupled with an annotation match.
520+
521+
522+
434523
// Module included in the following assemblies:
435524
//
436525
// * docs/rules-development-guide/master.adoc

0 commit comments

Comments
 (0)