Skip to content

Commit

Permalink
remove new method infer
Browse files Browse the repository at this point in the history
  • Loading branch information
CppCXY committed Jul 1, 2024
1 parent 84b1bd4 commit c13ba16
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 0 additions & 2 deletions EmmyLua.LanguageServer/CodeLens/CodeLensBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public OmniSharp.Extensions.LanguageServer.Protocol.Models.CodeLens Resolve(
return codeLens;
}



private static Command MakeCommand(List<ReferenceResult> results, LuaSyntaxElement element,
ServerContext serverContext)
{
Expand Down
17 changes: 9 additions & 8 deletions EmmyLua/CodeAnalysis/Compilation/Infer/CallExprInfer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ public static LuaType InferCallExpr(LuaCallExprSyntax callExpr, SearchContext co
}
});

if (returnType.Equals(Builtin.Unknown) && prefixExpr is LuaIndexExprSyntax indexExpr)
{
var fnName = indexExpr.Name;
if (fnName is not null && string.Equals(fnName, "new", StringComparison.CurrentCultureIgnoreCase))
{
returnType = context.Infer(indexExpr.PrefixExpr);
}
}
// TODO: use config enable this feature
// if (returnType.Equals(Builtin.Unknown) && prefixExpr is LuaIndexExprSyntax indexExpr)
// {
// var fnName = indexExpr.Name;
// if (fnName is not null && string.Equals(fnName, "new", StringComparison.CurrentCultureIgnoreCase))
// {
// returnType = context.Infer(indexExpr.PrefixExpr);
// }
// }

return UnwrapReturn(callExpr, context, returnType, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions EmmyLua/CodeAnalysis/Compilation/Search/References.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ private IEnumerable<ReferenceResult> FieldReferences(LuaDeclaration declaration,
var indexExprs = context.Compilation.Db.QueryIndexExprReferences(fieldName, context);
foreach (var indexExpr in indexExprs)
{
if (context.FindDeclaration(indexExpr) == declaration && indexExpr.KeyElement is not null)
if (context.FindDeclaration(indexExpr) == declaration && indexExpr.KeyElement is {} keyElement)
{
references.Add(new ReferenceResult(indexExpr.KeyElement.Location, indexExpr.KeyElement));
references.Add(new ReferenceResult(keyElement.Location, keyElement));
}
}

Expand Down

0 comments on commit c13ba16

Please sign in to comment.