Skip to content

Commit

Permalink
style: update style from new csharpier version
Browse files Browse the repository at this point in the history
  • Loading branch information
kthompson committed Jul 15, 2024
1 parent cb33bbc commit 9f2abb1
Show file tree
Hide file tree
Showing 27 changed files with 132 additions and 113 deletions.
4 changes: 2 additions & 2 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Nuke.Common.Tools.NerdbankGitVersioning;
using Nuke.Common.Utilities.Collections;
using Nuke.Components;

using static Nuke.Common.Tools.ReSharper.ReSharperTasks;

[UnsetVisualStudioEnvironmentVariables]
Expand Down Expand Up @@ -138,5 +137,6 @@ class Build
string IPublish.NuGetSource =>
GitRepository.IsOnMainBranch() ? PublicNuGetSource : GitHubRegistrySource;

T From<T>() where T : INukeBuild => (T)(object)this;
T From<T>()
where T : INukeBuild => (T)(object)this;
}
4 changes: 2 additions & 2 deletions src/Panther.Generators/SyntaxNodeGetChildrenGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void Execute(SourceGeneratorContext context)
"Panther.CodeAnalysis.Syntax.SeparatedSyntaxList`1"
);
var allTypes = GetAllTypes(compilation.Assembly);
var syntaxNodeTypes = allTypes.Where(
type => !type.IsAbstract && IsDerivedFrom(type, syntaxNodeType) && IsPartial(type)
var syntaxNodeTypes = allTypes.Where(type =>
!type.IsAbstract && IsDerivedFrom(type, syntaxNodeType) && IsPartial(type)
);

foreach (var syntaxNode in syntaxNodeTypes)
Expand Down
30 changes: 17 additions & 13 deletions src/Panther/CodeAnalysis/Binder/Symbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,38 @@ public string FullName
}
}


public (Symbol, bool existing) DeclareClass(string name, TextLocation location) =>
public (Symbol, bool existing) DeclareClass(string name, TextLocation location) =>
DeclareSymbol(name, SymbolFlags.Class, location);
public (Symbol, bool existing) DeclareField(string name, TextLocation location) =>

public (Symbol, bool existing) DeclareField(string name, TextLocation location) =>
DeclareSymbol(name, SymbolFlags.Field, location);
public (Symbol, bool existing) DeclareMethod(string name, TextLocation location) =>

public (Symbol, bool existing) DeclareMethod(string name, TextLocation location) =>
DeclareSymbol(name, SymbolFlags.Method, location);

public (Symbol, bool existing) DeclareSymbol(string name, SymbolFlags flags, TextLocation location)
public (Symbol, bool existing) DeclareSymbol(
string name,
SymbolFlags flags,
TextLocation location
)
{
_symbols ??= new();
_symbolList ??= new();
var symbol = new Symbol(name, flags, location, this);
var existing = !_symbols.TryAdd(name, symbol);

if(!existing) _symbolList.Add(symbol);


if (!existing)
_symbolList.Add(symbol);

return (existing ? _symbols[name] : symbol, existing);
}

public Symbol? Lookup(string name, bool includeParents = true) =>
public Symbol? Lookup(string name, bool includeParents = true) =>
_symbols?.GetValueOrDefault(name) ?? this.Parent?.Lookup(name, includeParents);

public IEnumerator<Symbol> GetEnumerator()
{
if(_symbolList == null)
if (_symbolList == null)
yield break;

foreach (var symbol in _symbolList)
Expand All @@ -64,4 +68,4 @@ IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}
12 changes: 6 additions & 6 deletions src/Panther/CodeAnalysis/Emit/Emitter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Linq;
using Mono.Cecil;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Rocks;
using Panther.CodeAnalysis.Symbols;
Expand Down Expand Up @@ -998,8 +998,8 @@ private void EmitCallExpression(ILProcessor ilProcessor, TypedCallExpression nod
return method;
}

var parameterTypeNames = methodSymbol.Parameters
.Select(p => LookupType(p.Type.Symbol).FullName)
var parameterTypeNames = methodSymbol
.Parameters.Select(p => LookupType(p.Type.Symbol).FullName)
.ToArray();
var methodName = methodSymbol.Name;

Expand Down Expand Up @@ -1286,8 +1286,8 @@ private MethodReference ResolvePropertyGetter(Type type, string propertyName)
if (methodDefinition.Parameters.Count != parameterTypeNames.Length)
continue;

var matches = methodDefinition.Parameters
.Select(p => p.ParameterType.FullName)
var matches = methodDefinition
.Parameters.Select(p => p.ParameterType.FullName)
.Zip(
parameterTypeNames,
(methodParam, searchParamName) => methodParam == searchParamName
Expand Down
4 changes: 2 additions & 2 deletions src/Panther/CodeAnalysis/Lowering/ThreeAddressCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ protected override TypedExpression RewriteCallExpression(TypedCallExpression nod
// can get out of order if there are side effects in any of the arguments. In order to prevent this we need
// to break out the evaluation of each argument and assign to a temporary variable in the correct order.
// we can then access this temp variable later when we call the function
var args = node.Arguments
.Select(RewriteExpression)
var args = node
.Arguments.Select(RewriteExpression)
.Select(expr => CreateTemporary(expr, "ctemp"))
.ToImmutableArray();

Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Symbols/Symbol.NoSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public abstract partial class Symbol
{
private sealed class NoSymbol : Symbol
{
public NoSymbol() : base(null, TextLocation.None, "<none>")
public NoSymbol()
: base(null, TextLocation.None, "<none>")
{
this.Type = Type.NoType;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Symbols/Symbol.RootSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ private sealed class RootSymbol : Symbol
public override Symbol Owner => this;
public override bool IsRoot => true;

public RootSymbol() : base(null, TextLocation.None, "global::")
public RootSymbol()
: base(null, TextLocation.None, "global::")
{
this.Type = Type.NoType;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Panther/CodeAnalysis/Symbols/SymbolExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ namespace Panther.CodeAnalysis.Symbols;

public static class SymbolExtensions
{
public static T WithFlags<T>(this T symbol, SymbolFlags flags) where T : Symbol
public static T WithFlags<T>(this T symbol, SymbolFlags flags)
where T : Symbol
{
symbol.Flags |= flags;
return symbol;
}

public static T WithType<T>(this T symbol, Type type) where T : Symbol
public static T WithType<T>(this T symbol, Type type)
where T : Symbol
{
symbol.Type = type;
return symbol;
Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Syntax/SeparatedSyntaxList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public abstract class SeparatedSyntaxList
public abstract ImmutableArray<SyntaxNode> GetWithSeparators();
}

public class SeparatedSyntaxList<T> : SeparatedSyntaxList, IReadOnlyList<T> where T : SyntaxNode
public class SeparatedSyntaxList<T> : SeparatedSyntaxList, IReadOnlyList<T>
where T : SyntaxNode
{
private readonly ImmutableArray<SyntaxNode> _nodesAndSeparators;

Expand Down
13 changes: 6 additions & 7 deletions src/Panther/CodeAnalysis/Syntax/SyntaxFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,12 @@ public static IEnumerable<SyntaxKind> GetUnaryOperatorKinds() =>
public static IEnumerable<SyntaxKind> GetBinaryOperatorKinds() =>
Enum.GetValues(typeof(SyntaxKind))
.Cast<SyntaxKind>()
.Where(
kind =>
kind != SyntaxKind.EqualsToken
&& kind != SyntaxKind.OpenParenToken
&& kind != SyntaxKind.DotToken
&& kind != SyntaxKind.OpenBracketToken
&& GetBinaryOperatorPrecedence(kind) > 0
.Where(kind =>
kind != SyntaxKind.EqualsToken
&& kind != SyntaxKind.OpenParenToken
&& kind != SyntaxKind.DotToken
&& kind != SyntaxKind.OpenBracketToken
&& GetBinaryOperatorPrecedence(kind) > 0
);

public static bool IsTrivia(this SyntaxKind kind) =>
Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Syntax/SyntaxToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ private SyntaxToken(
bool isInsertedToken,
ImmutableArray<SyntaxTrivia> leadingTrivia,
ImmutableArray<SyntaxTrivia> trailingTrivia
) : base(sourceFile)
)
: base(sourceFile)
{
Kind = kind;
Position = position;
Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Text/NoSourceFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public sealed class NoSourceFile : SourceFile

public override string ToString() => "<no source file>";

internal NoSourceFile() : base("", "") { }
internal NoSourceFile()
: base("", "") { }
}
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Text/ScriptSourceFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public sealed class ScriptSourceFile : SourceFile
public override int LineCount => Lines.Count;
private IReadOnlyList<TextLine> Lines { get; }

internal ScriptSourceFile(string text, string fileName) : base(fileName, text)
internal ScriptSourceFile(string text, string fileName)
: base(fileName, text)
{
Lines = ParseLines(this, text);
}
Expand Down
27 changes: 12 additions & 15 deletions src/Panther/CodeAnalysis/Typing/TypedBinaryOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ private TypedBinaryOperator(
SyntaxKind syntaxKind,
Type type,
Type resultType
) : this(kind, syntaxKind, type, type, resultType) { }
)
: this(kind, syntaxKind, type, type, resultType) { }

private TypedBinaryOperator(TypedBinaryOperatorKind kind, SyntaxKind syntaxKind, Type type)
: this(kind, syntaxKind, type, type, type) { }
Expand Down Expand Up @@ -175,21 +176,17 @@ private TypedBinaryOperator(TypedBinaryOperatorKind kind, SyntaxKind syntaxKind,
};

public static TypedBinaryOperator? Bind(SyntaxKind kind, Type leftType, Type rightType) =>
_operators.FirstOrDefault(
op =>
op.SyntaxKind == kind
&& (
(
op.LeftType == leftType
|| (op.LeftType.IsReferenceType && leftType == Type.Null)
)
&& op.RightType == rightType
|| (
op.RightType == rightType
|| (op.RightType.IsReferenceType && rightType == Type.Null)
)
&& op.LeftType == leftType
_operators.FirstOrDefault(op =>
op.SyntaxKind == kind
&& (
(op.LeftType == leftType || (op.LeftType.IsReferenceType && leftType == Type.Null))
&& op.RightType == rightType
|| (
op.RightType == rightType
|| (op.RightType.IsReferenceType && rightType == Type.Null)
)
&& op.LeftType == leftType
)
);

public static TypedBinaryOperator BindOrThrow(SyntaxKind kind, Type leftType, Type rightType) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public TypedConditionalGotoStatement(
SyntaxNode syntax,
TypedLabel TypedLabel,
TypedExpression condition
) : this(syntax, TypedLabel, condition, false) { }
)
: this(syntax, TypedLabel, condition, false) { }
}
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Typing/TypedErrorExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace Panther.CodeAnalysis.Typing;

internal sealed record TypedErrorExpression : TypedExpression
{
public TypedErrorExpression(SyntaxNode syntax) : base(syntax) { }
public TypedErrorExpression(SyntaxNode syntax)
: base(syntax) { }

public override TypedNodeKind Kind => TypedNodeKind.ErrorExpression;

Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Typing/TypedGotoStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ sealed record TypedGotoStatement : TypedStatement

public override TypedNodeKind Kind => TypedNodeKind.GotoStatement;

public TypedGotoStatement(SyntaxNode syntax, TypedLabel boundLabel) : base(syntax)
public TypedGotoStatement(SyntaxNode syntax, TypedLabel boundLabel)
: base(syntax)
{
TypedLabel = boundLabel;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Typing/TypedLiteralExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace Panther.CodeAnalysis.Typing;

internal sealed record TypedLiteralExpression : TypedExpression
{
public TypedLiteralExpression(SyntaxNode syntax, object value) : base(syntax)
public TypedLiteralExpression(SyntaxNode syntax, object value)
: base(syntax)
{
Value = value;
Type = value switch
Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Typing/TypedNopStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ internal sealed record TypedNopStatement : TypedStatement
{
public override TypedNodeKind Kind => TypedNodeKind.NopStatement;

public TypedNopStatement(SyntaxNode syntax) : base(syntax) { }
public TypedNopStatement(SyntaxNode syntax)
: base(syntax) { }

public override void Accept(TypedNodeVisitor visitor) => visitor.VisitNopStatement(this);

Expand Down
7 changes: 4 additions & 3 deletions src/Panther/CodeAnalysis/Typing/TypedScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ internal sealed class TypedScope : SymbolContainer

public TypedScope Parent { get; }

public TypedScope(TypedScope parent, string? name = null) : this(parent.Symbol, parent, name)
{ }
public TypedScope(TypedScope parent, string? name = null)
: this(parent.Symbol, parent, name) { }

public TypedScope(Symbol symbol, string? name = null) : this(symbol, null, name) { }
public TypedScope(Symbol symbol, string? name = null)
: this(symbol, null, name) { }

public TypedScope(TypedScope parent, Symbol symbol, string? name = null)
: this(symbol, parent, name) { }
Expand Down
3 changes: 2 additions & 1 deletion src/Panther/CodeAnalysis/Typing/TypedType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace Panther.CodeAnalysis.Typing;

internal sealed class TypedType : TypeSymbol
{
public TypedType(Symbol owner, TextLocation location, string name) : base(owner, location, name)
public TypedType(Symbol owner, TextLocation location, string name)
: base(owner, location, name)
{
Type = new ClassType(this);
}
Expand Down
Loading

0 comments on commit 9f2abb1

Please sign in to comment.