SourceFiles

io.joern.x2cpg.SourceFiles
object SourceFiles

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def determine(inputPath: String, sourceFileExtensions: Set[String], ignoredDefaultRegex: Option[Seq[Regex]], ignoredFilesRegex: Option[Regex], ignoredFilesPath: Option[Seq[String]])(implicit visitOptions: Seq[FileVisitOption]): List[String]

Determines a sorted list of file paths in a directory that match the specified criteria.

Determines a sorted list of file paths in a directory that match the specified criteria.

Value parameters

ignoredDefaultRegex

An optional sequence of regular expressions for default files to ignore.

ignoredFilesPath

An optional sequence of specific file paths to ignore.

ignoredFilesRegex

An optional regular expression for additional files to ignore.

inputPath

The root directory to search for files.

sourceFileExtensions

A set of file extensions to include in the search.

visitOptions

Implicit parameter defining the options for visiting the file tree. Defaults to VisitOptions.follow, which follows symbolic links.

Attributes

Returns

A sorted List[String] of file paths matching the criteria. This function traverses the file tree starting at the given inputPath and collects file paths that:

  • Have extensions specified in sourceFileExtensions.
  • Are not ignored based on ignoredDefaultRegex, ignoredFilesRegex, or ignoredFilesPath. It uses a custom FailsafeFileVisitor to handle the filtering logic and Files.walkFileTree to perform the traversal. Example usage:
val files = determine(
 inputPath = "/path/to/dir",
 sourceFileExtensions = Set(".scala", ".java"),
 ignoredDefaultRegex = Some(Seq(".*\\.tmp".r)),
 ignoredFilesRegex = Some(".*_backup\\.scala".r),
 ignoredFilesPath = Some(Seq("/path/to/dir/ignore_me.scala"))
)
println(files)
Throws
java.io.FileNotFoundException

if the inputPath does not exist or is not readable.

See also

FailsafeFileVisitor for details on the visitor used to process files.

def filterFile(file: String, inputPath: String, ignoredDefaultRegex: Option[Seq[Regex]], ignoredFilesRegex: Option[Regex], ignoredFilesPath: Option[Seq[String]]): Boolean

Filters a file based on the provided ignore rules.

Filters a file based on the provided ignore rules.

This method determines whether a given file should be excluded from processing based on several criteria, such as matching default ignore patterns, specific file name patterns, or explicit file paths to ignore.

Value parameters

file

The file name or path to evaluate.

ignoredDefaultRegex

Optional sequence of regular expressions defining default file patterns to ignore.

ignoredFilesPath

Optional sequence of file paths to explicitly exclude.

ignoredFilesRegex

Optional regular expression defining specific file name patterns to ignore.

inputPath

The root input path for the file traversal.

Attributes

Returns

true if the file is accepted, i.e., does not match any of the ignore criteria, false otherwise.

def filterFiles(files: List[String], inputPath: String, ignoredDefaultRegex: Option[Seq[Regex]], ignoredFilesRegex: Option[Regex], ignoredFilesPath: Option[Seq[String]]): List[String]

Filters a list of files based on the provided ignore rules.

Filters a list of files based on the provided ignore rules.

This method applies filterFile to each file in the input list, returning only those files that do not match any of the ignore criteria.

Value parameters

files

The list of file names or paths to evaluate.

ignoredDefaultRegex

Optional sequence of regular expressions defining default file patterns to ignore.

ignoredFilesPath

Optional sequence of file paths to explicitly exclude.

ignoredFilesRegex

Optional regular expression defining specific file name patterns to ignore.

inputPath

The root input path for the file traversal.

Attributes

Returns

A filtered list of files that do not match the ignore criteria.

def toAbsolutePath(path: String, rootPath: String): String

Constructs an absolute path against rootPath. If the given path is already absolute this path is returned unaltered. Otherwise, "rootPath / path" is returned.

Constructs an absolute path against rootPath. If the given path is already absolute this path is returned unaltered. Otherwise, "rootPath / path" is returned.

Attributes

def toRelativePath(path: String, rootPath: String): String

Constructs a relative path against rootPath. If the given path is not inside rootPath, path is returned unaltered. Otherwise, the path relative to rootPath is returned.

Constructs a relative path against rootPath. If the given path is not inside rootPath, path is returned unaltered. Otherwise, the path relative to rootPath is returned.

Attributes