-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc03535
commit 937067e
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vs | ||
.idea | ||
bin | ||
obj | ||
src/artifacts | ||
|
38 changes: 38 additions & 0 deletions
38
src/Draco.Compiler/Internal/Symbols/Syntax/SyntaxAutoPropertySymbol.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |