Utility
public static class UtilityInherits from System.Object
#Methods
#DetermineNodeConnections(string[])
public static List<List<GraphingNode>> DetermineNodeConnections(string[] YarnFileContents)Parameters
YarnFileContentsstring[]The collection of yarn file content to parse and walk
Returns List: A list of lists of GraphingNode each containing a node, its jumps, and any positional info.
#ExtractStringBlocks(IEnumerable<Node>, ProjectDebugInfo)
public static List<List<string>> ExtractStringBlocks(IEnumerable<Node> nodes, ProjectDebugInfo projectDebugInfo)Parameters
nodesSystem.Collections.Generic.IEnumerable<Yarn.Node>The nodes to get string blocks for.projectDebugInfoYarn.Compiler.ProjectDebugInfoAn object containing debugging information for the project.
Returns List: A collection of runs of lines.
#GenerateYarnFileWithDeclarations(IEnumerable<Yarn.Compiler.Declaration>, string, IEnumerable<string>?, IDictionary<string, string>?)
public static string GenerateYarnFileWithDeclarations(IEnumerable<Yarn.Compiler.Declaration> declarations, string title = "Program", IEnumerable<string>? tags = null, IDictionary<string, string>? headers = null)Parameters
declarationsSystem.Collections.Generic.IEnumerable<Yarn.Compiler.Declaration>The collection of Declaration objects to include in the output.titlestringThe title of the node that should be generated.tagsSystem.Collections.Generic.IEnumerable<string>The collection of tags that should be generated for the node. If this isnull, no tags will be generated.headersSystem.Collections.Generic.IDictionary<string, string>The collection of additional headers that should be generated for the node. If this isnull, no additional headers will be generated.
Returns String: A string containing a Yarn script that declares the
specified variables.
#GetCompiledCodeAsString(Program, CompilationResult?)
public static string GetCompiledCodeAsString(Program program, CompilationResult? result = null)Parameters
programYarn.ProgramThe program to be dumped as a string- The compilation result, needed for various elements of the dump like the lines
Returns String
#GetRange(ParserRuleContext)
ParserRuleContext in the
source code.public static Range GetRange(ParserRuleContext context)Parameters
contextParserRuleContextThe context to get a range for.
#GetYarnValue(IConvertible)
public static IYarnValue? GetYarnValue(IConvertible clrValue)Parameters
clrValueSystem.IConvertibleThe value to get a Yarn representation of.
Returns IYarnValue: An IYarnValue representation of clrValue.
#ParseSource(string) Obsolete
Use ParseSourceText
public static (FileParseResult, IEnumerable<Diagnostic>) ParseSource(string source)Parameters
sourcestringThe source code to parse.
Returns ValueTuple: A tuple containing a FileParseResult that
stores the parse tree and tokens, and a collection of Diagnostic objects that describe problems in the source
code.
#ParseSourceText(string, string)
public static FileParseResult ParseSourceText(string source, string sourceName = "<input>")Parameters
sourcestringThe source code to parse.sourceNamestringThe name of the source.
Returns FileParseResult: A FileParseResult representing the result of
parsing the source.
#TagLines(ISourceInput, HashSet<string>?, ILineTagGenerator?, ILineTagGenerator.TagAbortBehaviour)
public static (string ModifiedSource, ICollection<string> LineIDs, List<ILineTagGenerator.LineTaggingException> TagExceptions) TagLines(ISourceInput contents, HashSet<string>? excludedLineIDs = null, ILineTagGenerator? lineTagGenerator = null, ILineTagGenerator.TagAbortBehaviour tagAbortBehaviour = ILineTagGenerator.TagAbortBehaviour.CurrentNode)Parameters
contentsYarn.Compiler.ISourceInputThe source code to add line tags to.excludedLineIDsSystem.Collections.Generic.HashSet<string>A collection of line IDs that should not be used for generation. Primarily intended for other line tags from a different compilation job.lineTagGeneratorYarn.Compiler.ILineTagGeneratorThe line tag generator to use when generating a new line ID.tagAbortBehaviourYarn.Compiler.ILineTagGenerator.TagAbortBehaviourControls how the line tagging should handle encountering issues while tagging.
Returns ValueTuple: Tuple of the modified source code, with line tags added, an updated list of line IDs that were added, and any tagging exceptions that were encountered during tagging.
This method ensures that it does not generate line tags that are already present in the file.
Line tags are added to any line of source code that contains user-visible text: lines, options, and shortcut options.
#TagLines(string, HashSet<string>?, ILineTagGenerator?, ILineTagGenerator.TagAbortBehaviour)
public static (string ModifiedSource, ICollection<string> LineIDs, List<ILineTagGenerator.LineTaggingException> TagExceptions) TagLines(string contents, HashSet<string>? excludedLineIDs = null, ILineTagGenerator? lineTagGenerator = null, ILineTagGenerator.TagAbortBehaviour tagAbortBehaviour = ILineTagGenerator.TagAbortBehaviour.CurrentNode)Parameters
contentsstringThe source code to add line tags to.excludedLineIDsSystem.Collections.Generic.HashSet<string>A collection of line IDs that should not be used for generation. Primarily intended for other line tags from a different compilation job.lineTagGeneratorYarn.Compiler.ILineTagGeneratorThe line tag generator to use when generating a new line ID.tagAbortBehaviourYarn.Compiler.ILineTagGenerator.TagAbortBehaviourControls how the line tagging should handle encountering issues while tagging.
Returns ValueTuple: Tuple of the modified source code, with line tags added, an updated list of line IDs that were added, and any tagging exceptions that were encountered during tagging.
This method ensures that it does not generate line tags that are already present in the file.
Line tags are added to any line of source code that contains user-visible text: lines, options, and shortcut options.
#TryGetNodeTitle(string?, YarnSpinnerParser.NodeContext, string?, string?, string?, string?)
public static bool TryGetNodeTitle(string? sourceFileName, YarnSpinnerParser.NodeContext nodeContext, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out string? sourceTitle, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out string? uniqueTitle, out string? subtitle, out string? nodeGroupName)Parameters
sourceFileNamestringThe name of the file in which the node is defined, ornullif not available.nodeContextYarn.Compiler.YarnSpinnerParser.NodeContextThe parsed node's context.sourceTitlestringOn return, contains the title of the node, as it appears in the source code.uniqueTitlestringOn return, contains the unique title of the node, as stored in the output program.subtitlestringThe sub-title of the node, if present. This value is alwaysnullif the node is not in a node group.nodeGroupNamestringThe name of the node group the node is a member of, if any.
Returns Boolean: true if the sourceTitle and uniqueTitle could be
determined; false otherwise.
#WithSeverityOverrides(IEnumerable<Diagnostic>, IDictionary<string, Diagnostic.DiagnosticSeverity>?)
public static IEnumerable<Diagnostic> WithSeverityOverrides(this IEnumerable<Diagnostic> diagnostics, IDictionary<string, Diagnostic.DiagnosticSeverity>? overrides)Parameters
diagnosticsSystem.Collections.Generic.IEnumerable<Yarn.Compiler.Diagnostic>The collection of Diagnostic objects to override the severities of.overridesSystem.Collections.Generic.IDictionary<string, Yarn.Compiler.Diagnostic.DiagnosticSeverity>A dictionary of diagnostic codes to diagnostic severities.
Returns IEnumerable: The updated collection.
Generated from Yarn Spinner for Unity 3.3.