Skip to content

Commit e829224

Browse files
committed
Fix NRE as someone decided to write invalid inline code
1 parent 95be993 commit e829224

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/IronyModManager.Parser/Generic/WholeTextParser.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Created : 03-28-2020
55
//
66
// Last Modified By : Mario
7-
// Last Modified On : 02-12-2025
7+
// Last Modified On : 05-25-2025
88
// ***********************************************************************
99
// <copyright file="WholeTextParser.cs" company="Mario">
1010
// Mario
@@ -109,23 +109,32 @@ public override IEnumerable<IDefinition> Parse(ParserArgs args)
109109
else
110110
{
111111
var code = CodeParser.ParseScriptWithoutValidation(args.Lines, args.File);
112-
def.OriginalCode = def.Code = GetNonFileTagCode(code);
113112

114-
var definitions = new List<IDefinition>();
115-
definitions.AddRange(ParseSimpleTypes(code.Values, args, allowInlineAssignment: true));
116-
definitions.AddRange(ParseComplexTypes(code.Values, args));
117-
definitions.AddRange(ParseTypesForVariables(code.Values, args));
118-
foreach (var item in definitions)
113+
// Somebody decided to be a smart ass for some reason in inlines
114+
if (code.Error == null)
119115
{
120-
foreach (var tag in item.Tags)
116+
def.OriginalCode = def.Code = GetNonFileTagCode(code);
117+
var definitions = new List<IDefinition>();
118+
definitions.AddRange(ParseSimpleTypes(code.Values, args, allowInlineAssignment: true));
119+
definitions.AddRange(ParseComplexTypes(code.Values, args));
120+
definitions.AddRange(ParseTypesForVariables(code.Values, args));
121+
foreach (var item in definitions)
121122
{
122-
var lower = tag.ToLowerInvariant();
123-
if (!def.Tags.Contains(lower))
123+
foreach (var tag in item.Tags)
124124
{
125-
def.Tags.Add(lower);
125+
var lower = tag.ToLowerInvariant();
126+
if (!def.Tags.Contains(lower))
127+
{
128+
def.Tags.Add(lower);
129+
}
126130
}
127131
}
128132
}
133+
else
134+
{
135+
def.OriginalCode = def.Code = GetFileTagCode(args.File, args.Lines);
136+
def.Tags.Add(def.Id.ToLowerInvariant());
137+
}
129138
}
130139

131140
def.ValueType = ValueType.WholeTextFile;

0 commit comments

Comments
 (0)