Class Utils
java.lang.Object
org.clafer.cli.Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ScopeapplyScopeFile(Scope scope, AstModel model, String json, String fileName) Applies a .cfr-scope file (seeScopeFile) to a scope.static StringcountSuffix(int count) getAllModelClafers(AstModel model) All the clafers of the model, including the nested abstract ones and the type root #clafer#, except the roots of the model.static InstanceClafergetInstanceValueByName(InstanceClafer[] topClafers, String name) static AstClafergetModelChildByName(AstModel model, String name) static booleanisExplicitModel(File file, joptsimple.OptionSet options) Whether a model file is an explicit model, to be read byToAstrather than compiled by clafer: given with --explicit, or a .cfr file whose first line isAstPrinter.ExplicitHeader(or another//# OPTIONSline with --explicit).static voidprintClafer(InstanceClafer clafer, Appendable out) static voidproduceScopeFile(List<org.clafer.cli.ClaferNameScopePair> claferScopePairs, String scopesFile) static JavascriptFilestatic ScoperesolveScopes(File inputFile, JavascriptFile javascriptFile, joptsimple.OptionSet options) The scopes of the model: the model's, then its scope file's, if it has one, then the command line's.static ScoperesolveScopes(JavascriptFile javascriptFile, joptsimple.OptionSet options) static FileThe scope file given by --scope-file, otherwise the model's .cfr-scope file (model.cfr-scope next to model.cfr or model.js) if it exists, otherwise null.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
isExplicitModel
Whether a model file is an explicit model, to be read byToAstrather than compiled by clafer: given with --explicit, or a .cfr file whose first line isAstPrinter.ExplicitHeader(or another//# OPTIONSline with --explicit).- Throws:
IOException
-
readModel
Reads a model: an explicit model withToAst, another .cfr model withFrontend, otherwise a .js file. An explicit model starts from the default scope (its scopes are in its scope file, seeresolveScopes(File, JavascriptFile, OptionSet)).- Throws:
IllegalArgumentException- with the diagnostics, if the explicit model has errorsFrontend.ModelException- with the errors, if the .cfr model has errorsException
-
getAllModelClafers
All the clafers of the model, including the nested abstract ones and the type root #clafer#, except the roots of the model. -
produceScopeFile
public static void produceScopeFile(List<org.clafer.cli.ClaferNameScopePair> claferScopePairs, String scopesFile) throws FileNotFoundException - Throws:
FileNotFoundException
-
getInstanceValueByName
-
getModelChildByName
-
printClafer
- Throws:
IOException
-
countSuffix
-
resolveScopes
-
resolveScopes
public static Scope resolveScopes(File inputFile, JavascriptFile javascriptFile, joptsimple.OptionSet options) throws IOException The scopes of the model: the model's, then its scope file's, if it has one, then the command line's.- Throws:
IOException
-
scopeFile
-
applyScopeFile
Applies a .cfr-scope file (seeScopeFile) to a scope.- Throws:
IllegalArgumentException- if the file is malformed or a name is not of a clafer in the model
-