All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.hm.hafner.analysis.KotlinPackageDetector Maven / Gradle / Ivy

Go to download

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).

There is a newer version: 12.9.1
Show newest version
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