Interface ScalafmtSession


  • public interface ScalafmtSession
    A session based on a fixed configuration.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String format​(java.nio.file.Path file, java.lang.String code)
      Format a single file with the given configuration.
      ScalafmtResult formatOrError​(java.nio.file.Path file, java.lang.String code)
      Format a single file with the given configuration.
      boolean isGitOnly()
      Whether this configuration intends to limit files to those managed by git.
      boolean matchesProjectFilters​(java.nio.file.Path file)
      Whether the path matches the 'project.{excludeFilters,includeFilters}' setting.
    • Method Detail

      • format

        java.lang.String format​(java.nio.file.Path file,
                                java.lang.String code)
        Format a single file with the given configuration.
        Parameters:
        file - relative or absolute path to the file being formatted. Used only for the path name, the file does not have to exist on disk.
        code - the text contents to format.
        Returns:
        the formatted contents if formatting was successful, otherwise the original text contents.
      • formatOrError

        ScalafmtResult formatOrError​(java.nio.file.Path file,
                                     java.lang.String code)
        Format a single file with the given configuration.
        Parameters:
        file - relative or absolute path to the file being formatted. Used only for the path name, the file does not have to exist on disk.
        code - the text contents to format.
        Returns:
        the formatted contents if formatting was successful, otherwise an error.
      • matchesProjectFilters

        boolean matchesProjectFilters​(java.nio.file.Path file)
        Whether the path matches the 'project.{excludeFilters,includeFilters}' setting.
        Parameters:
        file - path to match
        Returns:
        true if the path matched the filters
      • isGitOnly

        boolean isGitOnly()
        Whether this configuration intends to limit files to those managed by git.