using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
namespace Ariadne.Generator
{
public class GeneratedArc
{
public readonly INamedTypeSymbol Type;
///
/// This field holds the script, or the class of passages with no Run, or null for an arc that only saves
/// fields.
///
public readonly ScriptClass Script;
public readonly List Fields;
public GeneratedArc(INamedTypeSymbol type, ScriptClass script, List fields)
{
Type = type;
Script = script;
Fields = fields;
}
///
/// Gets the path of the original non-code-behind file.
///
public string FilePath
{
get
{
// The code-behind sits beside the file with Run in it, if the class has one.
if (Script != null && Script.Run != null)
{
return Script.Methods[Script.Run].SyntaxTree.FilePath;
}
return Type.DeclaringSyntaxReferences.First().SyntaxTree.FilePath;
}
}
}
}