All this does is check the next one over what if the coder is insane and has 30 chains where eventually one isnt static, thatshould be reported, either a recursive method or a for loop that starts at one and checks if its static if it is and has a next field accessor it should convert the previous one to its class value and then check if the next one is also static, recursivly/repeatdly do this until all is good
ex.
AssetManager.traits.someting
should go
is AssetManager static? No?
Okay check its fields is traits in their, it is, is it static it is good no report so far
convert traits to its class (return type)
AssetManager.ActorTraitLibrary.someting
is something a static vall? it is? repeat previous otherwise report stays false
var fields_and_properties = _metaDataRender.GetFieldsAndProperties();
bool needsReport = true;
List<string> fullExpr = [.. GetFullMemberAccess(memberAccess).Split('.')];
if (fullExpr.Count > 1)
{
//TODO: Optimize this, also this just assumes that the chain is correct after one, Check Issue #
if (fields_and_properties.TryGetValue(memberAccess.Expression.ToString(), out var fieldList) &&
fieldList.Any(field => field.Name == fullExpr[1] && field.IsStatic))
{
needsReport = false;
}
}
FileLogger.Log("Ahh cant doo dat");
FileLogger.Log("LineStart: " + node.SyntaxTree.GetLineSpan(node.Span).EndLinePosition);
FileLogger.Log("CharStart: " + memberAccess.Expression.Span.Start);
if (needsReport)
{
diagnostics.Add(new Diagnostic()
{
Code = "ErrorCode_001",
Severity = DiagnosticSeverity.Error,
Message = $"{memberAccess.Expression} is NOT static you must create an instance",
Range = new OmniSharp.Extensions.LanguageServer.Protocol.Models.Range(node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line, memberAccess.Expression.Span.Start, node.SyntaxTree.GetLineSpan(node.Span).EndLinePosition.Line, memberAccess.Expression.Span.End),
Source = memberAccess.Expression.ToString(),
Tags = new Container<DiagnosticTag>(new DiagnosticTag[] { DiagnosticTag.Unnecessary })
});
}
All this does is check the next one over what if the coder is insane and has 30 chains where eventually one isnt static, thatshould be reported, either a recursive method or a for loop that starts at one and checks if its static if it is and has a next field accessor it should convert the previous one to its class value and then check if the next one is also static, recursivly/repeatdly do this until all is good
ex.
AssetManager.traits.someting
should go
is AssetManager static? No?
Okay check its fields is traits in their, it is, is it static it is good no report so far
convert traits to its class (return type)
AssetManager.ActorTraitLibrary.someting
is something a static vall? it is? repeat previous otherwise report stays false