Record Class ModelFiles
java.lang.Object
java.lang.Record
org.clafer.frontend.ModelFiles
- Record Components:
files- the files, in order, the model lastoptions- the options of all the files, combinederrors- the compiler's errors of reading the files and combining their options; the files are empty if there is one
public record ModelFiles(List<ModelFiles.ModelFile> files, ModelOptions options, List<String> errors)
extends Record
The files of a model: the model and the files it imports, transitively,
with
--import=FILE in their //# OPTIONS lines, as the
compiler reads them (Import.readModel): local files and http or
https URLs (Http). An import is relative to the folder or the URL of
the importing file; the imported files come before the files that import
them, each once, and the model last. The model is their concatenation, and
a line of it is shown in its file (position(int)). The web tools'
restrictions of the imports are ModelFiles.ImportOptions.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe restrictions of the imports, which only the command line gives, as the web tools give them to the compiler:static final recordstatic final recordA line in a file. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionModelFiles(List<ModelFiles.ModelFile> files, ModelOptions options, List<String> errors) Creates an instance of aModelFilesrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.errors()Returns the value of theerrorsrecord component.files()Returns the value of thefilesrecord component.format(Diagnostic d) final inthashCode()Returns a hash code value for this object.booleanstatic booleanstatic StringThe name of the model's file for its outputs: its path, or, for a URL, the last segment of its path (model.cfrif it has none), in the working folder.static ModelFilesA model in one file, whose imports are not read: its text and options.options()Returns the value of theoptionsrecord component.position(int line) static ModelFilesReads a model and the files it imports, local files and URLs.static ModelFilesReads a model and the local files it imports, taking the text of a file fromopenwhere it has one, e.g., a document open in an editor, and from disk otherwise.static ModelFilesread(String path, List<String> commandLineImports, Function<String, Optional<String>> open, ModelFiles.ImportOptions restrictions) Reads a model and the files it imports, as the compiler does (Import.readModel).text()final StringtoString()Returns a string representation of this record class.
-
Field Details
-
Stdin
-
-
Constructor Details
-
Method Details
-
of
A model in one file, whose imports are not read: its text and options.- Parameters:
path- the path that the messages show, or empty
-
text
-
read
Reads a model and the files it imports, local files and URLs.- Parameters:
path- the model's file or URL, as the messages show itcommandLineImports- the imports given on the command line, relative to the working folder, which come first
-
read
public static ModelFiles read(String path, List<String> commandLineImports, Function<String, Optional<String>> open) Reads a model and the local files it imports, taking the text of a file fromopenwhere it has one, e.g., a document open in an editor, and from disk otherwise. An import of a URL is an error (importsUrl()).- Parameters:
path- the model's file, as the messages show itcommandLineImports- the imports given on the command lineopen- the text of a file, by its path as the model names it, if it is not to be read from disk
-
read
public static ModelFiles read(String path, List<String> commandLineImports, Function<String, Optional<String>> open, ModelFiles.ImportOptions restrictions) Reads a model and the files it imports, as the compiler does (Import.readModel). The model is a file, a URL, or the standard input (Stdin, whose textopengives). The imports of the command line are relative to the working folder, and those of a file to its folder or URL, or, for the model, to--import-base. A file read from a URL may only import URLs.- Parameters:
path- the model's file or URL, as the messages show itcommandLineImports- the imports given on the command lineopen- the text of a file, by its path, if it is not to be readrestrictions- the restrictions of the imports
-
localName
-
importsUrl
- Returns:
- whether the model could not be read because it imports a URL,
which was not to be read (
ModelFiles.ImportOptions.readUrls)
-
isUrl
-
position
- Parameters:
line- a line of the model, from 1- Returns:
- the path of its file and its line in it
-
format
- Returns:
- the diagnostic at its position in its file, e.g.,
model.cfr:3:5: message, or without a path if the model has no name
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
files
-
options
-
errors
-