/*
/*
 * Copyright (c) 2024 Augur AI, Inc.
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. 
 * If a copy of the MPL was not distributed with this file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 
 * Copyright (c) 2024 Augur AI, Inc.
 *
 * This file is licensed under the Augur AI Proprietary License.
 *
 * Attribution:
 * This work is based on code from https://github.com/hofstadter-io/hof, licensed under the Apache License 2.0.
 */

package ast

import "strings"

type NodeBase struct {
	script  *Script
	docLine int
	begLine int
	endLine int
	name    string
	comment string
}

func (n *NodeBase) Script() *Script {
	return n.script
}

func (n *NodeBase) SetScript(s *Script) {
	n.script = s
}

func (n *NodeBase) Clone() Node {
	return &NodeBase{
		script:  n.script,
		docLine: n.docLine,
		begLine: n.begLine,
		endLine: n.endLine,
		name:    n.name,
		comment: n.comment,
	}
}

func (n *NodeBase) CloneNodeBase() NodeBase {
	return NodeBase{
		script:  n.script,
		docLine: n.docLine,
		begLine: n.begLine,
		endLine: n.endLine,
		name:    n.name,
		comment: n.comment,
	}
}

func (n *NodeBase) DocLine() int {
	return n.docLine
}
func (n *NodeBase) SetDocLine(i int) {
	n.docLine = i
}

func (n *NodeBase) BegLine() int {
	return n.begLine
}
func (n *NodeBase) SetBegLine(i int) {
	n.begLine = i
}

func (n *NodeBase) EndLine() int {
	return n.endLine
}
func (n *NodeBase) SetEndLine(i int) {
	n.endLine = i
}

func (n *NodeBase) String() string {
	return strings.Join(n.script.Lines[n.docLine:n.endLine+1], "\n")
}

func (n *NodeBase) Name() string {
	return n.name
}

func (n *NodeBase) Comment() string {
	return n.comment
}
func (n *NodeBase) AddComment(c string) {
	n.comment += c
}
