Add notice that the file is generated

Fixes #123
This commit is contained in:
Urtsi Santsi 2023-09-02 02:11:09 +03:00
parent 80cb57cb88
commit cf136ab09f
2 changed files with 11 additions and 2 deletions

View file

@ -291,7 +291,7 @@ class LanguageServer:
xml = None xml = None
try: try:
output = XmlOutput() output = XmlOutput()
xml = output.emit(open_file.ast) xml = output.emit(open_file.ast, generated_notice=False)
except: except:
printerr(traceback.format_exc()) printerr(traceback.format_exc())
self._send_error(id, ErrorCode.RequestFailed, "Could not compile document") self._send_error(id, ErrorCode.RequestFailed, "Could not compile document")

View file

@ -25,9 +25,18 @@ from blueprintcompiler.language.types import ClassName
class XmlEmitter: class XmlEmitter:
def __init__(self, indent=2): def __init__(self, indent=2, generated_notice=True):
self.indent = indent self.indent = indent
self.result = '<?xml version="1.0" encoding="UTF-8"?>' self.result = '<?xml version="1.0" encoding="UTF-8"?>'
if generated_notice:
self.result += (
"\n"
"<!--\n"
"DO NOT EDIT!\n"
"This file was @generated by blueprint-compiler. Instead, edit the\n"
"corresponding .blp file and regenerate this file with blueprint-compiler.\n"
"-->"
)
self._tag_stack = [] self._tag_stack = []
self._needs_newline = False self._needs_newline = False