Package org.openrewrite.java.marker
Class JavaSourceSet
java.lang.Object
org.openrewrite.java.marker.JavaSourceSet
- All Implemented Interfaces:
org.openrewrite.marker.Marker,org.openrewrite.marker.SourceSet
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTypesForGav(String gavKey, List<JavaType.FullyQualified> types) Add types for the given GAV key to this source set's classpath and gavToTypes mapping.static JavaSourceSetbuild(String sourceSetName, Collection<Path> classpath) Extract type information from the provided classpath.static JavaSourceSetbuild(String sourceSetName, Collection<Path> classpath, JavaTypeCache ignore, boolean fullTypeInformation) Deprecated.removeTypesForGav(String gavKey) Remove all types associated with the given GAV key from this source set's classpath and gavToTypes mapping.removeTypesMatching(String groupIdPattern, String artifactIdPattern) Remove types from this source set whose GAV keys match the given groupId and artifactId glob patterns.static List<JavaType.FullyQualified> typesFromPath(Path path, @Nullable String acceptPackage) static org.openrewrite.SourceFileupdateOnSourceFile(org.openrewrite.SourceFile sf, Function<JavaSourceSet, JavaSourceSet> transform) Apply a transformation to theJavaSourceSetmarker on a source file and replace it if changed.static org.openrewrite.SourceFileupdateOnSourceFile(org.openrewrite.SourceFile sf, Map<String, JavaSourceSet> cache, Function<JavaSourceSet, JavaSourceSet> transform) Apply a transformation to theJavaSourceSetmarker on a source file, using a cache keyed byJavaProjectID and source set name to avoid redundant recomputation across files in the same source set.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.openrewrite.marker.Marker
getId, print, withIdMethods inherited from interface org.openrewrite.marker.SourceSet
getName, withName
-
Constructor Details
-
JavaSourceSet
public JavaSourceSet()
-
-
Method Details
-
addTypesForGav
Add types for the given GAV key to this source set's classpath and gavToTypes mapping.- Parameters:
gavKey- a "group:artifact:version" stringtypes- the types provided by the artifact- Returns:
- a new JavaSourceSet with the types added
-
removeTypesForGav
Remove all types associated with the given GAV key from this source set's classpath and gavToTypes mapping.- Parameters:
gavKey- a "group:artifact:version" string- Returns:
- a new JavaSourceSet with the types removed, or this instance if the key is not present
-
removeTypesMatching
Remove types from this source set whose GAV keys match the given groupId and artifactId glob patterns.- Parameters:
groupIdPattern- glob pattern for groupId matchingartifactIdPattern- glob pattern for artifactId matching- Returns:
- a new JavaSourceSet with matching types removed, or this instance if no keys match
-
updateOnSourceFile
public static org.openrewrite.SourceFile updateOnSourceFile(org.openrewrite.SourceFile sf, Function<JavaSourceSet, JavaSourceSet> transform) Apply a transformation to theJavaSourceSetmarker on a source file and replace it if changed.- Parameters:
sf- the source file to updatetransform- a function that takes the current JavaSourceSet and returns an updated one- Returns:
- the source file with the updated marker, or unchanged if no JavaSourceSet is present or the transform is a no-op
-
updateOnSourceFile
public static org.openrewrite.SourceFile updateOnSourceFile(org.openrewrite.SourceFile sf, Map<String, JavaSourceSet> cache, Function<JavaSourceSet, JavaSourceSet> transform) Apply a transformation to theJavaSourceSetmarker on a source file, using a cache keyed byJavaProjectID and source set name to avoid redundant recomputation across files in the same source set.- Parameters:
sf- the source file to updatecache- a mutable map used to cache updated JavaSourceSets across callstransform- a function that takes the current JavaSourceSet and returns an updated one- Returns:
- the source file with the updated marker, or unchanged if no JavaSourceSet/JavaProject is present
-
build
@Deprecated public static JavaSourceSet build(String sourceSetName, Collection<Path> classpath, JavaTypeCache ignore, boolean fullTypeInformation) Deprecated.Extract type information from the provided classpath. Uses ClassGraph to compute the classpath.Does not support gavToTypes or typeToGav mapping
- Parameters:
ignore- Not used, does not do anything, to be deletedfullTypeInformation- Not used, does not do anything, to be deleted
-
build
Extract type information from the provided classpath. Uses file I/O to compute the classpath. -
typesFromPath
public static List<JavaType.FullyQualified> typesFromPath(Path path, @Nullable String acceptPackage)
-