Skip to content

Commit 5387b32

Browse files
committed
support '{uri}#L{line}:{col}' format source
1 parent 5cb1d6b commit 5387b32

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

EmmyLua/CodeAnalysis/Compilation/Symbol/LuaSymbol.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,36 @@ public bool ValidateFrameworkVersions(List<FrameworkVersion> versions)
142142
{
143143
var parts = source.Split('#');
144144
var uri = string.Empty;
145+
var lineColStr = string.Empty;
145146
var line = 0;
147+
var col = 0;
146148
if (parts.Length == 2)
147149
{
148150
uri = parts[0];
149-
if (!int.TryParse(parts[1], out line))
151+
lineColStr = parts[1];
152+
if (lineColStr.StartsWith('L'))
150153
{
151-
return null;
154+
lineColStr = lineColStr[1..];
152155
}
153156
}
154157

158+
if (lineColStr.IndexOf(':') > 0)
159+
{
160+
var lineCol = lineColStr.Split(':');
161+
if (lineCol.Length == 2 && int.TryParse(lineCol[0], out var l) && int.TryParse(lineCol[1], out var c))
162+
{
163+
line = l;
164+
col = c;
165+
}
166+
}
167+
else if (int.TryParse(lineColStr, out var l))
168+
{
169+
line = l;
170+
}
171+
155172
if (uri.Length > 0)
156173
{
157-
return new LuaLocation(line, 0, line, 0, uri);
174+
return new LuaLocation(line, col, line, col + 1, uri);
158175
}
159176
}
160177
}

0 commit comments

Comments
 (0)