Skip to content

Commit

Permalink
Added base for autoprops
Browse files Browse the repository at this point in the history
  • Loading branch information
LPeter1997 committed Oct 24, 2024
1 parent bc03535 commit 937067e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vs
.idea
bin
obj
src/artifacts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using Draco.Compiler.Api.Semantics;
using Draco.Compiler.Api.Syntax;
using Draco.Compiler.Internal.Binding;
using Draco.Compiler.Internal.Documentation;
using Draco.Compiler.Internal.Documentation.Extractors;
using Draco.Compiler.Internal.Symbols.Source;

namespace Draco.Compiler.Internal.Symbols.Syntax;

/// <summary>
/// The base for auto-properties defined based on some syntax.
/// </summary>
internal abstract class SyntaxAutoPropertySymbol : PropertySymbol, ISourceSymbol
{
public override Symbol ContainingSymbol { get; }
public override VariableDeclarationSyntax DeclaringSyntax { get; }

public override string Name => this.DeclaringSyntax.Name.Text;

public override Visibility Visibility =>
GetVisibilityFromTokenKind(this.DeclaringSyntax.VisibilityModifier?.Kind);

internal override string RawDocumentation => this.DeclaringSyntax.Documentation;

protected SyntaxAutoPropertySymbol(Symbol containingSymbol, VariableDeclarationSyntax syntax)
{
if (syntax.FieldModifier is not null) throw new ArgumentException("a property must not have the field modifier", nameof(syntax));

this.ContainingSymbol = containingSymbol;
this.DeclaringSyntax = syntax;
}

public abstract void Bind(IBinderProvider binderProvider);

private SymbolDocumentation BuildDocumentation() =>
MarkdownDocumentationExtractor.Extract(this);
}

0 comments on commit 937067e

Please sign in to comment.