edu.hm.hafner.analysis.KotlinPackageDetector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of analysis-model Show documentation
Show all versions of analysis-model Show documentation
This library provides a Java object model to read, aggregate, filter, and query static analysis reports.
It is used by Jenkins' warnings next generation plug-in to visualize the warnings of individual builds.
Additionally, this library is used by a GitHub action to autograde student software projects based on a given set of
metrics (unit tests, code and mutation coverage, static analysis warnings).
package edu.hm.hafner.analysis;
import java.util.regex.Pattern;
import edu.hm.hafner.analysis.PackageDetectors.FileSystem;
import edu.hm.hafner.util.VisibleForTesting;
/**
* Detects the package name of a Kotlin file.
*
* @author Bastian Kersting
*/
class KotlinPackageDetector extends AbstractPackageDetector {
private static final Pattern PACKAGE_PATTERN = Pattern.compile(
"^\\s*package\\s*([a-z]+[.\\w]*)\\s*.*");
KotlinPackageDetector() {
this(new FileSystem());
}
@VisibleForTesting
KotlinPackageDetector(final FileSystem fileSystem) {
super(fileSystem);
}
@Override
Pattern getPattern() {
return PACKAGE_PATTERN;
}
@Override
boolean accepts(final String fileName) {
return fileName.endsWith(".kt");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy