Max Command Count History: |
diff --git a/Source/Lib/Ide/Ide.RazorLib/Settings/Displays/IdeSettingsDisplay.razor.cs b/Source/Lib/Ide/Ide.RazorLib/Settings/Displays/IdeSettingsDisplay.razor.cs
index 9a1960efa..844aeb17c 100644
--- a/Source/Lib/Ide/Ide.RazorLib/Settings/Displays/IdeSettingsDisplay.razor.cs
+++ b/Source/Lib/Ide/Ide.RazorLib/Settings/Displays/IdeSettingsDisplay.razor.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Components;
using Luthetus.Common.RazorLib.FileSystems.Models;
+using Luthetus.TextEditor.RazorLib.CompilerServices;
using Luthetus.Ide.RazorLib.AppDatas.Models;
namespace Luthetus.Ide.RazorLib.Settings.Displays;
@@ -10,4 +11,9 @@ public partial class IdeSettingsDisplay : ComponentBase
private IEnvironmentProvider EnvironmentProvider { get; set; } = null!;
[Inject]
private IAppDataService AppDataService { get; set; } = null!;
+
+ private void WriteLuthetusDebugSomethingToConsole()
+ {
+ Console.WriteLine(LuthetusDebugSomething.CreateText());
+ }
}
\ No newline at end of file
diff --git a/Source/Lib/TextEditor/CompilerServices/Interfaces/IParser.cs b/Source/Lib/TextEditor/CompilerServices/Interfaces/IParser.cs
index df0979be9..e8f67aa50 100644
--- a/Source/Lib/TextEditor/CompilerServices/Interfaces/IParser.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Interfaces/IParser.cs
@@ -11,12 +11,5 @@ public interface IParser
public IBinderSession BinderSession { get; }
public ILexer Lexer { get; }
- public CompilationUnit Parse();
- ///
- /// This method is used when parsing many files as a single compilation.
- /// The first binder instance would be passed to the following parsers.
- /// The resourceUri is passed in so if a file is parsed for a second time,
- /// the previous symbols can be deleted so they do not duplicate.
- ///
- public CompilationUnit Parse(IBinder previousBinder, ResourceUri resourceUri);
+ public CompilationUnit Parse(IBinder binder, ResourceUri resourceUri);
}
diff --git a/Source/Lib/TextEditor/CompilerServices/LuthetusDebugSomething.cs b/Source/Lib/TextEditor/CompilerServices/LuthetusDebugSomething.cs
new file mode 100644
index 000000000..1cf20f5c8
--- /dev/null
+++ b/Source/Lib/TextEditor/CompilerServices/LuthetusDebugSomething.cs
@@ -0,0 +1,37 @@
+using System.Text;
+
+namespace Luthetus.TextEditor.RazorLib.CompilerServices;
+
+///
+/// Statically track the constructor invocations to make sense of possible optimizations.
+/// (this file likely can be deleted if you see this in the future (2024-12-10))
+///
+public static class LuthetusDebugSomething
+{
+ public static int CompilerService_ConstructorInvocationCount { get; set; }
+ public static int Lexer_ConstructorInvocationCount { get; set; }
+ public static int StringWalker_ConstructorInvocationCount { get; set; }
+ public static int Parser_ConstructorInvocationCount { get; set; }
+ public static int TokenWalker_ConstructorInvocationCount { get; set; }
+ public static int ParserModel_ConstructorInvocationCount { get; set; }
+ public static int Binder_ConstructorInvocationCount { get; set; }
+ public static int BinderSession_ConstructorInvocationCount { get; set; }
+
+ public static string CreateText()
+ {
+ var builder = new StringBuilder();
+
+ builder.AppendLine();
+ builder.AppendLine($"{nameof(CompilerService_ConstructorInvocationCount)}: {CompilerService_ConstructorInvocationCount:N0}");
+ builder.AppendLine($"{nameof(Lexer_ConstructorInvocationCount)}: {Lexer_ConstructorInvocationCount:N0}");
+ builder.AppendLine($"{nameof(StringWalker_ConstructorInvocationCount)}: {StringWalker_ConstructorInvocationCount:N0}");
+ builder.AppendLine($"{nameof(Parser_ConstructorInvocationCount)}: {Parser_ConstructorInvocationCount:N0}");
+ builder.AppendLine($"{nameof(TokenWalker_ConstructorInvocationCount)}: {TokenWalker_ConstructorInvocationCount:N0}");
+ builder.AppendLine($"{nameof(ParserModel_ConstructorInvocationCount)}: {ParserModel_ConstructorInvocationCount:N0}");
+ builder.AppendLine($"{nameof(Binder_ConstructorInvocationCount)}: {Binder_ConstructorInvocationCount:N0}");
+ builder.AppendLine($"{nameof(BinderSession_ConstructorInvocationCount)}: {BinderSession_ConstructorInvocationCount:N0}");
+ builder.AppendLine();
+
+ return builder.ToString();
+ }
+}
\ No newline at end of file
diff --git a/Source/Lib/TextEditor/CompilerServices/Utility/StringWalker.cs b/Source/Lib/TextEditor/CompilerServices/Utility/StringWalker.cs
index ea9ff14f5..602727d28 100644
--- a/Source/Lib/TextEditor/CompilerServices/Utility/StringWalker.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Utility/StringWalker.cs
@@ -14,6 +14,8 @@ public class StringWalker
/// Pass in the of a file, and its text. One can pass in for the if they are only working with the text itself.
public StringWalker(ResourceUri resourceUri, string sourceText)
{
+ ++LuthetusDebugSomething.StringWalker_ConstructorInvocationCount;
+
ResourceUri = resourceUri;
SourceText = sourceText;
}
diff --git a/Source/Lib/TextEditor/CompilerServices/Utility/TokenWalker.cs b/Source/Lib/TextEditor/CompilerServices/Utility/TokenWalker.cs
index 41e500a66..628a0643c 100644
--- a/Source/Lib/TextEditor/CompilerServices/Utility/TokenWalker.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Utility/TokenWalker.cs
@@ -15,6 +15,8 @@ public class TokenWalker
public TokenWalker(List tokenList, DiagnosticBag diagnosticBag)
{
+ ++LuthetusDebugSomething.TokenWalker_ConstructorInvocationCount;
+
if (tokenList.Count > 0 &&
tokenList[tokenList.Count - 1].SyntaxKind != SyntaxKind.EndOfFileToken)
{
From 1dab5b937a49d97630e1a962bf5c40d27e1307b4 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Wed, 11 Dec 2024 18:11:28 -0500
Subject: [PATCH 06/39] Idea
---
.../CSharp/LexerCase/CSharpLexer.cs | 72 +++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index fb5923284..a612bb284 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -9,6 +9,78 @@
namespace Luthetus.CompilerServices.CSharp.LexerCase;
+///
+/// Idea...
+/// =======
+///
+/// Preface of the idea:
+/// ====================
+/// The CSharpLexer is constructed within a function invocation,
+/// and is never exposed beyond the scope of that function invocation.
+///
+/// So, perhaps instead of getting the new CSharpLexer() invocations
+/// to be 1 time instead of 1,814 times.
+///
+/// It might be fine to make it a struct.
+///
+/// Issue with the idea:
+/// ====================
+/// I don't want to force every implementation of ILexer to be a struct.
+/// But, at the same time if I reference an ILexer implementation
+/// not by its concrete-struct type, but by the interface,
+/// then that struct will be boxed anyway.
+///
+/// How to continue with the idea:
+/// ==============================
+/// The ICompilerService has the method:
+/// ````public Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier);
+///
+/// Furthermore there is a 'default' implementation of ICompilerService that is available for use by anyone.
+/// It is named 'CompilerService'.
+///
+/// It implements 'ParseAsync(...)' but adds the 'virtual' keyword so that any inheriting type can override it.
+///
+/// Currently, the CSharpCompilerService inherits 'CompilerService' (not the interface).
+///
+/// In order to permit any language to "easily" create an implementation of 'ICompilerService'
+/// they can inherit 'CompilerService' and then override only what they want to be different
+/// from the default setup.
+///
+/// The result of this however is fairly "general" Func<...> that need to be defined
+/// in order to tell the 'CompilerService' how to construct an instance of the language's
+/// ILexer, IParser, IBinder...
+///
+/// So, if one wants to streamline the implementation of 'ICompilerService'
+/// by inheriting 'CompilerService' instead,
+/// then would they be able to avoid the ILexer, IParser, IBinder
+/// requirements of the 'CompilerService' base class?
+/// (Do this in order to avoid boxing of the struct implementation of ILexer or etc...)
+///
+/// The 'CompilerService' only invokes the funcs that provide an instance of ILexer and etc...
+/// from within 'ParseAsync(...)'.
+/// So, one can completely forgo the interface Type and do everything themselves
+/// by overriding 'ParseAsync(...)' in particular.
+/// ("everything" refers to the parsing itself, a lot of defaults are still
+/// being provided by the 'CompilerService' base class).
+///
+/// Side note 1:
+/// ============
+/// What benefits are there to having the parser ask the lexer for the next token
+/// during the lexing process, versus lexing the text entirely and
+/// storing the tokens in a list to then later be given to the parser?
+///
+/// Side note 2:
+/// ============
+/// The CSharpLexer is inheriting 'Lexer' at the moment.
+/// But, this was only done in order provide defaults for someone
+/// who wants to create an ILexer implementation.
+///
+/// The best case scenario is to implement the interface ILexer on CSharpLexer
+/// directly.
+///
+/// Furthermore, if one overrides 'ParseAsync(...)' they don't even
+/// have to implement ILexer at all. They have complete freedom over the 'ParseAsync(...)' method.
+///
public class CSharpLexer : Lexer
{
public CSharpLexer(ResourceUri resourceUri, string sourceText)
From 3ba3face21965e7ddd8c6d2c355cde10093c58a4 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Wed, 11 Dec 2024 18:20:08 -0500
Subject: [PATCH 07/39] CSharpLexer is struct: 34.9s
---
.../CSharpCompilerService.cs | 5 ++--
.../CSharp/LexerCase/CSharpLexer.cs | 26 ++++++++++++++-----
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index 580d30ce8..f31d30661 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -79,7 +79,7 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
// make use of the Lexer to do whatever syntax highlighting is possible.
try
{
- IParser parser = new CSharpParser((CSharpLexer)lexer);
+ IParser parser = new CSharpParser(lexer);
compilationUnit = parser.Parse(Binder, resourceUri);
}
finally
@@ -91,8 +91,7 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
var resource = _resourceMap[resourceUri];
var cSharpResource = (CSharpResource)resource;
- var cSharpLexer = (CSharpLexer)lexer;
- cSharpResource.EscapeCharacterList = cSharpLexer.EscapeCharacterList;
+ cSharpResource.EscapeCharacterList = lexer.EscapeCharacterList;
resource.SyntaxTokenList = lexer.SyntaxTokenList;
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index a612bb284..0c6940f41 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -4,6 +4,7 @@
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
using Luthetus.TextEditor.RazorLib.CompilerServices.GenericLexer.Decoration;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Implementations;
using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
@@ -81,22 +82,35 @@ namespace Luthetus.CompilerServices.CSharp.LexerCase;
/// Furthermore, if one overrides 'ParseAsync(...)' they don't even
/// have to implement ILexer at all. They have complete freedom over the 'ParseAsync(...)' method.
///
-public class CSharpLexer : Lexer
+public struct CSharpLexer : ILexer
{
+ private readonly StringWalker _stringWalker;
+ private readonly List _syntaxTokenList = new();
+ private readonly DiagnosticBag _diagnosticBag = new();
+
public CSharpLexer(ResourceUri resourceUri, string sourceText)
- : base(
- resourceUri,
- sourceText,
- new LexerKeywords(CSharpKeywords.NON_CONTEXTUAL_KEYWORDS, CSharpKeywords.CONTROL_KEYWORDS, CSharpKeywords.CONTEXTUAL_KEYWORDS))
{
++LuthetusDebugSomething.Lexer_ConstructorInvocationCount;
+
+ ResourceUri = resourceUri;
+ SourceText = sourceText;
+ LexerKeywords = new LexerKeywords(CSharpKeywords.NON_CONTEXTUAL_KEYWORDS, CSharpKeywords.CONTROL_KEYWORDS, CSharpKeywords.CONTEXTUAL_KEYWORDS);
+
+ _stringWalker = new(resourceUri, sourceText);
}
private byte _decorationByteLastEscapeCharacter = (byte)GenericDecorationKind.None;
public List EscapeCharacterList { get; } = new();
+
+ public ResourceUri ResourceUri { get; }
+ public string SourceText { get; }
+ public LexerKeywords LexerKeywords { get; }
+
+ public List SyntaxTokenList => _syntaxTokenList;
+ public List DiagnosticList => _diagnosticBag.ToList();
- public override void Lex()
+ public void Lex()
{
while (!_stringWalker.IsEof)
{
From a9f9a35a9a4d84c155a14be6e7f245c80dd23f5f Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Wed, 11 Dec 2024 18:26:47 -0500
Subject: [PATCH 08/39] Parse is struct 36s (but very nonscientific
measurements are being done)
---
.../CSharp/CompilerServiceCase/CSharpCompilerService.cs | 2 +-
Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index f31d30661..03f6dd7e3 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -79,7 +79,7 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
// make use of the Lexer to do whatever syntax highlighting is possible.
try
{
- IParser parser = new CSharpParser(lexer);
+ var parser = new CSharpParser(lexer);
compilationUnit = parser.Parse(Binder, resourceUri);
}
finally
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index 4d54a35f4..04fc60de2 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -14,7 +14,7 @@
namespace Luthetus.CompilerServices.CSharp.ParserCase;
-public class CSharpParser : IParser
+public struct CSharpParser : IParser
{
public CSharpParser(CSharpLexer lexer)
{
From 08b8efff4992b4b42eec2fe8810bece1e604b297 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Wed, 11 Dec 2024 18:35:13 -0500
Subject: [PATCH 09/39] Track counts in debug mode
---
.../CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs | 2 ++
.../CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs | 2 ++
.../CSharp/CompilerServiceCase/CSharpCompilerService.cs | 2 ++
Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs | 2 ++
Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs | 2 ++
.../CompilerServices/CSharp/ParserCase/CSharpParserModel.cs | 2 ++
.../Settings/Displays/IdeSettingsDisplay.razor.cs | 4 ++++
.../Lib/TextEditor/CompilerServices/Utility/StringWalker.cs | 2 ++
Source/Lib/TextEditor/CompilerServices/Utility/TokenWalker.cs | 2 ++
9 files changed, 20 insertions(+)
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
index 6118eb0c2..80b121747 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
@@ -40,7 +40,9 @@ public partial class CSharpBinder : IBinder
public CSharpBinder()
{
+ #if DEBUG
++LuthetusDebugSomething.Binder_ConstructorInvocationCount;
+ #endif
var globalBinderSession = StartBinderSession(ResourceUri.Empty);
globalBinderSession.ScopeList.Add(_globalScope);
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs
index 5c4cc3d63..82db5cef6 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs
@@ -21,7 +21,9 @@ public CSharpBinderSession(
int globalScopeIndexKey,
NamespaceStatementNode topLevelNamespaceStatementNode)
{
+ #if DEBUG
++LuthetusDebugSomething.BinderSession_ConstructorInvocationCount;
+ #endif
ResourceUri = resourceUri;
Binder = binder;
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index 03f6dd7e3..178f63cc2 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -28,7 +28,9 @@ public sealed class CSharpCompilerService : CompilerService
public CSharpCompilerService(ITextEditorService textEditorService)
: base(textEditorService)
{
+ #if DEBUG
++LuthetusDebugSomething.CompilerService_ConstructorInvocationCount;
+ #endif
Binder = CSharpBinder;
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index 0c6940f41..0fcab474e 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -90,7 +90,9 @@ public struct CSharpLexer : ILexer
public CSharpLexer(ResourceUri resourceUri, string sourceText)
{
+ #if DEBUG
++LuthetusDebugSomething.Lexer_ConstructorInvocationCount;
+ #endif
ResourceUri = resourceUri;
SourceText = sourceText;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index 04fc60de2..c55223fb2 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -18,7 +18,9 @@ public struct CSharpParser : IParser
{
public CSharpParser(CSharpLexer lexer)
{
+ #if DEBUG
++LuthetusDebugSomething.Parser_ConstructorInvocationCount;
+ #endif
Lexer = lexer;
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParserModel.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParserModel.cs
index 4c7ba3db1..40827fc5b 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParserModel.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParserModel.cs
@@ -22,7 +22,9 @@ public CSharpParserModel(
CodeBlockBuilder globalCodeBlockBuilder,
CodeBlockBuilder currentCodeBlockBuilder)
{
+ #if DEBUG
++LuthetusDebugSomething.ParserModel_ConstructorInvocationCount;
+ #endif
Binder = binder;
BinderSession = binderSession;
diff --git a/Source/Lib/Ide/Ide.RazorLib/Settings/Displays/IdeSettingsDisplay.razor.cs b/Source/Lib/Ide/Ide.RazorLib/Settings/Displays/IdeSettingsDisplay.razor.cs
index 844aeb17c..b1012cbe2 100644
--- a/Source/Lib/Ide/Ide.RazorLib/Settings/Displays/IdeSettingsDisplay.razor.cs
+++ b/Source/Lib/Ide/Ide.RazorLib/Settings/Displays/IdeSettingsDisplay.razor.cs
@@ -14,6 +14,10 @@ public partial class IdeSettingsDisplay : ComponentBase
private void WriteLuthetusDebugSomethingToConsole()
{
+ #if DEBUG
Console.WriteLine(LuthetusDebugSomething.CreateText());
+ #else
+ Console.WriteLine($"Must run in debug mode to see {nameof(WriteLuthetusDebugSomethingToConsole)}");
+ #endif
}
}
\ No newline at end of file
diff --git a/Source/Lib/TextEditor/CompilerServices/Utility/StringWalker.cs b/Source/Lib/TextEditor/CompilerServices/Utility/StringWalker.cs
index 602727d28..9a17e8fe9 100644
--- a/Source/Lib/TextEditor/CompilerServices/Utility/StringWalker.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Utility/StringWalker.cs
@@ -14,7 +14,9 @@ public class StringWalker
/// Pass in the of a file, and its text. One can pass in for the if they are only working with the text itself.
public StringWalker(ResourceUri resourceUri, string sourceText)
{
+ #if DEBUG
++LuthetusDebugSomething.StringWalker_ConstructorInvocationCount;
+ #endif
ResourceUri = resourceUri;
SourceText = sourceText;
diff --git a/Source/Lib/TextEditor/CompilerServices/Utility/TokenWalker.cs b/Source/Lib/TextEditor/CompilerServices/Utility/TokenWalker.cs
index 628a0643c..6dcb9bbe8 100644
--- a/Source/Lib/TextEditor/CompilerServices/Utility/TokenWalker.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Utility/TokenWalker.cs
@@ -15,7 +15,9 @@ public class TokenWalker
public TokenWalker(List tokenList, DiagnosticBag diagnosticBag)
{
+ #if DEBUG
++LuthetusDebugSomething.TokenWalker_ConstructorInvocationCount;
+ #endif
if (tokenList.Count > 0 &&
tokenList[tokenList.Count - 1].SyntaxKind != SyntaxKind.EndOfFileToken)
From d07de17f1cd9de5ab9ac7b5425825ac1317df3f4 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 13:23:34 -0500
Subject: [PATCH 10/39] Changes in place in order to optimize CompilationUnit
(nothing actually changes functionality wise here)
---
.../CompilerServiceCase/CSharpCompilerService.cs | 8 +++-----
.../CSharp/ParserCase/CSharpParser.cs | 2 +-
.../SyntaxActors/DotNetSolutionParser.cs | 2 +-
.../Razor/CompilerServiceCase/RazorResource.cs | 11 +++++------
.../Razor/CompilerServiceCase/SemanticResultRazor.cs | 5 +++--
.../CompilerServices/CompilerServiceResource.cs | 7 +++++++
.../Implementations/CompilerService.cs | 9 +++++++--
.../CompilerServices/Implementations/Parser.cs | 4 ++--
.../CompilerServices/Interfaces/ICompilationUnit.cs | 8 ++++++++
.../Interfaces/ICompilerServiceResource.cs | 4 ++--
.../TextEditor/CompilerServices/Interfaces/IParser.cs | 2 +-
.../CompilerServices/Syntax/Nodes/CompilationUnit.cs | 2 +-
12 files changed, 41 insertions(+), 23 deletions(-)
create mode 100644 Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilationUnit.cs
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index 178f63cc2..807d6359a 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -82,7 +82,7 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
try
{
var parser = new CSharpParser(lexer);
- compilationUnit = parser.Parse(Binder, resourceUri);
+ compilationUnit = (CompilationUnit)parser.Parse(Binder, resourceUri);
}
finally
{
@@ -90,11 +90,9 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
{
if (_resourceMap.ContainsKey(resourceUri))
{
- var resource = _resourceMap[resourceUri];
+ var resource = (CSharpResource)_resourceMap[resourceUri];
- var cSharpResource = (CSharpResource)resource;
- cSharpResource.EscapeCharacterList = lexer.EscapeCharacterList;
-
+ resource.EscapeCharacterList = lexer.EscapeCharacterList;
resource.SyntaxTokenList = lexer.SyntaxTokenList;
if (compilationUnit is not null)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index c55223fb2..6bcd42a43 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -34,7 +34,7 @@ public CSharpParser(CSharpLexer lexer)
IBinderSession IParser.BinderSession => BinderSession;
ILexer IParser.Lexer => Lexer;
- public CompilationUnit Parse(
+ public ICompilationUnit Parse(
IBinder binder,
ResourceUri resourceUri)
{
diff --git a/Source/Lib/CompilerServices/DotNetSolution/SyntaxActors/DotNetSolutionParser.cs b/Source/Lib/CompilerServices/DotNetSolution/SyntaxActors/DotNetSolutionParser.cs
index e465b881d..923d8b4a8 100644
--- a/Source/Lib/CompilerServices/DotNetSolution/SyntaxActors/DotNetSolutionParser.cs
+++ b/Source/Lib/CompilerServices/DotNetSolution/SyntaxActors/DotNetSolutionParser.cs
@@ -311,7 +311,7 @@ private void ParseCloseAssociatedGroupToken(CloseAssociatedGroupToken closeAssoc
}
}
- CompilationUnit IParser.Parse(IBinder previousBinder, ResourceUri resourceUri)
+ ICompilationUnit IParser.Parse(IBinder previousBinder, ResourceUri resourceUri)
{
Parse();
diff --git a/Source/Lib/CompilerServices/Razor/CompilerServiceCase/RazorResource.cs b/Source/Lib/CompilerServices/Razor/CompilerServiceCase/RazorResource.cs
index 9778c88af..33f5218b9 100644
--- a/Source/Lib/CompilerServices/Razor/CompilerServiceCase/RazorResource.cs
+++ b/Source/Lib/CompilerServices/Razor/CompilerServiceCase/RazorResource.cs
@@ -1,9 +1,10 @@
using System.Collections.Immutable;
-using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Symbols;
+using Luthetus.TextEditor.RazorLib;
using Luthetus.TextEditor.RazorLib.Lexers.Models;
-using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices;
-using Luthetus.TextEditor.RazorLib;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Symbols;
using Luthetus.CompilerServices.Xml.Html.Decoration;
namespace Luthetus.CompilerServices.Razor.CompilerServiceCase;
@@ -31,9 +32,7 @@ public override IReadOnlyList GetSymbols()
if (localRazorSyntaxTree?.SemanticResultRazor is null)
return Array.Empty();
- var symbols = localRazorSyntaxTree
- .SemanticResultRazor
- .CompilationUnit
+ var symbols = ((CompilationUnit)localRazorSyntaxTree.SemanticResultRazor.CompilationUnit)
.Binder
.SymbolsList;
diff --git a/Source/Lib/CompilerServices/Razor/CompilerServiceCase/SemanticResultRazor.cs b/Source/Lib/CompilerServices/Razor/CompilerServiceCase/SemanticResultRazor.cs
index 6362d791c..d16d1be06 100644
--- a/Source/Lib/CompilerServices/Razor/CompilerServiceCase/SemanticResultRazor.cs
+++ b/Source/Lib/CompilerServices/Razor/CompilerServiceCase/SemanticResultRazor.cs
@@ -1,5 +1,6 @@
using System.Collections.Immutable;
using Luthetus.TextEditor.RazorLib.CompilerServices;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
using Luthetus.TextEditor.RazorLib.Lexers.Models;
@@ -26,7 +27,7 @@ public record SemanticResultRazor
/// diagnostics, on hover tooltips, etc...
///
public SemanticResultRazor(
- CompilationUnit compilationUnit,
+ ICompilationUnit compilationUnit,
List codebehindClassInsertions,
List codebehindRenderFunctionInsertions,
AdhocTextInsertion adhocTextInsertionOfTheRenderFunctionItselfIntoTheCodebehindClass,
@@ -39,7 +40,7 @@ public SemanticResultRazor(
ClassContents = classContents;
}
- public CompilationUnit CompilationUnit { get; }
+ public ICompilationUnit CompilationUnit { get; }
public List CodebehindClassInsertions { get; }
public List CodebehindRenderFunctionInsertions { get; }
public AdhocTextInsertion AdhocTextInsertionOfTheRenderFunctionItselfIntoTheCodebehindClass { get; }
diff --git a/Source/Lib/TextEditor/CompilerServices/CompilerServiceResource.cs b/Source/Lib/TextEditor/CompilerServices/CompilerServiceResource.cs
index ba057160d..34858198a 100644
--- a/Source/Lib/TextEditor/CompilerServices/CompilerServiceResource.cs
+++ b/Source/Lib/TextEditor/CompilerServices/CompilerServiceResource.cs
@@ -21,6 +21,13 @@ public CompilerServiceResource(
public virtual CompilationUnit? CompilationUnit { get; set; }
public virtual IReadOnlyList SyntaxTokenList { get; set; } = ImmutableArray.Empty;
+ ICompilationUnit? ICompilerServiceResource.CompilationUnit => CompilationUnit;
+
+ public virtual IReadOnlyList GetTokens()
+ {
+ return SyntaxTokenList;
+ }
+
public virtual IReadOnlyList GetTokenTextSpans()
{
return SyntaxTokenList.Select(st => st.TextSpan).ToArray();
diff --git a/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerService.cs b/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerService.cs
index a94d4c16e..f1990fbd1 100644
--- a/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerService.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerService.cs
@@ -10,6 +10,11 @@
namespace Luthetus.TextEditor.RazorLib.CompilerServices.Implementations;
+///
+/// If inheriting this type:
+/// - The ICompilerServiceResource must be of type (or inherit) CompilerServiceResource.
+/// - The ICompilationUnit must be of type (or inherit) CompilationUnit.
+///
public class CompilerService : ICompilerService
{
protected readonly List _emptyAutocompleteEntryList = new();
@@ -195,7 +200,7 @@ public virtual Task ParseAsync(ITextEditorEditContext editContext, TextEditorMod
parser = _compilerServiceOptions.GetParserFunc.Invoke(resource, lexer);
}
- compilationUnit = parser.Parse(Binder, resourceUri);
+ compilationUnit = (CompilationUnit)parser.Parse(Binder, resourceUri);
}
finally
{
@@ -203,7 +208,7 @@ public virtual Task ParseAsync(ITextEditorEditContext editContext, TextEditorMod
{
if (_resourceMap.ContainsKey(resourceUri))
{
- var resource = _resourceMap[resourceUri];
+ var resource = (CompilerServiceResource)_resourceMap[resourceUri];
resource.SyntaxTokenList = lexer.SyntaxTokenList;
diff --git a/Source/Lib/TextEditor/CompilerServices/Implementations/Parser.cs b/Source/Lib/TextEditor/CompilerServices/Implementations/Parser.cs
index b42e6844a..abd98e8aa 100644
--- a/Source/Lib/TextEditor/CompilerServices/Implementations/Parser.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Implementations/Parser.cs
@@ -22,7 +22,7 @@ public Parser(ILexer lexer)
public ILexer Lexer { get; }
/// This method is used when parsing many files as a single compilation. The first binder instance would be passed to the following parsers. The resourceUri is passed in so if a file is parsed for a second time, the previous symbols can be deleted so they do not duplicate.
- public CompilationUnit Parse(
+ public ICompilationUnit Parse(
IBinder previousBinder,
ResourceUri resourceUri)
{
@@ -32,7 +32,7 @@ public CompilationUnit Parse(
return Parse();
}
- public virtual CompilationUnit Parse()
+ public virtual ICompilationUnit Parse()
{
var globalCodeBlockBuilder = new CodeBlockBuilder(null, null);
var currentCodeBlockBuilder = globalCodeBlockBuilder;
diff --git a/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilationUnit.cs b/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilationUnit.cs
new file mode 100644
index 000000000..7537ac981
--- /dev/null
+++ b/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilationUnit.cs
@@ -0,0 +1,8 @@
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
+
+namespace Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+
+public interface ICompilationUnit
+{
+ public CodeBlockNode RootCodeBlockNode { get; }
+}
diff --git a/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilerServiceResource.cs b/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilerServiceResource.cs
index a351e26ad..cefe0e557 100644
--- a/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilerServiceResource.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilerServiceResource.cs
@@ -9,9 +9,9 @@ public interface ICompilerServiceResource
{
public ResourceUri ResourceUri { get; }
public ICompilerService CompilerService { get; }
- public CompilationUnit? CompilationUnit { get; set; }
- public IReadOnlyList SyntaxTokenList { get; set; }
+ public ICompilationUnit? CompilationUnit { get; }
+ public IReadOnlyList GetTokens();
public IReadOnlyList GetTokenTextSpans();
public IReadOnlyList GetSymbols();
public IReadOnlyList GetDiagnostics();
diff --git a/Source/Lib/TextEditor/CompilerServices/Interfaces/IParser.cs b/Source/Lib/TextEditor/CompilerServices/Interfaces/IParser.cs
index e8f67aa50..88c570019 100644
--- a/Source/Lib/TextEditor/CompilerServices/Interfaces/IParser.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Interfaces/IParser.cs
@@ -11,5 +11,5 @@ public interface IParser
public IBinderSession BinderSession { get; }
public ILexer Lexer { get; }
- public CompilationUnit Parse(IBinder binder, ResourceUri resourceUri);
+ public ICompilationUnit Parse(IBinder binder, ResourceUri resourceUri);
}
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/CompilationUnit.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/CompilationUnit.cs
index b15f29c6e..46b3dabd6 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/CompilationUnit.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/CompilationUnit.cs
@@ -10,7 +10,7 @@ namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
/// a singular C# resource file (that is to say a singular file on the user's file system).
/// TODO: How should work in regards to the C# 'partial' keyword, would many C# resource files need be stitched together into a single ?
///
-public sealed class CompilationUnit : ISyntaxNode
+public sealed class CompilationUnit : ICompilationUnit, ISyntaxNode
{
public CompilationUnit(
CodeBlockNode? rootCodeBlockNode,
From 6565148add1ae8de2a5115b31aeef49e67eeb427 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 13:52:04 -0500
Subject: [PATCH 11/39] DOES NOT BUILD: Changing code to use
CSharpCompilationUnit.cs
---
.../CSharpCompilationUnit.cs | 26 +++
.../CSharpCompilerService.cs | 13 +-
.../CSharp/ParserCase/CSharpParser.cs | 159 ++++++++---------
.../Internals/ParseContextualKeywords.cs | 88 +++++-----
.../Internals/ParseDefaultKeywords.cs | 162 +++++++++---------
.../Interfaces/ICompilationUnit.cs | 3 +
6 files changed, 232 insertions(+), 219 deletions(-)
create mode 100644 Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilationUnit.cs
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilationUnit.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilationUnit.cs
new file mode 100644
index 000000000..c8369d5bd
--- /dev/null
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilationUnit.cs
@@ -0,0 +1,26 @@
+using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Implementations;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+using Luthetus.TextEditor.RazorLib.Lexers.Models;
+
+namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
+
+public sealed class CSharpCompilationUnit : ICompilationUnit
+{
+ public CSharpCompilationUnit(
+ ResourceUri resourceUri,
+ CSharpBinder binder)
+ {
+ ResourceUri = resourceUri;
+ Binder = binder;
+ }
+
+ public ResourceUri ResourceUri { get; set; }
+ public CSharpLexer Lexer { get; set; }
+ public CSharpParser Parser { get; set; }
+ public CSharpParserModel ParserModel { get; set; }
+ public CSharpBinder Binder { get; set; }
+ public CSharpBinderSession BinderSession { get; set; }
+ public CodeBlockNode RootCodeBlockNode { get; set; }
+ public ImmutableArray DiagnosticsList { get; init; }
+}
\ No newline at end of file
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index 807d6359a..9c39c9f9e 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -72,17 +72,18 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
var presentationModel = modelModifier.PresentationModelList.First(
x => x.TextEditorPresentationKey == CompilerServiceDiagnosticPresentationFacts.PresentationKey);
-
- var lexer = new CSharpLexer(resourceUri, presentationModel.PendingCalculation.ContentAtRequest);
- lexer.Lex();
+
+ var cSharpCompilationUnit = new CSharpCompilationUnit(resourceUri, CSharpBinder);
+ cSharpCompilationUnit.Lexer = new CSharpLexer(resourceUri, presentationModel.PendingCalculation.ContentAtRequest);
+ cSharpCompilationUnit.Lexer.Lex();
- CompilationUnit? compilationUnit = null;
// Even if the parser throws an exception, be sure to
// make use of the Lexer to do whatever syntax highlighting is possible.
try
{
- var parser = new CSharpParser(lexer);
- compilationUnit = (CompilationUnit)parser.Parse(Binder, resourceUri);
+ cSharpCompilationUnit.BinderSession = (CSharpBinderSession)Binder.StartBinderSession(resourceUri);
+ var parser = new CSharpParser();
+ parser.Parse(cSharpCompilationUnit);
}
finally
{
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index 6bcd42a43..f24b3fe88 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -14,40 +14,26 @@
namespace Luthetus.CompilerServices.CSharp.ParserCase;
-public struct CSharpParser : IParser
+public struct CSharpParser
{
- public CSharpParser(CSharpLexer lexer)
+ public CSharpParser()
{
#if DEBUG
++LuthetusDebugSomething.Parser_ConstructorInvocationCount;
#endif
-
- Lexer = lexer;
}
public TextEditorDiagnostic[] DiagnosticsList { get; private set; } = Array.Empty();
- public CSharpBinder Binder { get; private set; }
- public CSharpBinderSession BinderSession { get; private set; }
- public CSharpLexer Lexer { get; }
- IBinder IParser.Binder => Binder;
- IBinderSession IParser.BinderSession => BinderSession;
- ILexer IParser.Lexer => Lexer;
-
- public ICompilationUnit Parse(
- IBinder binder,
- ResourceUri resourceUri)
+ public void Parse(CSharpCompilationUnit compilationUnit)
{
- Binder = (CSharpBinder)binder;
- BinderSession = (CSharpBinderSession)Binder.StartBinderSession(resourceUri);
-
var globalCodeBlockBuilder = new CodeBlockBuilder(null, null);
var currentCodeBlockBuilder = globalCodeBlockBuilder;
var diagnosticBag = new DiagnosticBag();
- var model = new CSharpParserModel(
- Binder,
- BinderSession,
+ compilationUnit.ParserModel = new CSharpParserModel(
+ cSharpCompilationUnit.Binder,
+ cSharpCompilationUnit.BinderSession,
new TokenWalker(Lexer.SyntaxTokenList, diagnosticBag),
new Stack(),
diagnosticBag,
@@ -55,17 +41,17 @@ public ICompilationUnit Parse(
currentCodeBlockBuilder);
#if DEBUG
- model.TokenWalker.ProtectedTokenSyntaxKindList = new() { SyntaxKind.StatementDelimiterToken, SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, };
+ compilationUnit.ParserModel.TokenWalker.ProtectedTokenSyntaxKindList = new() { SyntaxKind.StatementDelimiterToken, SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, };
#endif
while (true)
{
- // The last statement in this while loop is conditionally: '_ = model.TokenWalker.Consume();'.
+ // The last statement in this while loop is conditionally: '_ = compilationUnit.ParserModel.TokenWalker.Consume();'.
// Knowing this to be the case is extremely important.
- var token = model.TokenWalker.Current;
+ var token = compilationUnit.ParserModel.TokenWalker.Current;
#if DEBUG
- Console.WriteLine(token.SyntaxKind + "___" + token.TextSpan.GetText() + "___" + model.TokenWalker.Index);
+ Console.WriteLine(token.SyntaxKind + "___" + token.TextSpan.GetText() + "___" + compilationUnit.ParserModel.TokenWalker.Index);
#endif
switch (token.SyntaxKind)
@@ -79,150 +65,150 @@ public ICompilationUnit Parse(
case SyntaxKind.StarToken:
case SyntaxKind.DollarSignToken:
case SyntaxKind.AtToken:
- if (model.StatementBuilder.ChildList.Count == 0)
+ if (compilationUnit.ParserModel.StatementBuilder.ChildList.Count == 0)
{
- ParseOthers.StartStatement_Expression(model);
+ ParseOthers.StartStatement_Expression(compilationUnit);
}
else
{
- var expressionNode = ParseOthers.ParseExpression(model);
- model.StatementBuilder.ChildList.Add(expressionNode);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
}
break;
case SyntaxKind.PreprocessorDirectiveToken:
- ParseTokens.ParsePreprocessorDirectiveToken((PreprocessorDirectiveToken)token, model);
+ ParseTokens.ParsePreprocessorDirectiveToken((PreprocessorDirectiveToken)token, compilationUnit);
break;
case SyntaxKind.IdentifierToken:
- ParseTokens.ParseIdentifierToken(model);
+ ParseTokens.ParseIdentifierToken(compilationUnit);
break;
case SyntaxKind.OpenBraceToken:
- model.StatementBuilder.FinishStatement(model);
+ compilationUnit.ParserModel.StatementBuilder.FinishStatement(compilationUnit);
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
#endif
- var openBraceToken = (OpenBraceToken)model.TokenWalker.Consume();
+ var openBraceToken = (OpenBraceToken)compilationUnit.ParserModel.TokenWalker.Consume();
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
#endif
- ParseTokens.ParseOpenBraceToken(openBraceToken, model);
+ ParseTokens.ParseOpenBraceToken(openBraceToken, compilationUnit);
break;
case SyntaxKind.CloseBraceToken:
- model.StatementBuilder.FinishStatement(model);
+ compilationUnit.ParserModel.StatementBuilder.FinishStatement(compilationUnit);
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
#endif
- var closeBraceToken = (CloseBraceToken)model.TokenWalker.Consume();
+ var closeBraceToken = (CloseBraceToken)compilationUnit.ParserModel.TokenWalker.Consume();
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
#endif
- ParseTokens.ParseCloseBraceToken(closeBraceToken, model);
+ ParseTokens.ParseCloseBraceToken(closeBraceToken, compilationUnit);
break;
case SyntaxKind.OpenParenthesisToken:
- if (model.StatementBuilder.ChildList.Count == 0)
- ParseOthers.StartStatement_Expression(model);
+ if (compilationUnit.ParserModel.StatementBuilder.ChildList.Count == 0)
+ ParseOthers.StartStatement_Expression(compilationUnit);
else
- ParseTokens.ParseOpenParenthesisToken(model);
+ ParseTokens.ParseOpenParenthesisToken(compilationUnit);
break;
case SyntaxKind.CloseParenthesisToken:
- ParseTokens.ParseCloseParenthesisToken((CloseParenthesisToken)token, model);
+ ParseTokens.ParseCloseParenthesisToken((CloseParenthesisToken)token, compilationUnit);
break;
case SyntaxKind.OpenAngleBracketToken:
- if (model.StatementBuilder.ChildList.Count == 0)
- ParseOthers.StartStatement_Expression(model);
+ if (compilationUnit.ParserModel.StatementBuilder.ChildList.Count == 0)
+ ParseOthers.StartStatement_Expression(compilationUnit);
else
- ParseTokens.ParseOpenAngleBracketToken((OpenAngleBracketToken)token, model);
+ ParseTokens.ParseOpenAngleBracketToken((OpenAngleBracketToken)token, compilationUnit);
break;
case SyntaxKind.CloseAngleBracketToken:
- ParseTokens.ParseCloseAngleBracketToken((CloseAngleBracketToken)token, model);
+ ParseTokens.ParseCloseAngleBracketToken((CloseAngleBracketToken)token, compilationUnit);
break;
case SyntaxKind.OpenSquareBracketToken:
- ParseTokens.ParseOpenSquareBracketToken(model);
+ ParseTokens.ParseOpenSquareBracketToken(compilationUnit);
break;
case SyntaxKind.CloseSquareBracketToken:
- ParseTokens.ParseCloseSquareBracketToken((CloseSquareBracketToken)token, model);
+ ParseTokens.ParseCloseSquareBracketToken((CloseSquareBracketToken)token, compilationUnit);
break;
case SyntaxKind.ColonToken:
- ParseTokens.ParseColonToken(model);
+ ParseTokens.ParseColonToken(compilationUnit);
break;
case SyntaxKind.MemberAccessToken:
- ParseTokens.ParseMemberAccessToken((MemberAccessToken)token, model);
+ ParseTokens.ParseMemberAccessToken((MemberAccessToken)token, compilationUnit);
break;
case SyntaxKind.EqualsToken:
- ParseTokens.ParseEqualsToken(model);
+ ParseTokens.ParseEqualsToken(compilationUnit);
break;
case SyntaxKind.StatementDelimiterToken:
- model.StatementBuilder.FinishStatement(model);
+ compilationUnit.ParserModel.StatementBuilder.FinishStatement(compilationUnit);
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
#endif
- var statementDelimiterToken = (StatementDelimiterToken)model.TokenWalker.Consume();
+ var statementDelimiterToken = (StatementDelimiterToken)compilationUnit.ParserModel.TokenWalker.Consume();
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
#endif
- ParseTokens.ParseStatementDelimiterToken(statementDelimiterToken, model);
+ ParseTokens.ParseStatementDelimiterToken(statementDelimiterToken, compilationUnit);
break;
case SyntaxKind.EndOfFileToken:
- if (model.SyntaxStack.TryPeek(out var syntax) &&
+ if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out var syntax) &&
syntax is EndOfFileToken)
{
- _ = model.SyntaxStack.Pop();
+ _ = compilationUnit.ParserModel.SyntaxStack.Pop();
}
- if (model.SyntaxStack.TryPop(out var notUsedSyntax))
+ if (compilationUnit.ParserModel.SyntaxStack.TryPop(out var notUsedSyntax))
{
if (notUsedSyntax is null)
{
}
else if (notUsedSyntax is IExpressionNode)
{
- model.CurrentCodeBlockBuilder.ChildList.Add(notUsedSyntax);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(notUsedSyntax);
}
else if (notUsedSyntax.SyntaxKind == SyntaxKind.AmbiguousIdentifierNode)
{
var ambiguousIdentifierNode = (AmbiguousIdentifierNode)notUsedSyntax;
- model.CurrentCodeBlockBuilder.ChildList.Add(notUsedSyntax);
- model.DiagnosticBag.ReportUndefinedTypeOrNamespace(
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(notUsedSyntax);
+ compilationUnit.ParserModel.DiagnosticBag.ReportUndefinedTypeOrNamespace(
ambiguousIdentifierNode.IdentifierToken.TextSpan,
ambiguousIdentifierNode.IdentifierToken.TextSpan.GetText());
}
}
- else if (model.StatementBuilder.ChildList.Any())
+ else if (compilationUnit.ParserModel.StatementBuilder.ChildList.Any())
{
- foreach (var item in model.StatementBuilder.ChildList)
+ foreach (var item in compilationUnit.ParserModel.StatementBuilder.ChildList)
{
- model.CurrentCodeBlockBuilder.ChildList.Add(item);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(item);
}
}
break;
default:
if (UtilityApi.IsContextualKeywordSyntaxKind(token.SyntaxKind))
- ParseTokens.ParseKeywordContextualToken(model);
+ ParseTokens.ParseKeywordContextualToken(compilationUnit);
else if (UtilityApi.IsKeywordSyntaxKind(token.SyntaxKind))
- ParseTokens.ParseKeywordToken(model);
+ ParseTokens.ParseKeywordToken(compilationUnit);
break;
}
if (token.SyntaxKind == SyntaxKind.EndOfFileToken)
{
- if (model.CurrentCodeBlockBuilder.ParseChildScopeQueue.TryDequeue(out var deferredChildScope))
- deferredChildScope.PrepareMainParserLoop(model.TokenWalker.Index, model);
+ if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.ParseChildScopeQueue.TryDequeue(out var deferredChildScope))
+ deferredChildScope.PrepareMainParserLoop(compilationUnit.ParserModel.TokenWalker.Index, compilationUnit);
else
break;
}
- if (model.TokenWalker.ConsumeCounter == 0)
+ if (compilationUnit.ParserModel.TokenWalker.ConsumeCounter == 0)
{
// This means either:
// - None of the methods for syntax could make sense of the token, so they didn't consume it.
@@ -232,38 +218,35 @@ public ICompilationUnit Parse(
// To avoid an infinite loop, this will ensure at least 1 token is consumed each iteration of the while loop.
//
// (and that the token index increased by at least 1 from the previous loop; this is implicitly what is implied).
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
}
- else if (model.TokenWalker.ConsumeCounter < 0)
+ else if (compilationUnit.ParserModel.TokenWalker.ConsumeCounter < 0)
{
- // This means that a syntax invoked 'model.TokenWalker.Backtrack()'.
- // Without invoking an equal amount of 'model.TokenWalker.Consume()' to avoid an infinite loop.
- throw new LuthetusTextEditorException($"model.TokenWalker.ConsumeCounter:{model.TokenWalker.ConsumeCounter} < 0");
+ // This means that a syntax invoked 'compilationUnit.ParserModel.TokenWalker.Backtrack()'.
+ // Without invoking an equal amount of 'compilationUnit.ParserModel.TokenWalker.Consume()' to avoid an infinite loop.
+ throw new LuthetusTextEditorException($"compilationUnit.ParserModel.TokenWalker.ConsumeCounter:{compilationUnit.ParserModel.TokenWalker.ConsumeCounter} < 0");
}
- model.TokenWalker.ConsumeCounterReset();
+ compilationUnit.ParserModel.TokenWalker.ConsumeCounterReset();
}
- if (model.CurrentCodeBlockBuilder.Parent is not null)
+ if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.Parent is not null)
{
// The current token here would be the EOF token.
- Binder.CloseScope(model.TokenWalker.Current.TextSpan, model);
+ Binder.CloseScope(compilationUnit.ParserModel.TokenWalker.Current.TextSpan, compilationUnit);
}
- DiagnosticsList = model.DiagnosticBag.ToArray();
+ DiagnosticsList = compilationUnit.ParserModel.DiagnosticBag.ToArray();
- var topLevelStatementsCodeBlock = model.CurrentCodeBlockBuilder.Build(
+ var topLevelStatementsCodeBlock = compilationUnit.ParserModel.CurrentCodeBlockBuilder.Build(
DiagnosticsList
.Union(Binder.DiagnosticsList)
.Union(Lexer.DiagnosticList)
.ToArray());
- Binder.FinalizeBinderSession(BinderSession);
- return new CompilationUnit(
- topLevelStatementsCodeBlock,
- Lexer,
- this,
- Binder);
+ cSharpCompilationUnit.CSharpBinder.FinalizeBinderSession(cSharpCompilationUnit.BinderSession);
+
+ cSharpCompilationUnit.RootCodeBlockNode = topLevelStatementsCodeBlock;
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
index cbb8b84a3..7025dac64 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
@@ -8,7 +8,7 @@ namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
public class ParseContextualKeywords
{
- public static void HandleVarTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleVarTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
if (model.StatementBuilder.ChildList.Count == 0)
ParseTokens.ParseIdentifierToken(model);
@@ -16,202 +16,202 @@ public static void HandleVarTokenContextualKeyword(CSharpParserModel model)
ParseOthers.StartStatement_Expression(model);
}
- public static void HandlePartialTokenContextualKeyword(CSharpParserModel model)
+ public static void HandlePartialTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleAddTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleAddTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleAndTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleAndTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleAliasTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleAliasTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleAscendingTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleAscendingTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleArgsTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleArgsTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleAsyncTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleAsyncTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleAwaitTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleAwaitTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleByTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleByTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleDescendingTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleDescendingTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleDynamicTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleDynamicTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleEqualsTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleEqualsTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleFileTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleFileTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleFromTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleFromTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleGetTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleGetTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleGlobalTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleGlobalTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleGroupTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleGroupTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleInitTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleInitTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleIntoTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleIntoTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleJoinTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleJoinTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleLetTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleLetTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleManagedTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleManagedTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleNameofTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleNameofTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleNintTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleNintTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleNotTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleNotTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleNotnullTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleNotnullTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleNuintTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleNuintTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleOnTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleOnTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleOrTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleOrTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleOrderbyTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleOrderbyTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleRecordTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleRecordTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
ParseDefaultKeywords.HandleStorageModifierTokenKeyword(model);
}
- public static void HandleRemoveTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleRemoveTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleRequiredTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleRequiredTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleScopedTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleScopedTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleSelectTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleSelectTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleSetTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleSetTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleUnmanagedTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleUnmanagedTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleValueTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleValueTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleWhenTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleWhenTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleWhereTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleWhereTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
var whereTokenContextualKeyword = (KeywordContextualToken)model.TokenWalker.Consume();
@@ -230,17 +230,17 @@ public static void HandleWhereTokenContextualKeyword(CSharpParserModel model)
}
}
- public static void HandleWithTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleWithTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleYieldTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleYieldTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
- public static void HandleUnrecognizedTokenContextualKeyword(CSharpParserModel model)
+ public static void HandleUnrecognizedTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
index ebbb5f037..32edaaefc 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
@@ -10,39 +10,39 @@ namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
public class ParseDefaultKeywords
{
- public static void HandleAsTokenKeyword(CSharpParserModel model)
+ public static void HandleAsTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleBaseTokenKeyword(CSharpParserModel model)
+ public static void HandleBaseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleBoolTokenKeyword(CSharpParserModel model)
+ public static void HandleBoolTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleBreakTokenKeyword(CSharpParserModel model)
+ public static void HandleBreakTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleByteTokenKeyword(CSharpParserModel model)
+ public static void HandleByteTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleCaseTokenKeyword(CSharpParserModel model)
+ public static void HandleCaseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.ExpressionList.Add((SyntaxKind.ColonToken, null));
var expressionNode = ParseOthers.ParseExpression(model);
var colonToken = (ColonToken)model.TokenWalker.Match(SyntaxKind.ColonToken);
}
- public static void HandleCatchTokenKeyword(CSharpParserModel model)
+ public static void HandleCatchTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var catchKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -86,32 +86,32 @@ public static void HandleCatchTokenKeyword(CSharpParserModel model)
}
}
- public static void HandleCharTokenKeyword(CSharpParserModel model)
+ public static void HandleCharTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleCheckedTokenKeyword(CSharpParserModel model)
+ public static void HandleCheckedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleConstTokenKeyword(CSharpParserModel model)
+ public static void HandleConstTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleContinueTokenKeyword(CSharpParserModel model)
+ public static void HandleContinueTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleDecimalTokenKeyword(CSharpParserModel model)
+ public static void HandleDecimalTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleDefaultTokenKeyword(CSharpParserModel model)
+ public static void HandleDefaultTokenKeyword(CSharpCompilationUnit compilationUnit)
{
// Switch statement default case.
if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.ColonToken)
@@ -120,12 +120,12 @@ public static void HandleDefaultTokenKeyword(CSharpParserModel model)
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleDelegateTokenKeyword(CSharpParserModel model)
+ public static void HandleDelegateTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleDoTokenKeyword(CSharpParserModel model)
+ public static void HandleDoTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var doKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -144,17 +144,17 @@ public static void HandleDoTokenKeyword(CSharpParserModel model)
model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = doWhileStatementNode;
}
- public static void HandleDoubleTokenKeyword(CSharpParserModel model)
+ public static void HandleDoubleTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleElseTokenKeyword(CSharpParserModel model)
+ public static void HandleElseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleEnumTokenKeyword(CSharpParserModel model)
+ public static void HandleEnumTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleStorageModifierTokenKeyword(model);
@@ -163,28 +163,28 @@ public static void HandleEnumTokenKeyword(CSharpParserModel model)
// HandleTypeIdentifierKeyword(model);
}
- public static void HandleEventTokenKeyword(CSharpParserModel model)
+ public static void HandleEventTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleExplicitTokenKeyword(CSharpParserModel model)
+ public static void HandleExplicitTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleExternTokenKeyword(CSharpParserModel model)
+ public static void HandleExternTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleFalseTokenKeyword(CSharpParserModel model)
+ public static void HandleFalseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var expressionNode = ParseOthers.ParseExpression(model);
model.StatementBuilder.ChildList.Add(expressionNode);
}
- public static void HandleFinallyTokenKeyword(CSharpParserModel model)
+ public static void HandleFinallyTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var finallyKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -225,17 +225,17 @@ public static void HandleFinallyTokenKeyword(CSharpParserModel model)
}
}
- public static void HandleFixedTokenKeyword(CSharpParserModel model)
+ public static void HandleFixedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleFloatTokenKeyword(CSharpParserModel model)
+ public static void HandleFloatTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleForTokenKeyword(CSharpParserModel model)
+ public static void HandleForTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var forKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -340,7 +340,7 @@ public static void HandleForTokenKeyword(CSharpParserModel model)
model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = forStatementNode;
}
- public static void HandleForeachTokenKeyword(CSharpParserModel model)
+ public static void HandleForeachTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var foreachKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -374,32 +374,32 @@ public static void HandleForeachTokenKeyword(CSharpParserModel model)
model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = foreachStatementNode;
}
- public static void HandleGotoTokenKeyword(CSharpParserModel model)
+ public static void HandleGotoTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleImplicitTokenKeyword(CSharpParserModel model)
+ public static void HandleImplicitTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleInTokenKeyword(CSharpParserModel model)
+ public static void HandleInTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleIntTokenKeyword(CSharpParserModel model)
+ public static void HandleIntTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleIsTokenKeyword(CSharpParserModel model)
+ public static void HandleIsTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleLockTokenKeyword(CSharpParserModel model)
+ public static void HandleLockTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var lockKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -421,83 +421,83 @@ public static void HandleLockTokenKeyword(CSharpParserModel model)
model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = lockStatementNode;
}
- public static void HandleLongTokenKeyword(CSharpParserModel model)
+ public static void HandleLongTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleNullTokenKeyword(CSharpParserModel model)
+ public static void HandleNullTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleObjectTokenKeyword(CSharpParserModel model)
+ public static void HandleObjectTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleOperatorTokenKeyword(CSharpParserModel model)
+ public static void HandleOperatorTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleOutTokenKeyword(CSharpParserModel model)
+ public static void HandleOutTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleParamsTokenKeyword(CSharpParserModel model)
+ public static void HandleParamsTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleProtectedTokenKeyword(CSharpParserModel model)
+ public static void HandleProtectedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var protectedTokenKeyword = (KeywordToken)model.TokenWalker.Consume();
model.StatementBuilder.ChildList.Add(protectedTokenKeyword);
}
- public static void HandleReadonlyTokenKeyword(CSharpParserModel model)
+ public static void HandleReadonlyTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleRefTokenKeyword(CSharpParserModel model)
+ public static void HandleRefTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleSbyteTokenKeyword(CSharpParserModel model)
+ public static void HandleSbyteTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleShortTokenKeyword(CSharpParserModel model)
+ public static void HandleShortTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleSizeofTokenKeyword(CSharpParserModel model)
+ public static void HandleSizeofTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleStackallocTokenKeyword(CSharpParserModel model)
+ public static void HandleStackallocTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleStringTokenKeyword(CSharpParserModel model)
+ public static void HandleStringTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleStructTokenKeyword(CSharpParserModel model)
+ public static void HandleStructTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleStorageModifierTokenKeyword(model);
}
- public static void HandleSwitchTokenKeyword(CSharpParserModel model)
+ public static void HandleSwitchTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var switchKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -519,23 +519,23 @@ public static void HandleSwitchTokenKeyword(CSharpParserModel model)
model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = switchStatementNode;
}
- public static void HandleThisTokenKeyword(CSharpParserModel model)
+ public static void HandleThisTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleThrowTokenKeyword(CSharpParserModel model)
+ public static void HandleThrowTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleTrueTokenKeyword(CSharpParserModel model)
+ public static void HandleTrueTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var expressionNode = ParseOthers.ParseExpression(model);
model.StatementBuilder.ChildList.Add(expressionNode);
}
- public static void HandleTryTokenKeyword(CSharpParserModel model)
+ public static void HandleTryTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var tryKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -559,47 +559,47 @@ public static void HandleTryTokenKeyword(CSharpParserModel model)
model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = tryStatementTryNode;
}
- public static void HandleTypeofTokenKeyword(CSharpParserModel model)
+ public static void HandleTypeofTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleUintTokenKeyword(CSharpParserModel model)
+ public static void HandleUintTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleUlongTokenKeyword(CSharpParserModel model)
+ public static void HandleUlongTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleUncheckedTokenKeyword(CSharpParserModel model)
+ public static void HandleUncheckedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleUnsafeTokenKeyword(CSharpParserModel model)
+ public static void HandleUnsafeTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleUshortTokenKeyword(CSharpParserModel model)
+ public static void HandleUshortTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleVoidTokenKeyword(CSharpParserModel model)
+ public static void HandleVoidTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleTypeIdentifierKeyword(model);
}
- public static void HandleVolatileTokenKeyword(CSharpParserModel model)
+ public static void HandleVolatileTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleWhileTokenKeyword(CSharpParserModel model)
+ public static void HandleWhileTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var whileKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -633,7 +633,7 @@ public static void HandleWhileTokenKeyword(CSharpParserModel model)
}
}
- public static void HandleUnrecognizedTokenKeyword(CSharpParserModel model)
+ public static void HandleUnrecognizedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
@@ -641,17 +641,17 @@ public static void HandleUnrecognizedTokenKeyword(CSharpParserModel model)
/// The 'Default' of this method name is confusing.
/// It seems to refer to the 'default' of switch statement rather than the 'default' keyword itself?
///
- public static void HandleDefault(CSharpParserModel model)
+ public static void HandleDefault(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleTypeIdentifierKeyword(CSharpParserModel model)
+ public static void HandleTypeIdentifierKeyword(CSharpCompilationUnit compilationUnit)
{
ParseTokens.ParseIdentifierToken(model);
}
- public static void HandleNewTokenKeyword(CSharpParserModel model)
+ public static void HandleNewTokenKeyword(CSharpCompilationUnit compilationUnit)
{
if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenParenthesisToken ||
UtilityApi.IsConvertibleToIdentifierToken(model.TokenWalker.Next.SyntaxKind))
@@ -665,50 +665,50 @@ public static void HandleNewTokenKeyword(CSharpParserModel model)
}
}
- public static void HandlePublicTokenKeyword(CSharpParserModel model)
+ public static void HandlePublicTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var publicKeywordToken = (KeywordToken)model.TokenWalker.Consume();
model.StatementBuilder.ChildList.Add(publicKeywordToken);
}
- public static void HandleInternalTokenKeyword(CSharpParserModel model)
+ public static void HandleInternalTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var internalTokenKeyword = (KeywordToken)model.TokenWalker.Consume();
model.StatementBuilder.ChildList.Add(internalTokenKeyword);
}
- public static void HandlePrivateTokenKeyword(CSharpParserModel model)
+ public static void HandlePrivateTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var privateTokenKeyword = (KeywordToken)model.TokenWalker.Consume();
model.StatementBuilder.ChildList.Add(privateTokenKeyword);
}
- public static void HandleStaticTokenKeyword(CSharpParserModel model)
+ public static void HandleStaticTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleOverrideTokenKeyword(CSharpParserModel model)
+ public static void HandleOverrideTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleVirtualTokenKeyword(CSharpParserModel model)
+ public static void HandleVirtualTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleAbstractTokenKeyword(CSharpParserModel model)
+ public static void HandleAbstractTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleSealedTokenKeyword(CSharpParserModel model)
+ public static void HandleSealedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
- public static void HandleIfTokenKeyword(CSharpParserModel model)
+ public static void HandleIfTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var ifTokenKeyword = (KeywordToken)model.TokenWalker.Consume();
@@ -725,7 +725,7 @@ public static void HandleIfTokenKeyword(CSharpParserModel model)
model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = boundIfStatementNode;
}
- public static void HandleUsingTokenKeyword(CSharpParserModel model)
+ public static void HandleUsingTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var usingKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -747,7 +747,7 @@ public static void HandleUsingTokenKeyword(CSharpParserModel model)
model.StatementBuilder.ChildList.Add(usingStatementNode);
}
- public static void HandleInterfaceTokenKeyword(CSharpParserModel model)
+ public static void HandleInterfaceTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleStorageModifierTokenKeyword(model);
}
@@ -763,7 +763,7 @@ public static void HandleInterfaceTokenKeyword(CSharpParserModel model)
/// Invocation of this method implies the current token was
/// class, interface, struct, etc...
///
- public static void HandleStorageModifierTokenKeyword(CSharpParserModel model)
+ public static void HandleStorageModifierTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var storageModifierToken = model.TokenWalker.Consume();
@@ -874,12 +874,12 @@ public static void HandleStorageModifierTokenKeyword(CSharpParserModel model)
model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = typeDefinitionNode;
}
- public static void HandleClassTokenKeyword(CSharpParserModel model)
+ public static void HandleClassTokenKeyword(CSharpCompilationUnit compilationUnit)
{
HandleStorageModifierTokenKeyword(model);
}
- public static void HandleNamespaceTokenKeyword(CSharpParserModel model)
+ public static void HandleNamespaceTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var namespaceKeywordToken = (KeywordToken)model.TokenWalker.Consume();
@@ -904,7 +904,7 @@ public static void HandleNamespaceTokenKeyword(CSharpParserModel model)
model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = namespaceStatementNode;
}
- public static void HandleReturnTokenKeyword(CSharpParserModel model)
+ public static void HandleReturnTokenKeyword(CSharpCompilationUnit compilationUnit)
{
model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
}
diff --git a/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilationUnit.cs b/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilationUnit.cs
index 7537ac981..fb057c2e9 100644
--- a/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilationUnit.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilationUnit.cs
@@ -2,6 +2,9 @@
namespace Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+///
+/// Example usage: Every '.cs' file in a .NET Solution is an 'ICompilationUnit'
+///
public interface ICompilationUnit
{
public CodeBlockNode RootCodeBlockNode { get; }
From 9ad8732319837746e49dad94e72c706c248ac2de Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:00:03 -0500
Subject: [PATCH 12/39] DOES NOT BUILD: Still changing IParserModel arguments
to CSharpCompilationUnit
---
.../BinderCase/CSharpBinder.Expressions.cs | 66 +++++++++----------
.../ParserCase/Internals/ParseFunctions.cs | 6 +-
.../ParserCase/Internals/ParseOthers.cs | 10 +--
.../ParserCase/Internals/ParseTokens.cs | 42 ++++++------
.../CSharp/ParserCase/Internals/ParseTypes.cs | 14 ++--
.../ParserCase/Internals/ParseVariables.cs | 12 ++--
.../Internals/TokenWalkerExtensionMethods.cs | 4 +-
.../CSharp/ParserCase/Internals/UtilityApi.cs | 6 +-
8 files changed, 80 insertions(+), 80 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
index dedab153c..e1eaae413 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
@@ -26,7 +26,7 @@ public partial class CSharpBinder
/// if the parameters were not mergeable.
///
public IExpressionNode AnyMergeToken(
- IExpressionNode expressionPrimary, ISyntaxToken token, IParserModel model)
+ IExpressionNode expressionPrimary, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
#if DEBUG
Console.WriteLine($"{expressionPrimary.SyntaxKind} + {token.SyntaxKind}");
@@ -94,7 +94,7 @@ public IExpressionNode AnyMergeToken(
/// if the parameters were not mergeable.
///
public IExpressionNode AnyMergeExpression(
- IExpressionNode expressionPrimary, IExpressionNode expressionSecondary, IParserModel model)
+ IExpressionNode expressionPrimary, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
#if DEBUG
Console.WriteLine($"{expressionPrimary.SyntaxKind} + {expressionSecondary.SyntaxKind}");
@@ -132,7 +132,7 @@ public IExpressionNode AnyMergeExpression(
}
public IExpressionNode AmbiguousIdentifierMergeToken(
- AmbiguousIdentifierExpressionNode ambiguousIdentifierExpressionNode, ISyntaxToken token, IParserModel model)
+ AmbiguousIdentifierExpressionNode ambiguousIdentifierExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
if (token.SyntaxKind == SyntaxKind.OpenParenthesisToken &&
ambiguousIdentifierExpressionNode.Token.SyntaxKind == SyntaxKind.IdentifierToken)
@@ -315,7 +315,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
}
public IExpressionNode AmbiguousIdentifierMergeExpression(
- AmbiguousIdentifierExpressionNode ambiguousIdentifierExpressionNode, IExpressionNode expressionSecondary, IParserModel model)
+ AmbiguousIdentifierExpressionNode ambiguousIdentifierExpressionNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
if (ambiguousIdentifierExpressionNode.GenericParametersListingNode is not null &&
!ambiguousIdentifierExpressionNode.GenericParametersListingNode.CloseAngleBracketToken.ConstructorWasInvoked)
@@ -329,7 +329,7 @@ public IExpressionNode AmbiguousIdentifierMergeExpression(
public IExpressionNode ForceDecisionAmbiguousIdentifier(
IExpressionNode expressionPrimary,
AmbiguousIdentifierExpressionNode ambiguousIdentifierExpressionNode,
- IParserModel model,
+ CSharpCompilationUnit compilationUnit,
bool forceVariableReferenceNode = false)
{
if (ambiguousIdentifierExpressionNode.FollowsMemberAccessToken)
@@ -395,21 +395,21 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
}
public IExpressionNode BadMergeToken(
- BadExpressionNode badExpressionNode, ISyntaxToken token, IParserModel model)
+ BadExpressionNode badExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
badExpressionNode.SyntaxList.Add(token);
return badExpressionNode;
}
public IExpressionNode BadMergeExpression(
- BadExpressionNode badExpressionNode, IExpressionNode expressionSecondary, IParserModel model)
+ BadExpressionNode badExpressionNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
badExpressionNode.SyntaxList.Add(expressionSecondary);
return badExpressionNode;
}
public IExpressionNode BinaryMergeToken(
- BinaryExpressionNode binaryExpressionNode, ISyntaxToken token, IParserModel model)
+ BinaryExpressionNode binaryExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -462,7 +462,7 @@ public IExpressionNode BinaryMergeToken(
}
public IExpressionNode CommaSeparatedMergeToken(
- CommaSeparatedExpressionNode commaSeparatedExpressionNode, ISyntaxToken token, IParserModel model)
+ CommaSeparatedExpressionNode commaSeparatedExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
if (token.SyntaxKind == SyntaxKind.CommaToken)
{
@@ -481,7 +481,7 @@ public IExpressionNode CommaSeparatedMergeToken(
}
public IExpressionNode CommaSeparatedMergeExpression(
- CommaSeparatedExpressionNode commaSeparatedExpressionNode, IExpressionNode expressionSecondary, IParserModel model)
+ CommaSeparatedExpressionNode commaSeparatedExpressionNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken || model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseParenthesisToken)
{
@@ -493,7 +493,7 @@ public IExpressionNode CommaSeparatedMergeExpression(
}
public IExpressionNode ConstructorInvocationMergeToken(
- ConstructorInvocationExpressionNode constructorInvocationExpressionNode, ISyntaxToken token, IParserModel model)
+ ConstructorInvocationExpressionNode constructorInvocationExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -607,7 +607,7 @@ public IExpressionNode ConstructorInvocationMergeToken(
}
public IExpressionNode ConstructorInvocationMergeExpression(
- ConstructorInvocationExpressionNode constructorInvocationExpressionNode, IExpressionNode expressionSecondary, IParserModel model)
+ ConstructorInvocationExpressionNode constructorInvocationExpressionNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
if (constructorInvocationExpressionNode.ConstructorInvocationStageKind != ConstructorInvocationStageKind.ObjectInitializationParameters &&
expressionSecondary.SyntaxKind == SyntaxKind.AmbiguousIdentifierExpressionNode)
@@ -743,7 +743,7 @@ public IExpressionNode ConstructorInvocationMergeExpression(
}
public IExpressionNode EmptyMergeToken(
- EmptyExpressionNode emptyExpressionNode, ISyntaxToken token, IParserModel model)
+ EmptyExpressionNode emptyExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
if (UtilityApi.IsConvertibleToTypeClauseNode(token.SyntaxKind))
{
@@ -834,7 +834,7 @@ public IExpressionNode EmptyMergeToken(
}
public IExpressionNode ExplicitCastMergeToken(
- ExplicitCastNode explicitCastNode, ISyntaxToken token, IParserModel model)
+ ExplicitCastNode explicitCastNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -852,7 +852,7 @@ public IExpressionNode ExplicitCastMergeToken(
}
public IExpressionNode GenericParametersListingMergeToken(
- GenericParametersListingNode genericParametersListingNode, ISyntaxToken token, IParserModel model)
+ GenericParametersListingNode genericParametersListingNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -874,7 +874,7 @@ public IExpressionNode GenericParametersListingMergeToken(
}
public IExpressionNode GenericParametersListingMergeExpression(
- GenericParametersListingNode genericParametersListingNode, IExpressionNode expressionSecondary, IParserModel model)
+ GenericParametersListingNode genericParametersListingNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
if (expressionSecondary.SyntaxKind == SyntaxKind.EmptyExpressionNode)
return genericParametersListingNode;
@@ -928,7 +928,7 @@ public IExpressionNode GenericParametersListingMergeExpression(
}
public IExpressionNode FunctionParametersListingMergeToken(
- FunctionParametersListingNode functionParametersListingNode, ISyntaxToken token, IParserModel model)
+ FunctionParametersListingNode functionParametersListingNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -941,7 +941,7 @@ public IExpressionNode FunctionParametersListingMergeToken(
}
public IExpressionNode FunctionParametersListingMergeExpression(
- FunctionParametersListingNode functionParametersListingNode, IExpressionNode expressionSecondary, IParserModel model)
+ FunctionParametersListingNode functionParametersListingNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
if (expressionSecondary.SyntaxKind == SyntaxKind.EmptyExpressionNode)
return functionParametersListingNode;
@@ -966,7 +966,7 @@ public IExpressionNode FunctionParametersListingMergeExpression(
}
public IExpressionNode FunctionArgumentsListingMergeToken(
- FunctionArgumentsListingNode functionArgumentsListingNode, ISyntaxToken token, IParserModel model)
+ FunctionArgumentsListingNode functionArgumentsListingNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -979,7 +979,7 @@ public IExpressionNode FunctionArgumentsListingMergeToken(
}
public IExpressionNode FunctionArgumentsListingMergeExpression(
- FunctionArgumentsListingNode functionArgumentsListingNode, IExpressionNode expressionSecondary, IParserModel model)
+ FunctionArgumentsListingNode functionArgumentsListingNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
if (expressionSecondary.SyntaxKind == SyntaxKind.EmptyExpressionNode)
return functionArgumentsListingNode;
@@ -1007,7 +1007,7 @@ public IExpressionNode FunctionArgumentsListingMergeExpression(
}
public IExpressionNode LambdaMergeToken(
- LambdaExpressionNode lambdaExpressionNode, ISyntaxToken token, IParserModel model)
+ LambdaExpressionNode lambdaExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
if (token.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
@@ -1114,7 +1114,7 @@ public IExpressionNode LambdaMergeToken(
}
public IExpressionNode LambdaMergeExpression(
- LambdaExpressionNode lambdaExpressionNode, IExpressionNode expressionSecondary, IParserModel model)
+ LambdaExpressionNode lambdaExpressionNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
switch (expressionSecondary.SyntaxKind)
{
@@ -1132,7 +1132,7 @@ public IExpressionNode LambdaMergeExpression(
/// they are much higher priority.
///
public IExpressionNode LiteralMergeToken(
- LiteralExpressionNode literalExpressionNode, ISyntaxToken token, IParserModel model)
+ LiteralExpressionNode literalExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -1150,7 +1150,7 @@ public IExpressionNode LiteralMergeToken(
}
public IExpressionNode ParenthesizedMergeToken(
- ParenthesizedExpressionNode parenthesizedExpressionNode, ISyntaxToken token, IParserModel model)
+ ParenthesizedExpressionNode parenthesizedExpressionNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -1178,7 +1178,7 @@ public IExpressionNode ParenthesizedMergeToken(
}
public IExpressionNode ParenthesizedMergeExpression(
- ParenthesizedExpressionNode parenthesizedExpressionNode, IExpressionNode expressionSecondary, IParserModel model)
+ ParenthesizedExpressionNode parenthesizedExpressionNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
if (model.TokenWalker.Peek(1).SyntaxKind == SyntaxKind.EqualsToken &&
model.TokenWalker.Peek(2).SyntaxKind == SyntaxKind.CloseAngleBracketToken)
@@ -1225,7 +1225,7 @@ public IExpressionNode ParenthesizedMergeExpression(
}
public IExpressionNode TypeClauseMergeToken(
- TypeClauseNode typeClauseNode, ISyntaxToken token, IParserModel model)
+ TypeClauseNode typeClauseNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -1338,7 +1338,7 @@ public IExpressionNode TypeClauseMergeToken(
}
public IExpressionNode TypeClauseMergeExpression(
- TypeClauseNode typeClauseNode, IExpressionNode expressionSecondary, IParserModel model)
+ TypeClauseNode typeClauseNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
switch (expressionSecondary.SyntaxKind)
{
@@ -1356,13 +1356,13 @@ public IExpressionNode TypeClauseMergeExpression(
}
public IExpressionNode VariableAssignmentMergeToken(
- VariableAssignmentExpressionNode variableAssignmentNode, ISyntaxToken token, IParserModel model)
+ VariableAssignmentExpressionNode variableAssignmentNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
return variableAssignmentNode;
}
public IExpressionNode VariableAssignmentMergeExpression(
- VariableAssignmentExpressionNode variableAssignmentNode, IExpressionNode expressionSecondary, IParserModel model)
+ VariableAssignmentExpressionNode variableAssignmentNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
if (variableAssignmentNode.ExpressionNode == EmptyExpressionNode.Empty)
{
@@ -1376,7 +1376,7 @@ public IExpressionNode VariableAssignmentMergeExpression(
}
public IExpressionNode FunctionInvocationMergeToken(
- FunctionInvocationNode functionInvocationNode, ISyntaxToken token, IParserModel model)
+ FunctionInvocationNode functionInvocationNode, ISyntaxToken token, CSharpCompilationUnit compilationUnit)
{
switch (token.SyntaxKind)
{
@@ -1389,7 +1389,7 @@ public IExpressionNode FunctionInvocationMergeToken(
}
public IExpressionNode FunctionInvocationMergeExpression(
- FunctionInvocationNode functionInvocationNode, IExpressionNode expressionSecondary, IParserModel model)
+ FunctionInvocationNode functionInvocationNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
if (expressionSecondary.SyntaxKind == SyntaxKind.AmbiguousIdentifierExpressionNode)
{
@@ -1408,7 +1408,7 @@ public IExpressionNode FunctionInvocationMergeExpression(
}
public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
- LambdaExpressionNode lambdaExpressionNode, IExpressionNode expressionNode, IParserModel model)
+ LambdaExpressionNode lambdaExpressionNode, IExpressionNode expressionNode, CSharpCompilationUnit compilationUnit)
{
if (expressionNode.SyntaxKind == SyntaxKind.BadExpressionNode)
{
@@ -1556,7 +1556,7 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
/// So, this method will remove any entries in the model.ExpressionList
/// that have the 'ParenthesizedExpressionNode' as the to-be primary expression.
///
- public void ClearFromExpressionList(IExpressionNode expressionNode, IParserModel model)
+ public void ClearFromExpressionList(IExpressionNode expressionNode, CSharpCompilationUnit compilationUnit)
{
for (int i = model.ExpressionList.Count - 1; i > -1; i--)
{
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
index 524d21e70..a6691c6ad 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
@@ -13,7 +13,7 @@ public static void HandleFunctionDefinition(
IdentifierToken consumedIdentifierToken,
TypeClauseNode consumedTypeClauseNode,
GenericParametersListingNode? consumedGenericArgumentsListingNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
{
@@ -63,7 +63,7 @@ public static void HandleFunctionDefinition(
public static void HandleConstructorDefinition(
TypeDefinitionNode typeDefinitionNodeCodeBlockOwner,
IdentifierToken consumedIdentifierToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var functionArgumentsListingNode = HandleFunctionArguments(model);
@@ -116,7 +116,7 @@ public static void HandleConstructorDefinition(
}
/// Use this method for function definition, whereas should be used for function invocation.
- public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpParserModel model)
+ public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpCompilationUnit compilationUnit)
{
var openParenthesisToken = (OpenParenthesisToken)model.TokenWalker.Consume();
var functionArgumentEntryNodeList = new List();
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
index de54851d1..68879e218 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
@@ -15,7 +15,7 @@ public static class ParseOthers
///
/// TODO: Delete this method, to parse a namespace identifier one should be able to just invoke 'ParseExpression(...)'
///
- public static ISyntax HandleNamespaceIdentifier(CSharpParserModel model)
+ public static ISyntax HandleNamespaceIdentifier(CSharpCompilationUnit compilationUnit)
{
var combineNamespaceIdentifierIntoOne = new List();
@@ -53,7 +53,7 @@ public static ISyntax HandleNamespaceIdentifier(CSharpParserModel model)
return new IdentifierToken(identifierTextSpan);
}
- public static void StartStatement_Expression(CSharpParserModel model)
+ public static void StartStatement_Expression(CSharpCompilationUnit compilationUnit)
{
var expressionNode = ParseOthers.ParseExpression(model);
model.CurrentCodeBlockBuilder.ChildList.Add(expressionNode);
@@ -78,7 +78,7 @@ public static void StartStatement_Expression(CSharpParserModel model)
/// if the root primary expression is not equal to the model.ForceParseExpressionSyntaxKind
/// then stop.
///
- public static bool TryParseExpression(SyntaxKind? syntaxKind, CSharpParserModel model, out IExpressionNode expressionNode)
+ public static bool TryParseExpression(SyntaxKind? syntaxKind, CSharpCompilationUnit compilationUnit, out IExpressionNode expressionNode)
{
var originalTokenIndex = model.TokenWalker.Index;
@@ -127,7 +127,7 @@ public static bool SyntaxIsEndDelimiter(SyntaxKind syntaxKind)
/// In the case where the first token of the expression had already been 'Consume()'-ed then 'model.TokenWalker.Backtrack();'
/// might be of use in order to move the model.TokenWalker backwards prior to invoking this method.
///
- public static IExpressionNode ParseExpression(CSharpParserModel model)
+ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationUnit)
{
#if DEBUG
Console.WriteLine("\nParseExpression(...)");
@@ -288,7 +288,7 @@ public static IExpressionNode ParseExpression(CSharpParserModel model)
///
/// LambdaExpressionNode for example, needs to override 'SyntaxKind.StatementDelimiterToken'.
///
- private static IExpressionNode BubbleUpParseExpression(int indexTriggered, IExpressionNode expressionPrimary, CSharpParserModel model)
+ private static IExpressionNode BubbleUpParseExpression(int indexTriggered, IExpressionNode expressionPrimary, CSharpCompilationUnit compilationUnit)
{
var triggeredDelimiterTuple = model.ExpressionList[indexTriggered];
IExpressionNode? previousDelimiterExpressionNode = null;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
index a74e98afe..6eb839dd7 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
@@ -14,12 +14,12 @@ public static class ParseTokens
{
public static void ParsePreprocessorDirectiveToken(
PreprocessorDirectiveToken consumedPreprocessorDirectiveToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var consumedToken = model.TokenWalker.Consume();
}
- public static void ParseIdentifierToken(CSharpParserModel model)
+ public static void ParseIdentifierToken(CSharpCompilationUnit compilationUnit)
{
var originalTokenIndex = model.TokenWalker.Index;
@@ -79,7 +79,7 @@ public static void ParseIdentifierToken(CSharpParserModel model)
}
}
- public static void MoveToHandleFunctionDefinition(VariableDeclarationNode variableDeclarationNode, IParserModel model)
+ public static void MoveToHandleFunctionDefinition(VariableDeclarationNode variableDeclarationNode, CSharpCompilationUnit compilationUnit)
{
ParseFunctions.HandleFunctionDefinition(
variableDeclarationNode.IdentifierToken,
@@ -88,7 +88,7 @@ public static void MoveToHandleFunctionDefinition(VariableDeclarationNode variab
(CSharpParserModel)model);
}
- public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode variableDeclarationNode, IParserModel model)
+ public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode variableDeclarationNode, CSharpCompilationUnit compilationUnit)
{
var variableKind = VariableKind.Local;
@@ -121,7 +121,7 @@ public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode
}
}
- public static void MoveToHandleTypeClauseNode(int originalTokenIndex, TypeClauseNode typeClauseNode, IParserModel model)
+ public static void MoveToHandleTypeClauseNode(int originalTokenIndex, TypeClauseNode typeClauseNode, CSharpCompilationUnit compilationUnit)
{
if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.StatementDelimiterToken ||
model.TokenWalker.Current.SyntaxKind == SyntaxKind.EndOfFileToken ||
@@ -152,7 +152,7 @@ public static void MoveToHandleTypeClauseNode(int originalTokenIndex, TypeClause
return;
}
- public static void ParsePropertyDefinition(CSharpParserModel model, IVariableDeclarationNode variableDeclarationNode)
+ public static void ParsePropertyDefinition(CSharpCompilationUnit compilationUnit, IVariableDeclarationNode variableDeclarationNode)
{
#if DEBUG
model.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
@@ -196,7 +196,7 @@ public static void ParsePropertyDefinition(CSharpParserModel model, IVariableDec
#endif
}
- public static void ParsePropertyDefinition_ExpressionBound(CSharpParserModel model)
+ public static void ParsePropertyDefinition_ExpressionBound(CSharpCompilationUnit compilationUnit)
{
var equalsToken = (EqualsToken)model.TokenWalker.Consume();
var closeAngleBracketToken = (CloseAngleBracketToken)model.TokenWalker.Consume();
@@ -205,7 +205,7 @@ public static void ParsePropertyDefinition_ExpressionBound(CSharpParserModel mod
var statementDelimiterToken = (StatementDelimiterToken)model.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
}
- public static void ParseColonToken(CSharpParserModel model)
+ public static void ParseColonToken(CSharpCompilationUnit compilationUnit)
{
var colonToken = (ColonToken)model.TokenWalker.Consume();
@@ -231,7 +231,7 @@ public static void ParseColonToken(CSharpParserModel model)
/// OpenBraceToken is passed in to the method because it is a protected token,
/// and is preferably consumed from the main loop so it can be more easily tracked.
///
- public static void ParseOpenBraceToken(OpenBraceToken openBraceToken, CSharpParserModel model)
+ public static void ParseOpenBraceToken(OpenBraceToken openBraceToken, CSharpCompilationUnit compilationUnit)
{
if (model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner is null)
{
@@ -266,7 +266,7 @@ public static void ParseOpenBraceToken(OpenBraceToken openBraceToken, CSharpPars
/// CloseBraceToken is passed in to the method because it is a protected token,
/// and is preferably consumed from the main loop so it can be more easily tracked.
///
- public static void ParseCloseBraceToken(CloseBraceToken closeBraceToken, CSharpParserModel model)
+ public static void ParseCloseBraceToken(CloseBraceToken closeBraceToken, CSharpCompilationUnit compilationUnit)
{
if (model.CurrentCodeBlockBuilder.ParseChildScopeQueue.TryDequeue(out var deferredChildScope))
{
@@ -280,30 +280,30 @@ public static void ParseCloseBraceToken(CloseBraceToken closeBraceToken, CSharpP
model.Binder.CloseScope(closeBraceToken.TextSpan, model);
}
- public static void ParseOpenParenthesisToken(CSharpParserModel model)
+ public static void ParseOpenParenthesisToken(CSharpCompilationUnit compilationUnit)
{
}
public static void ParseCloseParenthesisToken(
CloseParenthesisToken consumedCloseParenthesisToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var closesParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Consume();
}
public static void ParseOpenAngleBracketToken(
OpenAngleBracketToken consumedOpenAngleBracketToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
public static void ParseCloseAngleBracketToken(
CloseAngleBracketToken consumedCloseAngleBracketToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
- public static void ParseOpenSquareBracketToken(CSharpParserModel model)
+ public static void ParseOpenSquareBracketToken(CSharpCompilationUnit compilationUnit)
{
var openSquareBracketToken = (OpenSquareBracketToken)model.TokenWalker.Consume();
@@ -360,11 +360,11 @@ public static void ParseOpenSquareBracketToken(CSharpParserModel model)
public static void ParseCloseSquareBracketToken(
CloseSquareBracketToken consumedCloseSquareBracketToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
- public static void ParseEqualsToken(CSharpParserModel model)
+ public static void ParseEqualsToken(CSharpCompilationUnit compilationUnit)
{
if (model.StatementBuilder.ChildList.Count == 0)
{
@@ -392,7 +392,7 @@ public static void ParseEqualsToken(CSharpParserModel model)
public static void ParseMemberAccessToken(
MemberAccessToken consumedMemberAccessToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
@@ -400,7 +400,7 @@ public static void ParseMemberAccessToken(
/// StatementDelimiterToken is passed in to the method because it is a protected token,
/// and is preferably consumed from the main loop so it can be more easily tracked.
///
- public static void ParseStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, CSharpParserModel model)
+ public static void ParseStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, CSharpCompilationUnit compilationUnit)
{
if (model.SyntaxStack.TryPeek(out var syntax) && syntax.SyntaxKind == SyntaxKind.NamespaceStatementNode)
{
@@ -443,7 +443,7 @@ public static void ParseStatementDelimiterToken(StatementDelimiterToken statemen
}
}
- public static void ParseKeywordToken(CSharpParserModel model)
+ public static void ParseKeywordToken(CSharpCompilationUnit compilationUnit)
{
// 'return', 'if', 'get', etc...
switch (model.TokenWalker.Current.SyntaxKind)
@@ -688,7 +688,7 @@ public static void ParseKeywordToken(CSharpParserModel model)
}
}
- public static void ParseKeywordContextualToken(CSharpParserModel model)
+ public static void ParseKeywordContextualToken(CSharpCompilationUnit compilationUnit)
{
switch (model.TokenWalker.Current.SyntaxKind)
{
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
index 929b67504..699fc69b4 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
@@ -10,20 +10,20 @@ public static class ParseTypes
{
public static void HandleStaticClassIdentifier(
IdentifierToken consumedIdentifierToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
public static void HandleUndefinedTypeOrNamespaceReference(
IdentifierToken consumedIdentifierToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
///
/// This method is used for generic type definition such as, 'class List<T> { ... }'
///
- public static GenericArgumentsListingNode HandleGenericArguments(CSharpParserModel model)
+ public static GenericArgumentsListingNode HandleGenericArguments(CSharpCompilationUnit compilationUnit)
{
var openAngleBracketToken = (OpenAngleBracketToken)model.TokenWalker.Consume();
@@ -72,7 +72,7 @@ public static GenericArgumentsListingNode HandleGenericArguments(CSharpParserMod
public static void HandleAttribute(
OpenSquareBracketToken consumedOpenSquareBracketToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
@@ -88,12 +88,12 @@ public static void HandleAttribute(
/// Furthermore, because there is a need to disambiguate, more checks are performed in this method
/// than in .
///
- public static bool IsPossibleTypeClause(ISyntaxToken syntaxToken, CSharpParserModel model)
+ public static bool IsPossibleTypeClause(ISyntaxToken syntaxToken, CSharpCompilationUnit compilationUnit)
{
return false;
}
- public static TypeClauseNode MatchTypeClause(CSharpParserModel model)
+ public static TypeClauseNode MatchTypeClause(CSharpCompilationUnit compilationUnit)
{
if (ParseOthers.TryParseExpression(SyntaxKind.TypeClauseNode, model, out var expressionNode))
{
@@ -183,7 +183,7 @@ public static TypeClauseNode MatchTypeClause(CSharpParserModel model)
public static void HandlePrimaryConstructorDefinition(
TypeDefinitionNode typeDefinitionNode,
OpenParenthesisToken consumedOpenParenthesisToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
index eeceb1ce0..d3020a399 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
@@ -12,7 +12,7 @@ public static class ParseVariables
{
public static void HandleVariableReference(
IdentifierToken consumedIdentifierToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
@@ -21,7 +21,7 @@ public static void HandleVariableReference(
TypeClauseNode consumedTypeClauseNode,
IdentifierToken consumedIdentifierToken,
VariableKind variableKind,
- IParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
IVariableDeclarationNode variableDeclarationNode;
@@ -43,7 +43,7 @@ public static void HandleVariableDeclarationStatement(
TypeClauseNode consumedTypeClauseNode,
IdentifierToken consumedIdentifierToken,
VariableKind variableKind,
- IParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var variableDeclarationNode = HandleVariableDeclarationExpression(
consumedTypeClauseNode,
@@ -102,7 +102,7 @@ public static void HandleVariableDeclarationStatement(
public static void HandlePropertyDeclaration(
IVariableDeclarationNode consumedVariableDeclarationNode,
OpenBraceToken consumedOpenBraceToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
@@ -110,14 +110,14 @@ public static void HandlePropertyExpression(
IVariableDeclarationNode consumedVariableDeclarationNode,
EqualsToken consumedEqualsToken,
CloseAngleBracketToken consumedCloseAngleBracketToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
public static void HandleVariableAssignment(
IdentifierToken consumedIdentifierToken,
EqualsToken consumedEqualsToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
index 8472ae980..ecdee05ea 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
@@ -7,7 +7,7 @@ namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
internal static class TokenWalkerExtensionMethods
{
- public static TypeClauseNode MatchTypeClauseNode(this TokenWalker tokenWalker, CSharpParserModel model)
+ public static TypeClauseNode MatchTypeClauseNode(this TokenWalker tokenWalker, CSharpCompilationUnit compilationUnit)
{
return ParseTypes.MatchTypeClause(model);
}
@@ -15,7 +15,7 @@ public static TypeClauseNode MatchTypeClauseNode(this TokenWalker tokenWalker, C
public static void DeferParsingOfChildScope(
this TokenWalker tokenWalker,
OpenBraceToken consumedOpenBraceToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
// Pop off the 'TypeDefinitionNode', then push it back on when later dequeued.
var pendingCodeBlockOwner = model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs
index 4e713d8fd..3d3b4116d 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs
@@ -64,7 +64,7 @@ public static bool IsTypeIdentifierKeywordSyntaxKind(SyntaxKind syntaxKind)
/// AND check if
/// any 'var' identified definitions are in scope.
///
- public static bool IsVarContextualKeyword(CSharpParserModel parserModel, SyntaxKind syntaxKind)
+ public static bool IsVarContextualKeyword(CSharpCompilationUnit compilationUnit, SyntaxKind syntaxKind)
{
if (syntaxKind != SyntaxKind.VarTokenContextualKeyword)
return false;
@@ -187,7 +187,7 @@ public static bool IsConvertibleToTypeClauseNode(SyntaxKind syntaxKind)
IsContextualKeywordSyntaxKind(syntaxKind);
}
- public static TypeClauseNode ConvertToTypeClauseNode(ISyntax syntax, IParserModel model)
+ public static TypeClauseNode ConvertToTypeClauseNode(ISyntax syntax, CSharpCompilationUnit compilationUnit)
{
if (syntax.SyntaxKind == SyntaxKind.TypeClauseNode)
{
@@ -234,7 +234,7 @@ public static bool IsConvertibleToIdentifierToken(SyntaxKind syntaxKind)
IsContextualKeywordSyntaxKind(syntaxKind);
}
- public static IdentifierToken ConvertToIdentifierToken(ISyntax syntax, IParserModel model)
+ public static IdentifierToken ConvertToIdentifierToken(ISyntax syntax, CSharpCompilationUnit compilationUnit)
{
if (syntax.SyntaxKind == SyntaxKind.IdentifierToken)
{
From 70f773702e34c5b830a464b5943b54a6aa8a8a9d Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:03:52 -0500
Subject: [PATCH 13/39] Most arguments are fixed to use CSharpCompilationUnit
---
.../CSharp/BinderCase/CSharpBinder.Main.cs | 52 +++++++++----------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
index 80b121747..370ba64bd 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
@@ -120,7 +120,7 @@ public void FinalizeBinderSession(IBinderSession binderSession)
public LiteralExpressionNode BindLiteralExpressionNode(
LiteralExpressionNode literalExpressionNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
TypeClauseNode typeClauseNode;
@@ -150,7 +150,7 @@ public BinaryOperatorNode BindBinaryOperatorNode(
IExpressionNode leftExpressionNode,
ISyntaxToken operatorToken,
IExpressionNode rightExpressionNode,
- CSharpParserModel parserModel)
+ CSharpCompilationUnit compilationUnit)
{
var problematicTextSpan = (TextEditorTextSpan?)null;
@@ -219,7 +219,7 @@ public BinaryOperatorNode BindBinaryOperatorNode(
/// TODO: Construct a BoundStringInterpolationExpressionNode and identify the expressions within the string literal. For now I am just making the dollar sign the same color as a string literal.
public void BindStringInterpolationExpression(
DollarSignToken dollarSignToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
AddSymbolReference(new StringInterpolationSymbol(dollarSignToken.TextSpan with
{
@@ -229,7 +229,7 @@ public void BindStringInterpolationExpression(
public void BindStringVerbatimExpression(
AtToken atToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
AddSymbolReference(new StringVerbatimSymbol(atToken.TextSpan with
{
@@ -239,7 +239,7 @@ public void BindStringVerbatimExpression(
public void BindFunctionDefinitionNode(
FunctionDefinitionNode functionDefinitionNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var functionIdentifierText = functionDefinitionNode.FunctionIdentifierToken.TextSpan.GetText();
@@ -268,7 +268,7 @@ void IBinder.BindFunctionOptionalArgument(FunctionArgumentEntryNode functionArgu
public void BindFunctionOptionalArgument(
FunctionArgumentEntryNode functionArgumentEntryNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var argumentTypeClauseNode = functionArgumentEntryNode.VariableDeclarationNode.TypeClauseNode;
@@ -332,14 +332,14 @@ public IfStatementNode BindIfStatementNode(
public void SetCurrentNamespaceStatementNode(
NamespaceStatementNode namespaceStatementNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
model.BinderSession.CurrentNamespaceStatementNode = namespaceStatementNode;
}
public void BindNamespaceStatementNode(
NamespaceStatementNode namespaceStatementNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var namespaceString = namespaceStatementNode.IdentifierToken.TextSpan.GetText();
AddSymbolReference(new NamespaceSymbol(namespaceStatementNode.IdentifierToken.TextSpan), model);
@@ -370,7 +370,7 @@ public void BindConstructorInvocationNode()
public InheritanceStatementNode BindInheritanceStatementNode(
TypeClauseNode typeClauseNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
AddSymbolReference(new TypeSymbol(typeClauseNode.TypeIdentifierToken.TextSpan with
{
@@ -389,7 +389,7 @@ void IBinder.BindVariableDeclarationNode(IVariableDeclarationNode variableDeclar
public void BindVariableDeclarationNode(
IVariableDeclarationNode variableDeclarationNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
CreateVariableSymbol(variableDeclarationNode.IdentifierToken, variableDeclarationNode.VariableKind, model);
var text = variableDeclarationNode.IdentifierToken.TextSpan.GetText();
@@ -432,7 +432,7 @@ public void BindVariableDeclarationNode(
public VariableReferenceNode ConstructAndBindVariableReferenceNode(
IdentifierToken variableIdentifierToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var text = variableIdentifierToken.TextSpan.GetText();
VariableReferenceNode? variableReferenceNode;
@@ -475,7 +475,7 @@ public VariableReferenceNode ConstructAndBindVariableReferenceNode(
public void BindVariableAssignmentExpressionNode(
VariableAssignmentExpressionNode variableAssignmentExpressionNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var text = variableAssignmentExpressionNode.VariableIdentifierToken.TextSpan.GetText();
VariableKind variableKind = VariableKind.Local;
@@ -515,7 +515,7 @@ public void BindVariableAssignmentExpressionNode(
public void BindConstructorDefinitionIdentifierToken(
IdentifierToken identifierToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var constructorSymbol = new ConstructorSymbol(identifierToken.TextSpan with
{
@@ -527,7 +527,7 @@ public void BindConstructorDefinitionIdentifierToken(
public void BindFunctionInvocationNode(
FunctionInvocationNode functionInvocationNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var functionInvocationIdentifierText = functionInvocationNode
.FunctionInvocationIdentifierToken.TextSpan.GetText();
@@ -559,7 +559,7 @@ public void BindFunctionInvocationNode(
public void BindNamespaceReference(
IdentifierToken namespaceIdentifierToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var namespaceSymbol = new NamespaceSymbol(namespaceIdentifierToken.TextSpan with
{
@@ -571,7 +571,7 @@ public void BindNamespaceReference(
public void BindTypeClauseNode(
TypeClauseNode typeClauseNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
if (!typeClauseNode.IsKeywordType)
{
@@ -594,7 +594,7 @@ public void BindTypeClauseNode(
public void BindTypeIdentifier(
IdentifierToken identifierToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
if (identifierToken.SyntaxKind == SyntaxKind.IdentifierToken)
{
@@ -609,7 +609,7 @@ public void BindTypeIdentifier(
public void BindUsingStatementNode(
UsingStatementNode usingStatementNode,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
AddSymbolReference(new NamespaceSymbol(usingStatementNode.NamespaceIdentifier.TextSpan), model);
@@ -622,7 +622,7 @@ public AttributeNode BindAttributeNode(
OpenSquareBracketToken openSquareBracketToken,
List innerTokens,
CloseSquareBracketToken closeSquareBracketToken,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
AddSymbolReference(new TypeSymbol(openSquareBracketToken.TextSpan with
{
@@ -640,7 +640,7 @@ public void OpenScope(
ICodeBlockOwner codeBlockOwner,
TypeClauseNode? scopeReturnTypeClauseNode,
TextEditorTextSpan textSpan,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var scope = new Scope(
codeBlockOwner,
@@ -658,7 +658,7 @@ void IBinder.AddNamespaceToCurrentScope(string namespaceString, IParserModel mod
public void AddNamespaceToCurrentScope(
string namespaceString,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
if (_namespaceGroupNodeMap.TryGetValue(namespaceString, out var namespaceGroupNode) &&
namespaceGroupNode is not null)
@@ -679,7 +679,7 @@ public void AddNamespaceToCurrentScope(
public void CloseScope(
TextEditorTextSpan textSpan,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
// Check if it is the global scope, if so return early.
{
@@ -734,7 +734,7 @@ public void CloseScope(
public void BindTypeDefinitionNode(
TypeDefinitionNode typeDefinitionNode,
- CSharpParserModel model,
+ CSharpCompilationUnit compilationUnit,
bool shouldOverwrite = false)
{
var typeIdentifierText = typeDefinitionNode.TypeIdentifierToken.TextSpan.GetText();
@@ -783,7 +783,7 @@ public void BindTypeDefinitionNode(
/// This method will handle the , but also invoke because each definition is being treated as a reference itself.
private void AddSymbolDefinition(
ISymbol symbol,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
var symbolDefinitionId = ISymbol.GetSymbolDefinitionId(
symbol.TextSpan.GetText(),
@@ -812,7 +812,7 @@ private void AddSymbolDefinition(
AddSymbolReference(symbol, model);
}
- private void AddSymbolReference(ISymbol symbol, CSharpParserModel model)
+ private void AddSymbolReference(ISymbol symbol, CSharpCompilationUnit compilationUnit)
{
var symbolDefinitionId = ISymbol.GetSymbolDefinitionId(
symbol.TextSpan.GetText(),
@@ -846,7 +846,7 @@ private void AddSymbolReference(ISymbol symbol, CSharpParserModel model)
public void CreateVariableSymbol(
IdentifierToken identifierToken,
VariableKind variableKind,
- CSharpParserModel model)
+ CSharpCompilationUnit compilationUnit)
{
switch (variableKind)
{
From f647ddfb42770032d406cddbbe3806a43e7a56dc Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:07:42 -0500
Subject: [PATCH 14/39] DOES NOT BUILD: Fixing usages of model. to be
'compilationUnit.ParserModel'
---
.../Internals/ParseContextualKeywords.cs | 96 +++++++++----------
1 file changed, 48 insertions(+), 48 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
index 7025dac64..6b9a8bc9a 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
@@ -10,7 +10,7 @@ public class ParseContextualKeywords
{
public static void HandleVarTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- if (model.StatementBuilder.ChildList.Count == 0)
+ if (compilationUnit.ParserModel.StatementBuilder.ChildList.Count == 0)
ParseTokens.ParseIdentifierToken(model);
else
ParseOthers.StartStatement_Expression(model);
@@ -18,152 +18,152 @@ public static void HandleVarTokenContextualKeyword(CSharpCompilationUnit compila
public static void HandlePartialTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleAddTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleAndTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleAliasTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleAscendingTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleArgsTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleAsyncTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleAwaitTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleByTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleDescendingTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleDynamicTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleEqualsTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleFileTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleFromTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleGetTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleGlobalTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleGroupTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleInitTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleIntoTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleJoinTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleLetTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleManagedTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleNameofTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleNintTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleNotTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleNotnullTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleNuintTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleOnTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleOrTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleOrderbyTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleRecordTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
@@ -173,75 +173,75 @@ public static void HandleRecordTokenContextualKeyword(CSharpCompilationUnit comp
public static void HandleRemoveTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleRequiredTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleScopedTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleSelectTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleSetTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleUnmanagedTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleValueTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleWhenTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleWhereTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- var whereTokenContextualKeyword = (KeywordContextualToken)model.TokenWalker.Consume();
+ var whereTokenContextualKeyword = (KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume();
- if (model.SyntaxStack.TryPeek(out var syntax) && syntax.SyntaxKind != SyntaxKind.TypeDefinitionNode)
+ if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out var syntax) && syntax.SyntaxKind != SyntaxKind.TypeDefinitionNode)
return;
- while (!model.TokenWalker.IsEof)
+ while (!compilationUnit.ParserModel.TokenWalker.IsEof)
{
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
- model.TokenWalker.Current.SyntaxKind == SyntaxKind.StatementDelimiterToken)
+ if (compilationUnit.ParserModel.ParserModeldel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
+ compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.StatementDelimiterToken)
{
break;
}
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
}
}
public static void HandleWithTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleYieldTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleUnrecognizedTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordContextualToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
}
From 729dab15735aadfb532d5c61a960f9a2a5eb86f9 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:17:20 -0500
Subject: [PATCH 15/39] DOES NOT BUILD: Replacing model. with
'compilationUnit.ParserModel.'
---
.../Internals/ParseDefaultKeywords.cs | 318 +++++++++---------
.../ParserCase/Internals/ParseFunctions.cs | 78 ++---
.../ParserCase/Internals/ParseOthers.cs | 106 +++---
3 files changed, 251 insertions(+), 251 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
index 32edaaefc..37b17d483 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
@@ -12,12 +12,12 @@ public class ParseDefaultKeywords
{
public static void HandleAsTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleBaseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleBoolTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -27,7 +27,7 @@ public static void HandleBoolTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleBreakTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleByteTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -37,32 +37,32 @@ public static void HandleByteTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleCaseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.ExpressionList.Add((SyntaxKind.ColonToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.ColonToken, null));
var expressionNode = ParseOthers.ParseExpression(model);
- var colonToken = (ColonToken)model.TokenWalker.Match(SyntaxKind.ColonToken);
+ var colonToken = (ColonToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.ColonToken);
}
public static void HandleCatchTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var catchKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var catchKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var openParenthesisToken = (OpenParenthesisToken)model.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
+ var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
- var typeClause = model.TokenWalker.MatchTypeClauseNode(model);
+ var typeClause = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(model);
- if (model.TokenWalker.Current.SyntaxKind != SyntaxKind.CloseParenthesisToken)
- _ = (IdentifierToken)model.TokenWalker.Match(SyntaxKind.IdentifierToken);
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind != SyntaxKind.CloseParenthesisToken)
+ _ = (IdentifierToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
- var closeParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
+ var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
TryStatementNode? tryStatementNode = null;
- if (model.SyntaxStack.TryPeek(out var syntax) &&
+ if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out var syntax) &&
syntax is TryStatementNode temporaryTryStatementNodeOne)
{
tryStatementNode = temporaryTryStatementNodeOne;
}
- else if (model.SyntaxStack.TryPeek(out syntax) &&
+ else if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out syntax) &&
syntax is TryStatementTryNode tryNode)
{
if (tryNode.Parent is TryStatementNode temporaryTryStatementNodeTwo)
@@ -81,8 +81,8 @@ public static void HandleCatchTokenKeyword(CSharpCompilationUnit compilationUnit
codeBlockNode: null);
tryStatementNode.SetTryStatementCatchNode(catchNode);
- model.SyntaxStack.Push(catchNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = catchNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(catchNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = catchNode;
}
}
@@ -93,17 +93,17 @@ public static void HandleCharTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleCheckedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleConstTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleContinueTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleDecimalTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -114,10 +114,10 @@ public static void HandleDecimalTokenKeyword(CSharpCompilationUnit compilationUn
public static void HandleDefaultTokenKeyword(CSharpCompilationUnit compilationUnit)
{
// Switch statement default case.
- if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.ColonToken)
- _ = model.TokenWalker.Consume();
+ if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.ColonToken)
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
else
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleDelegateTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -127,7 +127,7 @@ public static void HandleDelegateTokenKeyword(CSharpCompilationUnit compilationU
public static void HandleDoTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var doKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var doKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
var doWhileStatementNode = new DoWhileStatementNode(
doKeywordToken,
@@ -139,9 +139,9 @@ public static void HandleDoTokenKeyword(CSharpCompilationUnit compilationUnit)
closeParenthesisToken: default);
// Have to push twice so it is on the stack when the 'while' keyword is parsed.
- model.SyntaxStack.Push(doWhileStatementNode);
- model.SyntaxStack.Push(doWhileStatementNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = doWhileStatementNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(doWhileStatementNode);
+ compilationUnit.ParserModel.SyntaxStack.Push(doWhileStatementNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = doWhileStatementNode;
}
public static void HandleDoubleTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -151,7 +151,7 @@ public static void HandleDoubleTokenKeyword(CSharpCompilationUnit compilationUni
public static void HandleElseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleEnumTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -170,32 +170,32 @@ public static void HandleEventTokenKeyword(CSharpCompilationUnit compilationUnit
public static void HandleExplicitTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleExternTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleFalseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var expressionNode = ParseOthers.ParseExpression(model);
- model.StatementBuilder.ChildList.Add(expressionNode);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
}
public static void HandleFinallyTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var finallyKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var finallyKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
TryStatementNode? tryStatementNode = null;
- if (model.SyntaxStack.TryPeek(out var syntax) &&
+ if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out var syntax) &&
syntax is TryStatementNode temporaryTryStatementNodeOne)
{
tryStatementNode = temporaryTryStatementNodeOne;
}
- else if (model.SyntaxStack.TryPeek(out syntax) &&
+ else if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out syntax) &&
syntax is TryStatementTryNode tryNode)
{
if (tryNode.Parent is TryStatementNode temporaryTryStatementNodeTwo)
@@ -203,7 +203,7 @@ public static void HandleFinallyTokenKeyword(CSharpCompilationUnit compilationUn
tryStatementNode = temporaryTryStatementNodeTwo;
}
}
- else if (model.SyntaxStack.TryPeek(out syntax) &&
+ else if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out syntax) &&
syntax is TryStatementCatchNode catchNode)
{
if (catchNode.Parent is TryStatementNode temporaryTryStatementNodeThree)
@@ -220,14 +220,14 @@ public static void HandleFinallyTokenKeyword(CSharpCompilationUnit compilationUn
codeBlockNode: null);
tryStatementNode.SetTryStatementFinallyNode(finallyNode);
- model.SyntaxStack.Push(finallyNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = finallyNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(finallyNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = finallyNode;
}
}
public static void HandleFixedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleFloatTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -237,32 +237,32 @@ public static void HandleFloatTokenKeyword(CSharpCompilationUnit compilationUnit
public static void HandleForTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var forKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var forKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var openParenthesisToken = (OpenParenthesisToken)model.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
+ var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
// Initialization Case One
// ;
var initializationExpressionNode = (IExpressionNode)new EmptyExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
- var initializationStatementDelimiterToken = (StatementDelimiterToken)model.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
+ var initializationStatementDelimiterToken = (StatementDelimiterToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
var badStateInitialization = false;
if (initializationStatementDelimiterToken.IsFabricated)
{
// Initialization Case Two
// i = 0;
- var identifierToken = (IdentifierToken)model.TokenWalker.Match(SyntaxKind.IdentifierToken);
+ var identifierToken = (IdentifierToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
if (identifierToken.IsFabricated)
{
// Initialization Case Three
// int i = 0;
- var typeClauseNode = model.TokenWalker.MatchTypeClauseNode(model);
+ var typeClauseNode = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(model);
var isCaseThree = !typeClauseNode.IsFabricated;
if (isCaseThree)
{
- identifierToken = (IdentifierToken)model.TokenWalker.Match(SyntaxKind.IdentifierToken);
+ identifierToken = (IdentifierToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
}
else
{
@@ -276,51 +276,51 @@ public static void HandleForTokenKeyword(CSharpCompilationUnit compilationUnit)
{
// Read the remainder
// = 0;
- var equalsToken = (EqualsToken)model.TokenWalker.Match(SyntaxKind.EqualsToken);
+ var equalsToken = (EqualsToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.EqualsToken);
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
initializationExpressionNode = ParseOthers.ParseExpression(model);
- initializationStatementDelimiterToken = (StatementDelimiterToken)model.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
+ initializationStatementDelimiterToken = (StatementDelimiterToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
}
}
// Condition Case One
// ;
var conditionExpressionNode = (IExpressionNode)new EmptyExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
- var conditionStatementDelimiterToken = (StatementDelimiterToken)model.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
+ var conditionStatementDelimiterToken = (StatementDelimiterToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
if (conditionStatementDelimiterToken.IsFabricated)
{
// Condition Case Two
// i < 10;
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
conditionExpressionNode = ParseOthers.ParseExpression(model);
- conditionStatementDelimiterToken = (StatementDelimiterToken)model.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
+ conditionStatementDelimiterToken = (StatementDelimiterToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
}
// Updation Case One
// )
var updationExpressionNode = (IExpressionNode)new EmptyExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
- var closeParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
+ var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
if (closeParenthesisToken.IsFabricated)
{
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
updationExpressionNode = ParseOthers.ParseExpression(model);
- closeParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
+ closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
if (closeParenthesisToken.IsFabricated)
{
- while (!model.TokenWalker.IsEof)
+ while (!compilationUnit.ParserModel.TokenWalker.IsEof)
{
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseParenthesisToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseParenthesisToken)
break;
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
}
}
}
@@ -336,18 +336,18 @@ public static void HandleForTokenKeyword(CSharpCompilationUnit compilationUnit)
closeParenthesisToken,
codeBlockNode: null);
- model.SyntaxStack.Push(forStatementNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = forStatementNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(forStatementNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = forStatementNode;
}
public static void HandleForeachTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var foreachKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var foreachKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var openParenthesisToken = (OpenParenthesisToken)model.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
+ var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
- var typeClauseNode = model.TokenWalker.MatchTypeClauseNode(model);
- var variableIdentifierToken = (IdentifierToken)model.TokenWalker.Match(SyntaxKind.IdentifierToken);
+ var typeClauseNode = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(model);
+ var variableIdentifierToken = (IdentifierToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
var variableDeclarationStatementNode = new VariableDeclarationNode(
typeClauseNode,
@@ -355,11 +355,11 @@ public static void HandleForeachTokenKeyword(CSharpCompilationUnit compilationUn
VariableKind.Local,
false);
- var inKeywordToken = (KeywordToken)model.TokenWalker.Match(SyntaxKind.InTokenKeyword);
+ var inKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.InTokenKeyword);
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
var expressionNode = ParseOthers.ParseExpression(model);
- var closeParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
+ var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
var foreachStatementNode = new ForeachStatementNode(
foreachKeywordToken,
@@ -370,23 +370,23 @@ public static void HandleForeachTokenKeyword(CSharpCompilationUnit compilationUn
closeParenthesisToken,
codeBlockNode: null);
- model.SyntaxStack.Push(foreachStatementNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = foreachStatementNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(foreachStatementNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = foreachStatementNode;
}
public static void HandleGotoTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleImplicitTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleInTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleIntTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -396,19 +396,19 @@ public static void HandleIntTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleIsTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleLockTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var lockKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var lockKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var openParenthesisToken = (OpenParenthesisToken)model.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
+ var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
var expressionNode = ParseOthers.ParseExpression(model);
- var closeParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
+ var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
var lockStatementNode = new LockStatementNode(
lockKeywordToken,
@@ -417,8 +417,8 @@ public static void HandleLockTokenKeyword(CSharpCompilationUnit compilationUnit)
closeParenthesisToken,
codeBlockNode: null);
- model.SyntaxStack.Push(lockStatementNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = lockStatementNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(lockStatementNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = lockStatementNode;
}
public static void HandleLongTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -438,33 +438,33 @@ public static void HandleObjectTokenKeyword(CSharpCompilationUnit compilationUni
public static void HandleOperatorTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleOutTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleParamsTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleProtectedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var protectedTokenKeyword = (KeywordToken)model.TokenWalker.Consume();
- model.StatementBuilder.ChildList.Add(protectedTokenKeyword);
+ var protectedTokenKeyword = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(protectedTokenKeyword);
}
public static void HandleReadonlyTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleRefTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleSbyteTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -479,12 +479,12 @@ public static void HandleShortTokenKeyword(CSharpCompilationUnit compilationUnit
public static void HandleSizeofTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleStackallocTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleStringTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -499,14 +499,14 @@ public static void HandleStructTokenKeyword(CSharpCompilationUnit compilationUni
public static void HandleSwitchTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var switchKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var switchKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var openParenthesisToken = (OpenParenthesisToken)model.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
+ var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
var expressionNode = ParseOthers.ParseExpression(model);
- var closeParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
+ var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
var switchStatementNode = new SwitchStatementNode(
switchKeywordToken,
@@ -515,29 +515,29 @@ public static void HandleSwitchTokenKeyword(CSharpCompilationUnit compilationUni
closeParenthesisToken,
codeBlockNode: null);
- model.SyntaxStack.Push(switchStatementNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = switchStatementNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(switchStatementNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = switchStatementNode;
}
public static void HandleThisTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleThrowTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleTrueTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var expressionNode = ParseOthers.ParseExpression(model);
- model.StatementBuilder.ChildList.Add(expressionNode);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
}
public static void HandleTryTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var tryKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var tryKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
var tryStatementNode = new TryStatementNode(
tryNode: null,
@@ -551,17 +551,17 @@ public static void HandleTryTokenKeyword(CSharpCompilationUnit compilationUnit)
tryStatementNode.SetTryStatementTryNode(tryStatementTryNode);
- model.CurrentCodeBlockBuilder.ChildList.Add(tryStatementNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(tryStatementNode);
- model.SyntaxStack.Push(tryStatementNode);
+ compilationUnit.ParserModel.SyntaxStack.Push(tryStatementNode);
- model.SyntaxStack.Push(tryStatementTryNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = tryStatementTryNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(tryStatementTryNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = tryStatementTryNode;
}
public static void HandleTypeofTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleUintTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -576,12 +576,12 @@ public static void HandleUlongTokenKeyword(CSharpCompilationUnit compilationUnit
public static void HandleUncheckedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleUnsafeTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleUshortTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -596,21 +596,21 @@ public static void HandleVoidTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleVolatileTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleWhileTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var whileKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var whileKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var openParenthesisToken = (OpenParenthesisToken)model.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
+ var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
var expressionNode = ParseOthers.ParseExpression(model);
- var closeParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
+ var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
- if (model.SyntaxStack.TryPeek(out var syntax) &&
+ if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out var syntax) &&
syntax is DoWhileStatementNode doWhileStatementNode)
{
doWhileStatementNode.SetWhileProperties(
@@ -628,14 +628,14 @@ public static void HandleWhileTokenKeyword(CSharpCompilationUnit compilationUnit
closeParenthesisToken,
codeBlockNode: null);
- model.SyntaxStack.Push(whileStatementNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = whileStatementNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(whileStatementNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = whileStatementNode;
}
}
public static void HandleUnrecognizedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
/// The 'Default' of this method name is confusing.
@@ -643,7 +643,7 @@ public static void HandleUnrecognizedTokenKeyword(CSharpCompilationUnit compilat
///
public static void HandleDefault(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleTypeIdentifierKeyword(CSharpCompilationUnit compilationUnit)
@@ -653,87 +653,87 @@ public static void HandleTypeIdentifierKeyword(CSharpCompilationUnit compilation
public static void HandleNewTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenParenthesisToken ||
- UtilityApi.IsConvertibleToIdentifierToken(model.TokenWalker.Next.SyntaxKind))
+ if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenParenthesisToken ||
+ UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind))
{
var expressionNode = ParseOthers.ParseExpression(model);
- model.StatementBuilder.ChildList.Add(expressionNode);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
}
else
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
}
public static void HandlePublicTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var publicKeywordToken = (KeywordToken)model.TokenWalker.Consume();
- model.StatementBuilder.ChildList.Add(publicKeywordToken);
+ var publicKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(publicKeywordToken);
}
public static void HandleInternalTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var internalTokenKeyword = (KeywordToken)model.TokenWalker.Consume();
- model.StatementBuilder.ChildList.Add(internalTokenKeyword);
+ var internalTokenKeyword = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(internalTokenKeyword);
}
public static void HandlePrivateTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var privateTokenKeyword = (KeywordToken)model.TokenWalker.Consume();
- model.StatementBuilder.ChildList.Add(privateTokenKeyword);
+ var privateTokenKeyword = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(privateTokenKeyword);
}
public static void HandleStaticTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleOverrideTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleVirtualTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleAbstractTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleSealedTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleIfTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var ifTokenKeyword = (KeywordToken)model.TokenWalker.Consume();
+ var ifTokenKeyword = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var openParenthesisToken = model.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
+ var openParenthesisToken = compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
if (openParenthesisToken.IsFabricated)
return;
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
var expression = ParseOthers.ParseExpression(model);
- var boundIfStatementNode = model.Binder.BindIfStatementNode(ifTokenKeyword, expression);
- model.SyntaxStack.Push(boundIfStatementNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = boundIfStatementNode;
+ var boundIfStatementNode = compilationUnit.ParserModel.Binder.BindIfStatementNode(ifTokenKeyword, expression);
+ compilationUnit.ParserModel.SyntaxStack.Push(boundIfStatementNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = boundIfStatementNode;
}
public static void HandleUsingTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var usingKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var usingKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
var handleNamespaceIdentifierResult = ParseOthers.HandleNamespaceIdentifier(model);
if (handleNamespaceIdentifierResult.SyntaxKind == SyntaxKind.EmptyNode)
{
- model.DiagnosticBag.ReportTodoException(usingKeywordToken.TextSpan, "Expected a namespace identifier.");
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(usingKeywordToken.TextSpan, "Expected a namespace identifier.");
return;
}
@@ -743,8 +743,8 @@ public static void HandleUsingTokenKeyword(CSharpCompilationUnit compilationUnit
usingKeywordToken,
namespaceIdentifier);
- model.Binder.BindUsingStatementNode(usingStatementNode, model);
- model.StatementBuilder.ChildList.Add(usingStatementNode);
+ compilationUnit.ParserModel.Binder.BindUsingStatementNode(usingStatementNode, model);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(usingStatementNode);
}
public static void HandleInterfaceTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -765,16 +765,16 @@ public static void HandleInterfaceTokenKeyword(CSharpCompilationUnit compilation
///
public static void HandleStorageModifierTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var storageModifierToken = model.TokenWalker.Consume();
+ var storageModifierToken = compilationUnit.ParserModel.TokenWalker.Consume();
// Given: public partial class MyClass { }
// Then: partial
var hasPartialModifier = false;
- if (model.StatementBuilder.TryPeek(out var syntax) && syntax is ISyntaxToken syntaxToken)
+ if (compilationUnit.ParserModel.StatementBuilder.TryPeek(out var syntax) && syntax is ISyntaxToken syntaxToken)
{
if (syntaxToken.SyntaxKind == SyntaxKind.PartialTokenContextualKeyword)
{
- _ = model.StatementBuilder.Pop();
+ _ = compilationUnit.ParserModel.StatementBuilder.Pop();
hasPartialModifier = true;
}
}
@@ -784,24 +784,24 @@ public static void HandleStorageModifierTokenKeyword(CSharpCompilationUnit compi
// Given: public class MyClass { }
// Then: public
var accessModifierKind = AccessModifierKind.Public;
- if (model.StatementBuilder.TryPeek(out syntax) && syntax is ISyntaxToken firstSyntaxToken)
+ if (compilationUnit.ParserModel.StatementBuilder.TryPeek(out syntax) && syntax is ISyntaxToken firstSyntaxToken)
{
var firstOutput = UtilityApi.GetAccessModifierKindFromToken(firstSyntaxToken);
if (firstOutput is not null)
{
- _ = model.StatementBuilder.Pop();
+ _ = compilationUnit.ParserModel.StatementBuilder.Pop();
accessModifierKind = firstOutput.Value;
// Given: protected internal class MyClass { }
// Then: protected internal
- if (model.StatementBuilder.TryPeek(out syntax) && syntax is ISyntaxToken secondSyntaxToken)
+ if (compilationUnit.ParserModel.StatementBuilder.TryPeek(out syntax) && syntax is ISyntaxToken secondSyntaxToken)
{
var secondOutput = UtilityApi.GetAccessModifierKindFromToken(secondSyntaxToken);
if (secondOutput is not null)
{
- _ = model.StatementBuilder.Pop();
+ _ = compilationUnit.ParserModel.StatementBuilder.Pop();
if ((firstOutput.Value.ToString().ToLower() == "protected" &&
secondOutput.Value.ToString().ToLower() == "internal") ||
@@ -828,9 +828,9 @@ public static void HandleStorageModifierTokenKeyword(CSharpCompilationUnit compi
if (storageModifierKind is null)
return;
if (storageModifierKind == StorageModifierKind.Record &&
- model.TokenWalker.Current.SyntaxKind == SyntaxKind.StructTokenKeyword)
+ compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.StructTokenKeyword)
{
- var structKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var structKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
storageModifierKind = StorageModifierKind.RecordStruct;
}
@@ -839,21 +839,21 @@ public static void HandleStorageModifierTokenKeyword(CSharpCompilationUnit compi
IdentifierToken identifierToken;
// Retrospective: What is the purpose of this 'if (contextualKeyword) logic'?
// Response: maybe it is because 'var' contextual keyword is allowed to be a class name?
- if (UtilityApi.IsContextualKeywordSyntaxKind(model.TokenWalker.Current.SyntaxKind))
+ if (UtilityApi.IsContextualKeywordSyntaxKind(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind))
{
- var contextualKeywordToken = (KeywordContextualToken)model.TokenWalker.Consume();
+ var contextualKeywordToken = (KeywordContextualToken)compilationUnit.ParserModel.TokenWalker.Consume();
// Take the contextual keyword as an identifier
identifierToken = new IdentifierToken(contextualKeywordToken.TextSpan);
}
else
{
- identifierToken = (IdentifierToken)model.TokenWalker.Match(SyntaxKind.IdentifierToken);
+ identifierToken = (IdentifierToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
}
// Given: public class MyClass { }
// Then:
GenericArgumentsListingNode? genericArgumentsListingNode = null;
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
genericArgumentsListingNode = ParseTypes.HandleGenericArguments(model);
var typeDefinitionNode = new TypeDefinitionNode(
@@ -868,10 +868,10 @@ public static void HandleStorageModifierTokenKeyword(CSharpCompilationUnit compi
openBraceToken: default,
codeBlockNode: null);
- model.Binder.BindTypeDefinitionNode(typeDefinitionNode, model);
- model.Binder.BindTypeIdentifier(identifierToken, model);
- model.SyntaxStack.Push(typeDefinitionNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = typeDefinitionNode;
+ compilationUnit.ParserModel.Binder.BindTypeDefinitionNode(typeDefinitionNode, model);
+ compilationUnit.ParserModel.Binder.BindTypeIdentifier(identifierToken, model);
+ compilationUnit.ParserModel.SyntaxStack.Push(typeDefinitionNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = typeDefinitionNode;
}
public static void HandleClassTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -881,13 +881,13 @@ public static void HandleClassTokenKeyword(CSharpCompilationUnit compilationUnit
public static void HandleNamespaceTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var namespaceKeywordToken = (KeywordToken)model.TokenWalker.Consume();
+ var namespaceKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
var handleNamespaceIdentifierResult = ParseOthers.HandleNamespaceIdentifier(model);
if (handleNamespaceIdentifierResult.SyntaxKind == SyntaxKind.EmptyNode)
{
- model.DiagnosticBag.ReportTodoException(namespaceKeywordToken.TextSpan, "Expected a namespace identifier.");
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(namespaceKeywordToken.TextSpan, "Expected a namespace identifier.");
return;
}
@@ -898,14 +898,14 @@ public static void HandleNamespaceTokenKeyword(CSharpCompilationUnit compilation
namespaceIdentifier,
null);
- model.Binder.SetCurrentNamespaceStatementNode(namespaceStatementNode, model);
+ compilationUnit.ParserModel.Binder.SetCurrentNamespaceStatementNode(namespaceStatementNode, model);
- model.SyntaxStack.Push(namespaceStatementNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = namespaceStatementNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(namespaceStatementNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = namespaceStatementNode;
}
public static void HandleReturnTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
index a6691c6ad..6a150b549 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
@@ -15,7 +15,7 @@ public static void HandleFunctionDefinition(
GenericParametersListingNode? consumedGenericArgumentsListingNode,
CSharpCompilationUnit compilationUnit)
{
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
{
var successGenericParametersListingNode = ParseOthers.TryParseExpression(
SyntaxKind.GenericParametersListingNode,
@@ -26,7 +26,7 @@ public static void HandleFunctionDefinition(
consumedGenericArgumentsListingNode = (GenericParametersListingNode)genericParametersListingNode;
}
- if (model.TokenWalker.Current.SyntaxKind != SyntaxKind.OpenParenthesisToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind != SyntaxKind.OpenParenthesisToken)
return;
var functionArgumentsListingNode = HandleFunctionArguments(model);
@@ -40,22 +40,22 @@ public static void HandleFunctionDefinition(
null,
null);
- model.Binder.BindFunctionDefinitionNode(functionDefinitionNode, model);
- model.SyntaxStack.Push(functionDefinitionNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = functionDefinitionNode;
+ compilationUnit.ParserModel.Binder.BindFunctionDefinitionNode(functionDefinitionNode, model);
+ compilationUnit.ParserModel.SyntaxStack.Push(functionDefinitionNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = functionDefinitionNode;
- if (model.CurrentCodeBlockBuilder.CodeBlockOwner is TypeDefinitionNode typeDefinitionNode &&
+ if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner is TypeDefinitionNode typeDefinitionNode &&
typeDefinitionNode.IsInterface)
{
// TODO: Would method constraints break this code? "public T Aaa() where T : OtherClass"
- var statementDelimiterToken = model.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
+ var statementDelimiterToken = compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
foreach (var argument in functionDefinitionNode.FunctionArgumentsListingNode.FunctionArgumentEntryNodeList)
{
if (argument.IsOptional)
- model.Binder.BindFunctionOptionalArgument(argument, model);
+ compilationUnit.ParserModel.Binder.BindFunctionOptionalArgument(argument, model);
else
- model.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, model);
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, model);
}
}
}
@@ -80,37 +80,37 @@ public static void HandleConstructorDefinition(
null,
null);
- model.Binder.BindConstructorDefinitionIdentifierToken(consumedIdentifierToken, model);
- model.SyntaxStack.Push(constructorDefinitionNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = constructorDefinitionNode;
+ compilationUnit.ParserModel.Binder.BindConstructorDefinitionIdentifierToken(consumedIdentifierToken, model);
+ compilationUnit.ParserModel.SyntaxStack.Push(constructorDefinitionNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = constructorDefinitionNode;
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.ColonToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.ColonToken)
{
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
// Constructor invokes some other constructor as well
// 'this(...)' or 'base(...)'
KeywordToken keywordToken;
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.ThisTokenKeyword)
- keywordToken = (KeywordToken)model.TokenWalker.Match(SyntaxKind.ThisTokenKeyword);
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.BaseTokenKeyword)
- keywordToken = (KeywordToken)model.TokenWalker.Match(SyntaxKind.BaseTokenKeyword);
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.ThisTokenKeyword)
+ keywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.ThisTokenKeyword);
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.BaseTokenKeyword)
+ keywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.BaseTokenKeyword);
else
keywordToken = default;
- while (!model.TokenWalker.IsEof)
+ while (!compilationUnit.ParserModel.TokenWalker.IsEof)
{
// TODO: This won't work because an OpenBraceToken can appear inside the "other constructor invocation"...
// ...If one were to skip over this syntax for the time being, it should be done by counting the
// matched OpenParenthesisToken and CloseParenthesisToken until it evens out.
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
- model.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
+ compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken)
{
break;
}
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
}
}
}
@@ -118,18 +118,18 @@ public static void HandleConstructorDefinition(
/// Use this method for function definition, whereas should be used for function invocation.
public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpCompilationUnit compilationUnit)
{
- var openParenthesisToken = (OpenParenthesisToken)model.TokenWalker.Consume();
+ var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Consume();
var functionArgumentEntryNodeList = new List();
var openParenthesisCount = 1;
var corruptState = false;
- while (!model.TokenWalker.IsEof)
+ while (!compilationUnit.ParserModel.TokenWalker.IsEof)
{
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenParenthesisToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenParenthesisToken)
{
openParenthesisCount++;
}
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseParenthesisToken)
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseParenthesisToken)
{
openParenthesisCount--;
@@ -138,18 +138,18 @@ public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpCompila
break;
}
}
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
{
break;
}
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken &&
- model.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken &&
+ compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
break;
}
else if (!corruptState)
{
- var tokenIndexOriginal = model.TokenWalker.Index;
+ var tokenIndexOriginal = compilationUnit.ParserModel.TokenWalker.Index;
var successTypeClauseNode = ParseOthers.TryParseExpression(SyntaxKind.TypeClauseNode, model, out var typeClauseNode);
var successName = false;
@@ -158,12 +158,12 @@ public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpCompila
// 'TypeClauseNode' or 'VariableDeclarationNode'
var successNameableToken = false;
- if (UtilityApi.IsConvertibleToIdentifierToken(model.TokenWalker.Current.SyntaxKind))
+ if (UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind))
{
- var identifierToken = UtilityApi.ConvertToIdentifierToken(model.TokenWalker.Consume(), model);
+ var identifierToken = UtilityApi.ConvertToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Consume(), model);
successNameableToken = true;
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken)
{
// Optional
}
@@ -185,10 +185,10 @@ public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpCompila
functionArgumentEntryNodeList.Add(functionArgumentEntryNode);
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken)
- _ = model.TokenWalker.Consume();
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken)
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
- if (tokenIndexOriginal < model.TokenWalker.Index)
+ if (tokenIndexOriginal < compilationUnit.ParserModel.TokenWalker.Index)
continue; // Already consumed so avoid the one at the end of the while loop
}
@@ -201,13 +201,13 @@ public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpCompila
}
}
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
}
var closeParenthesisToken = default(CloseParenthesisToken);
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseParenthesisToken)
- closeParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Consume();
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseParenthesisToken)
+ closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Consume();
return new FunctionArgumentsListingNode(
openParenthesisToken,
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
index 68879e218..1ee91a04a 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
@@ -19,11 +19,11 @@ public static ISyntax HandleNamespaceIdentifier(CSharpCompilationUnit compilatio
{
var combineNamespaceIdentifierIntoOne = new List();
- while (!model.TokenWalker.IsEof)
+ while (!compilationUnit.ParserModel.TokenWalker.IsEof)
{
if (combineNamespaceIdentifierIntoOne.Count % 2 == 0)
{
- var matchedToken = model.TokenWalker.Match(SyntaxKind.IdentifierToken);
+ var matchedToken = compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
combineNamespaceIdentifierIntoOne.Add(matchedToken);
if (matchedToken.IsFabricated)
@@ -31,8 +31,8 @@ public static ISyntax HandleNamespaceIdentifier(CSharpCompilationUnit compilatio
}
else
{
- if (SyntaxKind.MemberAccessToken == model.TokenWalker.Current.SyntaxKind)
- combineNamespaceIdentifierIntoOne.Add(model.TokenWalker.Consume());
+ if (SyntaxKind.MemberAccessToken == compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)
+ combineNamespaceIdentifierIntoOne.Add(compilationUnit.ParserModel.TokenWalker.Consume());
else
break;
}
@@ -56,17 +56,17 @@ public static ISyntax HandleNamespaceIdentifier(CSharpCompilationUnit compilatio
public static void StartStatement_Expression(CSharpCompilationUnit compilationUnit)
{
var expressionNode = ParseOthers.ParseExpression(model);
- model.CurrentCodeBlockBuilder.ChildList.Add(expressionNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(expressionNode);
}
///
/// ParseExpression while expressionPrimary.SyntaxKind == syntaxKind
///
/// if (expressionPrimary.SyntaxKind != syntaxKind)
- /// model.TokenWalker.Backtrack() to either the previous loops tokenIndex where
+ /// compilationUnit.ParserModel.TokenWalker.Backtrack() to either the previous loops tokenIndex where
/// the syntax kinds did match.
///
- /// Or, if they never matched then model.TokenWalker.Backtrack()
+ /// Or, if they never matched then compilationUnit.ParserModel.TokenWalker.Backtrack()
/// to the tokenIndex that was had when this function was invoked.
///
/// Return true if a match was found, return false if NO match was found.
@@ -75,15 +75,15 @@ public static void StartStatement_Expression(CSharpCompilationUnit compilationUn
/// As a result, some statements need to read a TypeClauseNode by invoking 'ParseExpression(...)'.
///
/// In order to "short circut" or "force exit" from the expression code back to the statement code,
- /// if the root primary expression is not equal to the model.ForceParseExpressionSyntaxKind
+ /// if the root primary expression is not equal to the compilationUnit.ParserModel.ForceParseExpressionSyntaxKind
/// then stop.
///
public static bool TryParseExpression(SyntaxKind? syntaxKind, CSharpCompilationUnit compilationUnit, out IExpressionNode expressionNode)
{
- var originalTokenIndex = model.TokenWalker.Index;
+ var originalTokenIndex = compilationUnit.ParserModelTokenWalker.Index;
if (syntaxKind is not null)
- model.TryParseExpressionSyntaxKindList.Add(syntaxKind.Value);
+ compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Add(syntaxKind.Value);
try
{
@@ -93,12 +93,12 @@ public static bool TryParseExpression(SyntaxKind? syntaxKind, CSharpCompilationU
Console.WriteLine($"try => {expressionNode.SyntaxKind}\n");
#endif
- return model.TryParseExpressionSyntaxKindList.Contains(expressionNode.SyntaxKind);
+ return compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Contains(expressionNode.SyntaxKind);
}
finally
{
- model.TryParseExpressionSyntaxKindList.Clear();
- model.ForceParseExpressionInitialPrimaryExpression = EmptyExpressionNode.Empty;
+ compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Clear();
+ compilationUnit.ParserModel.ForceParseExpressionInitialPrimaryExpression = EmptyExpressionNode.Empty;
}
}
@@ -122,10 +122,10 @@ public static bool SyntaxIsEndDelimiter(SyntaxKind syntaxKind)
}
///
- /// Invoke this method when 'model.TokenWalker.Current' is the first token of the expression to be parsed.
+ /// Invoke this method when 'compilationUnit.ParserModel.TokenWalker.Current' is the first token of the expression to be parsed.
///
- /// In the case where the first token of the expression had already been 'Consume()'-ed then 'model.TokenWalker.Backtrack();'
- /// might be of use in order to move the model.TokenWalker backwards prior to invoking this method.
+ /// In the case where the first token of the expression had already been 'Consume()'-ed then 'compilationUnit.ParserModel.TokenWalker.Backtrack();'
+ /// might be of use in order to move the compilationUnit.ParserModel.TokenWalker backwards prior to invoking this method.
///
public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationUnit)
{
@@ -133,26 +133,26 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
Console.WriteLine("\nParseExpression(...)");
#endif
- var expressionPrimary = model.ForceParseExpressionInitialPrimaryExpression;
- var indexToken = model.TokenWalker.Index;
+ var expressionPrimary = compilationUnit.ParserModel.ForceParseExpressionInitialPrimaryExpression;
+ var indexToken = compilationUnit.ParserModel.TokenWalker.Index;
var forceExit = false;
- var indexTokenRoot = model.TokenWalker.Index;
+ var indexTokenRoot = compilationUnit.ParserModel.TokenWalker.Index;
var expressionPrimaryPreviousRoot = expressionPrimary;
- while (!model.TokenWalker.IsEof)
+ while (!compilationUnit.ParserModel.TokenWalker.IsEof)
{
#if DEBUG
- WriteExpressionList(model.ExpressionList);
+ WriteExpressionList(compilationUnit.ParserModel.ExpressionList);
#endif
- var tokenCurrent = model.TokenWalker.Current;
+ var tokenCurrent = compilationUnit.ParserModel.TokenWalker.Current;
if (SyntaxIsEndDelimiter(tokenCurrent.SyntaxKind)) // Check if the tokenCurrent is a token that is used as a end-delimiter before iterating the list?
{
- for (int i = model.ExpressionList.Count - 1; i > -1; i--)
+ for (int i = compilationUnit.ParserModel.ExpressionList.Count - 1; i > -1; i--)
{
- var delimiterExpressionTuple = model.ExpressionList[i];
+ var delimiterExpressionTuple = compilationUnit.ParserModel.ExpressionList[i];
if (delimiterExpressionTuple.DelimiterSyntaxKind == tokenCurrent.SyntaxKind)
{
@@ -174,31 +174,31 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
break;
}
- expressionPrimary = model.Binder.AnyMergeToken(expressionPrimary, tokenCurrent, model);
+ expressionPrimary = compilationUnit.ParserModel.Binder.AnyMergeToken(expressionPrimary, tokenCurrent, model);
#if DEBUG
Console.WriteLine($"\t=> {expressionPrimary.SyntaxKind}");
#endif
- if (model.TokenWalker.Index == indexToken)
- _ = model.TokenWalker.Consume();
- if (model.TokenWalker.Index < indexToken)
+ if (compilationUnit.ParserModel.TokenWalker.Index == indexToken)
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
+ if (compilationUnit.ParserModel.TokenWalker.Index < indexToken)
throw new LuthetusTextEditorException($"Infinite loop in {nameof(ParseExpression)}");
- indexToken = model.TokenWalker.Index;
+ indexToken = compilationUnit.ParserModel.TokenWalker.Index;
- if (model.NoLongerRelevantExpressionNode is not null) // try finally is not needed to guarantee setting 'model.NoLongerRelevantExpressionNode = null;' because this is an object reference comparison 'Object.ReferenceEquals'. Versus something more general that would break future parses if not properly cleared, like a SyntaxKind.
+ if (compilationUnit.ParserModel.NoLongerRelevantExpressionNode is not null) // try finally is not needed to guarantee setting 'compilationUnit.ParserModel.NoLongerRelevantExpressionNode = null;' because this is an object reference comparison 'Object.ReferenceEquals'. Versus something more general that would break future parses if not properly cleared, like a SyntaxKind.
{
- model.Binder.ClearFromExpressionList(model.NoLongerRelevantExpressionNode, model);
- model.NoLongerRelevantExpressionNode = null;
+ compilationUnit.ParserModel.Binder.ClearFromExpressionList(compilationUnit.ParserModel.NoLongerRelevantExpressionNode, model);
+ compilationUnit.ParserModel.NoLongerRelevantExpressionNode = null;
}
- if (model.TryParseExpressionSyntaxKindList.Count != 0)
+ if (compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Count != 0)
{
var isExpressionRoot = true;
var rootSyntaxKind = SyntaxKind.EmptyExpressionNode;
- foreach (var tuple in model.ExpressionList)
+ foreach (var tuple in compilationUnit.ParserModel.ExpressionList)
{
if (tuple.ExpressionNode is null)
continue;
@@ -212,26 +212,26 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
if (isExpressionRoot)
{
- success = model.TryParseExpressionSyntaxKindList.Contains(expressionPrimary.SyntaxKind);
+ success = compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Contains(expressionPrimary.SyntaxKind);
if (success)
{
expressionPrimaryPreviousRoot = expressionPrimary;
- indexTokenRoot = model.TokenWalker.Index;
+ indexTokenRoot = compilationUnit.ParserModel.TokenWalker.Index;
}
}
else
{
- success = model.TryParseExpressionSyntaxKindList.Contains(rootSyntaxKind);
+ success = compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Contains(rootSyntaxKind);
}
if (!success)
{
- var distance = model.TokenWalker.Index - indexTokenRoot;
+ var distance = compilationUnit.ParserModel.TokenWalker.Index - indexTokenRoot;
for (int i = 0; i < distance; i++)
{
- _ = model.TokenWalker.Backtrack();
+ _ = compilationUnit.ParserModel.TokenWalker.Backtrack();
}
expressionPrimary = expressionPrimaryPreviousRoot;
@@ -239,24 +239,24 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
forceExit = true;
#if DEBUG
- WriteExpressionList(model.ExpressionList);
+ WriteExpressionList(compilationUnit.ParserModel.ExpressionList);
Console.WriteLine("----TryParseExpressionSyntaxKindList");
#endif
}
}
- if (forceExit) // model.ForceParseExpressionSyntaxKind
+ if (forceExit) // compilationUnit.ParserModel.ForceParseExpressionSyntaxKind
break;
}
// It is vital that this 'clear' and 'add' are done in a way that permits an invoker of the 'ParseExpression' method to 'add' a similar 'forceExit' delimiter
- // Example: 'model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));'
- model.ExpressionList.Clear();
- model.ExpressionList.Add((SyntaxKind.StatementDelimiterToken, null));
+ // Example: 'compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));'
+ compilationUnit.ParserModel.ExpressionList.Clear();
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.StatementDelimiterToken, null));
if (expressionPrimary.SyntaxKind == SyntaxKind.AmbiguousIdentifierExpressionNode)
{
- expressionPrimary = model.Binder.ForceDecisionAmbiguousIdentifier(
+ expressionPrimary = compilationUnit.ParserModel.Binder.ForceDecisionAmbiguousIdentifier(
EmptyExpressionNode.Empty,
(AmbiguousIdentifierExpressionNode)expressionPrimary,
model);
@@ -290,10 +290,10 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
///
private static IExpressionNode BubbleUpParseExpression(int indexTriggered, IExpressionNode expressionPrimary, CSharpCompilationUnit compilationUnit)
{
- var triggeredDelimiterTuple = model.ExpressionList[indexTriggered];
+ var triggeredDelimiterTuple = compilationUnit.ParserModel.ExpressionList[indexTriggered];
IExpressionNode? previousDelimiterExpressionNode = null;
- var initialExpressionListCount = model.ExpressionList.Count;
+ var initialExpressionListCount = compilationUnit.ParserModel.ExpressionList.Count;
#if DEBUG
var nullNodeSyntaxKindText = "null";
@@ -302,8 +302,8 @@ private static IExpressionNode BubbleUpParseExpression(int indexTriggered, IExpr
for (int i = initialExpressionListCount - 1; i > indexTriggered - 1; i--)
{
- var delimiterExpressionTuple = model.ExpressionList[i];
- model.ExpressionList.RemoveAt(i);
+ var delimiterExpressionTuple = compilationUnit.ParserModel.ExpressionList[i];
+ compilationUnit.ParserModel.ExpressionList.RemoveAt(i);
if (delimiterExpressionTuple.ExpressionNode is null)
break; // This implies to forcibly return back to the statement while loop.
@@ -317,16 +317,16 @@ private static IExpressionNode BubbleUpParseExpression(int indexTriggered, IExpr
previousDelimiterExpressionNode = delimiterExpressionTuple.ExpressionNode;
- expressionPrimary = model.Binder.AnyMergeExpression(
+ expressionPrimary = compilationUnit.ParserModel.Binder.AnyMergeExpression(
delimiterExpressionTuple.ExpressionNode,
expressionPrimary, // expressionSecondary
model);
}
- if (model.NoLongerRelevantExpressionNode is not null) // try finally is not needed to guarantee setting 'model.NoLongerRelevantExpressionNode = null;' because this is an object reference comparison 'Object.ReferenceEquals'. Versus something more general that would break future parses if not properly cleared, like a SyntaxKind.
+ if (compilationUnit.ParserModel.NoLongerRelevantExpressionNode is not null) // try finally is not needed to guarantee setting 'compilationUnit.ParserModel.NoLongerRelevantExpressionNode = null;' because this is an object reference comparison 'Object.ReferenceEquals'. Versus something more general that would break future parses if not properly cleared, like a SyntaxKind.
{
- model.Binder.ClearFromExpressionList(model.NoLongerRelevantExpressionNode, model);
- model.NoLongerRelevantExpressionNode = null;
+ compilationUnit.ParserModel.Binder.ClearFromExpressionList(compilationUnit.ParserModel.NoLongerRelevantExpressionNode, model);
+ compilationUnit.ParserModel.NoLongerRelevantExpressionNode = null;
}
return expressionPrimary;
From e3a4a0a3430f883ace46012b6d1f670183683ccd Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:28:42 -0500
Subject: [PATCH 16/39] DOES NOT BUILD: Got all the 'model.' but still more
changes need to be done
---
.../BinderCase/CSharpBinder.Expressions.cs | 170 ++++++-------
.../CSharp/BinderCase/CSharpBinder.Main.cs | 108 ++++-----
.../ParserCase/Internals/ParseTokens.cs | 224 +++++++++---------
.../CSharp/ParserCase/Internals/ParseTypes.cs | 38 +--
.../ParserCase/Internals/ParseVariables.cs | 22 +-
.../Internals/TokenWalkerExtensionMethods.cs | 8 +-
.../CSharp/ParserCase/Internals/UtilityApi.cs | 12 +-
7 files changed, 291 insertions(+), 291 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
index e1eaae413..b99a845ec 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
@@ -154,8 +154,8 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
functionInvocationNode,
(CSharpParserModel)model);
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, functionInvocationNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, functionInvocationNode.FunctionParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, functionInvocationNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, functionInvocationNode.FunctionParametersListingNode));
return EmptyExpressionNode.Empty;
}
else if (token.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
@@ -169,8 +169,8 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
closeAngleBracketToken: default));
}
- model.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, ambiguousIdentifierExpressionNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, ambiguousIdentifierExpressionNode.GenericParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, ambiguousIdentifierExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, ambiguousIdentifierExpressionNode.GenericParametersListingNode));
return EmptyExpressionNode.Empty;
}
else if (token.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
@@ -183,7 +183,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
}
else if (token.SyntaxKind == SyntaxKind.EqualsToken)
{
- if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
var lambdaExpressionNode = new LambdaExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
SetLambdaExpressionNodeVariableDeclarationNodeList(lambdaExpressionNode, ambiguousIdentifierExpressionNode, model);
@@ -198,14 +198,14 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
(EqualsToken)token,
EmptyExpressionNode.Empty);
- model.ExpressionList.Add((SyntaxKind.CommaToken, variableAssignmentNode));
- model.ExpressionList.Add((SyntaxKind.EndOfFileToken, variableAssignmentNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, variableAssignmentNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.EndOfFileToken, variableAssignmentNode));
return EmptyExpressionNode.Empty;
}
else
{
- model.ExpressionList.Add((SyntaxKind.CommaToken, ambiguousIdentifierExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, ambiguousIdentifierExpressionNode));
return EmptyExpressionNode.Empty;
}
}
@@ -216,22 +216,22 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
ambiguousIdentifierExpressionNode,
model);
- _ = model.TokenWalker.Consume(); // Consume the IsTokenKeyword
+ _ = compilationUnit.ParserModel.TokenWalker.Consume(); // Consume the IsTokenKeyword
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.NotTokenContextualKeyword)
- _ = model.TokenWalker.Consume(); // Consume the NotTokenKeyword
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.NotTokenContextualKeyword)
+ _ = compilationUnit.ParserModel.TokenWalker.Consume(); // Consume the NotTokenKeyword
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.NullTokenKeyword)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.NullTokenKeyword)
{
- _ = model.TokenWalker.Consume(); // Consume the NullTokenKeyword
+ _ = compilationUnit.ParserModel.TokenWalker.Consume(); // Consume the NullTokenKeyword
}
- else if (UtilityApi.IsConvertibleToIdentifierToken(model.TokenWalker.Current.SyntaxKind))
+ else if (UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind))
{
ParseTokens.ParseIdentifierToken((CSharpParserModel)model); // Parse the type pattern matching / variable declaration
}
// Guaranteed to consume 1 further than the secondary loop so have to backtrack 1 time as well.
- _ = model.TokenWalker.Backtrack();
+ _ = compilationUnit.ParserModel.TokenWalker.Backtrack();
return ambiguousIdentifierExpressionNode;
}
@@ -242,40 +242,40 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
ambiguousIdentifierExpressionNode,
model);
- if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenBraceToken)
+ if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenBraceToken)
{
- var withKeywordContextualToken = model.TokenWalker.Consume();
+ var withKeywordContextualToken = compilationUnit.ParserModel.TokenWalker.Consume();
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
#endif
- var openBraceToken = (OpenBraceToken)model.TokenWalker.Consume();
+ var openBraceToken = (OpenBraceToken)compilationUnit.ParserModel.TokenWalker.Consume();
var openBraceCounter = 1;
while (true)
{
- if (model.TokenWalker.IsEof)
+ if (compilationUnit.ParserModel.TokenWalker.IsEof)
break;
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
{
++openBraceCounter;
}
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseBraceToken)
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseBraceToken)
{
if (--openBraceCounter <= 0)
break;
}
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
}
- var closeBraceToken = (CloseBraceToken)model.TokenWalker.Match(SyntaxKind.CloseBraceToken);
+ var closeBraceToken = (CloseBraceToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseBraceToken);
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
#endif
}
@@ -294,13 +294,13 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
if (decidedExpression.SyntaxKind != SyntaxKind.TypeClauseNode)
{
- model.DiagnosticBag.ReportTodoException(
- model.TokenWalker.Current.TextSpan,
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(
+ compilationUnit.ParserModel.TokenWalker.Current.TextSpan,
"if (decidedExpression.SyntaxKind != SyntaxKind.TypeClauseNode)");
return decidedExpression;
}
- var identifierToken = (IdentifierToken)model.TokenWalker.Match(SyntaxKind.IdentifierToken);
+ var identifierToken = (IdentifierToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
var variableDeclarationNode = ParseVariables.HandleVariableDeclarationExpression(
(TypeClauseNode)decidedExpression,
@@ -339,8 +339,8 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
{
if (TryGetVariableDeclarationHierarchically(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
ambiguousIdentifierExpressionNode.Token.TextSpan.GetText(),
out var existingVariableDeclarationNode))
{
@@ -359,8 +359,8 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
{
if (TryGetTypeDefinitionHierarchically(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
ambiguousIdentifierExpressionNode.Token.TextSpan.GetText(),
out var typeDefinitionNode))
{
@@ -468,7 +468,7 @@ public IExpressionNode CommaSeparatedMergeToken(
{
if (!commaSeparatedExpressionNode.CloseParenthesisToken.ConstructorWasInvoked)
{
- model.ExpressionList.Add((SyntaxKind.CommaToken, commaSeparatedExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, commaSeparatedExpressionNode));
return EmptyExpressionNode.Empty;
}
}
@@ -483,7 +483,7 @@ public IExpressionNode CommaSeparatedMergeToken(
public IExpressionNode CommaSeparatedMergeExpression(
CommaSeparatedExpressionNode commaSeparatedExpressionNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken || model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseParenthesisToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken || compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseParenthesisToken)
{
commaSeparatedExpressionNode.AddInnerExpressionNode(expressionSecondary);
return commaSeparatedExpressionNode;
@@ -522,8 +522,8 @@ public IExpressionNode ConstructorInvocationMergeToken(
constructorInvocationExpressionNode.SetFunctionParametersListingNode(functionParametersListingNode);
constructorInvocationExpressionNode.ConstructorInvocationStageKind = ConstructorInvocationStageKind.FunctionParameters;
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, constructorInvocationExpressionNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode.FunctionParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, constructorInvocationExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode.FunctionParametersListingNode));
return EmptyExpressionNode.Empty;
case SyntaxKind.CloseParenthesisToken:
if (constructorInvocationExpressionNode.FunctionParametersListingNode is not null)
@@ -546,8 +546,8 @@ public IExpressionNode ConstructorInvocationMergeToken(
}
constructorInvocationExpressionNode.ConstructorInvocationStageKind = ConstructorInvocationStageKind.GenericParameters;
- model.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, constructorInvocationExpressionNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode.ResultTypeClauseNode.GenericParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, constructorInvocationExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode.ResultTypeClauseNode.GenericParametersListingNode));
return EmptyExpressionNode.Empty;
case SyntaxKind.CloseAngleBracketToken:
constructorInvocationExpressionNode.ConstructorInvocationStageKind = ConstructorInvocationStageKind.Unset;
@@ -562,9 +562,9 @@ public IExpressionNode ConstructorInvocationMergeToken(
constructorInvocationExpressionNode.SetObjectInitializationParametersListingNode(objectInitializationParametersListingNode);
constructorInvocationExpressionNode.ConstructorInvocationStageKind = ConstructorInvocationStageKind.ObjectInitializationParameters;
- model.ExpressionList.Add((SyntaxKind.CloseBraceToken, constructorInvocationExpressionNode));
- model.ExpressionList.Add((SyntaxKind.EqualsToken, constructorInvocationExpressionNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseBraceToken, constructorInvocationExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.EqualsToken, constructorInvocationExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode));
return EmptyExpressionNode.Empty;
case SyntaxKind.CloseBraceToken:
constructorInvocationExpressionNode.ConstructorInvocationStageKind = ConstructorInvocationStageKind.Unset;
@@ -579,8 +579,8 @@ public IExpressionNode ConstructorInvocationMergeToken(
goto default;
}
case SyntaxKind.EqualsToken:
- model.ExpressionList.Add((SyntaxKind.EqualsToken, constructorInvocationExpressionNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.EqualsToken, constructorInvocationExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode));
if (constructorInvocationExpressionNode.ConstructorInvocationStageKind == ConstructorInvocationStageKind.ObjectInitializationParameters &&
constructorInvocationExpressionNode.ObjectInitializationParametersListingNode is not null)
@@ -599,7 +599,7 @@ public IExpressionNode ConstructorInvocationMergeToken(
goto default;
case SyntaxKind.CommaToken:
- model.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, constructorInvocationExpressionNode));
return EmptyExpressionNode.Empty;
default:
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), constructorInvocationExpressionNode, token);
@@ -665,8 +665,8 @@ public IExpressionNode ConstructorInvocationMergeExpression(
// This feels like hacky nonsense.
// It allows for ObjectInitialization and CollectionInitialization
// to use the same node but why not just use separate nodes?
- var currentTokenIsComma = model.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken;
- var currentTokenIsBrace = model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseBraceToken;
+ var currentTokenIsComma = compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken;
+ var currentTokenIsBrace = compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseBraceToken;
if (!objectInitializationParameterEntryNode.PropertyIdentifierToken.ConstructorWasInvoked &&
(!currentTokenIsComma && !currentTokenIsBrace))
@@ -755,8 +755,8 @@ public IExpressionNode EmptyMergeToken(
FollowsMemberAccessToken = emptyExpressionNode.FollowsMemberAccessToken
};
- if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.StatementDelimiterToken && !ambiguousExpressionNode.FollowsMemberAccessToken ||
- model.TryParseExpressionSyntaxKindList.Contains(SyntaxKind.TypeClauseNode) && model.TokenWalker.Next.SyntaxKind != SyntaxKind.WithTokenContextualKeyword)
+ if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.StatementDelimiterToken && !ambiguousExpressionNode.FollowsMemberAccessToken ||
+ compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Contains(SyntaxKind.TypeClauseNode) && compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind != SyntaxKind.WithTokenContextualKeyword)
{
return ForceDecisionAmbiguousIdentifier(
emptyExpressionNode,
@@ -790,8 +790,8 @@ public IExpressionNode EmptyMergeToken(
return new LiteralExpressionNode(token, tokenTypeClauseNode);
case SyntaxKind.OpenParenthesisToken:
var parenthesizedExpressionNode = new ParenthesizedExpressionNode((OpenParenthesisToken)token, CSharpFacts.Types.Void.ToTypeClause());
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, parenthesizedExpressionNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, parenthesizedExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, parenthesizedExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, parenthesizedExpressionNode));
return EmptyExpressionNode.Empty;
case SyntaxKind.NewTokenKeyword:
return new ConstructorInvocationExpressionNode(
@@ -809,7 +809,7 @@ public IExpressionNode EmptyMergeToken(
return emptyExpressionNode;
case SyntaxKind.OutTokenKeyword:
- if (UtilityApi.IsConvertibleToIdentifierToken(model.TokenWalker.Current.SyntaxKind))
+ if (UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind))
{
// Parse the variable reference / variable declaration
ParseTokens.ParseIdentifierToken((CSharpParserModel)model);
@@ -825,8 +825,8 @@ public IExpressionNode EmptyMergeToken(
new List(),
closeAngleBracketToken: default);
- model.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, genericParametersListingNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, genericParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, genericParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, genericParametersListingNode));
return EmptyExpressionNode.Empty;
default:
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), emptyExpressionNode, token);
@@ -857,7 +857,7 @@ public IExpressionNode GenericParametersListingMergeToken(
switch (token.SyntaxKind)
{
case SyntaxKind.CommaToken:
- model.ExpressionList.Add((SyntaxKind.CommaToken, genericParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, genericParametersListingNode));
return EmptyExpressionNode.Empty;
case SyntaxKind.CloseAngleBracketToken:
// This case only occurs when the text won't compile.
@@ -865,7 +865,7 @@ public IExpressionNode GenericParametersListingMergeToken(
// The case is for when the user types just the generic parameter listing text without an identifier before it.
//
// In the case of "SomeMethod()", the FunctionInvocationNode
- // is expected to have ran 'model.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, functionInvocationNode));'
+ // is expected to have ran 'compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, functionInvocationNode));'
// to receive the genericParametersListingNode.
return genericParametersListingNode;
default:
@@ -933,7 +933,7 @@ public IExpressionNode FunctionParametersListingMergeToken(
switch (token.SyntaxKind)
{
case SyntaxKind.CommaToken:
- model.ExpressionList.Add((SyntaxKind.CommaToken, functionParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, functionParametersListingNode));
return EmptyExpressionNode.Empty;
default:
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), functionParametersListingNode, token);
@@ -971,7 +971,7 @@ public IExpressionNode FunctionArgumentsListingMergeToken(
switch (token.SyntaxKind)
{
case SyntaxKind.CommaToken:
- model.ExpressionList.Add((SyntaxKind.CommaToken, functionArgumentsListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, functionArgumentsListingNode));
return EmptyExpressionNode.Empty;
default:
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), functionArgumentsListingNode, token);
@@ -1013,8 +1013,8 @@ public IExpressionNode LambdaMergeToken(
{
int startInclusiveIndex;
- if (model.TokenWalker.Previous.SyntaxKind == SyntaxKind.EqualsToken)
- startInclusiveIndex = model.TokenWalker.Previous.TextSpan.StartingIndexInclusive;
+ if (compilationUnit.ParserModel.TokenWalker.Previous.SyntaxKind == SyntaxKind.EqualsToken)
+ startInclusiveIndex = compilationUnit.ParserModel.TokenWalker.Previous.TextSpan.StartingIndexInclusive;
else
startInclusiveIndex = token.TextSpan.StartingIndexInclusive;
@@ -1027,19 +1027,19 @@ public IExpressionNode LambdaMergeToken(
token.TextSpan.ResourceUri,
token.TextSpan.SourceText);
- ((CSharpBinder)model.Binder).AddSymbolDefinition(
+ ((CSharpBinder)compilationUnit.ParserModel.Binder).AddSymbolDefinition(
new LambdaSymbol(textSpan, lambdaExpressionNode), (CSharpParserModel)model);
- if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenBraceToken)
+ if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenBraceToken)
{
lambdaExpressionNode.CodeBlockNodeIsExpression = false;
- model.ExpressionList.Add((SyntaxKind.CloseBraceToken, lambdaExpressionNode));
- model.ExpressionList.Add((SyntaxKind.StatementDelimiterToken, lambdaExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseBraceToken, lambdaExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.StatementDelimiterToken, lambdaExpressionNode));
return EmptyExpressionNode.Empty;
}
- model.ExpressionList.Add((SyntaxKind.StatementDelimiterToken, lambdaExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.StatementDelimiterToken, lambdaExpressionNode));
return EmptyExpressionNode.Empty;
}
else if (token.SyntaxKind == SyntaxKind.StatementDelimiterToken)
@@ -1050,7 +1050,7 @@ public IExpressionNode LambdaMergeToken(
}
else
{
- model.ExpressionList.Add((SyntaxKind.StatementDelimiterToken, lambdaExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.StatementDelimiterToken, lambdaExpressionNode));
return EmptyExpressionNode.Empty;
}
}
@@ -1074,8 +1074,8 @@ public IExpressionNode LambdaMergeToken(
else
{
lambdaExpressionNode.HasReadParameters = true;
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, lambdaExpressionNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, lambdaExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, lambdaExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, lambdaExpressionNode));
return EmptyExpressionNode.Empty;
}
}
@@ -1085,14 +1085,14 @@ public IExpressionNode LambdaMergeToken(
}
else if (token.SyntaxKind == SyntaxKind.EqualsToken)
{
- if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
return lambdaExpressionNode;
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), lambdaExpressionNode, token);
}
else if (token.SyntaxKind == SyntaxKind.CommaToken)
{
- model.ExpressionList.Add((SyntaxKind.CommaToken, lambdaExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, lambdaExpressionNode));
return EmptyExpressionNode.Empty;
}
else if (token.SyntaxKind == SyntaxKind.IdentifierToken)
@@ -1164,7 +1164,7 @@ public IExpressionNode ParenthesizedMergeToken(
return parenthesizedExpressionNode.SetCloseParenthesisToken((CloseParenthesisToken)token);
case SyntaxKind.EqualsToken:
- if (model.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
var lambdaExpressionNode = new LambdaExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
SetLambdaExpressionNodeVariableDeclarationNodeList(lambdaExpressionNode, parenthesizedExpressionNode.InnerExpression, model);
@@ -1180,8 +1180,8 @@ public IExpressionNode ParenthesizedMergeToken(
public IExpressionNode ParenthesizedMergeExpression(
ParenthesizedExpressionNode parenthesizedExpressionNode, IExpressionNode expressionSecondary, CSharpCompilationUnit compilationUnit)
{
- if (model.TokenWalker.Peek(1).SyntaxKind == SyntaxKind.EqualsToken &&
- model.TokenWalker.Peek(2).SyntaxKind == SyntaxKind.CloseAngleBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Peek(1).SyntaxKind == SyntaxKind.EqualsToken &&
+ compilationUnit.ParserModel.TokenWalker.Peek(2).SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
var lambdaExpressionNode = new LambdaExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
return SetLambdaExpressionNodeVariableDeclarationNodeList(lambdaExpressionNode, expressionSecondary, model);
@@ -1190,14 +1190,14 @@ public IExpressionNode ParenthesizedMergeExpression(
if (expressionSecondary.SyntaxKind == SyntaxKind.AmbiguousIdentifierExpressionNode)
expressionSecondary = ForceDecisionAmbiguousIdentifier(parenthesizedExpressionNode, (AmbiguousIdentifierExpressionNode)expressionSecondary, model);
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken)
{
- model.NoLongerRelevantExpressionNode = parenthesizedExpressionNode;
+ compilationUnit.ParserModel.NoLongerRelevantExpressionNode = parenthesizedExpressionNode;
var commaSeparatedExpressionNode = new CommaSeparatedExpressionNode();
commaSeparatedExpressionNode.AddInnerExpressionNode(expressionSecondary);
// commaSeparatedExpressionNode never saw the 'OpenParenthesisToken' so the 'ParenthesizedExpressionNode
// has to create the ExpressionList entry on behalf of the 'CommaSeparatedExpressionNode'.
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, commaSeparatedExpressionNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, commaSeparatedExpressionNode));
return commaSeparatedExpressionNode;
}
@@ -1239,8 +1239,8 @@ public IExpressionNode TypeClauseMergeToken(
closeAngleBracketToken: default));
}
- model.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, typeClauseNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, typeClauseNode.GenericParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseAngleBracketToken, typeClauseNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, typeClauseNode.GenericParametersListingNode));
return EmptyExpressionNode.Empty;
case SyntaxKind.CloseAngleBracketToken:
if (typeClauseNode.GenericParametersListingNode is not null)
@@ -1278,8 +1278,8 @@ public IExpressionNode TypeClauseMergeToken(
functionInvocationNode,
(CSharpParserModel)model);
- model.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, functionInvocationNode));
- model.ExpressionList.Add((SyntaxKind.CommaToken, functionInvocationNode.FunctionParametersListingNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, functionInvocationNode));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, functionInvocationNode.FunctionParametersListingNode));
return EmptyExpressionNode.Empty;
}
@@ -1293,7 +1293,7 @@ public IExpressionNode TypeClauseMergeToken(
var identifierToken = UtilityApi.ConvertToIdentifierToken(token, model);
var isRootExpression = true;
- foreach (var tuple in model.ExpressionList)
+ foreach (var tuple in compilationUnit.ParserModel.ExpressionList)
{
if (tuple.ExpressionNode is null)
continue;
@@ -1546,24 +1546,24 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
/// A ParenthesizedExpressionNode expression will "become" a CommaSeparatedExpressionNode
/// upon encounter a CommaToken within its parentheses.
///
- /// An issue arises however, because the model.ExpressionList still says to
+ /// An issue arises however, because the compilationUnit.ParserModel.ExpressionList still says to
/// "short circuit" when the CloseParenthesisToken is encountered,
/// and to at this point make the ParenthesizedExpressionNode the primary expression.
///
/// Well, the ParenthesizedExpressionNode should no longer exist, it was deemed
/// to be more accurately described by a CommaSeparatedExpressionNode.
///
- /// So, this method will remove any entries in the model.ExpressionList
+ /// So, this method will remove any entries in the compilationUnit.ParserModel.ExpressionList
/// that have the 'ParenthesizedExpressionNode' as the to-be primary expression.
///
public void ClearFromExpressionList(IExpressionNode expressionNode, CSharpCompilationUnit compilationUnit)
{
- for (int i = model.ExpressionList.Count - 1; i > -1; i--)
+ for (int i = compilationUnit.ParserModel.ExpressionList.Count - 1; i > -1; i--)
{
- var delimiterExpressionTuple = model.ExpressionList[i];
+ var delimiterExpressionTuple = compilationUnit.ParserModel.ExpressionList[i];
if (Object.ReferenceEquals(expressionNode, delimiterExpressionTuple.ExpressionNode))
- model.ExpressionList.RemoveAt(i);
+ compilationUnit.ParserModel.ExpressionList.RemoveAt(i);
}
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
index 370ba64bd..3df46505d 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
@@ -137,7 +137,7 @@ public LiteralExpressionNode BindLiteralExpressionNode(
break;
default:
typeClauseNode = CSharpFacts.Types.Void.ToTypeClause();
- model.DiagnosticBag.ReportTodoException(literalExpressionNode.LiteralSyntaxToken.TextSpan, $"{nameof(BindLiteralExpressionNode)}(...) failed to map SyntaxKind: '{literalExpressionNode.LiteralSyntaxToken.SyntaxKind}'");
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(literalExpressionNode.LiteralSyntaxToken.TextSpan, $"{nameof(BindLiteralExpressionNode)}(...) failed to map SyntaxKind: '{literalExpressionNode.LiteralSyntaxToken.SyntaxKind}'");
break;
}
@@ -252,12 +252,12 @@ public void BindFunctionDefinitionNode(
if (!TryAddFunctionDefinitionNodeByScope(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
functionIdentifierText,
functionDefinitionNode))
{
- model.BinderSession.DiagnosticBag.ReportAlreadyDefinedFunction(
+ compilationUnit.ParserModel.BinderSession.DiagnosticBag.ReportAlreadyDefinedFunction(
functionDefinitionNode.FunctionIdentifierToken.TextSpan,
functionIdentifierText);
}
@@ -276,8 +276,8 @@ public void BindFunctionOptionalArgument(
// TODO: Wouldn't this have a '!' at the start? And '... && typeDefinitionNode is not null' (2024-10-25)
if (TryGetTypeDefinitionHierarchically(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
argumentTypeClauseNode.TypeIdentifierToken.TextSpan.GetText(),
out var typeDefinitionNode)
|| typeDefinitionNode is null)
@@ -299,7 +299,7 @@ public void BindFunctionOptionalArgument(
EndingIndexExclusive = functionArgumentEntryNode.VariableDeclarationNode.IdentifierToken.TextSpan.EndingIndexExclusive
};
- model.BinderSession.DiagnosticBag.ReportBadFunctionOptionalArgumentDueToMismatchInType(
+ compilationUnit.ParserModel.BinderSession.DiagnosticBag.ReportBadFunctionOptionalArgumentDueToMismatchInType(
optionalArgumentTextSpan,
functionArgumentEntryNode.VariableDeclarationNode.IdentifierToken.TextSpan.GetText(),
functionArgumentEntryNode.VariableDeclarationNode.TypeClauseNode.ValueType?.Name ?? "null",
@@ -334,7 +334,7 @@ public void SetCurrentNamespaceStatementNode(
NamespaceStatementNode namespaceStatementNode,
CSharpCompilationUnit compilationUnit)
{
- model.BinderSession.CurrentNamespaceStatementNode = namespaceStatementNode;
+ compilationUnit.ParserModel.BinderSession.CurrentNamespaceStatementNode = namespaceStatementNode;
}
public void BindNamespaceStatementNode(
@@ -377,7 +377,7 @@ public InheritanceStatementNode BindInheritanceStatementNode(
DecorationByte = (byte)GenericDecorationKind.Type
}), model);
- model.DiagnosticBag.ReportTodoException(
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(
typeClauseNode.TypeIdentifierToken.TextSpan,
$"Implement {nameof(BindInheritanceStatementNode)}");
@@ -396,8 +396,8 @@ public void BindVariableDeclarationNode(
if (TryGetVariableDeclarationNodeByScope(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
out var existingVariableDeclarationNode))
{
@@ -409,13 +409,13 @@ public void BindVariableDeclarationNode(
// (if there is an error where something is defined twice for example)
SetVariableDeclarationNodeByScope(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
variableDeclarationNode);
}
- model.BinderSession.DiagnosticBag.ReportAlreadyDefinedVariable(
+ compilationUnit.ParserModel.BinderSession.DiagnosticBag.ReportAlreadyDefinedVariable(
variableDeclarationNode.IdentifierToken.TextSpan,
text);
}
@@ -423,8 +423,8 @@ public void BindVariableDeclarationNode(
{
_ = TryAddVariableDeclarationNodeByScope(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
variableDeclarationNode);
}
@@ -439,8 +439,8 @@ public VariableReferenceNode ConstructAndBindVariableReferenceNode(
if (TryGetVariableDeclarationHierarchically(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
out var variableDeclarationNode)
&& variableDeclarationNode is not null)
@@ -464,7 +464,7 @@ public VariableReferenceNode ConstructAndBindVariableReferenceNode(
variableIdentifierToken,
variableDeclarationNode);
- model.BinderSession.DiagnosticBag.ReportUndefinedVariable(
+ compilationUnit.ParserModel.BinderSession.DiagnosticBag.ReportUndefinedVariable(
variableIdentifierToken.TextSpan,
text);
}
@@ -482,8 +482,8 @@ public void BindVariableAssignmentExpressionNode(
if (TryGetVariableDeclarationHierarchically(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
out var variableDeclarationNode)
&& variableDeclarationNode is not null)
@@ -498,13 +498,13 @@ public void BindVariableAssignmentExpressionNode(
{
if (UtilityApi.IsContextualKeywordSyntaxKind(text))
{
- model.BinderSession.DiagnosticBag.TheNameDoesNotExistInTheCurrentContext(
+ compilationUnit.ParserModel.BinderSession.DiagnosticBag.TheNameDoesNotExistInTheCurrentContext(
variableAssignmentExpressionNode.VariableIdentifierToken.TextSpan,
text);
}
else
{
- model.BinderSession.DiagnosticBag.ReportUndefinedVariable(
+ compilationUnit.ParserModel.BinderSession.DiagnosticBag.ReportUndefinedVariable(
variableAssignmentExpressionNode.VariableIdentifierToken.TextSpan,
text);
}
@@ -541,8 +541,8 @@ public void BindFunctionInvocationNode(
if (TryGetFunctionHierarchically(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
functionInvocationIdentifierText,
out var functionDefinitionNode) &&
functionDefinitionNode is not null)
@@ -551,7 +551,7 @@ public void BindFunctionInvocationNode(
}
else
{
- model.BinderSession.DiagnosticBag.ReportUndefinedFunction(
+ compilationUnit.ParserModel.BinderSession.DiagnosticBag.ReportUndefinedFunction(
functionInvocationNode.FunctionInvocationIdentifierToken.TextSpan,
functionInvocationIdentifierText);
}
@@ -613,7 +613,7 @@ public void BindUsingStatementNode(
{
AddSymbolReference(new NamespaceSymbol(usingStatementNode.NamespaceIdentifier.TextSpan), model);
- model.BinderSession.CurrentUsingStatementNodeList.Add(usingStatementNode);
+ compilationUnit.ParserModel.BinderSession.CurrentUsingStatementNodeList.Add(usingStatementNode);
AddNamespaceToCurrentScope(usingStatementNode.NamespaceIdentifier.TextSpan.GetText(), model);
}
@@ -644,13 +644,13 @@ public void OpenScope(
{
var scope = new Scope(
codeBlockOwner,
- indexKey: model.BinderSession.GetNextIndexKey(),
- parentIndexKey: model.BinderSession.CurrentScopeIndexKey,
+ indexKey: compilationUnit.ParserModel.BinderSession.GetNextIndexKey(),
+ parentIndexKey: compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
textSpan.StartingIndexInclusive,
endingIndexExclusive: null);
- model.BinderSession.ScopeList.Insert(scope.IndexKey, scope);
- model.BinderSession.CurrentScopeIndexKey = scope.IndexKey;
+ compilationUnit.ParserModel.BinderSession.ScopeList.Insert(scope.IndexKey, scope);
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey = scope.IndexKey;
}
void IBinder.AddNamespaceToCurrentScope(string namespaceString, IParserModel model) =>
@@ -669,8 +669,8 @@ public void AddNamespaceToCurrentScope(
{
_ = TryAddTypeDefinitionNodeByScope(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
typeDefinitionNode.TypeIdentifierToken.TextSpan.GetText(),
typeDefinitionNode);
}
@@ -683,26 +683,26 @@ public void CloseScope(
{
// Check if it is the global scope, if so return early.
{
- if (model.BinderSession.CurrentScopeIndexKey == 0)
+ if (compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey == 0)
return;
}
- var inBuilder = model.CurrentCodeBlockBuilder;
+ var inBuilder = compilationUnit.ParserModel.CurrentCodeBlockBuilder;
var inOwner = inBuilder.CodeBlockOwner;
- var outBuilder = model.CurrentCodeBlockBuilder.Parent;
+ var outBuilder = compilationUnit.ParserModel.CurrentCodeBlockBuilder.Parent;
var outOwner = outBuilder?.CodeBlockOwner;
// Update Scope
{
- var scope = model.BinderSession.ScopeList[model.BinderSession.CurrentScopeIndexKey];
+ var scope = compilationUnit.ParserModel.BinderSession.ScopeList[compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey];
scope.EndingIndexExclusive = textSpan.EndingIndexExclusive;
- model.BinderSession.ScopeList[model.BinderSession.CurrentScopeIndexKey] = scope;
+ compilationUnit.ParserModel.BinderSession.ScopeList[compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey] = scope;
// Restore Parent Scope
if (scope.ParentIndexKey is not null)
{
- model.BinderSession.CurrentScopeIndexKey = scope.ParentIndexKey.Value;
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey = scope.ParentIndexKey.Value;
}
}
@@ -712,14 +712,14 @@ public void CloseScope(
inOwner.SetCodeBlockNode(inBuilder.Build(), model);
if (inOwner.SyntaxKind == SyntaxKind.NamespaceStatementNode)
- model.Binder.BindNamespaceStatementNode((NamespaceStatementNode)inOwner, model);
+ compilationUnit.ParserModel.Binder.BindNamespaceStatementNode((NamespaceStatementNode)inOwner, model);
else if (inOwner.SyntaxKind == SyntaxKind.TypeDefinitionNode)
- model.Binder.BindTypeDefinitionNode((TypeDefinitionNode)inOwner, model, true);
+ compilationUnit.ParserModel.Binder.BindTypeDefinitionNode((TypeDefinitionNode)inOwner, model, true);
// Restore Parent CodeBlockBuilder
if (outBuilder is not null)
{
- model.CurrentCodeBlockBuilder = outBuilder;
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder = outBuilder;
outBuilder.InnerPendingCodeBlockOwner = null;
if (inOwner.SyntaxKind != SyntaxKind.TryStatementTryNode &&
@@ -738,15 +738,15 @@ public void BindTypeDefinitionNode(
bool shouldOverwrite = false)
{
var typeIdentifierText = typeDefinitionNode.TypeIdentifierToken.TextSpan.GetText();
- var currentNamespaceStatementText = model.BinderSession.CurrentNamespaceStatementNode.IdentifierToken.TextSpan.GetText();
+ var currentNamespaceStatementText = compilationUnit.ParserModel.BinderSession.CurrentNamespaceStatementNode.IdentifierToken.TextSpan.GetText();
var namespaceAndTypeIdentifiers = new NamespaceAndTypeIdentifiers(currentNamespaceStatementText, typeIdentifierText);
typeDefinitionNode.EncompassingNamespaceIdentifierString = currentNamespaceStatementText;
if (TryGetTypeDefinitionNodeByScope(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
typeIdentifierText,
out var existingTypeDefinitionNode))
{
@@ -754,8 +754,8 @@ public void BindTypeDefinitionNode(
{
SetTypeDefinitionNodeByScope(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
typeIdentifierText,
typeDefinitionNode);
}
@@ -764,8 +764,8 @@ public void BindTypeDefinitionNode(
{
_ = TryAddTypeDefinitionNodeByScope(
model,
- model.BinderSession.ResourceUri,
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.ResourceUri,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
typeIdentifierText,
typeDefinitionNode);
}
@@ -787,10 +787,10 @@ private void AddSymbolDefinition(
{
var symbolDefinitionId = ISymbol.GetSymbolDefinitionId(
symbol.TextSpan.GetText(),
- model.BinderSession.CurrentScopeIndexKey);
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey);
var symbolDefinition = new SymbolDefinition(
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
symbol);
if (!_symbolDefinitions.TryAdd(
@@ -816,14 +816,14 @@ private void AddSymbolReference(ISymbol symbol, CSharpCompilationUnit compilatio
{
var symbolDefinitionId = ISymbol.GetSymbolDefinitionId(
symbol.TextSpan.GetText(),
- model.BinderSession.CurrentScopeIndexKey);
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey);
if (!_symbolDefinitions.TryGetValue(
symbolDefinitionId,
out var symbolDefinition))
{
symbolDefinition = new SymbolDefinition(
- model.BinderSession.CurrentScopeIndexKey,
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
symbol)
{
IsFabricated = true
@@ -840,7 +840,7 @@ private void AddSymbolReference(ISymbol symbol, CSharpCompilationUnit compilatio
symbolDefinition.SymbolReferences.Add(new SymbolReference(
symbol,
- model.BinderSession.CurrentScopeIndexKey));
+ compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey));
}
public void CreateVariableSymbol(
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
index 6eb839dd7..e9dd09e6c 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
@@ -16,20 +16,20 @@ public static void ParsePreprocessorDirectiveToken(
PreprocessorDirectiveToken consumedPreprocessorDirectiveToken,
CSharpCompilationUnit compilationUnit)
{
- var consumedToken = model.TokenWalker.Consume();
+ var consumedToken = compilationUnit.ParserModel.TokenWalker.Consume();
}
public static void ParseIdentifierToken(CSharpCompilationUnit compilationUnit)
{
- var originalTokenIndex = model.TokenWalker.Index;
+ var originalTokenIndex = compilationUnit.ParserModel.TokenWalker.Index;
- model.TryParseExpressionSyntaxKindList.Add(SyntaxKind.TypeClauseNode);
- model.TryParseExpressionSyntaxKindList.Add(SyntaxKind.VariableDeclarationNode);
- model.TryParseExpressionSyntaxKindList.Add(SyntaxKind.VariableReferenceNode);
- model.TryParseExpressionSyntaxKindList.Add(SyntaxKind.ConstructorInvocationExpressionNode);
+ compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Add(SyntaxKind.TypeClauseNode);
+ compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Add(SyntaxKind.VariableDeclarationNode);
+ compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Add(SyntaxKind.VariableReferenceNode);
+ compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Add(SyntaxKind.ConstructorInvocationExpressionNode);
- if (model.CurrentCodeBlockBuilder.CodeBlockOwner is not null &&
- model.CurrentCodeBlockBuilder.CodeBlockOwner.SyntaxKind != SyntaxKind.TypeDefinitionNode)
+ if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner is not null &&
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner.SyntaxKind != SyntaxKind.TypeDefinitionNode)
{
// There is a syntax conflict between a ConstructorDefinitionNode and a FunctionInvocationNode.
//
@@ -41,7 +41,7 @@ public static void ParseIdentifierToken(CSharpCompilationUnit compilationUnit)
// Then, it perhaps should be treated as a function invocation (or function definition).
// The main case for this being someone typing out pseudo code within a CodeBlockOwner
// that is a TypeDefinitionNode.
- model.TryParseExpressionSyntaxKindList.Add(SyntaxKind.FunctionInvocationNode);
+ compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Add(SyntaxKind.FunctionInvocationNode);
}
var successParse = ParseOthers.TryParseExpression(null, model, out var expressionNode);
@@ -49,7 +49,7 @@ public static void ParseIdentifierToken(CSharpCompilationUnit compilationUnit)
if (!successParse)
{
expressionNode = ParseOthers.ParseExpression(model);
- model.StatementBuilder.ChildList.Add(expressionNode);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
return;
}
@@ -59,8 +59,8 @@ public static void ParseIdentifierToken(CSharpCompilationUnit compilationUnit)
MoveToHandleTypeClauseNode(originalTokenIndex, (TypeClauseNode)expressionNode, model);
return;
case SyntaxKind.VariableDeclarationNode:
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenParenthesisToken ||
- model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenParenthesisToken ||
+ compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
{
MoveToHandleFunctionDefinition((VariableDeclarationNode)expressionNode, model);
return;
@@ -71,10 +71,10 @@ public static void ParseIdentifierToken(CSharpCompilationUnit compilationUnit)
case SyntaxKind.VariableReferenceNode:
case SyntaxKind.FunctionInvocationNode:
case SyntaxKind.ConstructorInvocationExpressionNode:
- model.StatementBuilder.ChildList.Add(expressionNode);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
return;
default:
- model.DiagnosticBag.ReportTodoException(model.TokenWalker.Current.TextSpan, $"nameof(ParseIdentifierToken) default case");
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(compilationUnit.ParserModel.TokenWalker.Current.TextSpan, $"nameof(ParseIdentifierToken) default case");
return;
}
}
@@ -92,30 +92,30 @@ public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode
{
var variableKind = VariableKind.Local;
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
- (model.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken &&
- model.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken))
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
+ (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken &&
+ compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken))
{
variableKind = VariableKind.Property;
}
- else if (model.CurrentCodeBlockBuilder.CodeBlockOwner is not null &&
- model.CurrentCodeBlockBuilder.CodeBlockOwner.SyntaxKind == SyntaxKind.TypeDefinitionNode)
+ else if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner is not null &&
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner.SyntaxKind == SyntaxKind.TypeDefinitionNode)
{
variableKind = VariableKind.Field;
}
((VariableDeclarationNode)variableDeclarationNode).VariableKind = variableKind;
- model.Binder.BindVariableDeclarationNode(variableDeclarationNode, model);
- model.CurrentCodeBlockBuilder.ChildList.Add(variableDeclarationNode);
- model.StatementBuilder.ChildList.Add(variableDeclarationNode);
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(variableDeclarationNode, model);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(variableDeclarationNode);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(variableDeclarationNode);
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
{
ParsePropertyDefinition((CSharpParserModel)model, variableDeclarationNode);
}
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken &&
- model.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken &&
+ compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
ParsePropertyDefinition_ExpressionBound((CSharpParserModel)model);
}
@@ -123,16 +123,16 @@ public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode
public static void MoveToHandleTypeClauseNode(int originalTokenIndex, TypeClauseNode typeClauseNode, CSharpCompilationUnit compilationUnit)
{
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.StatementDelimiterToken ||
- model.TokenWalker.Current.SyntaxKind == SyntaxKind.EndOfFileToken ||
- model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
- model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseBraceToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.StatementDelimiterToken ||
+ compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EndOfFileToken ||
+ compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
+ compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseBraceToken)
{
- model.StatementBuilder.ChildList.Add(typeClauseNode);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(typeClauseNode);
}
- else if (model.CurrentCodeBlockBuilder.CodeBlockOwner is TypeDefinitionNode typeDefinitionNode &&
+ else if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner is TypeDefinitionNode typeDefinitionNode &&
UtilityApi.IsConvertibleToIdentifierToken(typeClauseNode.TypeIdentifierToken.SyntaxKind) &&
- model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenParenthesisToken &&
+ compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenParenthesisToken &&
typeDefinitionNode.TypeIdentifierToken.TextSpan.GetText() == typeClauseNode.TypeIdentifierToken.TextSpan.GetText())
{
// ConstructorDefinitionNode
@@ -146,7 +146,7 @@ public static void MoveToHandleTypeClauseNode(int originalTokenIndex, TypeClause
}
else
{
- model.StatementBuilder.ChildList.Add(typeClauseNode);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(typeClauseNode);
}
return;
@@ -155,75 +155,75 @@ public static void MoveToHandleTypeClauseNode(int originalTokenIndex, TypeClause
public static void ParsePropertyDefinition(CSharpCompilationUnit compilationUnit, IVariableDeclarationNode variableDeclarationNode)
{
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
#endif
- var openBraceToken = (OpenBraceToken)model.TokenWalker.Consume();
+ var openBraceToken = (OpenBraceToken)compilationUnit.ParserModel.TokenWalker.Consume();
var openBraceCounter = 1;
while (true)
{
- if (model.TokenWalker.IsEof)
+ if (compilationUnit.ParserModel.TokenWalker.IsEof)
break;
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
{
++openBraceCounter;
}
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseBraceToken)
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseBraceToken)
{
if (--openBraceCounter <= 0)
break;
}
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.GetTokenContextualKeyword)
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.GetTokenContextualKeyword)
{
variableDeclarationNode.HasGetter = true;
}
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.SetTokenContextualKeyword)
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.SetTokenContextualKeyword)
{
variableDeclarationNode.HasSetter = true;
}
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
}
- var closeTokenIndex = model.TokenWalker.Index;
- var closeBraceToken = (CloseBraceToken)model.TokenWalker.Match(SyntaxKind.CloseBraceToken);
+ var closeTokenIndex = compilationUnit.ParserModel.TokenWalker.Index;
+ var closeBraceToken = (CloseBraceToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseBraceToken);
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
#endif
}
public static void ParsePropertyDefinition_ExpressionBound(CSharpCompilationUnit compilationUnit)
{
- var equalsToken = (EqualsToken)model.TokenWalker.Consume();
- var closeAngleBracketToken = (CloseAngleBracketToken)model.TokenWalker.Consume();
+ var equalsToken = (EqualsToken)compilationUnit.ParserModel.TokenWalker.Consume();
+ var closeAngleBracketToken = (CloseAngleBracketToken)compilationUnit.ParserModel.TokenWalker.Consume();
var expressionNode = ParseOthers.ParseExpression(model);
- var statementDelimiterToken = (StatementDelimiterToken)model.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
+ var statementDelimiterToken = (StatementDelimiterToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
}
public static void ParseColonToken(CSharpCompilationUnit compilationUnit)
{
- var colonToken = (ColonToken)model.TokenWalker.Consume();
+ var colonToken = (ColonToken)compilationUnit.ParserModel.TokenWalker.Consume();
- if (model.SyntaxStack.TryPeek(out var syntax) && syntax.SyntaxKind == SyntaxKind.TypeDefinitionNode)
+ if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out var syntax) && syntax.SyntaxKind == SyntaxKind.TypeDefinitionNode)
{
- var typeDefinitionNode = (TypeDefinitionNode)model.SyntaxStack.Pop();
- var inheritedTypeClauseNode = model.TokenWalker.MatchTypeClauseNode(model);
+ var typeDefinitionNode = (TypeDefinitionNode)compilationUnit.ParserModel.SyntaxStack.Pop();
+ var inheritedTypeClauseNode = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(model);
- model.Binder.BindTypeClauseNode(inheritedTypeClauseNode, model);
+ compilationUnit.ParserModel.Binder.BindTypeClauseNode(inheritedTypeClauseNode, model);
typeDefinitionNode.SetInheritedTypeClauseNode(inheritedTypeClauseNode);
- model.SyntaxStack.Push(typeDefinitionNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = typeDefinitionNode;
+ compilationUnit.ParserModel.SyntaxStack.Push(typeDefinitionNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = typeDefinitionNode;
}
else
{
- model.DiagnosticBag.ReportTodoException(colonToken.TextSpan, "Colon is in unexpected place.");
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(colonToken.TextSpan, "Colon is in unexpected place.");
}
}
@@ -233,32 +233,32 @@ public static void ParseColonToken(CSharpCompilationUnit compilationUnit)
///
public static void ParseOpenBraceToken(OpenBraceToken openBraceToken, CSharpCompilationUnit compilationUnit)
{
- if (model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner is null)
+ if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner is null)
{
- var arbitraryCodeBlockNode = new ArbitraryCodeBlockNode(model.CurrentCodeBlockBuilder.CodeBlockOwner);
- model.SyntaxStack.Push(arbitraryCodeBlockNode);
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = arbitraryCodeBlockNode;
+ var arbitraryCodeBlockNode = new ArbitraryCodeBlockNode(compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner);
+ compilationUnit.ParserModel.SyntaxStack.Push(arbitraryCodeBlockNode);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = arbitraryCodeBlockNode;
}
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner.SetOpenBraceToken(openBraceToken, model);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner.SetOpenBraceToken(openBraceToken, model);
- var parentScopeDirection = model.CurrentCodeBlockBuilder?.CodeBlockOwner?.ScopeDirectionKind ?? ScopeDirectionKind.Both;
+ var parentScopeDirection = compilationUnit.ParserModel.CurrentCodeBlockBuilder?.CodeBlockOwner?.ScopeDirectionKind ?? ScopeDirectionKind.Both;
if (parentScopeDirection == ScopeDirectionKind.Both)
{
- if (!model.CurrentCodeBlockBuilder.PermitInnerPendingCodeBlockOwnerToBeParsed)
+ if (!compilationUnit.ParserModel.CurrentCodeBlockBuilder.PermitInnerPendingCodeBlockOwnerToBeParsed)
{
- model.TokenWalker.DeferParsingOfChildScope(openBraceToken, model);
+ compilationUnit.ParserModel.TokenWalker.DeferParsingOfChildScope(openBraceToken, model);
return;
}
- model.CurrentCodeBlockBuilder.PermitInnerPendingCodeBlockOwnerToBeParsed = false;
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.PermitInnerPendingCodeBlockOwnerToBeParsed = false;
}
- var nextCodeBlockOwner = model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner;
+ var nextCodeBlockOwner = compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner;
var nextReturnTypeClauseNode = nextCodeBlockOwner.GetReturnTypeClauseNode();
- model.Binder.OpenScope(nextCodeBlockOwner, nextReturnTypeClauseNode, openBraceToken.TextSpan, model);
- model.CurrentCodeBlockBuilder = new(parent: model.CurrentCodeBlockBuilder, codeBlockOwner: nextCodeBlockOwner);
+ compilationUnit.ParserModel.Binder.OpenScope(nextCodeBlockOwner, nextReturnTypeClauseNode, openBraceToken.TextSpan, model);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder = new(parent: compilationUnit.ParserModel.CurrentCodeBlockBuilder, codeBlockOwner: nextCodeBlockOwner);
nextCodeBlockOwner.OnBoundScopeCreatedAndSetAsCurrent(model);
}
@@ -268,16 +268,16 @@ public static void ParseOpenBraceToken(OpenBraceToken openBraceToken, CSharpComp
///
public static void ParseCloseBraceToken(CloseBraceToken closeBraceToken, CSharpCompilationUnit compilationUnit)
{
- if (model.CurrentCodeBlockBuilder.ParseChildScopeQueue.TryDequeue(out var deferredChildScope))
+ if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.ParseChildScopeQueue.TryDequeue(out var deferredChildScope))
{
- deferredChildScope.PrepareMainParserLoop(model.TokenWalker.Index - 1, model);
+ deferredChildScope.PrepareMainParserLoop(compilationUnit.ParserModel.TokenWalker.Index - 1, model);
return;
}
- if (model.CurrentCodeBlockBuilder.CodeBlockOwner is not null)
- model.CurrentCodeBlockBuilder.CodeBlockOwner.SetCloseBraceToken(closeBraceToken, model);
+ if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner is not null)
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner.SetCloseBraceToken(closeBraceToken, model);
- model.Binder.CloseScope(closeBraceToken.TextSpan, model);
+ compilationUnit.ParserModel.Binder.CloseScope(closeBraceToken.TextSpan, model);
}
public static void ParseOpenParenthesisToken(CSharpCompilationUnit compilationUnit)
@@ -288,7 +288,7 @@ public static void ParseCloseParenthesisToken(
CloseParenthesisToken consumedCloseParenthesisToken,
CSharpCompilationUnit compilationUnit)
{
- var closesParenthesisToken = (CloseParenthesisToken)model.TokenWalker.Consume();
+ var closesParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Consume();
}
public static void ParseOpenAngleBracketToken(
@@ -305,11 +305,11 @@ public static void ParseCloseAngleBracketToken(
public static void ParseOpenSquareBracketToken(CSharpCompilationUnit compilationUnit)
{
- var openSquareBracketToken = (OpenSquareBracketToken)model.TokenWalker.Consume();
+ var openSquareBracketToken = (OpenSquareBracketToken)compilationUnit.ParserModel.TokenWalker.Consume();
- if (model.StatementBuilder.ChildList.Count != 0)
+ if (compilationUnit.ParserModel.StatementBuilder.ChildList.Count != 0)
{
- model.DiagnosticBag.ReportTodoException(
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(
openSquareBracketToken.TextSpan,
$"Unexpected '{nameof(OpenSquareBracketToken)}'");
return;
@@ -318,43 +318,43 @@ public static void ParseOpenSquareBracketToken(CSharpCompilationUnit compilation
var corruptState = false;
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
#endif
- while (!model.TokenWalker.IsEof)
+ while (!compilationUnit.ParserModel.TokenWalker.IsEof)
{
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenSquareBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenSquareBracketToken)
{
++openSquareBracketCounter;
}
- else if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseSquareBracketToken)
+ else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CloseSquareBracketToken)
{
if (--openSquareBracketCounter <= 0)
break;
}
else if (!corruptState)
{
- var tokenIndexOriginal = model.TokenWalker.Index;
+ var tokenIndexOriginal = compilationUnit.ParserModel.TokenWalker.Index;
- model.ExpressionList.Add((SyntaxKind.CloseSquareBracketToken, null));
- model.ExpressionList.Add((SyntaxKind.CommaToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseSquareBracketToken, null));
+ compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, null));
var expression = ParseOthers.ParseExpression(model);
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken)
- _ = model.TokenWalker.Consume();
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken)
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
- if (tokenIndexOriginal < model.TokenWalker.Index)
+ if (tokenIndexOriginal < compilationUnit.ParserModel.TokenWalker.Index)
continue; // Already consumed so avoid the one at the end of the while loop
}
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
}
- var closeTokenIndex = model.TokenWalker.Index;
- var closeSquareBracketToken = (CloseSquareBracketToken)model.TokenWalker.Match(SyntaxKind.CloseSquareBracketToken);
+ var closeTokenIndex = compilationUnit.ParserModel.TokenWalker.Index;
+ var closeSquareBracketToken = (CloseSquareBracketToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseSquareBracketToken);
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
#endif
}
@@ -366,18 +366,18 @@ public static void ParseCloseSquareBracketToken(
public static void ParseEqualsToken(CSharpCompilationUnit compilationUnit)
{
- if (model.StatementBuilder.ChildList.Count == 0)
+ if (compilationUnit.ParserModel.StatementBuilder.ChildList.Count == 0)
{
ParseOthers.StartStatement_Expression(model);
return;
}
- if (model.StatementBuilder.TryPeek(out var syntax) &&
+ if (compilationUnit.ParserModel.StatementBuilder.TryPeek(out var syntax) &&
syntax.SyntaxKind == SyntaxKind.VariableDeclarationNode)
{
var variableDeclarationNode = (VariableDeclarationNode)syntax;
- model.TokenWalker.Backtrack();
+ compilationUnit.ParserModel.TokenWalker.Backtrack();
var expression = ParseOthers.ParseExpression(model);
if (expression.SyntaxKind != SyntaxKind.VariableAssignmentExpressionNode)
@@ -386,7 +386,7 @@ public static void ParseEqualsToken(CSharpCompilationUnit compilationUnit)
return;
}
- model.StatementBuilder.ChildList.Add(expression);
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expression);
}
}
@@ -402,51 +402,51 @@ public static void ParseMemberAccessToken(
///
public static void ParseStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, CSharpCompilationUnit compilationUnit)
{
- if (model.SyntaxStack.TryPeek(out var syntax) && syntax.SyntaxKind == SyntaxKind.NamespaceStatementNode)
+ if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out var syntax) && syntax.SyntaxKind == SyntaxKind.NamespaceStatementNode)
{
- var closureCurrentCompilationUnitBuilder = model.CurrentCodeBlockBuilder;
+ var closureCurrentCompilationUnitBuilder = compilationUnit.ParserModel.CurrentCodeBlockBuilder;
ICodeBlockOwner? nextCodeBlockOwner = null;
TypeClauseNode? scopeReturnTypeClauseNode = null;
- var namespaceStatementNode = (NamespaceStatementNode)model.SyntaxStack.Pop();
+ var namespaceStatementNode = (NamespaceStatementNode)compilationUnit.ParserModel.SyntaxStack.Pop();
nextCodeBlockOwner = namespaceStatementNode;
namespaceStatementNode.SetStatementDelimiterToken(statementDelimiterToken, model);
- model.Binder.OpenScope(
+ compilationUnit.ParserModel.Binder.OpenScope(
nextCodeBlockOwner,
scopeReturnTypeClauseNode,
statementDelimiterToken.TextSpan,
model);
- model.Binder.AddNamespaceToCurrentScope(
+ compilationUnit.ParserModel.Binder.AddNamespaceToCurrentScope(
namespaceStatementNode.IdentifierToken.TextSpan.GetText(),
model);
- model.CurrentCodeBlockBuilder = new(model.CurrentCodeBlockBuilder, nextCodeBlockOwner);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder = new(compilationUnit.ParserModel.CurrentCodeBlockBuilder, nextCodeBlockOwner);
}
- else if (model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner is not null &&
- !model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner.OpenBraceToken.ConstructorWasInvoked)
+ else if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner is not null &&
+ !compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner.OpenBraceToken.ConstructorWasInvoked)
{
- var pendingChild = model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner;
+ var pendingChild = compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner;
- model.Binder.OpenScope(pendingChild, CSharpFacts.Types.Void.ToTypeClause(), statementDelimiterToken.TextSpan, model);
- model.CurrentCodeBlockBuilder = new(model.CurrentCodeBlockBuilder, pendingChild);
+ compilationUnit.ParserModel.Binder.OpenScope(pendingChild, CSharpFacts.Types.Void.ToTypeClause(), statementDelimiterToken.TextSpan, model);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder = new(compilationUnit.ParserModel.CurrentCodeBlockBuilder, pendingChild);
pendingChild.OnBoundScopeCreatedAndSetAsCurrent(model);
- model.Binder.CloseScope(statementDelimiterToken.TextSpan, model);
+ compilationUnit.ParserModel.Binder.CloseScope(statementDelimiterToken.TextSpan, model);
- if (model.CurrentCodeBlockBuilder.Parent is not null)
- model.CurrentCodeBlockBuilder = model.CurrentCodeBlockBuilder.Parent;
+ if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.Parent is not null)
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder = compilationUnit.ParserModel.CurrentCodeBlockBuilder.Parent;
- model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = null;
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = null;
}
}
public static void ParseKeywordToken(CSharpCompilationUnit compilationUnit)
{
// 'return', 'if', 'get', etc...
- switch (model.TokenWalker.Current.SyntaxKind)
+ switch (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)
{
case SyntaxKind.AsTokenKeyword:
ParseDefaultKeywords.HandleAsTokenKeyword(model);
@@ -690,7 +690,7 @@ public static void ParseKeywordToken(CSharpCompilationUnit compilationUnit)
public static void ParseKeywordContextualToken(CSharpCompilationUnit compilationUnit)
{
- switch (model.TokenWalker.Current.SyntaxKind)
+ switch (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)
{
case SyntaxKind.VarTokenContextualKeyword:
ParseContextualKeywords.HandleVarTokenContextualKeyword(model);
@@ -825,7 +825,7 @@ public static void ParseKeywordContextualToken(CSharpCompilationUnit compilation
ParseContextualKeywords.HandleUnrecognizedTokenContextualKeyword(model);
break;
default:
- model.DiagnosticBag.ReportTodoException(model.TokenWalker.Current.TextSpan, $"Implement the {model.TokenWalker.Current.SyntaxKind.ToString()} contextual keyword.");
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(compilationUnit.ParserModel.TokenWalker.Current.TextSpan, $"Implement the {compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind.ToString()} contextual keyword.");
break;
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
index 699fc69b4..3575b68c5 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
@@ -25,14 +25,14 @@ public static void HandleUndefinedTypeOrNamespaceReference(
///
public static GenericArgumentsListingNode HandleGenericArguments(CSharpCompilationUnit compilationUnit)
{
- var openAngleBracketToken = (OpenAngleBracketToken)model.TokenWalker.Consume();
+ var openAngleBracketToken = (OpenAngleBracketToken)compilationUnit.ParserModel.TokenWalker.Consume();
- if (SyntaxKind.CloseAngleBracketToken == model.TokenWalker.Current.SyntaxKind)
+ if (SyntaxKind.CloseAngleBracketToken == compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)
{
return new GenericArgumentsListingNode(
openAngleBracketToken,
ImmutableArray.Empty,
- (CloseAngleBracketToken)model.TokenWalker.Consume());
+ (CloseAngleBracketToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
var mutableGenericArgumentsListing = new List();
@@ -48,9 +48,9 @@ public static GenericArgumentsListingNode HandleGenericArguments(CSharpCompilati
var genericArgumentEntryNode = new GenericArgumentEntryNode(typeClauseNode);
mutableGenericArgumentsListing.Add(genericArgumentEntryNode);
- if (SyntaxKind.CommaToken == model.TokenWalker.Current.SyntaxKind)
+ if (SyntaxKind.CommaToken == compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)
{
- var commaToken = (CommaToken)model.TokenWalker.Consume();
+ var commaToken = (CommaToken)compilationUnit.ParserModel.TokenWalker.Consume();
// TODO: Track comma tokens?
//
@@ -62,7 +62,7 @@ public static GenericArgumentsListingNode HandleGenericArguments(CSharpCompilati
}
}
- var closeAngleBracketToken = (CloseAngleBracketToken)model.TokenWalker.Match(SyntaxKind.CloseAngleBracketToken);
+ var closeAngleBracketToken = (CloseAngleBracketToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseAngleBracketToken);
return new GenericArgumentsListingNode(
openAngleBracketToken,
@@ -101,7 +101,7 @@ public static TypeClauseNode MatchTypeClause(CSharpCompilationUnit compilationUn
}
else
{
- var syntaxToken = (IdentifierToken)model.TokenWalker.Match(SyntaxKind.IdentifierToken);
+ var syntaxToken = (IdentifierToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
return new TypeClauseNode(
syntaxToken,
@@ -111,15 +111,15 @@ public static TypeClauseNode MatchTypeClause(CSharpCompilationUnit compilationUn
/*ISyntaxToken syntaxToken;
- if (UtilityApi.IsKeywordSyntaxKind(model.TokenWalker.Current.SyntaxKind) &&
- (UtilityApi.IsTypeIdentifierKeywordSyntaxKind(model.TokenWalker.Current.SyntaxKind) ||
- UtilityApi.IsVarContextualKeyword(model, model.TokenWalker.Current.SyntaxKind)))
+ if (UtilityApi.IsKeywordSyntaxKind(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind) &&
+ (UtilityApi.IsTypeIdentifierKeywordSyntaxKind(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind) ||
+ UtilityApi.IsVarContextualKeyword(model, compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)))
{
- syntaxToken = model.TokenWalker.Consume();
+ syntaxToken = compilationUnit.ParserModel.TokenWalker.Consume();
}
else
{
- syntaxToken = model.TokenWalker.Match(SyntaxKind.IdentifierToken);
+ syntaxToken = compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
}
var typeClauseNode = new TypeClauseNode(
@@ -127,9 +127,9 @@ public static TypeClauseNode MatchTypeClause(CSharpCompilationUnit compilationUn
null,
null);
- model.Binder.BindTypeClauseNode(typeClauseNode, model);
+ compilationUnit.ParserModel.Binder.BindTypeClauseNode(typeClauseNode, model);
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
{
var genericParametersListingNode = (GenericParametersListingNode)ParseOthers.Force_ParseExpression(
SyntaxKind.GenericParametersListingNode,
@@ -138,16 +138,16 @@ public static TypeClauseNode MatchTypeClause(CSharpCompilationUnit compilationUn
typeClauseNode.SetGenericParametersListingNode(genericParametersListingNode);
}
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.QuestionMarkToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.QuestionMarkToken)
{
typeClauseNode.HasQuestionMark = true;
- _ = model.TokenWalker.Consume();
+ _ = compilationUnit.ParserModel.TokenWalker.Consume();
}
- while (model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenSquareBracketToken)
+ while (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenSquareBracketToken)
{
- var openSquareBracketToken = model.TokenWalker.Consume();
- var closeSquareBracketToken = model.TokenWalker.Match(SyntaxKind.CloseSquareBracketToken);
+ var openSquareBracketToken = compilationUnit.ParserModel.TokenWalker.Consume();
+ var closeSquareBracketToken = compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseSquareBracketToken);
var arraySyntaxTokenTextSpan = syntaxToken.TextSpan with
{
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
index d3020a399..59c6ace88 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
@@ -31,8 +31,8 @@ public static void HandleVariableReference(
variableKind,
false);
- model.Binder.BindVariableDeclarationNode(variableDeclarationNode, model);
- model.CurrentCodeBlockBuilder.ChildList.Add(variableDeclarationNode);
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(variableDeclarationNode, model);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(variableDeclarationNode);
return variableDeclarationNode;
}
@@ -56,14 +56,14 @@ public static void HandleVariableDeclarationStatement(
// if (variableKind == VariableKind.Local || variableKind == VariableKind.Closure)
- if (model.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken)
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken)
{
- if (model.TokenWalker.Peek(1).SyntaxKind == SyntaxKind.CloseAngleBracketToken)
+ if (compilationUnit.ParserModel.TokenWalker.Peek(1).SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
HandlePropertyExpression(
variableDeclarationNode,
- (EqualsToken)model.TokenWalker.Consume(),
- (CloseAngleBracketToken)model.TokenWalker.Consume(),
+ (EqualsToken)compilationUnit.ParserModel.TokenWalker.Consume(),
+ (CloseAngleBracketToken)compilationUnit.ParserModel.TokenWalker.Consume(),
(CSharpParserModel)model);
}
else
@@ -71,7 +71,7 @@ public static void HandleVariableDeclarationStatement(
// Variable initialization occurs here.
HandleVariableAssignment(
consumedIdentifierToken,
- (EqualsToken)model.TokenWalker.Consume(),
+ (EqualsToken)compilationUnit.ParserModel.TokenWalker.Consume(),
(CSharpParserModel)model);
}
}
@@ -80,22 +80,22 @@ public static void HandleVariableDeclarationStatement(
if (variableDeclarationNode.TypeClauseNode.TypeIdentifierToken.SyntaxKind ==
SyntaxKind.VarTokenContextualKeyword)
{
- model.DiagnosticBag.ReportImplicitlyTypedVariablesMustBeInitialized(
+ compilationUnit.ParserModel.DiagnosticBag.ReportImplicitlyTypedVariablesMustBeInitialized(
consumedIdentifierToken.TextSpan);
}
}
if (variableKind == VariableKind.Property &&
- model.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
+ compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
{
HandlePropertyDeclaration(
variableDeclarationNode,
- (OpenBraceToken)model.TokenWalker.Consume(),
+ (OpenBraceToken)compilationUnit.ParserModel.TokenWalker.Consume(),
(CSharpParserModel)model);
}
else
{
- _ = model.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
+ _ = compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
index ecdee05ea..13ea79e9f 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
@@ -18,14 +18,14 @@ public static void DeferParsingOfChildScope(
CSharpCompilationUnit compilationUnit)
{
// Pop off the 'TypeDefinitionNode', then push it back on when later dequeued.
- var pendingCodeBlockOwner = model.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner;
+ var pendingCodeBlockOwner = compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner;
var openTokenIndex = tokenWalker.Index - 1;
var openBraceCounter = 1;
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = true;
#endif
while (true)
@@ -50,10 +50,10 @@ public static void DeferParsingOfChildScope(
var closeBraceToken = (CloseBraceToken)tokenWalker.Match(SyntaxKind.CloseBraceToken);
#if DEBUG
- model.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
+ compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
#endif
- model.CurrentCodeBlockBuilder.ParseChildScopeQueue.Enqueue(new DeferredChildScope(
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ParseChildScopeQueue.Enqueue(new DeferredChildScope(
openTokenIndex,
closeTokenIndex,
pendingCodeBlockOwner));
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs
index 3d3b4116d..4b1dbc5a1 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs
@@ -216,11 +216,11 @@ public static TypeClauseNode ConvertToTypeClauseNode(ISyntax syntax, CSharpCompi
}
else
{
- // 'model.TokenWalker.Current.TextSpan' isn't necessarily the syntax passed to this method.
+ // 'compilationUnit.ParserModel.TokenWalker.Current.TextSpan' isn't necessarily the syntax passed to this method.
// TODO: But getting a TextSpan from a general type such as 'ISyntax' is a pain.
//
- model.DiagnosticBag.ReportTodoException(
- model.TokenWalker.Current.TextSpan,
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(
+ compilationUnit.ParserModel.TokenWalker.Current.TextSpan,
$"The {nameof(SyntaxKind)}: {syntax.SyntaxKind}, is not convertible to a {nameof(TypeClauseNode)}. Invoke {nameof(IsConvertibleToTypeClauseNode)} and check the result, before invoking {nameof(ConvertToTypeClauseNode)}.");
// TODO: Returning null when it can't be converted is a bad idea (the method return isn't documented as nullable).
@@ -247,11 +247,11 @@ public static IdentifierToken ConvertToIdentifierToken(ISyntax syntax, CSharpCom
}
else
{
- // 'model.TokenWalker.Current.TextSpan' isn't necessarily the syntax passed to this method.
+ // 'compilationUnit.ParserModel.TokenWalker.Current.TextSpan' isn't necessarily the syntax passed to this method.
// TODO: But getting a TextSpan from a general type such as 'ISyntax' is a pain.
//
- model.DiagnosticBag.ReportTodoException(
- model.TokenWalker.Current.TextSpan,
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(
+ compilationUnit.ParserModel.TokenWalker.Current.TextSpan,
$"The {nameof(SyntaxKind)}: {syntax.SyntaxKind}, is not convertible to a {nameof(IdentifierToken)}. Invoke {nameof(IsConvertibleToIdentifierToken)} and check the result, before invoking {nameof(ConvertToIdentifierToken)}.");
// TODO: Returning default when it can't be converted might be a fine idea? It isn't as bad as returning null.
From 13b1c5304ed6ef08f9f009100379d20114c0331b Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:32:34 -0500
Subject: [PATCH 17/39] DOES NOT BUILD: Fixing 'model)' to 'compilationUnit)'
---
.../Internals/ParseContextualKeywords.cs | 6 +-
.../Internals/ParseDefaultKeywords.cs | 94 +++++++++----------
.../ParserCase/Internals/ParseFunctions.cs | 14 +--
.../ParserCase/Internals/ParseOthers.cs | 20 ++--
4 files changed, 67 insertions(+), 67 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
index 6b9a8bc9a..19c5ad583 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
@@ -11,9 +11,9 @@ public class ParseContextualKeywords
public static void HandleVarTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
if (compilationUnit.ParserModel.StatementBuilder.ChildList.Count == 0)
- ParseTokens.ParseIdentifierToken(model);
+ ParseTokens.ParseIdentifierToken(compilationUnit);
else
- ParseOthers.StartStatement_Expression(model);
+ ParseOthers.StartStatement_Expression(compilationUnit);
}
public static void HandlePartialTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
@@ -168,7 +168,7 @@ public static void HandleOrderbyTokenContextualKeyword(CSharpCompilationUnit com
public static void HandleRecordTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
{
- ParseDefaultKeywords.HandleStorageModifierTokenKeyword(model);
+ ParseDefaultKeywords.HandleStorageModifierTokenKeyword(compilationUnit);
}
public static void HandleRemoveTokenContextualKeyword(CSharpCompilationUnit compilationUnit)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
index 37b17d483..a7a001b2f 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
@@ -22,7 +22,7 @@ public static void HandleBaseTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleBoolTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleBreakTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -32,13 +32,13 @@ public static void HandleBreakTokenKeyword(CSharpCompilationUnit compilationUnit
public static void HandleByteTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleCaseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.ColonToken, null));
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
var colonToken = (ColonToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.ColonToken);
}
@@ -48,7 +48,7 @@ public static void HandleCatchTokenKeyword(CSharpCompilationUnit compilationUnit
var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
- var typeClause = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(model);
+ var typeClause = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(compilationUnit);
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind != SyntaxKind.CloseParenthesisToken)
_ = (IdentifierToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
@@ -88,7 +88,7 @@ public static void HandleCatchTokenKeyword(CSharpCompilationUnit compilationUnit
public static void HandleCharTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleCheckedTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -108,7 +108,7 @@ public static void HandleContinueTokenKeyword(CSharpCompilationUnit compilationU
public static void HandleDecimalTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleDefaultTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -122,7 +122,7 @@ public static void HandleDefaultTokenKeyword(CSharpCompilationUnit compilationUn
public static void HandleDelegateTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleDoTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -146,7 +146,7 @@ public static void HandleDoTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleDoubleTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleElseTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -156,16 +156,16 @@ public static void HandleElseTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleEnumTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleStorageModifierTokenKeyword(model);
+ HandleStorageModifierTokenKeyword(compilationUnit);
// Why was this method invocation here? (2024-01-23)
//
- // HandleTypeIdentifierKeyword(model);
+ // HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleEventTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- model.StatementBuilder.ChildList.Add((KeywordToken)model.TokenWalker.Consume());
+ compilationUnit.ParserModel.StatementBuilder.ChildList.Add((KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume());
}
public static void HandleExplicitTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -180,7 +180,7 @@ public static void HandleExternTokenKeyword(CSharpCompilationUnit compilationUni
public static void HandleFalseTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
}
@@ -232,7 +232,7 @@ public static void HandleFixedTokenKeyword(CSharpCompilationUnit compilationUnit
public static void HandleFloatTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleForTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -257,7 +257,7 @@ public static void HandleForTokenKeyword(CSharpCompilationUnit compilationUnit)
{
// Initialization Case Three
// int i = 0;
- var typeClauseNode = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(model);
+ var typeClauseNode = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(compilationUnit);
var isCaseThree = !typeClauseNode.IsFabricated;
if (isCaseThree)
@@ -279,7 +279,7 @@ public static void HandleForTokenKeyword(CSharpCompilationUnit compilationUnit)
var equalsToken = (EqualsToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.EqualsToken);
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
- initializationExpressionNode = ParseOthers.ParseExpression(model);
+ initializationExpressionNode = ParseOthers.ParseExpression(compilationUnit);
initializationStatementDelimiterToken = (StatementDelimiterToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
}
@@ -296,7 +296,7 @@ public static void HandleForTokenKeyword(CSharpCompilationUnit compilationUnit)
// i < 10;
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
- conditionExpressionNode = ParseOthers.ParseExpression(model);
+ conditionExpressionNode = ParseOthers.ParseExpression(compilationUnit);
conditionStatementDelimiterToken = (StatementDelimiterToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
}
@@ -309,7 +309,7 @@ public static void HandleForTokenKeyword(CSharpCompilationUnit compilationUnit)
if (closeParenthesisToken.IsFabricated)
{
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
- updationExpressionNode = ParseOthers.ParseExpression(model);
+ updationExpressionNode = ParseOthers.ParseExpression(compilationUnit);
closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
@@ -346,7 +346,7 @@ public static void HandleForeachTokenKeyword(CSharpCompilationUnit compilationUn
var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
- var typeClauseNode = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(model);
+ var typeClauseNode = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(compilationUnit);
var variableIdentifierToken = (IdentifierToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.IdentifierToken);
var variableDeclarationStatementNode = new VariableDeclarationNode(
@@ -358,7 +358,7 @@ public static void HandleForeachTokenKeyword(CSharpCompilationUnit compilationUn
var inKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.InTokenKeyword);
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
var foreachStatementNode = new ForeachStatementNode(
@@ -391,7 +391,7 @@ public static void HandleInTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleIntTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleIsTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -406,7 +406,7 @@ public static void HandleLockTokenKeyword(CSharpCompilationUnit compilationUnit)
var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
@@ -423,17 +423,17 @@ public static void HandleLockTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleLongTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleNullTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleObjectTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleOperatorTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -469,12 +469,12 @@ public static void HandleRefTokenKeyword(CSharpCompilationUnit compilationUnit)
public static void HandleSbyteTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleShortTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleSizeofTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -489,12 +489,12 @@ public static void HandleStackallocTokenKeyword(CSharpCompilationUnit compilatio
public static void HandleStringTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleStructTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleStorageModifierTokenKeyword(model);
+ HandleStorageModifierTokenKeyword(compilationUnit);
}
public static void HandleSwitchTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -504,7 +504,7 @@ public static void HandleSwitchTokenKeyword(CSharpCompilationUnit compilationUni
var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
@@ -531,7 +531,7 @@ public static void HandleThrowTokenKeyword(CSharpCompilationUnit compilationUnit
public static void HandleTrueTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
}
@@ -566,12 +566,12 @@ public static void HandleTypeofTokenKeyword(CSharpCompilationUnit compilationUni
public static void HandleUintTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleUlongTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleUncheckedTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -586,12 +586,12 @@ public static void HandleUnsafeTokenKeyword(CSharpCompilationUnit compilationUni
public static void HandleUshortTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleVoidTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleTypeIdentifierKeyword(model);
+ HandleTypeIdentifierKeyword(compilationUnit);
}
public static void HandleVolatileTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -606,7 +606,7 @@ public static void HandleWhileTokenKeyword(CSharpCompilationUnit compilationUnit
var openParenthesisToken = (OpenParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.OpenParenthesisToken);
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
var closeParenthesisToken = (CloseParenthesisToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.CloseParenthesisToken);
@@ -648,7 +648,7 @@ public static void HandleDefault(CSharpCompilationUnit compilationUnit)
public static void HandleTypeIdentifierKeyword(CSharpCompilationUnit compilationUnit)
{
- ParseTokens.ParseIdentifierToken(model);
+ ParseTokens.ParseIdentifierToken(compilationUnit);
}
public static void HandleNewTokenKeyword(CSharpCompilationUnit compilationUnit)
@@ -656,7 +656,7 @@ public static void HandleNewTokenKeyword(CSharpCompilationUnit compilationUnit)
if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenParenthesisToken ||
UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind))
{
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
}
else
@@ -718,7 +718,7 @@ public static void HandleIfTokenKeyword(CSharpCompilationUnit compilationUnit)
return;
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, null));
- var expression = ParseOthers.ParseExpression(model);
+ var expression = ParseOthers.ParseExpression(compilationUnit);
var boundIfStatementNode = compilationUnit.ParserModel.Binder.BindIfStatementNode(ifTokenKeyword, expression);
compilationUnit.ParserModel.SyntaxStack.Push(boundIfStatementNode);
@@ -729,7 +729,7 @@ public static void HandleUsingTokenKeyword(CSharpCompilationUnit compilationUnit
{
var usingKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var handleNamespaceIdentifierResult = ParseOthers.HandleNamespaceIdentifier(model);
+ var handleNamespaceIdentifierResult = ParseOthers.HandleNamespaceIdentifier(compilationUnit);
if (handleNamespaceIdentifierResult.SyntaxKind == SyntaxKind.EmptyNode)
{
@@ -743,13 +743,13 @@ public static void HandleUsingTokenKeyword(CSharpCompilationUnit compilationUnit
usingKeywordToken,
namespaceIdentifier);
- compilationUnit.ParserModel.Binder.BindUsingStatementNode(usingStatementNode, model);
+ compilationUnit.ParserModel.Binder.BindUsingStatementNode(usingStatementNode, compilationUnit);
compilationUnit.ParserModel.StatementBuilder.ChildList.Add(usingStatementNode);
}
public static void HandleInterfaceTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleStorageModifierTokenKeyword(model);
+ HandleStorageModifierTokenKeyword(compilationUnit);
}
///
@@ -854,7 +854,7 @@ public static void HandleStorageModifierTokenKeyword(CSharpCompilationUnit compi
// Then:
GenericArgumentsListingNode? genericArgumentsListingNode = null;
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
- genericArgumentsListingNode = ParseTypes.HandleGenericArguments(model);
+ genericArgumentsListingNode = ParseTypes.HandleGenericArguments(compilationUnit);
var typeDefinitionNode = new TypeDefinitionNode(
accessModifierKind,
@@ -868,22 +868,22 @@ public static void HandleStorageModifierTokenKeyword(CSharpCompilationUnit compi
openBraceToken: default,
codeBlockNode: null);
- compilationUnit.ParserModel.Binder.BindTypeDefinitionNode(typeDefinitionNode, model);
- compilationUnit.ParserModel.Binder.BindTypeIdentifier(identifierToken, model);
+ compilationUnit.ParserModel.Binder.BindTypeDefinitionNode(typeDefinitionNode, compilationUnit);
+ compilationUnit.ParserModel.Binder.BindTypeIdentifier(identifierToken, compilationUnit);
compilationUnit.ParserModel.SyntaxStack.Push(typeDefinitionNode);
compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = typeDefinitionNode;
}
public static void HandleClassTokenKeyword(CSharpCompilationUnit compilationUnit)
{
- HandleStorageModifierTokenKeyword(model);
+ HandleStorageModifierTokenKeyword(compilationUnit);
}
public static void HandleNamespaceTokenKeyword(CSharpCompilationUnit compilationUnit)
{
var namespaceKeywordToken = (KeywordToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var handleNamespaceIdentifierResult = ParseOthers.HandleNamespaceIdentifier(model);
+ var handleNamespaceIdentifierResult = ParseOthers.HandleNamespaceIdentifier(compilationUnit);
if (handleNamespaceIdentifierResult.SyntaxKind == SyntaxKind.EmptyNode)
{
@@ -898,7 +898,7 @@ public static void HandleNamespaceTokenKeyword(CSharpCompilationUnit compilation
namespaceIdentifier,
null);
- compilationUnit.ParserModel.Binder.SetCurrentNamespaceStatementNode(namespaceStatementNode, model);
+ compilationUnit.ParserModel.Binder.SetCurrentNamespaceStatementNode(namespaceStatementNode, compilationUnit);
compilationUnit.ParserModel.SyntaxStack.Push(namespaceStatementNode);
compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = namespaceStatementNode;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
index 6a150b549..5d93fd564 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
@@ -29,7 +29,7 @@ public static void HandleFunctionDefinition(
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind != SyntaxKind.OpenParenthesisToken)
return;
- var functionArgumentsListingNode = HandleFunctionArguments(model);
+ var functionArgumentsListingNode = HandleFunctionArguments(compilationUnit);
var functionDefinitionNode = new FunctionDefinitionNode(
AccessModifierKind.Public,
@@ -40,7 +40,7 @@ public static void HandleFunctionDefinition(
null,
null);
- compilationUnit.ParserModel.Binder.BindFunctionDefinitionNode(functionDefinitionNode, model);
+ compilationUnit.ParserModel.Binder.BindFunctionDefinitionNode(functionDefinitionNode, compilationUnit);
compilationUnit.ParserModel.SyntaxStack.Push(functionDefinitionNode);
compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = functionDefinitionNode;
@@ -53,9 +53,9 @@ public static void HandleFunctionDefinition(
foreach (var argument in functionDefinitionNode.FunctionArgumentsListingNode.FunctionArgumentEntryNodeList)
{
if (argument.IsOptional)
- compilationUnit.ParserModel.Binder.BindFunctionOptionalArgument(argument, model);
+ compilationUnit.ParserModel.Binder.BindFunctionOptionalArgument(argument, compilationUnit);
else
- compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, model);
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, compilationUnit);
}
}
}
@@ -65,7 +65,7 @@ public static void HandleConstructorDefinition(
IdentifierToken consumedIdentifierToken,
CSharpCompilationUnit compilationUnit)
{
- var functionArgumentsListingNode = HandleFunctionArguments(model);
+ var functionArgumentsListingNode = HandleFunctionArguments(compilationUnit);
var typeClauseNode = new TypeClauseNode(
typeDefinitionNodeCodeBlockOwner.TypeIdentifierToken,
@@ -80,7 +80,7 @@ public static void HandleConstructorDefinition(
null,
null);
- compilationUnit.ParserModel.Binder.BindConstructorDefinitionIdentifierToken(consumedIdentifierToken, model);
+ compilationUnit.ParserModel.Binder.BindConstructorDefinitionIdentifierToken(consumedIdentifierToken, compilationUnit);
compilationUnit.ParserModel.SyntaxStack.Push(constructorDefinitionNode);
compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = constructorDefinitionNode;
@@ -160,7 +160,7 @@ public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpCompila
if (UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind))
{
- var identifierToken = UtilityApi.ConvertToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Consume(), model);
+ var identifierToken = UtilityApi.ConvertToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Consume(), compilationUnit);
successNameableToken = true;
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
index 1ee91a04a..681bd20a7 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
@@ -55,7 +55,7 @@ public static ISyntax HandleNamespaceIdentifier(CSharpCompilationUnit compilatio
public static void StartStatement_Expression(CSharpCompilationUnit compilationUnit)
{
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(expressionNode);
}
@@ -87,7 +87,7 @@ public static bool TryParseExpression(SyntaxKind? syntaxKind, CSharpCompilationU
try
{
- expressionNode = ParseExpression(model);
+ expressionNode = ParseExpression(compilationUnit);
#if DEBUG
Console.WriteLine($"try => {expressionNode.SyntaxKind}\n");
@@ -162,7 +162,7 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
break;
}
- expressionPrimary = BubbleUpParseExpression(i, expressionPrimary, model);
+ expressionPrimary = BubbleUpParseExpression(i, expressionPrimary, compilationUnit);
break;
}
}
@@ -170,11 +170,11 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
if (forceExit) // delimiterExpressionTuple.ExpressionNode is null
{
- expressionPrimary = BubbleUpParseExpression(0, expressionPrimary, model);
+ expressionPrimary = BubbleUpParseExpression(0, expressionPrimary, compilationUnit);
break;
}
- expressionPrimary = compilationUnit.ParserModel.Binder.AnyMergeToken(expressionPrimary, tokenCurrent, model);
+ expressionPrimary = compilationUnit.ParserModel.Binder.AnyMergeToken(expressionPrimary, tokenCurrent, compilationUnit);
#if DEBUG
Console.WriteLine($"\t=> {expressionPrimary.SyntaxKind}");
@@ -189,7 +189,7 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
if (compilationUnit.ParserModel.NoLongerRelevantExpressionNode is not null) // try finally is not needed to guarantee setting 'compilationUnit.ParserModel.NoLongerRelevantExpressionNode = null;' because this is an object reference comparison 'Object.ReferenceEquals'. Versus something more general that would break future parses if not properly cleared, like a SyntaxKind.
{
- compilationUnit.ParserModel.Binder.ClearFromExpressionList(compilationUnit.ParserModel.NoLongerRelevantExpressionNode, model);
+ compilationUnit.ParserModel.Binder.ClearFromExpressionList(compilationUnit.ParserModel.NoLongerRelevantExpressionNode, compilationUnit);
compilationUnit.ParserModel.NoLongerRelevantExpressionNode = null;
}
@@ -259,7 +259,7 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
expressionPrimary = compilationUnit.ParserModel.Binder.ForceDecisionAmbiguousIdentifier(
EmptyExpressionNode.Empty,
(AmbiguousIdentifierExpressionNode)expressionPrimary,
- model);
+ compilationUnit);
}
#if DEBUG
@@ -270,7 +270,7 @@ public static IExpressionNode ParseExpression(CSharpCompilationUnit compilationU
}
///
- /// 'BubbleUpParseExpression(i, expressionPrimary, model);'
+ /// 'BubbleUpParseExpression(i, expressionPrimary, compilationUnit);'
///
/// This is to have SyntaxKind.StatementDelimiterToken break out of the expression.
/// The parser is adding as the 0th item that
@@ -320,12 +320,12 @@ private static IExpressionNode BubbleUpParseExpression(int indexTriggered, IExpr
expressionPrimary = compilationUnit.ParserModel.Binder.AnyMergeExpression(
delimiterExpressionTuple.ExpressionNode,
expressionPrimary, // expressionSecondary
- model);
+ compilationUnit);
}
if (compilationUnit.ParserModel.NoLongerRelevantExpressionNode is not null) // try finally is not needed to guarantee setting 'compilationUnit.ParserModel.NoLongerRelevantExpressionNode = null;' because this is an object reference comparison 'Object.ReferenceEquals'. Versus something more general that would break future parses if not properly cleared, like a SyntaxKind.
{
- compilationUnit.ParserModel.Binder.ClearFromExpressionList(compilationUnit.ParserModel.NoLongerRelevantExpressionNode, model);
+ compilationUnit.ParserModel.Binder.ClearFromExpressionList(compilationUnit.ParserModel.NoLongerRelevantExpressionNode, compilationUnit);
compilationUnit.ParserModel.NoLongerRelevantExpressionNode = null;
}
From 7177aa716d03b4200efcc00d3a9acd38571df1da Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:36:56 -0500
Subject: [PATCH 18/39] DOES NOT BUILD: More fixing 'model)' to
'compilationUnit)'
---
.../ParserCase/Internals/ParseTokens.cs | 302 +++++++++---------
1 file changed, 151 insertions(+), 151 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
index e9dd09e6c..2e9d14ab2 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
@@ -48,7 +48,7 @@ public static void ParseIdentifierToken(CSharpCompilationUnit compilationUnit)
if (!successParse)
{
- expressionNode = ParseOthers.ParseExpression(model);
+ expressionNode = ParseOthers.ParseExpression(compilationUnit);
compilationUnit.ParserModel.StatementBuilder.ChildList.Add(expressionNode);
return;
}
@@ -56,17 +56,17 @@ public static void ParseIdentifierToken(CSharpCompilationUnit compilationUnit)
switch (expressionNode.SyntaxKind)
{
case SyntaxKind.TypeClauseNode:
- MoveToHandleTypeClauseNode(originalTokenIndex, (TypeClauseNode)expressionNode, model);
+ MoveToHandleTypeClauseNode(originalTokenIndex, (TypeClauseNode)expressionNode, compilationUnit);
return;
case SyntaxKind.VariableDeclarationNode:
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenParenthesisToken ||
compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
{
- MoveToHandleFunctionDefinition((VariableDeclarationNode)expressionNode, model);
+ MoveToHandleFunctionDefinition((VariableDeclarationNode)expressionNode, compilationUnit);
return;
}
- MoveToHandleVariableDeclarationNode((VariableDeclarationNode)expressionNode, model);
+ MoveToHandleVariableDeclarationNode((VariableDeclarationNode)expressionNode, compilationUnit);
return;
case SyntaxKind.VariableReferenceNode:
case SyntaxKind.FunctionInvocationNode:
@@ -85,7 +85,7 @@ public static void MoveToHandleFunctionDefinition(VariableDeclarationNode variab
variableDeclarationNode.IdentifierToken,
variableDeclarationNode.TypeClauseNode,
consumedGenericArgumentsListingNode: null,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
}
public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode variableDeclarationNode, CSharpCompilationUnit compilationUnit)
@@ -106,7 +106,7 @@ public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode
((VariableDeclarationNode)variableDeclarationNode).VariableKind = variableKind;
- compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(variableDeclarationNode, model);
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(variableDeclarationNode, compilationUnit);
compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(variableDeclarationNode);
compilationUnit.ParserModel.StatementBuilder.ChildList.Add(variableDeclarationNode);
@@ -117,7 +117,7 @@ public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode
else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken &&
compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
- ParsePropertyDefinition_ExpressionBound((CSharpParserModel)model);
+ ParsePropertyDefinition_ExpressionBound((CSharpParserModel)compilationUnit);
}
}
@@ -137,12 +137,12 @@ public static void MoveToHandleTypeClauseNode(int originalTokenIndex, TypeClause
{
// ConstructorDefinitionNode
- var identifierToken = UtilityApi.ConvertToIdentifierToken(typeClauseNode.TypeIdentifierToken, model);
+ var identifierToken = UtilityApi.ConvertToIdentifierToken(typeClauseNode.TypeIdentifierToken, compilationUnit);
ParseFunctions.HandleConstructorDefinition(
typeDefinitionNode,
identifierToken,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
}
else
{
@@ -201,7 +201,7 @@ public static void ParsePropertyDefinition_ExpressionBound(CSharpCompilationUnit
var equalsToken = (EqualsToken)compilationUnit.ParserModel.TokenWalker.Consume();
var closeAngleBracketToken = (CloseAngleBracketToken)compilationUnit.ParserModel.TokenWalker.Consume();
- var expressionNode = ParseOthers.ParseExpression(model);
+ var expressionNode = ParseOthers.ParseExpression(compilationUnit);
var statementDelimiterToken = (StatementDelimiterToken)compilationUnit.ParserModel.TokenWalker.Match(SyntaxKind.StatementDelimiterToken);
}
@@ -212,9 +212,9 @@ public static void ParseColonToken(CSharpCompilationUnit compilationUnit)
if (compilationUnit.ParserModel.SyntaxStack.TryPeek(out var syntax) && syntax.SyntaxKind == SyntaxKind.TypeDefinitionNode)
{
var typeDefinitionNode = (TypeDefinitionNode)compilationUnit.ParserModel.SyntaxStack.Pop();
- var inheritedTypeClauseNode = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(model);
+ var inheritedTypeClauseNode = compilationUnit.ParserModel.TokenWalker.MatchTypeClauseNode(compilationUnit);
- compilationUnit.ParserModel.Binder.BindTypeClauseNode(inheritedTypeClauseNode, model);
+ compilationUnit.ParserModel.Binder.BindTypeClauseNode(inheritedTypeClauseNode, compilationUnit);
typeDefinitionNode.SetInheritedTypeClauseNode(inheritedTypeClauseNode);
@@ -240,14 +240,14 @@ public static void ParseOpenBraceToken(OpenBraceToken openBraceToken, CSharpComp
compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = arbitraryCodeBlockNode;
}
- compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner.SetOpenBraceToken(openBraceToken, model);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner.SetOpenBraceToken(openBraceToken, compilationUnit);
var parentScopeDirection = compilationUnit.ParserModel.CurrentCodeBlockBuilder?.CodeBlockOwner?.ScopeDirectionKind ?? ScopeDirectionKind.Both;
if (parentScopeDirection == ScopeDirectionKind.Both)
{
if (!compilationUnit.ParserModel.CurrentCodeBlockBuilder.PermitInnerPendingCodeBlockOwnerToBeParsed)
{
- compilationUnit.ParserModel.TokenWalker.DeferParsingOfChildScope(openBraceToken, model);
+ compilationUnit.ParserModel.TokenWalker.DeferParsingOfChildScope(openBraceToken, compilationUnit);
return;
}
@@ -257,9 +257,9 @@ public static void ParseOpenBraceToken(OpenBraceToken openBraceToken, CSharpComp
var nextCodeBlockOwner = compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner;
var nextReturnTypeClauseNode = nextCodeBlockOwner.GetReturnTypeClauseNode();
- compilationUnit.ParserModel.Binder.OpenScope(nextCodeBlockOwner, nextReturnTypeClauseNode, openBraceToken.TextSpan, model);
+ compilationUnit.ParserModel.Binder.OpenScope(nextCodeBlockOwner, nextReturnTypeClauseNode, openBraceToken.TextSpan, compilationUnit);
compilationUnit.ParserModel.CurrentCodeBlockBuilder = new(parent: compilationUnit.ParserModel.CurrentCodeBlockBuilder, codeBlockOwner: nextCodeBlockOwner);
- nextCodeBlockOwner.OnBoundScopeCreatedAndSetAsCurrent(model);
+ nextCodeBlockOwner.OnBoundScopeCreatedAndSetAsCurrent(compilationUnit);
}
///
@@ -270,14 +270,14 @@ public static void ParseCloseBraceToken(CloseBraceToken closeBraceToken, CSharpC
{
if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.ParseChildScopeQueue.TryDequeue(out var deferredChildScope))
{
- deferredChildScope.PrepareMainParserLoop(compilationUnit.ParserModel.TokenWalker.Index - 1, model);
+ deferredChildScope.PrepareMainParserLoop(compilationUnit.ParserModel.TokenWalker.Index - 1, compilationUnit);
return;
}
if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner is not null)
- compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner.SetCloseBraceToken(closeBraceToken, model);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner.SetCloseBraceToken(closeBraceToken, compilationUnit);
- compilationUnit.ParserModel.Binder.CloseScope(closeBraceToken.TextSpan, model);
+ compilationUnit.ParserModel.Binder.CloseScope(closeBraceToken.TextSpan, compilationUnit);
}
public static void ParseOpenParenthesisToken(CSharpCompilationUnit compilationUnit)
@@ -338,7 +338,7 @@ public static void ParseOpenSquareBracketToken(CSharpCompilationUnit compilation
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseSquareBracketToken, null));
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, null));
- var expression = ParseOthers.ParseExpression(model);
+ var expression = ParseOthers.ParseExpression(compilationUnit);
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken)
_ = compilationUnit.ParserModel.TokenWalker.Consume();
@@ -368,7 +368,7 @@ public static void ParseEqualsToken(CSharpCompilationUnit compilationUnit)
{
if (compilationUnit.ParserModel.StatementBuilder.ChildList.Count == 0)
{
- ParseOthers.StartStatement_Expression(model);
+ ParseOthers.StartStatement_Expression(compilationUnit);
return;
}
@@ -378,7 +378,7 @@ public static void ParseEqualsToken(CSharpCompilationUnit compilationUnit)
var variableDeclarationNode = (VariableDeclarationNode)syntax;
compilationUnit.ParserModel.TokenWalker.Backtrack();
- var expression = ParseOthers.ParseExpression(model);
+ var expression = ParseOthers.ParseExpression(compilationUnit);
if (expression.SyntaxKind != SyntaxKind.VariableAssignmentExpressionNode)
{
@@ -411,17 +411,17 @@ public static void ParseStatementDelimiterToken(StatementDelimiterToken statemen
var namespaceStatementNode = (NamespaceStatementNode)compilationUnit.ParserModel.SyntaxStack.Pop();
nextCodeBlockOwner = namespaceStatementNode;
- namespaceStatementNode.SetStatementDelimiterToken(statementDelimiterToken, model);
+ namespaceStatementNode.SetStatementDelimiterToken(statementDelimiterToken, compilationUnit);
compilationUnit.ParserModel.Binder.OpenScope(
nextCodeBlockOwner,
scopeReturnTypeClauseNode,
statementDelimiterToken.TextSpan,
- model);
+ compilationUnit);
compilationUnit.ParserModel.Binder.AddNamespaceToCurrentScope(
namespaceStatementNode.IdentifierToken.TextSpan.GetText(),
- model);
+ compilationUnit);
compilationUnit.ParserModel.CurrentCodeBlockBuilder = new(compilationUnit.ParserModel.CurrentCodeBlockBuilder, nextCodeBlockOwner);
}
@@ -430,11 +430,11 @@ public static void ParseStatementDelimiterToken(StatementDelimiterToken statemen
{
var pendingChild = compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner;
- compilationUnit.ParserModel.Binder.OpenScope(pendingChild, CSharpFacts.Types.Void.ToTypeClause(), statementDelimiterToken.TextSpan, model);
+ compilationUnit.ParserModel.Binder.OpenScope(pendingChild, CSharpFacts.Types.Void.ToTypeClause(), statementDelimiterToken.TextSpan, compilationUnit);
compilationUnit.ParserModel.CurrentCodeBlockBuilder = new(compilationUnit.ParserModel.CurrentCodeBlockBuilder, pendingChild);
- pendingChild.OnBoundScopeCreatedAndSetAsCurrent(model);
+ pendingChild.OnBoundScopeCreatedAndSetAsCurrent(compilationUnit);
- compilationUnit.ParserModel.Binder.CloseScope(statementDelimiterToken.TextSpan, model);
+ compilationUnit.ParserModel.Binder.CloseScope(statementDelimiterToken.TextSpan, compilationUnit);
if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.Parent is not null)
compilationUnit.ParserModel.CurrentCodeBlockBuilder = compilationUnit.ParserModel.CurrentCodeBlockBuilder.Parent;
@@ -449,241 +449,241 @@ public static void ParseKeywordToken(CSharpCompilationUnit compilationUnit)
switch (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)
{
case SyntaxKind.AsTokenKeyword:
- ParseDefaultKeywords.HandleAsTokenKeyword(model);
+ ParseDefaultKeywords.HandleAsTokenKeyword(compilationUnit);
break;
case SyntaxKind.BaseTokenKeyword:
- ParseDefaultKeywords.HandleBaseTokenKeyword(model);
+ ParseDefaultKeywords.HandleBaseTokenKeyword(compilationUnit);
break;
case SyntaxKind.BoolTokenKeyword:
- ParseDefaultKeywords.HandleBoolTokenKeyword(model);
+ ParseDefaultKeywords.HandleBoolTokenKeyword(compilationUnit);
break;
case SyntaxKind.BreakTokenKeyword:
- ParseDefaultKeywords.HandleBreakTokenKeyword(model);
+ ParseDefaultKeywords.HandleBreakTokenKeyword(compilationUnit);
break;
case SyntaxKind.ByteTokenKeyword:
- ParseDefaultKeywords.HandleByteTokenKeyword(model);
+ ParseDefaultKeywords.HandleByteTokenKeyword(compilationUnit);
break;
case SyntaxKind.CaseTokenKeyword:
- ParseDefaultKeywords.HandleCaseTokenKeyword(model);
+ ParseDefaultKeywords.HandleCaseTokenKeyword(compilationUnit);
break;
case SyntaxKind.CatchTokenKeyword:
- ParseDefaultKeywords.HandleCatchTokenKeyword(model);
+ ParseDefaultKeywords.HandleCatchTokenKeyword(compilationUnit);
break;
case SyntaxKind.CharTokenKeyword:
- ParseDefaultKeywords.HandleCharTokenKeyword(model);
+ ParseDefaultKeywords.HandleCharTokenKeyword(compilationUnit);
break;
case SyntaxKind.CheckedTokenKeyword:
- ParseDefaultKeywords.HandleCheckedTokenKeyword(model);
+ ParseDefaultKeywords.HandleCheckedTokenKeyword(compilationUnit);
break;
case SyntaxKind.ConstTokenKeyword:
- ParseDefaultKeywords.HandleConstTokenKeyword(model);
+ ParseDefaultKeywords.HandleConstTokenKeyword(compilationUnit);
break;
case SyntaxKind.ContinueTokenKeyword:
- ParseDefaultKeywords.HandleContinueTokenKeyword(model);
+ ParseDefaultKeywords.HandleContinueTokenKeyword(compilationUnit);
break;
case SyntaxKind.DecimalTokenKeyword:
- ParseDefaultKeywords.HandleDecimalTokenKeyword(model);
+ ParseDefaultKeywords.HandleDecimalTokenKeyword(compilationUnit);
break;
case SyntaxKind.DefaultTokenKeyword:
- ParseDefaultKeywords.HandleDefaultTokenKeyword(model);
+ ParseDefaultKeywords.HandleDefaultTokenKeyword(compilationUnit);
break;
case SyntaxKind.DelegateTokenKeyword:
- ParseDefaultKeywords.HandleDelegateTokenKeyword(model);
+ ParseDefaultKeywords.HandleDelegateTokenKeyword(compilationUnit);
break;
case SyntaxKind.DoTokenKeyword:
- ParseDefaultKeywords.HandleDoTokenKeyword(model);
+ ParseDefaultKeywords.HandleDoTokenKeyword(compilationUnit);
break;
case SyntaxKind.DoubleTokenKeyword:
- ParseDefaultKeywords.HandleDoubleTokenKeyword(model);
+ ParseDefaultKeywords.HandleDoubleTokenKeyword(compilationUnit);
break;
case SyntaxKind.ElseTokenKeyword:
- ParseDefaultKeywords.HandleElseTokenKeyword(model);
+ ParseDefaultKeywords.HandleElseTokenKeyword(compilationUnit);
break;
case SyntaxKind.EnumTokenKeyword:
- ParseDefaultKeywords.HandleEnumTokenKeyword(model);
+ ParseDefaultKeywords.HandleEnumTokenKeyword(compilationUnit);
break;
case SyntaxKind.EventTokenKeyword:
- ParseDefaultKeywords.HandleEventTokenKeyword(model);
+ ParseDefaultKeywords.HandleEventTokenKeyword(compilationUnit);
break;
case SyntaxKind.ExplicitTokenKeyword:
- ParseDefaultKeywords.HandleExplicitTokenKeyword(model);
+ ParseDefaultKeywords.HandleExplicitTokenKeyword(compilationUnit);
break;
case SyntaxKind.ExternTokenKeyword:
- ParseDefaultKeywords.HandleExternTokenKeyword(model);
+ ParseDefaultKeywords.HandleExternTokenKeyword(compilationUnit);
break;
case SyntaxKind.FalseTokenKeyword:
- ParseDefaultKeywords.HandleFalseTokenKeyword(model);
+ ParseDefaultKeywords.HandleFalseTokenKeyword(compilationUnit);
break;
case SyntaxKind.FinallyTokenKeyword:
- ParseDefaultKeywords.HandleFinallyTokenKeyword(model);
+ ParseDefaultKeywords.HandleFinallyTokenKeyword(compilationUnit);
break;
case SyntaxKind.FixedTokenKeyword:
- ParseDefaultKeywords.HandleFixedTokenKeyword(model);
+ ParseDefaultKeywords.HandleFixedTokenKeyword(compilationUnit);
break;
case SyntaxKind.FloatTokenKeyword:
- ParseDefaultKeywords.HandleFloatTokenKeyword(model);
+ ParseDefaultKeywords.HandleFloatTokenKeyword(compilationUnit);
break;
case SyntaxKind.ForTokenKeyword:
- ParseDefaultKeywords.HandleForTokenKeyword(model);
+ ParseDefaultKeywords.HandleForTokenKeyword(compilationUnit);
break;
case SyntaxKind.ForeachTokenKeyword:
- ParseDefaultKeywords.HandleForeachTokenKeyword(model);
+ ParseDefaultKeywords.HandleForeachTokenKeyword(compilationUnit);
break;
case SyntaxKind.GotoTokenKeyword:
- ParseDefaultKeywords.HandleGotoTokenKeyword(model);
+ ParseDefaultKeywords.HandleGotoTokenKeyword(compilationUnit);
break;
case SyntaxKind.ImplicitTokenKeyword:
- ParseDefaultKeywords.HandleImplicitTokenKeyword(model);
+ ParseDefaultKeywords.HandleImplicitTokenKeyword(compilationUnit);
break;
case SyntaxKind.InTokenKeyword:
- ParseDefaultKeywords.HandleInTokenKeyword(model);
+ ParseDefaultKeywords.HandleInTokenKeyword(compilationUnit);
break;
case SyntaxKind.IntTokenKeyword:
- ParseDefaultKeywords.HandleIntTokenKeyword(model);
+ ParseDefaultKeywords.HandleIntTokenKeyword(compilationUnit);
break;
case SyntaxKind.IsTokenKeyword:
- ParseDefaultKeywords.HandleIsTokenKeyword(model);
+ ParseDefaultKeywords.HandleIsTokenKeyword(compilationUnit);
break;
case SyntaxKind.LockTokenKeyword:
- ParseDefaultKeywords.HandleLockTokenKeyword(model);
+ ParseDefaultKeywords.HandleLockTokenKeyword(compilationUnit);
break;
case SyntaxKind.LongTokenKeyword:
- ParseDefaultKeywords.HandleLongTokenKeyword(model);
+ ParseDefaultKeywords.HandleLongTokenKeyword(compilationUnit);
break;
case SyntaxKind.NullTokenKeyword:
- ParseDefaultKeywords.HandleNullTokenKeyword(model);
+ ParseDefaultKeywords.HandleNullTokenKeyword(compilationUnit);
break;
case SyntaxKind.ObjectTokenKeyword:
- ParseDefaultKeywords.HandleObjectTokenKeyword(model);
+ ParseDefaultKeywords.HandleObjectTokenKeyword(compilationUnit);
break;
case SyntaxKind.OperatorTokenKeyword:
- ParseDefaultKeywords.HandleOperatorTokenKeyword(model);
+ ParseDefaultKeywords.HandleOperatorTokenKeyword(compilationUnit);
break;
case SyntaxKind.OutTokenKeyword:
- ParseDefaultKeywords.HandleOutTokenKeyword(model);
+ ParseDefaultKeywords.HandleOutTokenKeyword(compilationUnit);
break;
case SyntaxKind.ParamsTokenKeyword:
- ParseDefaultKeywords.HandleParamsTokenKeyword(model);
+ ParseDefaultKeywords.HandleParamsTokenKeyword(compilationUnit);
break;
case SyntaxKind.ProtectedTokenKeyword:
- ParseDefaultKeywords.HandleProtectedTokenKeyword(model);
+ ParseDefaultKeywords.HandleProtectedTokenKeyword(compilationUnit);
break;
case SyntaxKind.ReadonlyTokenKeyword:
- ParseDefaultKeywords.HandleReadonlyTokenKeyword(model);
+ ParseDefaultKeywords.HandleReadonlyTokenKeyword(compilationUnit);
break;
case SyntaxKind.RefTokenKeyword:
- ParseDefaultKeywords.HandleRefTokenKeyword(model);
+ ParseDefaultKeywords.HandleRefTokenKeyword(compilationUnit);
break;
case SyntaxKind.SbyteTokenKeyword:
- ParseDefaultKeywords.HandleSbyteTokenKeyword(model);
+ ParseDefaultKeywords.HandleSbyteTokenKeyword(compilationUnit);
break;
case SyntaxKind.ShortTokenKeyword:
- ParseDefaultKeywords.HandleShortTokenKeyword(model);
+ ParseDefaultKeywords.HandleShortTokenKeyword(compilationUnit);
break;
case SyntaxKind.SizeofTokenKeyword:
- ParseDefaultKeywords.HandleSizeofTokenKeyword(model);
+ ParseDefaultKeywords.HandleSizeofTokenKeyword(compilationUnit);
break;
case SyntaxKind.StackallocTokenKeyword:
- ParseDefaultKeywords.HandleStackallocTokenKeyword(model);
+ ParseDefaultKeywords.HandleStackallocTokenKeyword(compilationUnit);
break;
case SyntaxKind.StringTokenKeyword:
- ParseDefaultKeywords.HandleStringTokenKeyword(model);
+ ParseDefaultKeywords.HandleStringTokenKeyword(compilationUnit);
break;
case SyntaxKind.StructTokenKeyword:
- ParseDefaultKeywords.HandleStructTokenKeyword(model);
+ ParseDefaultKeywords.HandleStructTokenKeyword(compilationUnit);
break;
case SyntaxKind.SwitchTokenKeyword:
- ParseDefaultKeywords.HandleSwitchTokenKeyword(model);
+ ParseDefaultKeywords.HandleSwitchTokenKeyword(compilationUnit);
break;
case SyntaxKind.ThisTokenKeyword:
- ParseDefaultKeywords.HandleThisTokenKeyword(model);
+ ParseDefaultKeywords.HandleThisTokenKeyword(compilationUnit);
break;
case SyntaxKind.ThrowTokenKeyword:
- ParseDefaultKeywords.HandleThrowTokenKeyword(model);
+ ParseDefaultKeywords.HandleThrowTokenKeyword(compilationUnit);
break;
case SyntaxKind.TrueTokenKeyword:
- ParseDefaultKeywords.HandleTrueTokenKeyword(model);
+ ParseDefaultKeywords.HandleTrueTokenKeyword(compilationUnit);
break;
case SyntaxKind.TryTokenKeyword:
- ParseDefaultKeywords.HandleTryTokenKeyword(model);
+ ParseDefaultKeywords.HandleTryTokenKeyword(compilationUnit);
break;
case SyntaxKind.TypeofTokenKeyword:
- ParseDefaultKeywords.HandleTypeofTokenKeyword(model);
+ ParseDefaultKeywords.HandleTypeofTokenKeyword(compilationUnit);
break;
case SyntaxKind.UintTokenKeyword:
- ParseDefaultKeywords.HandleUintTokenKeyword(model);
+ ParseDefaultKeywords.HandleUintTokenKeyword(compilationUnit);
break;
case SyntaxKind.UlongTokenKeyword:
- ParseDefaultKeywords.HandleUlongTokenKeyword(model);
+ ParseDefaultKeywords.HandleUlongTokenKeyword(compilationUnit);
break;
case SyntaxKind.UncheckedTokenKeyword:
- ParseDefaultKeywords.HandleUncheckedTokenKeyword(model);
+ ParseDefaultKeywords.HandleUncheckedTokenKeyword(compilationUnit);
break;
case SyntaxKind.UnsafeTokenKeyword:
- ParseDefaultKeywords.HandleUnsafeTokenKeyword(model);
+ ParseDefaultKeywords.HandleUnsafeTokenKeyword(compilationUnit);
break;
case SyntaxKind.UshortTokenKeyword:
- ParseDefaultKeywords.HandleUshortTokenKeyword(model);
+ ParseDefaultKeywords.HandleUshortTokenKeyword(compilationUnit);
break;
case SyntaxKind.VoidTokenKeyword:
- ParseDefaultKeywords.HandleVoidTokenKeyword(model);
+ ParseDefaultKeywords.HandleVoidTokenKeyword(compilationUnit);
break;
case SyntaxKind.VolatileTokenKeyword:
- ParseDefaultKeywords.HandleVolatileTokenKeyword(model);
+ ParseDefaultKeywords.HandleVolatileTokenKeyword(compilationUnit);
break;
case SyntaxKind.WhileTokenKeyword:
- ParseDefaultKeywords.HandleWhileTokenKeyword(model);
+ ParseDefaultKeywords.HandleWhileTokenKeyword(compilationUnit);
break;
case SyntaxKind.UnrecognizedTokenKeyword:
- ParseDefaultKeywords.HandleUnrecognizedTokenKeyword(model);
+ ParseDefaultKeywords.HandleUnrecognizedTokenKeyword(compilationUnit);
break;
case SyntaxKind.ReturnTokenKeyword:
- ParseDefaultKeywords.HandleReturnTokenKeyword(model);
+ ParseDefaultKeywords.HandleReturnTokenKeyword(compilationUnit);
break;
case SyntaxKind.NamespaceTokenKeyword:
- ParseDefaultKeywords.HandleNamespaceTokenKeyword(model);
+ ParseDefaultKeywords.HandleNamespaceTokenKeyword(compilationUnit);
break;
case SyntaxKind.ClassTokenKeyword:
- ParseDefaultKeywords.HandleClassTokenKeyword(model);
+ ParseDefaultKeywords.HandleClassTokenKeyword(compilationUnit);
break;
case SyntaxKind.InterfaceTokenKeyword:
- ParseDefaultKeywords.HandleInterfaceTokenKeyword(model);
+ ParseDefaultKeywords.HandleInterfaceTokenKeyword(compilationUnit);
break;
case SyntaxKind.UsingTokenKeyword:
- ParseDefaultKeywords.HandleUsingTokenKeyword(model);
+ ParseDefaultKeywords.HandleUsingTokenKeyword(compilationUnit);
break;
case SyntaxKind.PublicTokenKeyword:
- ParseDefaultKeywords.HandlePublicTokenKeyword(model);
+ ParseDefaultKeywords.HandlePublicTokenKeyword(compilationUnit);
break;
case SyntaxKind.InternalTokenKeyword:
- ParseDefaultKeywords.HandleInternalTokenKeyword(model);
+ ParseDefaultKeywords.HandleInternalTokenKeyword(compilationUnit);
break;
case SyntaxKind.PrivateTokenKeyword:
- ParseDefaultKeywords.HandlePrivateTokenKeyword(model);
+ ParseDefaultKeywords.HandlePrivateTokenKeyword(compilationUnit);
break;
case SyntaxKind.StaticTokenKeyword:
- ParseDefaultKeywords.HandleStaticTokenKeyword(model);
+ ParseDefaultKeywords.HandleStaticTokenKeyword(compilationUnit);
break;
case SyntaxKind.OverrideTokenKeyword:
- ParseDefaultKeywords.HandleOverrideTokenKeyword(model);
+ ParseDefaultKeywords.HandleOverrideTokenKeyword(compilationUnit);
break;
case SyntaxKind.VirtualTokenKeyword:
- ParseDefaultKeywords.HandleVirtualTokenKeyword(model);
+ ParseDefaultKeywords.HandleVirtualTokenKeyword(compilationUnit);
break;
case SyntaxKind.AbstractTokenKeyword:
- ParseDefaultKeywords.HandleAbstractTokenKeyword(model);
+ ParseDefaultKeywords.HandleAbstractTokenKeyword(compilationUnit);
break;
case SyntaxKind.SealedTokenKeyword:
- ParseDefaultKeywords.HandleSealedTokenKeyword(model);
+ ParseDefaultKeywords.HandleSealedTokenKeyword(compilationUnit);
break;
case SyntaxKind.IfTokenKeyword:
- ParseDefaultKeywords.HandleIfTokenKeyword(model);
+ ParseDefaultKeywords.HandleIfTokenKeyword(compilationUnit);
break;
case SyntaxKind.NewTokenKeyword:
- ParseDefaultKeywords.HandleNewTokenKeyword(model);
+ ParseDefaultKeywords.HandleNewTokenKeyword(compilationUnit);
break;
default:
- ParseDefaultKeywords.HandleDefault(model);
+ ParseDefaultKeywords.HandleDefault(compilationUnit);
break;
}
}
@@ -693,136 +693,136 @@ public static void ParseKeywordContextualToken(CSharpCompilationUnit compilation
switch (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)
{
case SyntaxKind.VarTokenContextualKeyword:
- ParseContextualKeywords.HandleVarTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleVarTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.PartialTokenContextualKeyword:
- ParseContextualKeywords.HandlePartialTokenContextualKeyword(model);
+ ParseContextualKeywords.HandlePartialTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.AddTokenContextualKeyword:
- ParseContextualKeywords.HandleAddTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleAddTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.AndTokenContextualKeyword:
- ParseContextualKeywords.HandleAndTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleAndTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.AliasTokenContextualKeyword:
- ParseContextualKeywords.HandleAliasTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleAliasTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.AscendingTokenContextualKeyword:
- ParseContextualKeywords.HandleAscendingTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleAscendingTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.ArgsTokenContextualKeyword:
- ParseContextualKeywords.HandleArgsTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleArgsTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.AsyncTokenContextualKeyword:
- ParseContextualKeywords.HandleAsyncTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleAsyncTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.AwaitTokenContextualKeyword:
- ParseContextualKeywords.HandleAwaitTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleAwaitTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.ByTokenContextualKeyword:
- ParseContextualKeywords.HandleByTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleByTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.DescendingTokenContextualKeyword:
- ParseContextualKeywords.HandleDescendingTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleDescendingTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.DynamicTokenContextualKeyword:
- ParseContextualKeywords.HandleDynamicTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleDynamicTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.EqualsTokenContextualKeyword:
- ParseContextualKeywords.HandleEqualsTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleEqualsTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.FileTokenContextualKeyword:
- ParseContextualKeywords.HandleFileTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleFileTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.FromTokenContextualKeyword:
- ParseContextualKeywords.HandleFromTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleFromTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.GetTokenContextualKeyword:
- ParseContextualKeywords.HandleGetTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleGetTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.GlobalTokenContextualKeyword:
- ParseContextualKeywords.HandleGlobalTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleGlobalTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.GroupTokenContextualKeyword:
- ParseContextualKeywords.HandleGroupTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleGroupTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.InitTokenContextualKeyword:
- ParseContextualKeywords.HandleInitTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleInitTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.IntoTokenContextualKeyword:
- ParseContextualKeywords.HandleIntoTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleIntoTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.JoinTokenContextualKeyword:
- ParseContextualKeywords.HandleJoinTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleJoinTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.LetTokenContextualKeyword:
- ParseContextualKeywords.HandleLetTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleLetTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.ManagedTokenContextualKeyword:
- ParseContextualKeywords.HandleManagedTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleManagedTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.NameofTokenContextualKeyword:
- ParseContextualKeywords.HandleNameofTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleNameofTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.NintTokenContextualKeyword:
- ParseContextualKeywords.HandleNintTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleNintTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.NotTokenContextualKeyword:
- ParseContextualKeywords.HandleNotTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleNotTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.NotnullTokenContextualKeyword:
- ParseContextualKeywords.HandleNotnullTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleNotnullTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.NuintTokenContextualKeyword:
- ParseContextualKeywords.HandleNuintTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleNuintTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.OnTokenContextualKeyword:
- ParseContextualKeywords.HandleOnTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleOnTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.OrTokenContextualKeyword:
- ParseContextualKeywords.HandleOrTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleOrTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.OrderbyTokenContextualKeyword:
- ParseContextualKeywords.HandleOrderbyTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleOrderbyTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.RecordTokenContextualKeyword:
- ParseContextualKeywords.HandleRecordTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleRecordTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.RemoveTokenContextualKeyword:
- ParseContextualKeywords.HandleRemoveTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleRemoveTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.RequiredTokenContextualKeyword:
- ParseContextualKeywords.HandleRequiredTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleRequiredTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.ScopedTokenContextualKeyword:
- ParseContextualKeywords.HandleScopedTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleScopedTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.SelectTokenContextualKeyword:
- ParseContextualKeywords.HandleSelectTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleSelectTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.SetTokenContextualKeyword:
- ParseContextualKeywords.HandleSetTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleSetTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.UnmanagedTokenContextualKeyword:
- ParseContextualKeywords.HandleUnmanagedTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleUnmanagedTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.ValueTokenContextualKeyword:
- ParseContextualKeywords.HandleValueTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleValueTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.WhenTokenContextualKeyword:
- ParseContextualKeywords.HandleWhenTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleWhenTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.WhereTokenContextualKeyword:
- ParseContextualKeywords.HandleWhereTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleWhereTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.WithTokenContextualKeyword:
- ParseContextualKeywords.HandleWithTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleWithTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.YieldTokenContextualKeyword:
- ParseContextualKeywords.HandleYieldTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleYieldTokenContextualKeyword(compilationUnit);
break;
case SyntaxKind.UnrecognizedTokenContextualKeyword:
- ParseContextualKeywords.HandleUnrecognizedTokenContextualKeyword(model);
+ ParseContextualKeywords.HandleUnrecognizedTokenContextualKeyword(compilationUnit);
break;
default:
compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(compilationUnit.ParserModel.TokenWalker.Current.TextSpan, $"Implement the {compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind.ToString()} contextual keyword.");
From 441dc28b2c6d51968583c01f0f09219e844568c6 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:42:12 -0500
Subject: [PATCH 19/39] DOES NOT BUILD: Changed 'model)' to 'compilationUnit)'
---
.../BinderCase/CSharpBinder.Expressions.cs | 154 +++++++++---------
.../CSharp/BinderCase/CSharpBinder.Main.cs | 58 +++----
.../CSharp/ParserCase/Internals/ParseTypes.cs | 6 +-
.../ParserCase/Internals/ParseVariables.cs | 10 +-
.../Internals/TokenWalkerExtensionMethods.cs | 2 +-
5 files changed, 115 insertions(+), 115 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
index b99a845ec..324904cfe 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
@@ -43,7 +43,7 @@ public IExpressionNode AnyMergeToken(
ForceDecisionAmbiguousIdentifier(
EmptyExpressionNode.Empty,
ambiguousIdentifierExpressionNode,
- model);
+ compilationUnit);
}
}
@@ -53,37 +53,37 @@ public IExpressionNode AnyMergeToken(
switch (expressionPrimary.SyntaxKind)
{
case SyntaxKind.EmptyExpressionNode:
- return EmptyMergeToken((EmptyExpressionNode)expressionPrimary, token, model);
+ return EmptyMergeToken((EmptyExpressionNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.LiteralExpressionNode:
- return LiteralMergeToken((LiteralExpressionNode)expressionPrimary, token, model);
+ return LiteralMergeToken((LiteralExpressionNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.BinaryExpressionNode:
- return BinaryMergeToken((BinaryExpressionNode)expressionPrimary, token, model);
+ return BinaryMergeToken((BinaryExpressionNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.ParenthesizedExpressionNode:
- return ParenthesizedMergeToken((ParenthesizedExpressionNode)expressionPrimary, token, model);
+ return ParenthesizedMergeToken((ParenthesizedExpressionNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.CommaSeparatedExpressionNode:
- return CommaSeparatedMergeToken((CommaSeparatedExpressionNode)expressionPrimary, token, model);
+ return CommaSeparatedMergeToken((CommaSeparatedExpressionNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.FunctionInvocationNode:
- return FunctionInvocationMergeToken((FunctionInvocationNode)expressionPrimary, token, model);
+ return FunctionInvocationMergeToken((FunctionInvocationNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.LambdaExpressionNode:
- return LambdaMergeToken((LambdaExpressionNode)expressionPrimary, token, model);
+ return LambdaMergeToken((LambdaExpressionNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.ConstructorInvocationExpressionNode:
- return ConstructorInvocationMergeToken((ConstructorInvocationExpressionNode)expressionPrimary, token, model);
+ return ConstructorInvocationMergeToken((ConstructorInvocationExpressionNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.ExplicitCastNode:
- return ExplicitCastMergeToken((ExplicitCastNode)expressionPrimary, token, model);
+ return ExplicitCastMergeToken((ExplicitCastNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.AmbiguousIdentifierExpressionNode:
- return AmbiguousIdentifierMergeToken((AmbiguousIdentifierExpressionNode)expressionPrimary, token, model);
+ return AmbiguousIdentifierMergeToken((AmbiguousIdentifierExpressionNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.TypeClauseNode:
- return TypeClauseMergeToken((TypeClauseNode)expressionPrimary, token, model);
+ return TypeClauseMergeToken((TypeClauseNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.VariableAssignmentExpressionNode:
- return VariableAssignmentMergeToken((VariableAssignmentExpressionNode)expressionPrimary, token, model);
+ return VariableAssignmentMergeToken((VariableAssignmentExpressionNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.GenericParametersListingNode:
- return GenericParametersListingMergeToken((GenericParametersListingNode)expressionPrimary, token, model);
+ return GenericParametersListingMergeToken((GenericParametersListingNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.FunctionParametersListingNode:
- return FunctionParametersListingMergeToken((FunctionParametersListingNode)expressionPrimary, token, model);
+ return FunctionParametersListingMergeToken((FunctionParametersListingNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.FunctionArgumentsListingNode:
- return FunctionArgumentsListingMergeToken((FunctionArgumentsListingNode)expressionPrimary, token, model);
+ return FunctionArgumentsListingMergeToken((FunctionArgumentsListingNode)expressionPrimary, token, compilationUnit);
case SyntaxKind.BadExpressionNode:
- return BadMergeToken((BadExpressionNode)expressionPrimary, token, model);
+ return BadMergeToken((BadExpressionNode)expressionPrimary, token, compilationUnit);
default:
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), expressionPrimary, token);
};
@@ -103,29 +103,29 @@ public IExpressionNode AnyMergeExpression(
switch (expressionPrimary.SyntaxKind)
{
case SyntaxKind.ParenthesizedExpressionNode:
- return ParenthesizedMergeExpression((ParenthesizedExpressionNode)expressionPrimary, expressionSecondary, model);
+ return ParenthesizedMergeExpression((ParenthesizedExpressionNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.CommaSeparatedExpressionNode:
- return CommaSeparatedMergeExpression((CommaSeparatedExpressionNode)expressionPrimary, expressionSecondary, model);
+ return CommaSeparatedMergeExpression((CommaSeparatedExpressionNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.FunctionInvocationNode:
- return FunctionInvocationMergeExpression((FunctionInvocationNode)expressionPrimary, expressionSecondary, model);
+ return FunctionInvocationMergeExpression((FunctionInvocationNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.LambdaExpressionNode:
- return LambdaMergeExpression((LambdaExpressionNode)expressionPrimary, expressionSecondary, model);
+ return LambdaMergeExpression((LambdaExpressionNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.ConstructorInvocationExpressionNode:
- return ConstructorInvocationMergeExpression((ConstructorInvocationExpressionNode)expressionPrimary, expressionSecondary, model);
+ return ConstructorInvocationMergeExpression((ConstructorInvocationExpressionNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.AmbiguousIdentifierExpressionNode:
- return AmbiguousIdentifierMergeExpression((AmbiguousIdentifierExpressionNode)expressionPrimary, expressionSecondary, model);
+ return AmbiguousIdentifierMergeExpression((AmbiguousIdentifierExpressionNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.TypeClauseNode:
- return TypeClauseMergeExpression((TypeClauseNode)expressionPrimary, expressionSecondary, model);
+ return TypeClauseMergeExpression((TypeClauseNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.VariableAssignmentExpressionNode:
- return VariableAssignmentMergeExpression((VariableAssignmentExpressionNode)expressionPrimary, expressionSecondary, model);
+ return VariableAssignmentMergeExpression((VariableAssignmentExpressionNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.GenericParametersListingNode:
- return GenericParametersListingMergeExpression((GenericParametersListingNode)expressionPrimary, expressionSecondary, model);
+ return GenericParametersListingMergeExpression((GenericParametersListingNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.FunctionParametersListingNode:
- return FunctionParametersListingMergeExpression((FunctionParametersListingNode)expressionPrimary, expressionSecondary, model);
+ return FunctionParametersListingMergeExpression((FunctionParametersListingNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.FunctionArgumentsListingNode:
- return FunctionArgumentsListingMergeExpression((FunctionArgumentsListingNode)expressionPrimary, expressionSecondary, model);
+ return FunctionArgumentsListingMergeExpression((FunctionArgumentsListingNode)expressionPrimary, expressionSecondary, compilationUnit);
case SyntaxKind.BadExpressionNode:
- return BadMergeExpression((BadExpressionNode)expressionPrimary, expressionSecondary, model);
+ return BadMergeExpression((BadExpressionNode)expressionPrimary, expressionSecondary, compilationUnit);
default:
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), expressionPrimary, expressionSecondary);
};
@@ -152,7 +152,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
BindFunctionInvocationNode(
functionInvocationNode,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, functionInvocationNode));
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, functionInvocationNode.FunctionParametersListingNode));
@@ -186,7 +186,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
var lambdaExpressionNode = new LambdaExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
- SetLambdaExpressionNodeVariableDeclarationNodeList(lambdaExpressionNode, ambiguousIdentifierExpressionNode, model);
+ SetLambdaExpressionNodeVariableDeclarationNodeList(lambdaExpressionNode, ambiguousIdentifierExpressionNode, compilationUnit);
return lambdaExpressionNode;
}
@@ -194,7 +194,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
if (UtilityApi.IsConvertibleToIdentifierToken(ambiguousIdentifierExpressionNode.Token.SyntaxKind))
{
var variableAssignmentNode = new VariableAssignmentExpressionNode(
- UtilityApi.ConvertToIdentifierToken(ambiguousIdentifierExpressionNode.Token, model),
+ UtilityApi.ConvertToIdentifierToken(ambiguousIdentifierExpressionNode.Token, compilationUnit),
(EqualsToken)token,
EmptyExpressionNode.Empty);
@@ -214,7 +214,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
ForceDecisionAmbiguousIdentifier(
EmptyExpressionNode.Empty,
ambiguousIdentifierExpressionNode,
- model);
+ compilationUnit);
_ = compilationUnit.ParserModel.TokenWalker.Consume(); // Consume the IsTokenKeyword
@@ -227,7 +227,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
}
else if (UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind))
{
- ParseTokens.ParseIdentifierToken((CSharpParserModel)model); // Parse the type pattern matching / variable declaration
+ ParseTokens.ParseIdentifierToken((CSharpParserModel)compilationUnit); // Parse the type pattern matching / variable declaration
}
// Guaranteed to consume 1 further than the secondary loop so have to backtrack 1 time as well.
@@ -240,7 +240,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
ForceDecisionAmbiguousIdentifier(
EmptyExpressionNode.Empty,
ambiguousIdentifierExpressionNode,
- model);
+ compilationUnit);
if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenBraceToken)
{
@@ -290,7 +290,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
var decidedExpression = ForceDecisionAmbiguousIdentifier(
EmptyExpressionNode.Empty,
ambiguousIdentifierExpressionNode,
- model);
+ compilationUnit);
if (decidedExpression.SyntaxKind != SyntaxKind.TypeClauseNode)
{
@@ -306,7 +306,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
(TypeClauseNode)decidedExpression,
identifierToken,
VariableKind.Local,
- model);
+ compilationUnit);
return variableDeclarationNode;
}
@@ -344,11 +344,11 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
ambiguousIdentifierExpressionNode.Token.TextSpan.GetText(),
out var existingVariableDeclarationNode))
{
- var identifierToken = UtilityApi.ConvertToIdentifierToken(ambiguousIdentifierExpressionNode.Token, model);
+ var identifierToken = UtilityApi.ConvertToIdentifierToken(ambiguousIdentifierExpressionNode.Token, compilationUnit);
var variableReferenceNode = ConstructAndBindVariableReferenceNode(
identifierToken,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
return variableReferenceNode;
}
@@ -364,8 +364,8 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
ambiguousIdentifierExpressionNode.Token.TextSpan.GetText(),
out var typeDefinitionNode))
{
- var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, model);
- BindTypeClauseNode(typeClauseNode, (CSharpParserModel)model);
+ var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, compilationUnit);
+ BindTypeClauseNode(typeClauseNode, (CSharpParserModel)compilationUnit);
return typeClauseNode;
}
}
@@ -374,19 +374,19 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
if (!forceVariableReferenceNode ||
UtilityApi.IsConvertibleToTypeClauseNode(ambiguousIdentifierExpressionNode.Token.SyntaxKind))
{
- var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, model);
- BindTypeClauseNode(typeClauseNode, (CSharpParserModel)model);
+ var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, compilationUnit);
+ BindTypeClauseNode(typeClauseNode, (CSharpParserModel)compilationUnit);
return typeClauseNode;
}
// Bind an undefined-variable
if (UtilityApi.IsConvertibleToIdentifierToken(ambiguousIdentifierExpressionNode.Token.SyntaxKind))
{
- var identifierToken = UtilityApi.ConvertToIdentifierToken(ambiguousIdentifierExpressionNode.Token, model);
+ var identifierToken = UtilityApi.ConvertToIdentifierToken(ambiguousIdentifierExpressionNode.Token, compilationUnit);
var variableReferenceNode = ConstructAndBindVariableReferenceNode(
identifierToken,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
return variableReferenceNode;
}
@@ -502,11 +502,11 @@ public IExpressionNode ConstructorInvocationMergeToken(
{
if (UtilityApi.IsConvertibleToTypeClauseNode(token.SyntaxKind))
{
- var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(token, model);
+ var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(token, compilationUnit);
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
return constructorInvocationExpressionNode.SetTypeClauseNode(typeClauseNode);
}
@@ -615,7 +615,7 @@ public IExpressionNode ConstructorInvocationMergeExpression(
expressionSecondary = ForceDecisionAmbiguousIdentifier(
constructorInvocationExpressionNode,
(AmbiguousIdentifierExpressionNode)expressionSecondary,
- model);
+ compilationUnit);
}
if (expressionSecondary.SyntaxKind == SyntaxKind.EmptyExpressionNode)
@@ -709,7 +709,7 @@ public IExpressionNode ConstructorInvocationMergeExpression(
expressionSecondary = ForceDecisionAmbiguousIdentifier(
constructorInvocationExpressionNode,
(AmbiguousIdentifierExpressionNode)expressionSecondary,
- model);
+ compilationUnit);
}
objectInitializationParameterEntryNode.ExpressionNode = expressionSecondary;
@@ -761,7 +761,7 @@ public IExpressionNode EmptyMergeToken(
return ForceDecisionAmbiguousIdentifier(
emptyExpressionNode,
ambiguousExpressionNode,
- model);
+ compilationUnit);
}
return ambiguousExpressionNode;
@@ -802,17 +802,17 @@ public IExpressionNode EmptyMergeToken(
case SyntaxKind.AsyncTokenContextualKeyword:
return new LambdaExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
case SyntaxKind.DollarSignToken:
- BindStringInterpolationExpression((DollarSignToken)token, (CSharpParserModel)model);
+ BindStringInterpolationExpression((DollarSignToken)token, (CSharpParserModel)compilationUnit);
return emptyExpressionNode;
case SyntaxKind.AtToken:
- BindStringVerbatimExpression((AtToken)token, (CSharpParserModel)model);
+ BindStringVerbatimExpression((AtToken)token, (CSharpParserModel)compilationUnit);
return emptyExpressionNode;
case SyntaxKind.OutTokenKeyword:
if (UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind))
{
// Parse the variable reference / variable declaration
- ParseTokens.ParseIdentifierToken((CSharpParserModel)model);
+ ParseTokens.ParseIdentifierToken((CSharpParserModel)compilationUnit);
}
return emptyExpressionNode;
@@ -883,11 +883,11 @@ public IExpressionNode GenericParametersListingMergeExpression(
{
var expressionSecondaryTyped = (AmbiguousIdentifierExpressionNode)expressionSecondary;
- var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(expressionSecondaryTyped.Token, model);
+ var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(expressionSecondaryTyped.Token, compilationUnit);
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
genericParametersListingNode.GenericParameterEntryNodeList.Add(
new GenericParameterEntryNode(typeClauseNode));
@@ -915,7 +915,7 @@ public IExpressionNode GenericParametersListingMergeExpression(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
genericParametersListingNode.GenericParameterEntryNodeList.Add(
new GenericParameterEntryNode(typeClauseNode));
@@ -951,7 +951,7 @@ public IExpressionNode FunctionParametersListingMergeExpression(
expressionSecondary = ForceDecisionAmbiguousIdentifier(
functionParametersListingNode,
(AmbiguousIdentifierExpressionNode)expressionSecondary,
- model);
+ compilationUnit);
}
var functionParameterEntryNode = new FunctionParameterEntryNode(
@@ -989,7 +989,7 @@ public IExpressionNode FunctionArgumentsListingMergeExpression(
expressionSecondary = ForceDecisionAmbiguousIdentifier(
functionArgumentsListingNode,
(AmbiguousIdentifierExpressionNode)expressionSecondary,
- model);
+ compilationUnit);
}
var functionArgumentEntryNode = new FunctionArgumentEntryNode(
@@ -1028,7 +1028,7 @@ public IExpressionNode LambdaMergeToken(
token.TextSpan.SourceText);
((CSharpBinder)compilationUnit.ParserModel.Binder).AddSymbolDefinition(
- new LambdaSymbol(textSpan, lambdaExpressionNode), (CSharpParserModel)model);
+ new LambdaSymbol(textSpan, lambdaExpressionNode), (CSharpParserModel)compilationUnit);
if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenBraceToken)
{
@@ -1159,7 +1159,7 @@ public IExpressionNode ParenthesizedMergeToken(
{
var typeClauseNode = (TypeClauseNode)parenthesizedExpressionNode.InnerExpression;
var explicitCastNode = new ExplicitCastNode(parenthesizedExpressionNode.OpenParenthesisToken, typeClauseNode);
- return ExplicitCastMergeToken(explicitCastNode, token, model);
+ return ExplicitCastMergeToken(explicitCastNode, token, compilationUnit);
}
return parenthesizedExpressionNode.SetCloseParenthesisToken((CloseParenthesisToken)token);
@@ -1167,7 +1167,7 @@ public IExpressionNode ParenthesizedMergeToken(
if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
var lambdaExpressionNode = new LambdaExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
- SetLambdaExpressionNodeVariableDeclarationNodeList(lambdaExpressionNode, parenthesizedExpressionNode.InnerExpression, model);
+ SetLambdaExpressionNodeVariableDeclarationNodeList(lambdaExpressionNode, parenthesizedExpressionNode.InnerExpression, compilationUnit);
return lambdaExpressionNode;
}
@@ -1184,11 +1184,11 @@ public IExpressionNode ParenthesizedMergeExpression(
compilationUnit.ParserModel.TokenWalker.Peek(2).SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
var lambdaExpressionNode = new LambdaExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
- return SetLambdaExpressionNodeVariableDeclarationNodeList(lambdaExpressionNode, expressionSecondary, model);
+ return SetLambdaExpressionNodeVariableDeclarationNodeList(lambdaExpressionNode, expressionSecondary, compilationUnit);
}
if (expressionSecondary.SyntaxKind == SyntaxKind.AmbiguousIdentifierExpressionNode)
- expressionSecondary = ForceDecisionAmbiguousIdentifier(parenthesizedExpressionNode, (AmbiguousIdentifierExpressionNode)expressionSecondary, model);
+ expressionSecondary = ForceDecisionAmbiguousIdentifier(parenthesizedExpressionNode, (AmbiguousIdentifierExpressionNode)expressionSecondary, compilationUnit);
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.CommaToken)
{
@@ -1215,7 +1215,7 @@ public IExpressionNode ParenthesizedMergeExpression(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
return new ExplicitCastNode(parenthesizedExpressionNode.OpenParenthesisToken, typeClauseNode);
}
@@ -1268,7 +1268,7 @@ public IExpressionNode TypeClauseMergeToken(
closeParenthesisToken: default);
var functionInvocationNode = new FunctionInvocationNode(
- UtilityApi.ConvertToIdentifierToken(typeClauseNode.TypeIdentifierToken, model),
+ UtilityApi.ConvertToIdentifierToken(typeClauseNode.TypeIdentifierToken, compilationUnit),
functionDefinitionNode: null,
typeClauseNode.GenericParametersListingNode,
functionParametersListingNode,
@@ -1276,7 +1276,7 @@ public IExpressionNode TypeClauseMergeToken(
BindFunctionInvocationNode(
functionInvocationNode,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, functionInvocationNode));
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, functionInvocationNode.FunctionParametersListingNode));
@@ -1290,7 +1290,7 @@ public IExpressionNode TypeClauseMergeToken(
default:
if (UtilityApi.IsConvertibleToIdentifierToken(token.SyntaxKind))
{
- var identifierToken = UtilityApi.ConvertToIdentifierToken(token, model);
+ var identifierToken = UtilityApi.ConvertToIdentifierToken(token, compilationUnit);
var isRootExpression = true;
foreach (var tuple in compilationUnit.ParserModel.ExpressionList)
@@ -1327,7 +1327,7 @@ public IExpressionNode TypeClauseMergeToken(
typeClauseNode,
identifierToken,
VariableKind.Local,
- model);
+ compilationUnit);
}
return variableDeclarationNode;
@@ -1393,7 +1393,7 @@ public IExpressionNode FunctionInvocationMergeExpression(
{
if (expressionSecondary.SyntaxKind == SyntaxKind.AmbiguousIdentifierExpressionNode)
{
- expressionSecondary = ForceDecisionAmbiguousIdentifier(functionInvocationNode, (AmbiguousIdentifierExpressionNode)expressionSecondary, model);
+ expressionSecondary = ForceDecisionAmbiguousIdentifier(functionInvocationNode, (AmbiguousIdentifierExpressionNode)expressionSecondary, compilationUnit);
}
switch (expressionSecondary.SyntaxKind)
@@ -1420,11 +1420,11 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
{
var ambiguousIdentifierExpressionNode = (AmbiguousIdentifierExpressionNode)badExpressionNode.SyntaxList[0];
- var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, model);
+ var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, compilationUnit);
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
var identifierToken = (IdentifierToken)badExpressionNode.SyntaxList[1];
@@ -1432,7 +1432,7 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
typeClauseNode,
identifierToken,
VariableKind.Local,
- model);
+ compilationUnit);
lambdaExpressionNode.AddVariableDeclarationNode(variableDeclarationNode);
}
@@ -1462,11 +1462,11 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
if (firstSyntax.SyntaxKind == SyntaxKind.AmbiguousIdentifierExpressionNode)
{
var ambiguousIdentifierExpressionNode = (AmbiguousIdentifierExpressionNode)firstSyntax;
- typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, model);
+ typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, compilationUnit);
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
}
else if (firstSyntax.SyntaxKind == SyntaxKind.IdentifierToken)
{
@@ -1475,7 +1475,7 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
}
var secondSyntax = badExpressionNode.SyntaxList[++i];
@@ -1517,7 +1517,7 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
typeClauseNode,
(IdentifierToken)variableIdentifier,
VariableKind.Local,
- model);
+ compilationUnit);
lambdaExpressionNode.AddVariableDeclarationNode(variableDeclarationNode);
}
@@ -1534,7 +1534,7 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
TypeFacts.Empty.ToTypeClause(),
(IdentifierToken)token,
VariableKind.Local,
- model);
+ compilationUnit);
lambdaExpressionNode.AddVariableDeclarationNode(variableDeclarationNode);
}
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
index 3df46505d..82612266c 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
@@ -224,7 +224,7 @@ public void BindStringInterpolationExpression(
AddSymbolReference(new StringInterpolationSymbol(dollarSignToken.TextSpan with
{
DecorationByte = (byte)GenericDecorationKind.StringLiteral,
- }), model);
+ }), compilationUnit);
}
public void BindStringVerbatimExpression(
@@ -234,7 +234,7 @@ public void BindStringVerbatimExpression(
AddSymbolReference(new StringVerbatimSymbol(atToken.TextSpan with
{
DecorationByte = (byte)GenericDecorationKind.StringLiteral,
- }), model);
+ }), compilationUnit);
}
public void BindFunctionDefinitionNode(
@@ -248,7 +248,7 @@ public void BindFunctionDefinitionNode(
DecorationByte = (byte)GenericDecorationKind.Function
});
- AddSymbolDefinition(functionSymbol, model);
+ AddSymbolDefinition(functionSymbol, compilationUnit);
if (!TryAddFunctionDefinitionNodeByScope(
model,
@@ -263,8 +263,8 @@ public void BindFunctionDefinitionNode(
}
}
- void IBinder.BindFunctionOptionalArgument(FunctionArgumentEntryNode functionArgumentEntryNode, IParserModel model) =>
- BindFunctionOptionalArgument(functionArgumentEntryNode, (CSharpParserModel)model);
+ void IBinder.BindFunctionOptionalArgument(FunctionArgumentEntryNode functionArgumentEntryNode, IParserModel compilationUnit) =>
+ BindFunctionOptionalArgument(functionArgumentEntryNode, (CSharpParserModel)compilationUnit);
public void BindFunctionOptionalArgument(
FunctionArgumentEntryNode functionArgumentEntryNode,
@@ -289,7 +289,7 @@ public void BindFunctionOptionalArgument(
functionArgumentEntryNode.OptionalCompileTimeConstantToken,
typeDefinitionNode.ToTypeClause());
- literalExpressionNode = BindLiteralExpressionNode(literalExpressionNode, model);
+ literalExpressionNode = BindLiteralExpressionNode(literalExpressionNode, compilationUnit);
if (literalExpressionNode.ResultTypeClauseNode.ValueType is null ||
literalExpressionNode.ResultTypeClauseNode.ValueType != functionArgumentEntryNode.VariableDeclarationNode.TypeClauseNode.ValueType)
@@ -342,7 +342,7 @@ public void BindNamespaceStatementNode(
CSharpCompilationUnit compilationUnit)
{
var namespaceString = namespaceStatementNode.IdentifierToken.TextSpan.GetText();
- AddSymbolReference(new NamespaceSymbol(namespaceStatementNode.IdentifierToken.TextSpan), model);
+ AddSymbolReference(new NamespaceSymbol(namespaceStatementNode.IdentifierToken.TextSpan), compilationUnit);
if (_namespaceGroupNodeMap.TryGetValue(namespaceString, out var inNamespaceGroupNode))
{
@@ -375,7 +375,7 @@ public InheritanceStatementNode BindInheritanceStatementNode(
AddSymbolReference(new TypeSymbol(typeClauseNode.TypeIdentifierToken.TextSpan with
{
DecorationByte = (byte)GenericDecorationKind.Type
- }), model);
+ }), compilationUnit);
compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(
typeClauseNode.TypeIdentifierToken.TextSpan,
@@ -384,14 +384,14 @@ public InheritanceStatementNode BindInheritanceStatementNode(
return new InheritanceStatementNode(typeClauseNode);
}
- void IBinder.BindVariableDeclarationNode(IVariableDeclarationNode variableDeclarationNode, IParserModel model) =>
- BindVariableDeclarationNode(variableDeclarationNode, (CSharpParserModel)model);
+ void IBinder.BindVariableDeclarationNode(IVariableDeclarationNode variableDeclarationNode, IParserModel compilationUnit) =>
+ BindVariableDeclarationNode(variableDeclarationNode, (CSharpParserModel)compilationUnit);
public void BindVariableDeclarationNode(
IVariableDeclarationNode variableDeclarationNode,
CSharpCompilationUnit compilationUnit)
{
- CreateVariableSymbol(variableDeclarationNode.IdentifierToken, variableDeclarationNode.VariableKind, model);
+ CreateVariableSymbol(variableDeclarationNode.IdentifierToken, variableDeclarationNode.VariableKind, compilationUnit);
var text = variableDeclarationNode.IdentifierToken.TextSpan.GetText();
if (TryGetVariableDeclarationNodeByScope(
@@ -469,7 +469,7 @@ public VariableReferenceNode ConstructAndBindVariableReferenceNode(
text);
}
- CreateVariableSymbol(variableReferenceNode.VariableIdentifierToken, variableDeclarationNode.VariableKind, model);
+ CreateVariableSymbol(variableReferenceNode.VariableIdentifierToken, variableDeclarationNode.VariableKind, compilationUnit);
return variableReferenceNode;
}
@@ -510,7 +510,7 @@ public void BindVariableAssignmentExpressionNode(
}
}
- CreateVariableSymbol(variableAssignmentExpressionNode.VariableIdentifierToken, variableKind, model);
+ CreateVariableSymbol(variableAssignmentExpressionNode.VariableIdentifierToken, variableKind, compilationUnit);
}
public void BindConstructorDefinitionIdentifierToken(
@@ -522,7 +522,7 @@ public void BindConstructorDefinitionIdentifierToken(
DecorationByte = (byte)GenericDecorationKind.Type
});
- AddSymbolDefinition(constructorSymbol, model);
+ AddSymbolDefinition(constructorSymbol, compilationUnit);
}
public void BindFunctionInvocationNode(
@@ -537,7 +537,7 @@ public void BindFunctionInvocationNode(
DecorationByte = (byte)GenericDecorationKind.Function
});
- AddSymbolReference(functionSymbol, model);
+ AddSymbolReference(functionSymbol, compilationUnit);
if (TryGetFunctionHierarchically(
model,
@@ -566,7 +566,7 @@ public void BindNamespaceReference(
DecorationByte = (byte)GenericDecorationKind.None
});
- AddSymbolReference(namespaceSymbol, model);
+ AddSymbolReference(namespaceSymbol, compilationUnit);
}
public void BindTypeClauseNode(
@@ -580,7 +580,7 @@ public void BindTypeClauseNode(
DecorationByte = (byte)GenericDecorationKind.Type
});
- AddSymbolReference(typeSymbol, model);
+ AddSymbolReference(typeSymbol, compilationUnit);
}
var matchingTypeDefintionNode = CSharpFacts.Types.TypeDefinitionNodes.SingleOrDefault(
@@ -603,7 +603,7 @@ public void BindTypeIdentifier(
DecorationByte = (byte)GenericDecorationKind.Type
});
- AddSymbolReference(typeSymbol, model);
+ AddSymbolReference(typeSymbol, compilationUnit);
}
}
@@ -611,10 +611,10 @@ public void BindUsingStatementNode(
UsingStatementNode usingStatementNode,
CSharpCompilationUnit compilationUnit)
{
- AddSymbolReference(new NamespaceSymbol(usingStatementNode.NamespaceIdentifier.TextSpan), model);
+ AddSymbolReference(new NamespaceSymbol(usingStatementNode.NamespaceIdentifier.TextSpan), compilationUnit);
compilationUnit.ParserModel.BinderSession.CurrentUsingStatementNodeList.Add(usingStatementNode);
- AddNamespaceToCurrentScope(usingStatementNode.NamespaceIdentifier.TextSpan.GetText(), model);
+ AddNamespaceToCurrentScope(usingStatementNode.NamespaceIdentifier.TextSpan.GetText(), compilationUnit);
}
/// TODO: Correctly implement this method. For now going to skip until the attribute closing square bracket.
@@ -628,7 +628,7 @@ public AttributeNode BindAttributeNode(
{
DecorationByte = (byte)GenericDecorationKind.Type,
EndingIndexExclusive = closeSquareBracketToken.TextSpan.EndingIndexExclusive
- }), model);
+ }), compilationUnit);
return new AttributeNode(
openSquareBracketToken,
@@ -653,8 +653,8 @@ public void OpenScope(
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey = scope.IndexKey;
}
- void IBinder.AddNamespaceToCurrentScope(string namespaceString, IParserModel model) =>
- AddNamespaceToCurrentScope(namespaceString, (CSharpParserModel)model);
+ void IBinder.AddNamespaceToCurrentScope(string namespaceString, IParserModel compilationUnit) =>
+ AddNamespaceToCurrentScope(namespaceString, (CSharpParserModel)compilationUnit);
public void AddNamespaceToCurrentScope(
string namespaceString,
@@ -709,10 +709,10 @@ public void CloseScope(
// Update CodeBlockOwner
if (inOwner is not null)
{
- inOwner.SetCodeBlockNode(inBuilder.Build(), model);
+ inOwner.SetCodeBlockNode(inBuilder.Build(), compilationUnit);
if (inOwner.SyntaxKind == SyntaxKind.NamespaceStatementNode)
- compilationUnit.ParserModel.Binder.BindNamespaceStatementNode((NamespaceStatementNode)inOwner, model);
+ compilationUnit.ParserModel.Binder.BindNamespaceStatementNode((NamespaceStatementNode)inOwner, compilationUnit);
else if (inOwner.SyntaxKind == SyntaxKind.TypeDefinitionNode)
compilationUnit.ParserModel.Binder.BindTypeDefinitionNode((TypeDefinitionNode)inOwner, model, true);
@@ -809,7 +809,7 @@ private void AddSymbolDefinition(
// TODO: The else branch of this if statement would mean the Symbol definition was found twice, should a diagnostic be reported here?
}
- AddSymbolReference(symbol, model);
+ AddSymbolReference(symbol, compilationUnit);
}
private void AddSymbolReference(ISymbol symbol, CSharpCompilationUnit compilationUnit)
@@ -854,13 +854,13 @@ public void CreateVariableSymbol(
AddSymbolDefinition(new FieldSymbol(identifierToken.TextSpan with
{
DecorationByte = (byte)GenericDecorationKind.Field
- }), model);
+ }), compilationUnit);
break;
case VariableKind.Property:
AddSymbolDefinition(new PropertySymbol(identifierToken.TextSpan with
{
DecorationByte = (byte)GenericDecorationKind.Property
- }), model);
+ }), compilationUnit);
break;
case VariableKind.Local:
goto default;
@@ -870,7 +870,7 @@ public void CreateVariableSymbol(
AddSymbolDefinition(new VariableSymbol(identifierToken.TextSpan with
{
DecorationByte = (byte)GenericDecorationKind.Variable
- }), model);
+ }), compilationUnit);
break;
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
index 3575b68c5..d0568cb3a 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
@@ -40,7 +40,7 @@ public static GenericArgumentsListingNode HandleGenericArguments(CSharpCompilati
while (true)
{
// TypeClause
- var typeClauseNode = MatchTypeClause(model);
+ var typeClauseNode = MatchTypeClause(compilationUnit);
if (typeClauseNode.IsFabricated)
break;
@@ -127,13 +127,13 @@ public static TypeClauseNode MatchTypeClause(CSharpCompilationUnit compilationUn
null,
null);
- compilationUnit.ParserModel.Binder.BindTypeClauseNode(typeClauseNode, model);
+ compilationUnit.ParserModel.Binder.BindTypeClauseNode(typeClauseNode, compilationUnit);
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenAngleBracketToken)
{
var genericParametersListingNode = (GenericParametersListingNode)ParseOthers.Force_ParseExpression(
SyntaxKind.GenericParametersListingNode,
- model);
+ compilationUnit);
typeClauseNode.SetGenericParametersListingNode(genericParametersListingNode);
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
index 59c6ace88..1fc11417d 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
@@ -31,7 +31,7 @@ public static void HandleVariableReference(
variableKind,
false);
- compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(variableDeclarationNode, model);
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(variableDeclarationNode, compilationUnit);
compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(variableDeclarationNode);
return variableDeclarationNode;
}
@@ -49,7 +49,7 @@ public static void HandleVariableDeclarationStatement(
consumedTypeClauseNode,
consumedIdentifierToken,
variableKind,
- model);
+ compilationUnit);
if (variableDeclarationNode is null)
return;
@@ -64,7 +64,7 @@ public static void HandleVariableDeclarationStatement(
variableDeclarationNode,
(EqualsToken)compilationUnit.ParserModel.TokenWalker.Consume(),
(CloseAngleBracketToken)compilationUnit.ParserModel.TokenWalker.Consume(),
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
}
else
{
@@ -72,7 +72,7 @@ public static void HandleVariableDeclarationStatement(
HandleVariableAssignment(
consumedIdentifierToken,
(EqualsToken)compilationUnit.ParserModel.TokenWalker.Consume(),
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
}
}
else
@@ -91,7 +91,7 @@ public static void HandleVariableDeclarationStatement(
HandlePropertyDeclaration(
variableDeclarationNode,
(OpenBraceToken)compilationUnit.ParserModel.TokenWalker.Consume(),
- (CSharpParserModel)model);
+ (CSharpParserModel)compilationUnit);
}
else
{
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
index 13ea79e9f..fda97ceef 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
@@ -9,7 +9,7 @@ internal static class TokenWalkerExtensionMethods
{
public static TypeClauseNode MatchTypeClauseNode(this TokenWalker tokenWalker, CSharpCompilationUnit compilationUnit)
{
- return ParseTypes.MatchTypeClause(model);
+ return ParseTypes.MatchTypeClause(compilationUnit);
}
public static void DeferParsingOfChildScope(
From ce4604a254d2ee3fbf0d213bb67e9df746623e9c Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:45:05 -0500
Subject: [PATCH 20/39] DOES NOT BUILD: change remaining 'model' references to
'compilationUnit.ParserModel'
---
.../Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs | 6 +++---
.../CSharp/ParserCase/Internals/ParseFunctions.cs | 4 ++--
.../CSharp/ParserCase/Internals/ParseTokens.cs | 4 ++--
.../CSharp/ParserCase/Internals/ParseTypes.cs | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index f24b3fe88..d0beed793 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -253,14 +253,14 @@ public void Parse(CSharpCompilationUnit compilationUnit)
// TODO: Are the comments below still of value? If they are not of value anymore then delete them.
//{
- // In regards to whether to '_ = model.TokenWalker.Consume();'
+ // In regards to whether to '_ = compilationUnit.ParserModel.TokenWalker.Consume();'
// at the start of the while loop, or at the end:
//
// The end is better because:
//
// - Anytime one wants to check the previous token,
- // with the 'Consume()' at the end of the loop then one can use 'model.TokenWalker.Previous'.
- // But, if 'Consume()' is at the start of the loop then one has to use 'model.TokenWalker.Peek(-2)' and that feels very janky.
+ // with the 'Consume()' at the end of the loop then one can use 'compilationUnit.ParserModel.TokenWalker.Previous'.
+ // But, if 'Consume()' is at the start of the loop then one has to use 'compilationUnit.ParserModel.TokenWalker.Peek(-2)' and that feels very janky.
//
// - As well, helps ensure a "handle-syntax" does not 'Consume()' someone elses syntax.
// If an individual "syntax" cannot make sense of the current token,
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
index 5d93fd564..f71c1e580 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
@@ -19,7 +19,7 @@ public static void HandleFunctionDefinition(
{
var successGenericParametersListingNode = ParseOthers.TryParseExpression(
SyntaxKind.GenericParametersListingNode,
- model,
+ compilationUnit,
out var genericParametersListingNode);
if (successGenericParametersListingNode)
@@ -150,7 +150,7 @@ public static FunctionArgumentsListingNode HandleFunctionArguments(CSharpCompila
else if (!corruptState)
{
var tokenIndexOriginal = compilationUnit.ParserModel.TokenWalker.Index;
- var successTypeClauseNode = ParseOthers.TryParseExpression(SyntaxKind.TypeClauseNode, model, out var typeClauseNode);
+ var successTypeClauseNode = ParseOthers.TryParseExpression(SyntaxKind.TypeClauseNode, compilationUnit, out var typeClauseNode);
var successName = false;
if (successTypeClauseNode)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
index 2e9d14ab2..743d56fee 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
@@ -44,7 +44,7 @@ public static void ParseIdentifierToken(CSharpCompilationUnit compilationUnit)
compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Add(SyntaxKind.FunctionInvocationNode);
}
- var successParse = ParseOthers.TryParseExpression(null, model, out var expressionNode);
+ var successParse = ParseOthers.TryParseExpression(null, compilationUnit, out var expressionNode);
if (!successParse)
{
@@ -112,7 +112,7 @@ public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
{
- ParsePropertyDefinition((CSharpParserModel)model, variableDeclarationNode);
+ ParsePropertyDefinition((CSharpParserModel)compilationUnit, variableDeclarationNode);
}
else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken &&
compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
index d0568cb3a..1c2880da4 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
@@ -95,7 +95,7 @@ public static bool IsPossibleTypeClause(ISyntaxToken syntaxToken, CSharpCompilat
public static TypeClauseNode MatchTypeClause(CSharpCompilationUnit compilationUnit)
{
- if (ParseOthers.TryParseExpression(SyntaxKind.TypeClauseNode, model, out var expressionNode))
+ if (ParseOthers.TryParseExpression(SyntaxKind.TypeClauseNode, compilationUnit, out var expressionNode))
{
return (TypeClauseNode)expressionNode;
}
@@ -113,7 +113,7 @@ public static TypeClauseNode MatchTypeClause(CSharpCompilationUnit compilationUn
if (UtilityApi.IsKeywordSyntaxKind(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind) &&
(UtilityApi.IsTypeIdentifierKeywordSyntaxKind(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind) ||
- UtilityApi.IsVarContextualKeyword(model, compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)))
+ UtilityApi.IsVarContextualKeyword(compilationUnit, compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind)))
{
syntaxToken = compilationUnit.ParserModel.TokenWalker.Consume();
}
From 0608111fc816d094bcdf61e428a93e4b638421a7 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 14:50:10 -0500
Subject: [PATCH 21/39] DOES NOT BUILD: fix initial using statement errors.
---
.../CSharp/BinderCase/CSharpBinder.Expressions.cs | 1 +
.../CSharp/BinderCase/CSharpBinder.Main.cs | 1 +
.../CSharp/CompilerServiceCase/CSharpCompilationUnit.cs | 7 ++++++-
.../Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs | 1 +
.../CSharp/ParserCase/Internals/ParseContextualKeywords.cs | 1 +
.../CSharp/ParserCase/Internals/ParseDefaultKeywords.cs | 1 +
.../CSharp/ParserCase/Internals/ParseFunctions.cs | 1 +
.../CSharp/ParserCase/Internals/ParseOthers.cs | 1 +
.../CSharp/ParserCase/Internals/ParseTokens.cs | 1 +
.../CSharp/ParserCase/Internals/ParseTypes.cs | 1 +
.../CSharp/ParserCase/Internals/ParseVariables.cs | 1 +
.../ParserCase/Internals/TokenWalkerExtensionMethods.cs | 1 +
.../CSharp/ParserCase/Internals/UtilityApi.cs | 1 +
13 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
index 324904cfe..59fcfc31c 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
@@ -16,6 +16,7 @@
using Luthetus.CompilerServices.CSharp.ParserCase;
using Luthetus.CompilerServices.CSharp.ParserCase.Internals;
using Luthetus.CompilerServices.CSharp.LexerCase;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.BinderCase;
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
index 82612266c..f68e14ce3 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
@@ -15,6 +15,7 @@
using Luthetus.CompilerServices.CSharp.Facts;
using Luthetus.CompilerServices.CSharp.ParserCase;
using Luthetus.CompilerServices.CSharp.ParserCase.Internals;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.BinderCase;
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilationUnit.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilationUnit.cs
index c8369d5bd..17947979c 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilationUnit.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilationUnit.cs
@@ -1,9 +1,14 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices;
using Luthetus.TextEditor.RazorLib.CompilerServices.Implementations;
using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
using Luthetus.TextEditor.RazorLib.Lexers.Models;
+using Luthetus.CompilerServices.CSharp.LexerCase;
+using Luthetus.CompilerServices.CSharp.ParserCase;
+using Luthetus.CompilerServices.CSharp.BinderCase;
-namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
+namespace Luthetus.CompilerServices.CSharp.CompilerServiceCase;
public sealed class CSharpCompilationUnit : ICompilationUnit
{
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index d0beed793..65fda9f94 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -11,6 +11,7 @@
using Luthetus.CompilerServices.CSharp.BinderCase;
using Luthetus.CompilerServices.CSharp.LexerCase;
using Luthetus.CompilerServices.CSharp.ParserCase.Internals;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
index 19c5ad583..ccb399b4b 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
@@ -3,6 +3,7 @@
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
index a7a001b2f..56a135230 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseDefaultKeywords.cs
@@ -5,6 +5,7 @@
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
using Luthetus.CompilerServices.CSharp.Facts;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
index f71c1e580..aceecc343 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseFunctions.cs
@@ -4,6 +4,7 @@
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
index 681bd20a7..f69dd1260 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
@@ -7,6 +7,7 @@
using Luthetus.TextEditor.RazorLib.Lexers.Models;
using Luthetus.TextEditor.RazorLib.Exceptions;
using Luthetus.CompilerServices.CSharp.Facts;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
index 743d56fee..2967492fa 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
@@ -7,6 +7,7 @@
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.CompilerServices.CSharp.Facts;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
index 1c2880da4..d7f24a8ba 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTypes.cs
@@ -3,6 +3,7 @@
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
index 1fc11417d..c75478823 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
@@ -5,6 +5,7 @@
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
using Luthetus.CompilerServices.CSharp.Facts;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
index fda97ceef..b578405a7 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
@@ -2,6 +2,7 @@
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs
index 4b1dbc5a1..632249675 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/UtilityApi.cs
@@ -4,6 +4,7 @@
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
namespace Luthetus.CompilerServices.CSharp.ParserCase.Internals;
From 555d4f0a0ee2b7003fc4ea2b060b1e787591be7b Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 15:12:53 -0500
Subject: [PATCH 22/39] DOES NOT BUILD: inter-project related errors remain
---
.../BinderCase/CSharpBinder.Expressions.cs | 40 ++++++++--------
.../CSharp/BinderCase/CSharpBinder.Main.cs | 32 ++++++-------
.../CSharpCompilerService.cs | 8 ++--
.../CompilerServiceCase/CSharpResource.cs | 48 +++++++++++++++++--
.../CSharp/ParserCase/CSharpParser.cs | 16 +++----
.../Internals/ParseContextualKeywords.cs | 2 +-
.../ParserCase/Internals/ParseOthers.cs | 2 +-
.../ParserCase/Internals/ParseTokens.cs | 8 ++--
.../ParserCase/Internals/ParseVariables.cs | 6 +--
9 files changed, 100 insertions(+), 62 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
index 59fcfc31c..4726a3690 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs
@@ -153,7 +153,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
BindFunctionInvocationNode(
functionInvocationNode,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, functionInvocationNode));
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, functionInvocationNode.FunctionParametersListingNode));
@@ -228,7 +228,7 @@ public IExpressionNode AmbiguousIdentifierMergeToken(
}
else if (UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind))
{
- ParseTokens.ParseIdentifierToken((CSharpParserModel)compilationUnit); // Parse the type pattern matching / variable declaration
+ ParseTokens.ParseIdentifierToken(compilationUnit); // Parse the type pattern matching / variable declaration
}
// Guaranteed to consume 1 further than the secondary loop so have to backtrack 1 time as well.
@@ -339,7 +339,7 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
if (UtilityApi.IsConvertibleToIdentifierToken(ambiguousIdentifierExpressionNode.Token.SyntaxKind))
{
if (TryGetVariableDeclarationHierarchically(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
ambiguousIdentifierExpressionNode.Token.TextSpan.GetText(),
@@ -349,7 +349,7 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
var variableReferenceNode = ConstructAndBindVariableReferenceNode(
identifierToken,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
return variableReferenceNode;
}
@@ -359,14 +359,14 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
UtilityApi.IsConvertibleToTypeClauseNode(ambiguousIdentifierExpressionNode.Token.SyntaxKind))
{
if (TryGetTypeDefinitionHierarchically(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
ambiguousIdentifierExpressionNode.Token.TextSpan.GetText(),
out var typeDefinitionNode))
{
var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, compilationUnit);
- BindTypeClauseNode(typeClauseNode, (CSharpParserModel)compilationUnit);
+ BindTypeClauseNode(typeClauseNode, compilationUnit);
return typeClauseNode;
}
}
@@ -376,7 +376,7 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
UtilityApi.IsConvertibleToTypeClauseNode(ambiguousIdentifierExpressionNode.Token.SyntaxKind))
{
var typeClauseNode = UtilityApi.ConvertToTypeClauseNode(ambiguousIdentifierExpressionNode.Token, compilationUnit);
- BindTypeClauseNode(typeClauseNode, (CSharpParserModel)compilationUnit);
+ BindTypeClauseNode(typeClauseNode, compilationUnit);
return typeClauseNode;
}
@@ -387,7 +387,7 @@ public IExpressionNode ForceDecisionAmbiguousIdentifier(
var variableReferenceNode = ConstructAndBindVariableReferenceNode(
identifierToken,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
return variableReferenceNode;
}
@@ -507,7 +507,7 @@ public IExpressionNode ConstructorInvocationMergeToken(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
return constructorInvocationExpressionNode.SetTypeClauseNode(typeClauseNode);
}
@@ -803,17 +803,17 @@ public IExpressionNode EmptyMergeToken(
case SyntaxKind.AsyncTokenContextualKeyword:
return new LambdaExpressionNode(CSharpFacts.Types.Void.ToTypeClause());
case SyntaxKind.DollarSignToken:
- BindStringInterpolationExpression((DollarSignToken)token, (CSharpParserModel)compilationUnit);
+ BindStringInterpolationExpression((DollarSignToken)token, compilationUnit);
return emptyExpressionNode;
case SyntaxKind.AtToken:
- BindStringVerbatimExpression((AtToken)token, (CSharpParserModel)compilationUnit);
+ BindStringVerbatimExpression((AtToken)token, compilationUnit);
return emptyExpressionNode;
case SyntaxKind.OutTokenKeyword:
if (UtilityApi.IsConvertibleToIdentifierToken(compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind))
{
// Parse the variable reference / variable declaration
- ParseTokens.ParseIdentifierToken((CSharpParserModel)compilationUnit);
+ ParseTokens.ParseIdentifierToken(compilationUnit);
}
return emptyExpressionNode;
@@ -888,7 +888,7 @@ public IExpressionNode GenericParametersListingMergeExpression(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
genericParametersListingNode.GenericParameterEntryNodeList.Add(
new GenericParameterEntryNode(typeClauseNode));
@@ -916,7 +916,7 @@ public IExpressionNode GenericParametersListingMergeExpression(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
genericParametersListingNode.GenericParameterEntryNodeList.Add(
new GenericParameterEntryNode(typeClauseNode));
@@ -1029,7 +1029,7 @@ public IExpressionNode LambdaMergeToken(
token.TextSpan.SourceText);
((CSharpBinder)compilationUnit.ParserModel.Binder).AddSymbolDefinition(
- new LambdaSymbol(textSpan, lambdaExpressionNode), (CSharpParserModel)compilationUnit);
+ new LambdaSymbol(textSpan, lambdaExpressionNode), compilationUnit);
if (compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.OpenBraceToken)
{
@@ -1216,7 +1216,7 @@ public IExpressionNode ParenthesizedMergeExpression(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
return new ExplicitCastNode(parenthesizedExpressionNode.OpenParenthesisToken, typeClauseNode);
}
@@ -1277,7 +1277,7 @@ public IExpressionNode TypeClauseMergeToken(
BindFunctionInvocationNode(
functionInvocationNode,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CloseParenthesisToken, functionInvocationNode));
compilationUnit.ParserModel.ExpressionList.Add((SyntaxKind.CommaToken, functionInvocationNode.FunctionParametersListingNode));
@@ -1425,7 +1425,7 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
var identifierToken = (IdentifierToken)badExpressionNode.SyntaxList[1];
@@ -1467,7 +1467,7 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
}
else if (firstSyntax.SyntaxKind == SyntaxKind.IdentifierToken)
{
@@ -1476,7 +1476,7 @@ public IExpressionNode SetLambdaExpressionNodeVariableDeclarationNodeList(
BindTypeClauseNode(
typeClauseNode,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
}
var secondSyntax = badExpressionNode.SyntaxList[++i];
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
index f68e14ce3..62298a11b 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
@@ -207,7 +207,7 @@ public BinaryOperatorNode BindBinaryOperatorNode(
$" for types: {leftExpressionNode.ConstructTextSpanRecursively().GetText()}" +
$" and {rightExpressionNode.ConstructTextSpanRecursively().GetText()}";
- parserModel.DiagnosticBag.ReportTodoException(problematicTextSpan.Value, errorMessage);
+ compilationUnit.ParserModel.DiagnosticBag.ReportTodoException(problematicTextSpan.Value, errorMessage);
}
return new BinaryOperatorNode(
@@ -252,7 +252,7 @@ public void BindFunctionDefinitionNode(
AddSymbolDefinition(functionSymbol, compilationUnit);
if (!TryAddFunctionDefinitionNodeByScope(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
functionIdentifierText,
@@ -265,7 +265,7 @@ public void BindFunctionDefinitionNode(
}
void IBinder.BindFunctionOptionalArgument(FunctionArgumentEntryNode functionArgumentEntryNode, IParserModel compilationUnit) =>
- BindFunctionOptionalArgument(functionArgumentEntryNode, (CSharpParserModel)compilationUnit);
+ BindFunctionOptionalArgument(functionArgumentEntryNode, compilationUnit);
public void BindFunctionOptionalArgument(
FunctionArgumentEntryNode functionArgumentEntryNode,
@@ -386,7 +386,7 @@ public InheritanceStatementNode BindInheritanceStatementNode(
}
void IBinder.BindVariableDeclarationNode(IVariableDeclarationNode variableDeclarationNode, IParserModel compilationUnit) =>
- BindVariableDeclarationNode(variableDeclarationNode, (CSharpParserModel)compilationUnit);
+ BindVariableDeclarationNode(variableDeclarationNode, compilationUnit);
public void BindVariableDeclarationNode(
IVariableDeclarationNode variableDeclarationNode,
@@ -396,7 +396,7 @@ public void BindVariableDeclarationNode(
var text = variableDeclarationNode.IdentifierToken.TextSpan.GetText();
if (TryGetVariableDeclarationNodeByScope(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
@@ -409,7 +409,7 @@ public void BindVariableDeclarationNode(
// TODO: Track one or many declarations?...
// (if there is an error where something is defined twice for example)
SetVariableDeclarationNodeByScope(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
@@ -423,7 +423,7 @@ public void BindVariableDeclarationNode(
else
{
_ = TryAddVariableDeclarationNodeByScope(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
@@ -439,7 +439,7 @@ public VariableReferenceNode ConstructAndBindVariableReferenceNode(
VariableReferenceNode? variableReferenceNode;
if (TryGetVariableDeclarationHierarchically(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
@@ -482,7 +482,7 @@ public void BindVariableAssignmentExpressionNode(
VariableKind variableKind = VariableKind.Local;
if (TryGetVariableDeclarationHierarchically(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
text,
@@ -541,7 +541,7 @@ public void BindFunctionInvocationNode(
AddSymbolReference(functionSymbol, compilationUnit);
if (TryGetFunctionHierarchically(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
functionInvocationIdentifierText,
@@ -655,7 +655,7 @@ public void OpenScope(
}
void IBinder.AddNamespaceToCurrentScope(string namespaceString, IParserModel compilationUnit) =>
- AddNamespaceToCurrentScope(namespaceString, (CSharpParserModel)compilationUnit);
+ AddNamespaceToCurrentScope(namespaceString, compilationUnit);
public void AddNamespaceToCurrentScope(
string namespaceString,
@@ -669,7 +669,7 @@ public void AddNamespaceToCurrentScope(
foreach (var typeDefinitionNode in typeDefinitionNodes)
{
_ = TryAddTypeDefinitionNodeByScope(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
typeDefinitionNode.TypeIdentifierToken.TextSpan.GetText(),
@@ -715,7 +715,7 @@ public void CloseScope(
if (inOwner.SyntaxKind == SyntaxKind.NamespaceStatementNode)
compilationUnit.ParserModel.Binder.BindNamespaceStatementNode((NamespaceStatementNode)inOwner, compilationUnit);
else if (inOwner.SyntaxKind == SyntaxKind.TypeDefinitionNode)
- compilationUnit.ParserModel.Binder.BindTypeDefinitionNode((TypeDefinitionNode)inOwner, model, true);
+ compilationUnit.ParserModel.Binder.BindTypeDefinitionNode((TypeDefinitionNode)inOwner, compilationUnit, true);
// Restore Parent CodeBlockBuilder
if (outBuilder is not null)
@@ -745,7 +745,7 @@ public void BindTypeDefinitionNode(
typeDefinitionNode.EncompassingNamespaceIdentifierString = currentNamespaceStatementText;
if (TryGetTypeDefinitionNodeByScope(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
typeIdentifierText,
@@ -754,7 +754,7 @@ public void BindTypeDefinitionNode(
if (shouldOverwrite || existingTypeDefinitionNode.IsFabricated)
{
SetTypeDefinitionNodeByScope(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
typeIdentifierText,
@@ -764,7 +764,7 @@ public void BindTypeDefinitionNode(
else
{
_ = TryAddTypeDefinitionNodeByScope(
- model,
+ compilationUnit,
compilationUnit.ParserModel.BinderSession.ResourceUri,
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey,
typeIdentifierText,
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index 9c39c9f9e..9060044e0 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -93,11 +93,11 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
{
var resource = (CSharpResource)_resourceMap[resourceUri];
- resource.EscapeCharacterList = lexer.EscapeCharacterList;
- resource.SyntaxTokenList = lexer.SyntaxTokenList;
+ resource.EscapeCharacterList = cSharpCompilationUnit.Lexer.EscapeCharacterList;
+ resource.SyntaxTokenList = cSharpCompilationUnit.Lexer.SyntaxTokenList;
- if (compilationUnit is not null)
- resource.CompilationUnit = compilationUnit;
+ if (cSharpCompilationUnit is not null)
+ resource.CompilationUnit = cSharpCompilationUnit;
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpResource.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpResource.cs
index 5e743c3f9..f78b69665 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpResource.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpResource.cs
@@ -1,19 +1,33 @@
using System.Collections.Immutable;
using Luthetus.TextEditor.RazorLib.CompilerServices;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax;
using Luthetus.TextEditor.RazorLib.Lexers.Models;
namespace Luthetus.CompilerServices.CSharp.CompilerServiceCase;
-public class CSharpResource : CompilerServiceResource
+public sealed class CSharpResource : ICompilerServiceResource
{
public CSharpResource(ResourceUri resourceUri, CSharpCompilerService cSharpCompilerService)
- : base(resourceUri, cSharpCompilerService)
{
+ ResourceUri = resourceUri;
+ CompilerService = cSharpCompilerService;
}
-
+
+ public ResourceUri ResourceUri { get; }
+ public ICompilerService CompilerService { get; }
+ public CSharpCompilationUnit? CompilationUnit { get; set; }
+ public IReadOnlyList SyntaxTokenList { get; set; } = ImmutableArray.Empty;
public IReadOnlyList EscapeCharacterList { get; internal set; }
-
- public override IReadOnlyList GetTokenTextSpans()
+
+ ICompilationUnit? ICompilerServiceResource.CompilationUnit => CompilationUnit;
+
+ public IReadOnlyList GetTokens()
+ {
+ return SyntaxTokenList;
+ }
+
+ public IReadOnlyList GetTokenTextSpans()
{
var tokenTextSpanList = new List();
@@ -22,4 +36,28 @@ public override IReadOnlyList GetTokenTextSpans()
return tokenTextSpanList;
}
+
+ public IReadOnlyList GetSymbols()
+ {
+ var localCompilationUnit = CompilationUnit;
+
+ if (localCompilationUnit is null)
+ return Array.Empty();
+
+ return localCompilationUnit.Binder.Symbols
+ .Where(s => s.TextSpan.ResourceUri == ResourceUri)
+ .ToArray();
+ }
+
+ public IReadOnlyList GetDiagnostics()
+ {
+ var localCompilationUnit = CompilationUnit;
+
+ if (localCompilationUnit is null)
+ return Array.Empty();
+
+ return localCompilationUnit.DiagnosticsList
+ .Where(s => s.TextSpan.ResourceUri == ResourceUri)
+ .ToArray();
+ }
}
\ No newline at end of file
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index 65fda9f94..de2a1ee6a 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -33,9 +33,9 @@ public void Parse(CSharpCompilationUnit compilationUnit)
var diagnosticBag = new DiagnosticBag();
compilationUnit.ParserModel = new CSharpParserModel(
- cSharpCompilationUnit.Binder,
- cSharpCompilationUnit.BinderSession,
- new TokenWalker(Lexer.SyntaxTokenList, diagnosticBag),
+ compilationUnit.Binder,
+ compilationUnit.BinderSession,
+ new TokenWalker(compilationUnit.Lexer.SyntaxTokenList, diagnosticBag),
new Stack(),
diagnosticBag,
globalCodeBlockBuilder,
@@ -234,20 +234,20 @@ public void Parse(CSharpCompilationUnit compilationUnit)
if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.Parent is not null)
{
// The current token here would be the EOF token.
- Binder.CloseScope(compilationUnit.ParserModel.TokenWalker.Current.TextSpan, compilationUnit);
+ compilationUnit.Binder.CloseScope(compilationUnit.ParserModel.TokenWalker.Current.TextSpan, compilationUnit);
}
DiagnosticsList = compilationUnit.ParserModel.DiagnosticBag.ToArray();
var topLevelStatementsCodeBlock = compilationUnit.ParserModel.CurrentCodeBlockBuilder.Build(
DiagnosticsList
- .Union(Binder.DiagnosticsList)
- .Union(Lexer.DiagnosticList)
+ .Union(compilationUnit.Binder.DiagnosticsList)
+ .Union(compilationUnit.Lexer.DiagnosticList)
.ToArray());
- cSharpCompilationUnit.CSharpBinder.FinalizeBinderSession(cSharpCompilationUnit.BinderSession);
+ compilationUnit.Binder.FinalizeBinderSession(compilationUnit.BinderSession);
- cSharpCompilationUnit.RootCodeBlockNode = topLevelStatementsCodeBlock;
+ compilationUnit.RootCodeBlockNode = topLevelStatementsCodeBlock;
}
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
index ccb399b4b..fe1cd5017 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseContextualKeywords.cs
@@ -221,7 +221,7 @@ public static void HandleWhereTokenContextualKeyword(CSharpCompilationUnit compi
while (!compilationUnit.ParserModel.TokenWalker.IsEof)
{
- if (compilationUnit.ParserModel.ParserModeldel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
+ if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken ||
compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.StatementDelimiterToken)
{
break;
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
index f69dd1260..b2b606809 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseOthers.cs
@@ -81,7 +81,7 @@ public static void StartStatement_Expression(CSharpCompilationUnit compilationUn
///
public static bool TryParseExpression(SyntaxKind? syntaxKind, CSharpCompilationUnit compilationUnit, out IExpressionNode expressionNode)
{
- var originalTokenIndex = compilationUnit.ParserModelTokenWalker.Index;
+ var originalTokenIndex = compilationUnit.ParserModel.TokenWalker.Index;
if (syntaxKind is not null)
compilationUnit.ParserModel.TryParseExpressionSyntaxKindList.Add(syntaxKind.Value);
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
index 2967492fa..518cfb15f 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
@@ -86,7 +86,7 @@ public static void MoveToHandleFunctionDefinition(VariableDeclarationNode variab
variableDeclarationNode.IdentifierToken,
variableDeclarationNode.TypeClauseNode,
consumedGenericArgumentsListingNode: null,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
}
public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode variableDeclarationNode, CSharpCompilationUnit compilationUnit)
@@ -113,12 +113,12 @@ public static void MoveToHandleVariableDeclarationNode(IVariableDeclarationNode
if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.OpenBraceToken)
{
- ParsePropertyDefinition((CSharpParserModel)compilationUnit, variableDeclarationNode);
+ ParsePropertyDefinition(compilationUnit, variableDeclarationNode);
}
else if (compilationUnit.ParserModel.TokenWalker.Current.SyntaxKind == SyntaxKind.EqualsToken &&
compilationUnit.ParserModel.TokenWalker.Next.SyntaxKind == SyntaxKind.CloseAngleBracketToken)
{
- ParsePropertyDefinition_ExpressionBound((CSharpParserModel)compilationUnit);
+ ParsePropertyDefinition_ExpressionBound(compilationUnit);
}
}
@@ -143,7 +143,7 @@ public static void MoveToHandleTypeClauseNode(int originalTokenIndex, TypeClause
ParseFunctions.HandleConstructorDefinition(
typeDefinitionNode,
identifierToken,
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
}
else
{
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
index c75478823..fa7efc2bf 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseVariables.cs
@@ -65,7 +65,7 @@ public static void HandleVariableDeclarationStatement(
variableDeclarationNode,
(EqualsToken)compilationUnit.ParserModel.TokenWalker.Consume(),
(CloseAngleBracketToken)compilationUnit.ParserModel.TokenWalker.Consume(),
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
}
else
{
@@ -73,7 +73,7 @@ public static void HandleVariableDeclarationStatement(
HandleVariableAssignment(
consumedIdentifierToken,
(EqualsToken)compilationUnit.ParserModel.TokenWalker.Consume(),
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
}
}
else
@@ -92,7 +92,7 @@ public static void HandleVariableDeclarationStatement(
HandlePropertyDeclaration(
variableDeclarationNode,
(OpenBraceToken)compilationUnit.ParserModel.TokenWalker.Consume(),
- (CSharpParserModel)compilationUnit);
+ compilationUnit);
}
else
{
From 96e84ed84e489579b3ab96475c3f01c83ae64966 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 17:50:22 -0500
Subject: [PATCH 23/39] This surprisingly runs, I broke the tooltip since
CSharpBinder doesn't implement IBinder anymore, will look into this
---
.../CSharp/BinderCase/CSharpBinder.Main.cs | 317 +++++++-----------
.../CSharp/BinderCase/CSharpBinderSession.cs | 5 +-
.../CSharpCompilerService.cs | 16 +-
.../CompilerServiceCase/CSharpResource.cs | 6 +-
.../ParserCase/CSharpCodeBlockBuilder.cs | 67 ++++
.../ParserCase/CSharpDeferredChildScope.cs | 41 +++
.../CSharp/ParserCase/CSharpParser.cs | 2 +-
.../CSharp/ParserCase/CSharpParserModel.cs | 15 +-
.../ParserCase/CSharpStatementBuilder.cs | 81 +++++
.../ParserCase/Internals/ParseTokens.cs | 10 +-
.../Internals/TokenWalkerExtensionMethods.cs | 2 +-
.../RuntimeAssembliesLoaderFactory.cs | 48 +--
.../CompilerServices/Razor/RazorSyntaxTree.cs | 5 +-
.../Syntax/Nodes/ArbitraryCodeBlockNode.cs | 23 +-
.../Syntax/Nodes/ConstructorDefinitionNode.cs | 32 +-
.../Syntax/Nodes/DoWhileStatementNode.cs | 23 +-
.../Syntax/Nodes/ForStatementNode.cs | 23 +-
.../Syntax/Nodes/ForeachStatementNode.cs | 22 +-
.../Syntax/Nodes/FunctionDefinitionNode.cs | 30 +-
.../Syntax/Nodes/IfStatementNode.cs | 23 +-
.../Nodes/Interfaces/ICodeBlockOwner.cs | 31 +-
.../Syntax/Nodes/LockStatementNode.cs | 23 +-
.../Syntax/Nodes/NamespaceStatementNode.cs | 23 +-
.../Syntax/Nodes/SwitchExpressionNode.cs | 23 +-
.../Syntax/Nodes/SwitchStatementNode.cs | 23 +-
.../Syntax/Nodes/TryStatementCatchNode.cs | 23 +-
.../Syntax/Nodes/TryStatementFinallyNode.cs | 23 +-
.../Syntax/Nodes/TryStatementTryNode.cs | 23 +-
.../Syntax/Nodes/TypeDefinitionNode.cs | 33 +-
.../Syntax/Nodes/WhileStatementNode.cs | 23 +-
30 files changed, 517 insertions(+), 522 deletions(-)
create mode 100644 Source/Lib/CompilerServices/CSharp/ParserCase/CSharpCodeBlockBuilder.cs
create mode 100644 Source/Lib/CompilerServices/CSharp/ParserCase/CSharpDeferredChildScope.cs
create mode 100644 Source/Lib/CompilerServices/CSharp/ParserCase/CSharpStatementBuilder.cs
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
index 62298a11b..5a328b539 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
@@ -19,9 +19,9 @@
namespace Luthetus.CompilerServices.CSharp.BinderCase;
-public partial class CSharpBinder : IBinder
+public partial class CSharpBinder
{
- private readonly Dictionary _binderSessionMap = new();
+ private readonly Dictionary _binderSessionMap = new();
//private readonly object _binderSessionMapLock = new();
///
@@ -75,10 +75,8 @@ public ITextEditorSymbol[] Symbols
}
}
- ITextEditorSymbol[] IBinder.SymbolsList => Symbols;
-
///
- public IBinderSession StartBinderSession(ResourceUri resourceUri)
+ public CSharpBinderSession StartBinderSession(ResourceUri resourceUri)
{
foreach (var namespaceGroupNodeKvp in _namespaceGroupNodeMap)
{
@@ -114,7 +112,7 @@ public IBinderSession StartBinderSession(ResourceUri resourceUri)
}
///
- public void FinalizeBinderSession(IBinderSession binderSession)
+ public void FinalizeBinderSession(CSharpBinderSession binderSession)
{
UpsertBinderSession(binderSession);
}
@@ -264,9 +262,6 @@ public void BindFunctionDefinitionNode(
}
}
- void IBinder.BindFunctionOptionalArgument(FunctionArgumentEntryNode functionArgumentEntryNode, IParserModel compilationUnit) =>
- BindFunctionOptionalArgument(functionArgumentEntryNode, compilationUnit);
-
public void BindFunctionOptionalArgument(
FunctionArgumentEntryNode functionArgumentEntryNode,
CSharpCompilationUnit compilationUnit)
@@ -385,9 +380,6 @@ public InheritanceStatementNode BindInheritanceStatementNode(
return new InheritanceStatementNode(typeClauseNode);
}
- void IBinder.BindVariableDeclarationNode(IVariableDeclarationNode variableDeclarationNode, IParserModel compilationUnit) =>
- BindVariableDeclarationNode(variableDeclarationNode, compilationUnit);
-
public void BindVariableDeclarationNode(
IVariableDeclarationNode variableDeclarationNode,
CSharpCompilationUnit compilationUnit)
@@ -654,9 +646,6 @@ public void OpenScope(
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey = scope.IndexKey;
}
- void IBinder.AddNamespaceToCurrentScope(string namespaceString, IParserModel compilationUnit) =>
- AddNamespaceToCurrentScope(namespaceString, compilationUnit);
-
public void AddNamespaceToCurrentScope(
string namespaceString,
CSharpCompilationUnit compilationUnit)
@@ -710,7 +699,7 @@ public void CloseScope(
// Update CodeBlockOwner
if (inOwner is not null)
{
- inOwner.SetCodeBlockNode(inBuilder.Build(), compilationUnit);
+ inOwner.SetCodeBlockNode(inBuilder.Build(), compilationUnit.ParserModel.DiagnosticBag, compilationUnit.ParserModel.TokenWalker);
if (inOwner.SyntaxKind == SyntaxKind.NamespaceStatementNode)
compilationUnit.ParserModel.Binder.BindNamespaceStatementNode((NamespaceStatementNode)inOwner, compilationUnit);
@@ -918,18 +907,18 @@ symbolDefinition.Value with
/// If none of the searched scopes contained a match then set the out parameter to null and return false.
///
public bool TryGetFunctionHierarchically(
- IParserModel? parserModel,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int initialScopeIndexKey,
string identifierText,
out FunctionDefinitionNode? functionDefinitionNode)
{
- var localScope = GetScopeByScopeIndexKey(parserModel, resourceUri, initialScopeIndexKey);
+ var localScope = GetScopeByScopeIndexKey(compilationUnit, resourceUri, initialScopeIndexKey);
while (localScope is not null)
{
if (TryGetFunctionDefinitionNodeByScope(
- parserModel,
+ compilationUnit,
resourceUri,
localScope.IndexKey,
identifierText,
@@ -941,7 +930,7 @@ public bool TryGetFunctionHierarchically(
if (localScope.ParentIndexKey is null)
localScope = null;
else
- localScope = GetScopeByScopeIndexKey(parserModel, resourceUri, localScope.ParentIndexKey.Value);
+ localScope = GetScopeByScopeIndexKey(compilationUnit, resourceUri, localScope.ParentIndexKey.Value);
}
functionDefinitionNode = null;
@@ -954,18 +943,18 @@ public bool TryGetFunctionHierarchically(
/// If none of the searched scopes contained a match then set the out parameter to null and return false.
///
public bool TryGetTypeDefinitionHierarchically(
- IParserModel? parserModel,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int initialScopeIndexKey,
string identifierText,
out TypeDefinitionNode? typeDefinitionNode)
{
- var localScope = GetScopeByScopeIndexKey(parserModel, resourceUri, initialScopeIndexKey);
+ var localScope = GetScopeByScopeIndexKey(compilationUnit, resourceUri, initialScopeIndexKey);
while (localScope is not null)
{
if (TryGetTypeDefinitionNodeByScope(
- parserModel,
+ compilationUnit,
resourceUri,
localScope.IndexKey,
identifierText,
@@ -977,7 +966,7 @@ public bool TryGetTypeDefinitionHierarchically(
if (localScope.ParentIndexKey is null)
localScope = null;
else
- localScope = GetScopeByScopeIndexKey(parserModel, resourceUri, localScope.ParentIndexKey.Value);
+ localScope = GetScopeByScopeIndexKey(compilationUnit, resourceUri, localScope.ParentIndexKey.Value);
}
typeDefinitionNode = null;
@@ -990,18 +979,18 @@ public bool TryGetTypeDefinitionHierarchically(
/// If none of the searched scopes contained a match then set the out parameter to null and return false.
///
public bool TryGetVariableDeclarationHierarchically(
- IParserModel? parserModel,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int initialScopeIndexKey,
string identifierText,
out IVariableDeclarationNode? variableDeclarationStatementNode)
{
- var localScope = GetScopeByScopeIndexKey(parserModel, resourceUri, initialScopeIndexKey);
+ var localScope = GetScopeByScopeIndexKey(compilationUnit, resourceUri, initialScopeIndexKey);
while (localScope is not null)
{
if (TryGetVariableDeclarationNodeByScope(
- parserModel,
+ compilationUnit,
resourceUri,
localScope.IndexKey,
identifierText,
@@ -1013,31 +1002,25 @@ public bool TryGetVariableDeclarationHierarchically(
if (localScope.ParentIndexKey is null)
localScope = null;
else
- localScope = GetScopeByScopeIndexKey(parserModel, resourceUri, localScope.ParentIndexKey.Value);
+ localScope = GetScopeByScopeIndexKey(compilationUnit, resourceUri, localScope.ParentIndexKey.Value);
}
variableDeclarationStatementNode = null;
return false;
}
- IScope? IBinder.GetScope(TextEditorTextSpan textSpan) =>
- GetScope(model: null, textSpan);
-
- public IScope? GetScope(IParserModel? model, TextEditorTextSpan textSpan)
+ public IScope? GetScope(CSharpCompilationUnit? compilationUnit, TextEditorTextSpan textSpan)
{
- return GetScopeByPositionIndex(model, textSpan.ResourceUri, textSpan.StartingIndexInclusive);
+ return GetScopeByPositionIndex(compilationUnit, textSpan.ResourceUri, textSpan.StartingIndexInclusive);
}
- IScope? IBinder.GetScopeByPositionIndex(ResourceUri resourceUri, int positionIndex) =>
- GetScopeByPositionIndex(model: null, resourceUri, positionIndex);
-
- public IScope? GetScopeByPositionIndex(IParserModel? model, ResourceUri resourceUri, int positionIndex)
+ public IScope? GetScopeByPositionIndex(CSharpCompilationUnit? compilationUnit, ResourceUri resourceUri, int positionIndex)
{
var scopeList = new List();
- if (TryGetBinderSession(model, resourceUri, out var targetBinderSession))
+ if (TryGetBinderSession(compilationUnit, resourceUri, out var targetBinderSession))
scopeList.AddRange(targetBinderSession.ScopeList);
- if (TryGetBinderSession(model, ResourceUri.Empty, out var globalBinderSession))
+ if (TryGetBinderSession(compilationUnit, ResourceUri.Empty, out var globalBinderSession))
scopeList.AddRange(globalBinderSession.ScopeList);
var possibleScopes = scopeList.Where(x =>
@@ -1050,58 +1033,49 @@ public bool TryGetVariableDeclarationHierarchically(
return possibleScopes.MinBy(x => positionIndex - x.StartingIndexInclusive);
}
- IScope? IBinder.GetScopeByScopeIndexKey(ResourceUri resourceUri, int scopeIndexKey) =>
- GetScopeByScopeIndexKey(model: null, resourceUri, scopeIndexKey);
-
- public IScope? GetScopeByScopeIndexKey(IParserModel? model, ResourceUri resourceUri, int scopeIndexKey)
+ public IScope? GetScopeByScopeIndexKey(CSharpCompilationUnit? compilationUnit, ResourceUri resourceUri, int scopeIndexKey)
{
var scopeList = new List();
- if (TryGetBinderSession(model, resourceUri, out var targetBinderSession))
+ if (TryGetBinderSession(compilationUnit, resourceUri, out var targetBinderSession))
scopeList.AddRange(targetBinderSession.ScopeList);
- if (TryGetBinderSession(model, ResourceUri.Empty, out var globalBinderSession))
+ if (TryGetBinderSession(compilationUnit, ResourceUri.Empty, out var globalBinderSession))
scopeList.AddRange(globalBinderSession.ScopeList);
return scopeList[scopeIndexKey];
}
- IScope[]? IBinder.GetScopeList(ResourceUri resourceUri) =>
- GetScopeList(model: null, resourceUri);
-
- public IScope[]? GetScopeList(IParserModel? model, ResourceUri resourceUri)
+ public IScope[]? GetScopeList(CSharpCompilationUnit? compilationUnit, ResourceUri resourceUri)
{
var scopeList = new List();
- if (TryGetBinderSession(model, resourceUri, out var targetBinderSession))
+ if (TryGetBinderSession(compilationUnit, resourceUri, out var targetBinderSession))
scopeList.AddRange(targetBinderSession.ScopeList);
- if (TryGetBinderSession(model, ResourceUri.Empty, out var globalBinderSession))
+ if (TryGetBinderSession(compilationUnit, ResourceUri.Empty, out var globalBinderSession))
scopeList.AddRange(globalBinderSession.ScopeList);
return scopeList.ToArray();
}
- bool IBinder.TryGetBinderSession(ResourceUri resourceUri, out IBinderSession binderSession) =>
- TryGetBinderSession(parserModel: null, resourceUri, out binderSession);
-
///
/// If the resourceUri is the in progress BinderSession's ResourceUri,
/// then the in progress instance should be returned via the out variable.
///
/// TODO: This is quite confusingly written at the moment.
///
- public bool TryGetBinderSession(IParserModel? parserModel, ResourceUri resourceUri, out IBinderSession binderSession)
+ public bool TryGetBinderSession(CSharpCompilationUnit? compilationUnit, ResourceUri resourceUri, out CSharpBinderSession binderSession)
{
- if (parserModel is not null &&
- resourceUri == parserModel.BinderSession.ResourceUri)
+ if (compilationUnit is not null &&
+ resourceUri == compilationUnit.ParserModel.BinderSession.ResourceUri)
{
- binderSession = parserModel.BinderSession;
+ binderSession = compilationUnit.ParserModel.BinderSession;
return true;
}
return _binderSessionMap.TryGetValue(resourceUri, out binderSession);
}
- public void UpsertBinderSession(IBinderSession binderSession)
+ public void UpsertBinderSession(CSharpBinderSession binderSession)
{
try
{
@@ -1121,17 +1095,12 @@ public bool RemoveBinderSession(ResourceUri resourceUri)
return _binderSessionMap.Remove(resourceUri);
}
- TypeDefinitionNode[] IBinder.GetTypeDefinitionNodesByScope(
- ResourceUri resourceUri,
- int scopeIndexKey) =>
- GetTypeDefinitionNodesByScope(model: null, resourceUri, scopeIndexKey);
-
public TypeDefinitionNode[] GetTypeDefinitionNodesByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return Array.Empty();
return binderSession.ScopeTypeDefinitionMap
@@ -1140,21 +1109,14 @@ public TypeDefinitionNode[] GetTypeDefinitionNodesByScope(
.ToArray();
}
- bool IBinder.TryGetTypeDefinitionNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- string typeIdentifierText,
- out TypeDefinitionNode typeDefinitionNode) =>
- TryGetTypeDefinitionNodeByScope(model: null, resourceUri, scopeIndexKey, typeIdentifierText, out typeDefinitionNode);
-
public bool TryGetTypeDefinitionNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
string typeIdentifierText,
out TypeDefinitionNode typeDefinitionNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
{
typeDefinitionNode = null;
return false;
@@ -1164,59 +1126,40 @@ public bool TryGetTypeDefinitionNodeByScope(
return binderSession.ScopeTypeDefinitionMap.TryGetValue(scopeKeyAndIdentifierText, out typeDefinitionNode);
}
- bool IBinder.TryAddTypeDefinitionNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- string typeIdentifierText,
- TypeDefinitionNode typeDefinitionNode) =>
- TryAddTypeDefinitionNodeByScope(model: null, resourceUri, scopeIndexKey, typeIdentifierText, typeDefinitionNode);
-
public bool TryAddTypeDefinitionNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
string typeIdentifierText,
TypeDefinitionNode typeDefinitionNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return false;
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, typeIdentifierText);
return binderSession.ScopeTypeDefinitionMap.TryAdd(scopeKeyAndIdentifierText, typeDefinitionNode);
}
- void IBinder.SetTypeDefinitionNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- string typeIdentifierText,
- TypeDefinitionNode typeDefinitionNode) =>
- SetTypeDefinitionNodeByScope(model: null, resourceUri, scopeIndexKey, typeIdentifierText, typeDefinitionNode);
-
public void SetTypeDefinitionNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
string typeIdentifierText,
TypeDefinitionNode typeDefinitionNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return;
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, typeIdentifierText);
binderSession.ScopeTypeDefinitionMap[scopeKeyAndIdentifierText] = typeDefinitionNode;
}
- FunctionDefinitionNode[] IBinder.GetFunctionDefinitionNodesByScope(
- ResourceUri resourceUri,
- int scopeIndexKey) =>
- GetFunctionDefinitionNodesByScope(model: null, resourceUri, scopeIndexKey);
-
public FunctionDefinitionNode[] GetFunctionDefinitionNodesByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return Array.Empty();
return binderSession.ScopeFunctionDefinitionMap
@@ -1225,21 +1168,14 @@ public FunctionDefinitionNode[] GetFunctionDefinitionNodesByScope(
.ToArray();
}
- bool IBinder.TryGetFunctionDefinitionNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- string functionIdentifierText,
- out FunctionDefinitionNode functionDefinitionNode) =>
- TryGetFunctionDefinitionNodeByScope(model: null, resourceUri, scopeIndexKey, functionIdentifierText, out functionDefinitionNode);
-
public bool TryGetFunctionDefinitionNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
string functionIdentifierText,
out FunctionDefinitionNode functionDefinitionNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
{
functionDefinitionNode = null;
return false;
@@ -1249,59 +1185,40 @@ public bool TryGetFunctionDefinitionNodeByScope(
return binderSession.ScopeFunctionDefinitionMap.TryGetValue(scopeKeyAndIdentifierText, out functionDefinitionNode);
}
- bool IBinder.TryAddFunctionDefinitionNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- string functionIdentifierText,
- FunctionDefinitionNode functionDefinitionNode) =>
- TryAddFunctionDefinitionNodeByScope(model: null, resourceUri, scopeIndexKey, functionIdentifierText, functionDefinitionNode);
-
public bool TryAddFunctionDefinitionNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
string functionIdentifierText,
FunctionDefinitionNode functionDefinitionNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return false;
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, functionIdentifierText);
return binderSession.ScopeFunctionDefinitionMap.TryAdd(scopeKeyAndIdentifierText, functionDefinitionNode);
}
-
- void IBinder.SetFunctionDefinitionNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- string functionIdentifierText,
- FunctionDefinitionNode functionDefinitionNode) =>
- SetFunctionDefinitionNodeByScope(model: null, resourceUri, scopeIndexKey, functionIdentifierText, functionDefinitionNode);
-
+
public void SetFunctionDefinitionNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
string functionIdentifierText,
FunctionDefinitionNode functionDefinitionNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return;
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, functionIdentifierText);
binderSession.ScopeFunctionDefinitionMap[scopeKeyAndIdentifierText] = functionDefinitionNode;
}
- IVariableDeclarationNode[] IBinder.GetVariableDeclarationNodesByScope(
- ResourceUri resourceUri,
- int scopeIndexKey) =>
- GetVariableDeclarationNodesByScope(model: null, resourceUri, scopeIndexKey);
-
public IVariableDeclarationNode[] GetVariableDeclarationNodesByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return Array.Empty();
return binderSession.ScopeVariableDeclarationMap
@@ -1310,21 +1227,14 @@ public IVariableDeclarationNode[] GetVariableDeclarationNodesByScope(
.ToArray();
}
- bool IBinder.TryGetVariableDeclarationNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- string variableIdentifierText,
- out IVariableDeclarationNode variableDeclarationNode) =>
- TryGetVariableDeclarationNodeByScope(model: null, resourceUri, scopeIndexKey, variableIdentifierText, out variableDeclarationNode);
-
public bool TryGetVariableDeclarationNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
string variableIdentifierText,
out IVariableDeclarationNode variableDeclarationNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
{
variableDeclarationNode = null;
return false;
@@ -1333,60 +1243,41 @@ public bool TryGetVariableDeclarationNodeByScope(
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, variableIdentifierText);
return binderSession.ScopeVariableDeclarationMap.TryGetValue(scopeKeyAndIdentifierText, out variableDeclarationNode);
}
-
- bool IBinder.TryAddVariableDeclarationNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- string variableIdentifierText,
- IVariableDeclarationNode variableDeclarationNode) =>
- TryAddVariableDeclarationNodeByScope(model: null, resourceUri, scopeIndexKey, variableIdentifierText, variableDeclarationNode);
public bool TryAddVariableDeclarationNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
string variableIdentifierText,
IVariableDeclarationNode variableDeclarationNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return false;
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, variableIdentifierText);
return binderSession.ScopeVariableDeclarationMap.TryAdd(scopeKeyAndIdentifierText, variableDeclarationNode);
}
-
- void IBinder.SetVariableDeclarationNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- string variableIdentifierText,
- IVariableDeclarationNode variableDeclarationNode) =>
- SetVariableDeclarationNodeByScope(model: null, resourceUri, scopeIndexKey, variableIdentifierText, variableDeclarationNode);
public void SetVariableDeclarationNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
string variableIdentifierText,
IVariableDeclarationNode variableDeclarationNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return;
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, variableIdentifierText);
binderSession.ScopeVariableDeclarationMap[scopeKeyAndIdentifierText] = variableDeclarationNode;
}
-
- TypeClauseNode? IBinder.GetReturnTypeClauseNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey) =>
- GetReturnTypeClauseNodeByScope(model: null, resourceUri, scopeIndexKey);
public TypeClauseNode? GetReturnTypeClauseNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
return null;
if (binderSession.ScopeReturnTypeClauseNodeMap.TryGetValue(scopeIndexKey, out var returnTypeClauseNode))
@@ -1395,19 +1286,13 @@ public void SetVariableDeclarationNodeByScope(
return null;
}
- bool IBinder.TryAddReturnTypeClauseNodeByScope(
- ResourceUri resourceUri,
- int scopeIndexKey,
- TypeClauseNode typeClauseNode) =>
- TryAddReturnTypeClauseNodeByScope(model: null, resourceUri, scopeIndexKey, typeClauseNode);
-
public bool TryAddReturnTypeClauseNodeByScope(
- IParserModel? model,
+ CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
int scopeIndexKey,
TypeClauseNode typeClauseNode)
{
- if (!TryGetBinderSession(model, resourceUri, out var binderSession))
+ if (!TryGetBinderSession(compilationUnit, resourceUri, out var binderSession))
{
typeClauseNode = null;
return false;
@@ -1415,13 +1300,10 @@ public bool TryAddReturnTypeClauseNodeByScope(
return binderSession.ScopeReturnTypeClauseNodeMap.TryAdd(scopeIndexKey, typeClauseNode);
}
-
- TextEditorTextSpan? IBinder.GetDefinitionTextSpan(TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource) =>
- GetDefinitionTextSpan(model: null, textSpan, compilerServiceResource);
- public TextEditorTextSpan? GetDefinitionTextSpan(IParserModel? model, TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource)
+ public TextEditorTextSpan? GetDefinitionTextSpan(CSharpCompilationUnit? compilationUnit, TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource)
{
- var definitionNode = GetDefinitionNode(model, textSpan, compilerServiceResource);
+ var definitionNode = GetDefinitionNode(compilationUnit, textSpan, compilerServiceResource);
if (definitionNode is null)
return null;
@@ -1439,12 +1321,9 @@ public bool TryAddReturnTypeClauseNodeByScope(
}
}
- ISyntaxNode? IBinder.GetDefinitionNode(TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource) =>
- GetDefinitionNode(model: null, textSpan, compilerServiceResource);
-
- public ISyntaxNode? GetDefinitionNode(IParserModel? model, TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource)
+ public ISyntaxNode? GetDefinitionNode(CSharpCompilationUnit? compilationUnit, TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource)
{
- var boundScope = GetScope(model, textSpan);
+ var boundScope = GetScope(compilationUnit, textSpan);
if (compilerServiceResource.CompilationUnit is null)
return null;
@@ -1478,7 +1357,7 @@ public bool TryAddReturnTypeClauseNodeByScope(
case SyntaxKind.FieldSymbol:
{
if (TryGetVariableDeclarationHierarchically(
- model,
+ compilationUnit,
textSpan.ResourceUri,
boundScope.IndexKey,
textSpan.GetText(),
@@ -1495,7 +1374,7 @@ public bool TryAddReturnTypeClauseNodeByScope(
case SyntaxKind.FunctionSymbol:
{
if (TryGetFunctionHierarchically(
- model,
+ compilationUnit,
textSpan.ResourceUri,
boundScope.IndexKey,
textSpan.GetText(),
@@ -1513,7 +1392,7 @@ public bool TryAddReturnTypeClauseNodeByScope(
case SyntaxKind.ConstructorSymbol:
{
if (TryGetTypeDefinitionHierarchically(
- model,
+ compilationUnit,
textSpan.ResourceUri,
boundScope.IndexKey,
textSpan.GetText(),
@@ -1530,12 +1409,9 @@ public bool TryAddReturnTypeClauseNodeByScope(
return null;
}
- ISyntaxNode? IBinder.GetSyntaxNode(int positionIndex, ResourceUri resourceUri, ICompilerServiceResource? compilerServiceResource) =>
- GetSyntaxNode(model: null, positionIndex, resourceUri, compilerServiceResource);
-
- public ISyntaxNode? GetSyntaxNode(IParserModel? model, int positionIndex, ResourceUri resourceUri, ICompilerServiceResource? compilerServiceResource)
+ public ISyntaxNode? GetSyntaxNode(CSharpCompilationUnit? compilationUnit, int positionIndex, ResourceUri resourceUri, ICompilerServiceResource? compilerServiceResource)
{
- var scope = GetScopeByPositionIndex(model, resourceUri, positionIndex);
+ var scope = GetScopeByPositionIndex(compilationUnit, resourceUri, positionIndex);
if (scope is null)
return null;
@@ -1597,9 +1473,9 @@ public bool TryAddReturnTypeClauseNodeByScope(
if (fallbackTextSpan is not null && compilerServiceResource is not null)
{
- var fallbackScope = GetScopeByPositionIndex(model, resourceUri, fallbackTextSpan.Value.StartingIndexInclusive);
+ var fallbackScope = GetScopeByPositionIndex(compilationUnit, resourceUri, fallbackTextSpan.Value.StartingIndexInclusive);
if (scope is not null)
- return GetFallbackNode(model, positionIndex, resourceUri, compilerServiceResource, fallbackScope);
+ return GetFallbackNode(compilationUnit, positionIndex, resourceUri, compilerServiceResource, fallbackScope);
}
}
}
@@ -1623,7 +1499,7 @@ public bool TryAddReturnTypeClauseNodeByScope(
/// ...This should likely be changed, because function argument goto definition won't work if done from the argument listing, rather than the code block of the function.
/// This method will act as a temporary work around.
///
- public ISyntaxNode? GetFallbackNode(IParserModel? model, int positionIndex, ResourceUri resourceUri, ICompilerServiceResource compilerServiceResource, IScope scope)
+ public ISyntaxNode? GetFallbackNode(CSharpCompilationUnit? compilationUnit, int positionIndex, ResourceUri resourceUri, ICompilerServiceResource compilerServiceResource, IScope scope)
{
if (compilerServiceResource.CompilationUnit is null)
return null;
@@ -1657,7 +1533,7 @@ public bool TryAddReturnTypeClauseNodeByScope(
case SyntaxKind.FieldSymbol:
{
if (TryGetVariableDeclarationHierarchically(
- model,
+ compilationUnit,
foundSymbol.TextSpan.ResourceUri,
scope.IndexKey,
foundSymbol.TextSpan.GetText(),
@@ -1752,4 +1628,47 @@ public bool TryAddReturnTypeClauseNodeByScope(
}
}
}
+
+ public void OnBoundScopeCreatedAndSetAsCurrent(ICodeBlockOwner codeBlockOwner, CSharpCompilationUnit compilationUnit)
+ {
+ if (codeBlockOwner.SyntaxKind == SyntaxKind.TypeDefinitionNode)
+ {
+ var typeDefinitionNode = (TypeDefinitionNode)codeBlockOwner;
+
+ if (typeDefinitionNode.PrimaryConstructorFunctionArgumentsListingNode is not null)
+ {
+ foreach (var argument in typeDefinitionNode.PrimaryConstructorFunctionArgumentsListingNode.FunctionArgumentEntryNodeList)
+ {
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, compilationUnit);
+ }
+ }
+ }
+ else if (codeBlockOwner.SyntaxKind == SyntaxKind.NamespaceStatementNode)
+ {
+ var namespaceStatementNode = (NamespaceStatementNode)codeBlockOwner;
+ var namespaceString = namespaceStatementNode.IdentifierToken.TextSpan.GetText();
+ compilationUnit.ParserModel.Binder.AddNamespaceToCurrentScope(namespaceString, compilationUnit);
+ }
+ else if (codeBlockOwner.SyntaxKind == SyntaxKind.FunctionDefinitionNode)
+ {
+ var functionDefinitionNode = (FunctionDefinitionNode)codeBlockOwner;
+ foreach (var argument in functionDefinitionNode.FunctionArgumentsListingNode.FunctionArgumentEntryNodeList)
+ {
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, compilationUnit);
+ }
+ }
+ else if (codeBlockOwner.SyntaxKind == SyntaxKind.ForeachStatementNode)
+ {
+ var foreachStatementNode = (ForeachStatementNode)codeBlockOwner;
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(foreachStatementNode.VariableDeclarationNode, compilationUnit);
+ }
+ else if (codeBlockOwner.SyntaxKind == SyntaxKind.ConstructorDefinitionNode)
+ {
+ var constructorDefinitionNode = (ConstructorDefinitionNode)codeBlockOwner;
+ foreach (var argument in constructorDefinitionNode.FunctionArgumentsListingNode.FunctionArgumentEntryNodeList)
+ {
+ compilationUnit.ParserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, compilationUnit);
+ }
+ }
+ }
}
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs
index 82db5cef6..6165bb4db 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs
@@ -8,7 +8,7 @@
namespace Luthetus.CompilerServices.CSharp.BinderCase;
-public class CSharpBinderSession : IBinderSession
+public class CSharpBinderSession
{
///
/// Should 0 be the global scope?
@@ -45,9 +45,6 @@ public CSharpBinderSession(
public Dictionary ScopeVariableDeclarationMap { get; } = new();
public Dictionary ScopeReturnTypeClauseNodeMap { get; } = new();
- IBinder IBinderSession.Binder => Binder;
- int IBinderSession.CurrentScopeIndexKey { get => CurrentScopeIndexKey; set => CurrentScopeIndexKey = value; }
-
public int GetNextIndexKey()
{
return ++_indexKey;
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index 9060044e0..65b888732 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -32,8 +32,6 @@ public CSharpCompilerService(ITextEditorService textEditorService)
++LuthetusDebugSomething.CompilerService_ConstructorInvocationCount;
#endif
- Binder = CSharpBinder;
-
_compilerServiceOptions = new()
{
RegisterResourceFunc = resourceUri => new CSharpResource(resourceUri, this),
@@ -44,6 +42,12 @@ public CSharpCompilerService(ITextEditorService textEditorService)
public override Type? SymbolRendererType { get; protected set; }
public override Type? DiagnosticRendererType { get; protected set; }
+
+ public override IBinder Binder
+ {
+ get => throw new NotImplementedException("Use {nameof(CSharpBinder)}");
+ protected set => throw new NotImplementedException("Use {nameof(CSharpBinder)}");
+ }
public event Action? CursorMovedInSyntaxTree;
@@ -81,7 +85,7 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
// make use of the Lexer to do whatever syntax highlighting is possible.
try
{
- cSharpCompilationUnit.BinderSession = (CSharpBinderSession)Binder.StartBinderSession(resourceUri);
+ cSharpCompilationUnit.BinderSession = (CSharpBinderSession)CSharpBinder.StartBinderSession(resourceUri);
var parser = new CSharpParser();
parser.Parse(cSharpCompilationUnit);
}
@@ -134,7 +138,7 @@ public override List GetAutocompleteEntries(string word, Text
while (targetScope is not null)
{
autocompleteEntryList.AddRange(
- CSharpBinder.GetVariableDeclarationNodesByScope(model: null, textSpan.ResourceUri, targetScope.IndexKey)
+ CSharpBinder.GetVariableDeclarationNodesByScope(compilationUnit: null, textSpan.ResourceUri, targetScope.IndexKey)
.Select(x => x.IdentifierToken.TextSpan.GetText())
.ToArray()
.Where(x => x.Contains(word, StringComparison.InvariantCulture))
@@ -149,7 +153,7 @@ public override List GetAutocompleteEntries(string word, Text
}));
autocompleteEntryList.AddRange(
- CSharpBinder.GetFunctionDefinitionNodesByScope(model: null, textSpan.ResourceUri, targetScope.IndexKey)
+ CSharpBinder.GetFunctionDefinitionNodesByScope(compilationUnit: null, textSpan.ResourceUri, targetScope.IndexKey)
.Select(x => x.FunctionIdentifierToken.TextSpan.GetText())
.ToArray()
.Where(x => x.Contains(word, StringComparison.InvariantCulture))
@@ -166,7 +170,7 @@ public override List GetAutocompleteEntries(string word, Text
if (targetScope.ParentIndexKey is null)
targetScope = null;
else
- targetScope = CSharpBinder.GetScopeByScopeIndexKey(model: null, textSpan.ResourceUri, targetScope.ParentIndexKey.Value);
+ targetScope = CSharpBinder.GetScopeByScopeIndexKey(compilationUnit: null, textSpan.ResourceUri, targetScope.ParentIndexKey.Value);
}
var allTypeDefinitions = CSharpBinder.AllTypeDefinitions;
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpResource.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpResource.cs
index f78b69665..363579bb1 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpResource.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpResource.cs
@@ -56,8 +56,10 @@ public IReadOnlyList GetDiagnostics()
if (localCompilationUnit is null)
return Array.Empty();
- return localCompilationUnit.DiagnosticsList
+ // TODO: (2024-12-12)
+ /*return localCompilationUnit.DiagnosticsList
.Where(s => s.TextSpan.ResourceUri == ResourceUri)
- .ToArray();
+ .ToArray();*/
+ return Array.Empty();
}
}
\ No newline at end of file
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpCodeBlockBuilder.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpCodeBlockBuilder.cs
new file mode 100644
index 000000000..200c8bc27
--- /dev/null
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpCodeBlockBuilder.cs
@@ -0,0 +1,67 @@
+using Luthetus.TextEditor.RazorLib.CompilerServices;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
+using System.Collections.Immutable;
+
+namespace Luthetus.CompilerServices.CSharp.ParserCase;
+
+public class CSharpCodeBlockBuilder
+{
+ public CSharpCodeBlockBuilder(CSharpCodeBlockBuilder? parent, ICodeBlockOwner? codeBlockOwner)
+ {
+ Parent = parent;
+ CodeBlockOwner = codeBlockOwner;
+ }
+
+ public List ChildList { get; } = new();
+ public CSharpCodeBlockBuilder? Parent { get; }
+ ///
+ /// Given: "public class MyClass { ... }"
Then: The 'MyClass' body-code-block would
+ /// have an owner of 'TypeDefinitionNode'.
+ /// Purpose: When parsing a class definition's constructor. I need to know if the code block I
+ /// exist in is one which a class owns. Furthermore, I need to verify that the code-block-owner's
+ /// Identifier is equal to the constructor's identifier.
+ ///
+ public ICodeBlockOwner? CodeBlockOwner { get; }
+
+ ///
+ /// Method with generic type constraint:
+ /// ````public void M(T? item) where T : struct { } // https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/where-generic-type-constraint
+ ///
+ /// Any syntax that goes from parentheses to OpenBraceToken / CloseBraceToken to define a scope:
+ /// ````foreach (var item in list)
+ /// ````{
+ /// ```` Console.WriteLine(item);
+ /// ````}
+ ///
+ /// Any syntax that goes from parenthesis to a "single statement body" deliminated by StatementDelimiterToken:
+ /// ````foreach (var item in list)
+ /// ```` Console.WriteLine(item);
+ ///
+ /// The idea is that syntax which defines a scope does not necessarily flow
+ /// in a simple way.
+ ///
+ /// "Any syntax that goes from parentheses to OpenBraceToken / CloseBraceToken to define a scope"
+ /// is a fairly simple case.
+ /// One could go immediately from the CloseParenthesisToken to the OpenBraceToken.
+ ///
+ /// But, if there is any syntax between the syntax that identifies
+ /// a code block owner, and the actual code block itself, things get more complicated.
+ ///
+ public ICodeBlockOwner? InnerPendingCodeBlockOwner { get; set; }
+
+ public Queue ParseChildScopeQueue { get; set; } = new();
+ public bool PermitInnerPendingCodeBlockOwnerToBeParsed { get; set; }
+ public int? DequeuedIndexForChildList { get; set; }
+
+ public CodeBlockNode Build()
+ {
+ return new CodeBlockNode(ChildList.ToArray());
+ }
+
+ public CodeBlockNode Build(TextEditorDiagnostic[] diagnostics)
+ {
+ return new CodeBlockNode(ChildList.ToArray(), diagnostics);
+ }
+}
\ No newline at end of file
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpDeferredChildScope.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpDeferredChildScope.cs
new file mode 100644
index 000000000..9fd99b18e
--- /dev/null
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpDeferredChildScope.cs
@@ -0,0 +1,41 @@
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
+
+namespace Luthetus.CompilerServices.CSharp.ParserCase;
+
+public class CSharpDeferredChildScope
+{
+ public CSharpDeferredChildScope(
+ int openTokenIndex,
+ int closeTokenIndex,
+ ICodeBlockOwner pendingCodeBlockOwner)
+ {
+ OpenTokenIndex = openTokenIndex;
+ CloseTokenIndex = closeTokenIndex;
+ PendingCodeBlockOwner = pendingCodeBlockOwner;
+ }
+
+ public int OpenTokenIndex { get; }
+ public int CloseTokenIndex { get; }
+ public ICodeBlockOwner PendingCodeBlockOwner { get; }
+
+ public int TokenIndexToRestore { get; private set; }
+
+ public void PrepareMainParserLoop(int tokenIndexToRestore, CSharpCompilationUnit compilationUnit)
+ {
+ TokenIndexToRestore = tokenIndexToRestore;
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.PermitInnerPendingCodeBlockOwnerToBeParsed = true;
+
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.DequeuedIndexForChildList = null;
+
+ compilationUnit.ParserModel.TokenWalker.DeferredParsing(
+ OpenTokenIndex,
+ CloseTokenIndex,
+ TokenIndexToRestore);
+
+ compilationUnit.ParserModel.SyntaxStack.Push(PendingCodeBlockOwner);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = PendingCodeBlockOwner;
+ }
+}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index de2a1ee6a..2642a2826 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -28,7 +28,7 @@ public CSharpParser()
public void Parse(CSharpCompilationUnit compilationUnit)
{
- var globalCodeBlockBuilder = new CodeBlockBuilder(null, null);
+ var globalCodeBlockBuilder = new CSharpCodeBlockBuilder(null, null);
var currentCodeBlockBuilder = globalCodeBlockBuilder;
var diagnosticBag = new DiagnosticBag();
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParserModel.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParserModel.cs
index 40827fc5b..102242f5b 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParserModel.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParserModel.cs
@@ -11,7 +11,7 @@
namespace Luthetus.CompilerServices.CSharp.ParserCase;
-public class CSharpParserModel : IParserModel
+public class CSharpParserModel
{
public CSharpParserModel(
CSharpBinder binder,
@@ -19,8 +19,8 @@ public CSharpParserModel(
TokenWalker tokenWalker,
Stack syntaxStack,
DiagnosticBag diagnosticBag,
- CodeBlockBuilder globalCodeBlockBuilder,
- CodeBlockBuilder currentCodeBlockBuilder)
+ CSharpCodeBlockBuilder globalCodeBlockBuilder,
+ CSharpCodeBlockBuilder currentCodeBlockBuilder)
{
#if DEBUG
++LuthetusDebugSomething.ParserModel_ConstructorInvocationCount;
@@ -44,15 +44,12 @@ public CSharpParserModel(
public CSharpBinderSession BinderSession { get; }
public TokenWalker TokenWalker { get; }
public Stack SyntaxStack { get; set; }
- public StatementBuilder StatementBuilder { get; set; } = new();
+ public CSharpStatementBuilder StatementBuilder { get; set; } = new();
public List<(SyntaxKind DelimiterSyntaxKind, IExpressionNode ExpressionNode)> ExpressionList { get; set; }
public IExpressionNode? NoLongerRelevantExpressionNode { get; set; }
public List TryParseExpressionSyntaxKindList { get; } = new();
public IExpressionNode ForceParseExpressionInitialPrimaryExpression { get; set; }
public DiagnosticBag DiagnosticBag { get; }
- public CodeBlockBuilder GlobalCodeBlockBuilder { get; set; }
- public CodeBlockBuilder CurrentCodeBlockBuilder { get; set; }
-
- IBinder IParserModel.Binder => Binder;
- IBinderSession IParserModel.BinderSession => BinderSession;
+ public CSharpCodeBlockBuilder GlobalCodeBlockBuilder { get; set; }
+ public CSharpCodeBlockBuilder CurrentCodeBlockBuilder { get; set; }
}
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpStatementBuilder.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpStatementBuilder.cs
new file mode 100644
index 000000000..553a38463
--- /dev/null
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpStatementBuilder.cs
@@ -0,0 +1,81 @@
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+using Luthetus.CompilerServices.CSharp.CompilerServiceCase;
+
+namespace Luthetus.CompilerServices.CSharp.ParserCase;
+
+public class CSharpStatementBuilder
+{
+ public List ChildList { get; } = new();
+
+ /// Invokes the other overload with index: ^1
+ public bool TryPeek(out ISyntax syntax)
+ {
+ return TryPeek(^1, out syntax);
+ }
+
+ /// ^1 gives the last entry
+ public bool TryPeek(Index index, out ISyntax syntax)
+ {
+ if (ChildList.Count - index.Value > -1)
+ {
+ syntax = ChildList[index];
+ return true;
+ }
+
+ syntax = null;
+ return false;
+ }
+
+ public ISyntax Pop()
+ {
+ var syntax = ChildList[^1];
+ ChildList.RemoveAt(ChildList.Count - 1);
+ return syntax;
+ }
+
+ ///
+ /// If 'StatementDelimiterToken', 'OpenBraceToken', or 'CloseBraceToken'
+ /// are parsed by the main loop,
+ ///
+ /// Then check that the last item in the StatementBuilder.ChildList
+ /// has been added to the compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.
+ ///
+ /// If it was not yet added, then add it.
+ ///
+ /// Lastly, clear the StatementBuilder.ChildList.
+ ///
+ public void FinishStatement(CSharpCompilationUnit compilationUnit)
+ {
+ if (ChildList.Count == 0)
+ return;
+
+ var statementSyntax = ChildList[^1];
+
+ ISyntax codeBlockBuilderSyntax;
+
+ if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Count == 0)
+ codeBlockBuilderSyntax = EmptyExpressionNode.Empty;
+ else
+ codeBlockBuilderSyntax = compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList[^1];
+
+ if (!Object.ReferenceEquals(statementSyntax, codeBlockBuilderSyntax))
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ChildList.Add(statementSyntax);
+
+ ChildList.Clear();
+ }
+
+ public void WriteToConsole()
+ {
+ Console.Write("StatementBuilder: ");
+
+ foreach (var child in ChildList)
+ {
+ Console.Write($"{child.SyntaxKind}, ");
+ }
+
+ Console.WriteLine();
+ }
+}
+
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
index 518cfb15f..d44f3833e 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/ParseTokens.cs
@@ -241,7 +241,7 @@ public static void ParseOpenBraceToken(OpenBraceToken openBraceToken, CSharpComp
compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = arbitraryCodeBlockNode;
}
- compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner.SetOpenBraceToken(openBraceToken, compilationUnit);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner.SetOpenBraceToken(openBraceToken, compilationUnit.ParserModel.DiagnosticBag, compilationUnit.ParserModel.TokenWalker);
var parentScopeDirection = compilationUnit.ParserModel.CurrentCodeBlockBuilder?.CodeBlockOwner?.ScopeDirectionKind ?? ScopeDirectionKind.Both;
if (parentScopeDirection == ScopeDirectionKind.Both)
@@ -260,7 +260,7 @@ public static void ParseOpenBraceToken(OpenBraceToken openBraceToken, CSharpComp
compilationUnit.ParserModel.Binder.OpenScope(nextCodeBlockOwner, nextReturnTypeClauseNode, openBraceToken.TextSpan, compilationUnit);
compilationUnit.ParserModel.CurrentCodeBlockBuilder = new(parent: compilationUnit.ParserModel.CurrentCodeBlockBuilder, codeBlockOwner: nextCodeBlockOwner);
- nextCodeBlockOwner.OnBoundScopeCreatedAndSetAsCurrent(compilationUnit);
+ compilationUnit.ParserModel.Binder.OnBoundScopeCreatedAndSetAsCurrent(nextCodeBlockOwner, compilationUnit);
}
///
@@ -276,7 +276,7 @@ public static void ParseCloseBraceToken(CloseBraceToken closeBraceToken, CSharpC
}
if (compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner is not null)
- compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner.SetCloseBraceToken(closeBraceToken, compilationUnit);
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.CodeBlockOwner.SetCloseBraceToken(closeBraceToken, compilationUnit.ParserModel.DiagnosticBag, compilationUnit.ParserModel.TokenWalker);
compilationUnit.ParserModel.Binder.CloseScope(closeBraceToken.TextSpan, compilationUnit);
}
@@ -412,7 +412,7 @@ public static void ParseStatementDelimiterToken(StatementDelimiterToken statemen
var namespaceStatementNode = (NamespaceStatementNode)compilationUnit.ParserModel.SyntaxStack.Pop();
nextCodeBlockOwner = namespaceStatementNode;
- namespaceStatementNode.SetStatementDelimiterToken(statementDelimiterToken, compilationUnit);
+ namespaceStatementNode.SetStatementDelimiterToken(statementDelimiterToken, compilationUnit.ParserModel.DiagnosticBag, compilationUnit.ParserModel.TokenWalker);
compilationUnit.ParserModel.Binder.OpenScope(
nextCodeBlockOwner,
@@ -433,7 +433,7 @@ public static void ParseStatementDelimiterToken(StatementDelimiterToken statemen
compilationUnit.ParserModel.Binder.OpenScope(pendingChild, CSharpFacts.Types.Void.ToTypeClause(), statementDelimiterToken.TextSpan, compilationUnit);
compilationUnit.ParserModel.CurrentCodeBlockBuilder = new(compilationUnit.ParserModel.CurrentCodeBlockBuilder, pendingChild);
- pendingChild.OnBoundScopeCreatedAndSetAsCurrent(compilationUnit);
+ compilationUnit.ParserModel.Binder.OnBoundScopeCreatedAndSetAsCurrent(pendingChild, compilationUnit);
compilationUnit.ParserModel.Binder.CloseScope(statementDelimiterToken.TextSpan, compilationUnit);
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
index b578405a7..9bd8196d5 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/Internals/TokenWalkerExtensionMethods.cs
@@ -54,7 +54,7 @@ public static void DeferParsingOfChildScope(
compilationUnit.ParserModel.TokenWalker.SuppressProtectedSyntaxKindConsumption = false;
#endif
- compilationUnit.ParserModel.CurrentCodeBlockBuilder.ParseChildScopeQueue.Enqueue(new DeferredChildScope(
+ compilationUnit.ParserModel.CurrentCodeBlockBuilder.ParseChildScopeQueue.Enqueue(new CSharpDeferredChildScope(
openTokenIndex,
closeTokenIndex,
pendingCodeBlockOwner));
diff --git a/Source/Lib/CompilerServices/CSharp/RuntimeAssemblies/RuntimeAssembliesLoaderFactory.cs b/Source/Lib/CompilerServices/CSharp/RuntimeAssemblies/RuntimeAssembliesLoaderFactory.cs
index fe199bcd9..e3cdf38d7 100644
--- a/Source/Lib/CompilerServices/CSharp/RuntimeAssemblies/RuntimeAssembliesLoaderFactory.cs
+++ b/Source/Lib/CompilerServices/CSharp/RuntimeAssemblies/RuntimeAssembliesLoaderFactory.cs
@@ -54,29 +54,29 @@ private class RuntimeAssembliesLoader : IRuntimeAssembliesLoader
{
public void CreateCache(CSharpBinder cSharpBinder)
{
- var globalCodeBlockBuilder = new CodeBlockBuilder(null, null);
- var currentCodeBlockBuilder = globalCodeBlockBuilder;
- var diagnosticBag = new DiagnosticBag();
-
- var model = new CSharpParserModel(
- cSharpBinder,
- (CSharpBinderSession)cSharpBinder.StartBinderSession(new ResourceUri("aaa")),
- new TokenWalker(new List(), new()),
- new Stack(),
- diagnosticBag,
- globalCodeBlockBuilder,
- currentCodeBlockBuilder);
-
- // TODO: Do not use 'System.IO.Directory' because this doesn't work...
- // ... when running the website
- //
- // Get the array of runtime assemblies.
- string[] runtimeAssemblyPaths = Directory.GetFiles(
- RuntimeEnvironment.GetRuntimeDirectory(),
- "*.dll");
-
- // Create the list of assembly paths consisting of runtime assemblies.
- var listOfRuntimeAssemblyPaths = new List(runtimeAssemblyPaths);
+ //var globalCodeBlockBuilder = new CodeBlockBuilder(null, null);
+ //var currentCodeBlockBuilder = globalCodeBlockBuilder;
+ //var diagnosticBag = new DiagnosticBag();
+
+ //var model = new CSharpParserModel(
+ // cSharpBinder,
+ // (CSharpBinderSession)cSharpBinder.StartBinderSession(new ResourceUri("aaa")),
+ // new TokenWalker(new List(), new()),
+ // new Stack(),
+ // diagnosticBag,
+ // globalCodeBlockBuilder,
+ // currentCodeBlockBuilder);
+
+ //// TODO: Do not use 'System.IO.Directory' because this doesn't work...
+ //// ... when running the website
+ ////
+ //// Get the array of runtime assemblies.
+ //string[] runtimeAssemblyPaths = Directory.GetFiles(
+ // RuntimeEnvironment.GetRuntimeDirectory(),
+ // "*.dll");
+
+ //// Create the list of assembly paths consisting of runtime assemblies.
+ /*var listOfRuntimeAssemblyPaths = new List(runtimeAssemblyPaths);
// Create PathAssemblyResolver that can resolve assemblies using the created list.
var resolver = new PathAssemblyResolver(listOfRuntimeAssemblyPaths);
@@ -259,7 +259,7 @@ public void CreateCache(CSharpBinder cSharpBinder)
}
}
}
- }
+ }*/
}
private TypeClauseNode GetTypeClauseNode(
diff --git a/Source/Lib/CompilerServices/Razor/RazorSyntaxTree.cs b/Source/Lib/CompilerServices/Razor/RazorSyntaxTree.cs
index 08611023a..86bdf8ef6 100644
--- a/Source/Lib/CompilerServices/Razor/RazorSyntaxTree.cs
+++ b/Source/Lib/CompilerServices/Razor/RazorSyntaxTree.cs
@@ -109,7 +109,8 @@ public void ParseCodebehind()
lexer.Lex();
- var parser = new CSharpParser(lexer);
+ // TODO: (2024-12-12)
+ /*var parser = new CSharpParser(lexer);
var compilationUnit = parser.Parse(new CSharpBinder(), lexer.ResourceUri);
@@ -118,7 +119,7 @@ public void ParseCodebehind()
_codebehindClassInsertions,
_codebehindRenderFunctionInsertions,
renderFunctionAdhocTextInsertion,
- classContents);
+ classContents);*/
}
/// currentCharacterIn:
-
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ArbitraryCodeBlockNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ArbitraryCodeBlockNode.cs
index bbe8ab9c5..45321cd7b 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ArbitraryCodeBlockNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ArbitraryCodeBlockNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -35,47 +36,41 @@ public ArbitraryCodeBlockNode(ICodeBlockOwner? parentCodeBlockOwner)
return ParentCodeBlockOwner?.GetReturnTypeClauseNode();
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ConstructorDefinitionNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ConstructorDefinitionNode.cs
index 85b66bee2..5dc40798b 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ConstructorDefinitionNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ConstructorDefinitionNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
@@ -65,56 +66,41 @@ public ConstructorDefinitionNode(
return ReturnTypeClauseNode;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- foreach (var argument in FunctionArgumentsListingNode.FunctionArgumentEntryNodeList)
- {
- parserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, parserModel);
-
- /*if (argument.IsOptional)
- parserModel.Binder.BindFunctionOptionalArgument(argument, parserModel);
- else
- parserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, parserModel);*/
-
-
- }
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/DoWhileStatementNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/DoWhileStatementNode.cs
index 5238a4886..1f081892b 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/DoWhileStatementNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/DoWhileStatementNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -52,47 +53,41 @@ public DoWhileStatementNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ForStatementNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ForStatementNode.cs
index 9304c3c6e..526a15171 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ForStatementNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ForStatementNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -61,47 +62,41 @@ public ForStatementNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ForeachStatementNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ForeachStatementNode.cs
index 7c67ee304..d97a4c900 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ForeachStatementNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/ForeachStatementNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -53,46 +54,41 @@ public ForeachStatementNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- parserModel.Binder.BindVariableDeclarationNode(VariableDeclarationNode, parserModel);
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/FunctionDefinitionNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/FunctionDefinitionNode.cs
index 1d2fb95e0..d12ece838 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/FunctionDefinitionNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/FunctionDefinitionNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -72,54 +73,41 @@ public ICodeBlockOwner SetExpressionBody(CodeBlockNode codeBlockNode)
return this;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- foreach (var argument in FunctionArgumentsListingNode.FunctionArgumentEntryNodeList)
- {
- parserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, parserModel);
-
- /*if (argument.IsOptional)
- parserModel.Binder.BindFunctionOptionalArgument(argument, parserModel);
- else
- parserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, parserModel);*/
- }
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/IfStatementNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/IfStatementNode.cs
index 43a2c0d0e..492ffdba3 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/IfStatementNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/IfStatementNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -41,47 +42,41 @@ public IfStatementNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/Interfaces/ICodeBlockOwner.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/Interfaces/ICodeBlockOwner.cs
index 03ba37831..013046ad5 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/Interfaces/ICodeBlockOwner.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/Interfaces/ICodeBlockOwner.cs
@@ -1,3 +1,4 @@
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
using Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
@@ -16,38 +17,28 @@ public interface ICodeBlockOwner : ISyntaxNode
public TypeClauseNode? GetReturnTypeClauseNode();
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel);
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel);
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel);
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel);
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker);
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker);
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker);
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker);
- ///
- /// Once the code block owner's scope has been constructed,
- /// this method gives them an opportunity to pull any variables
- /// into scope that ought to be there.
- /// As well, the current code block builder will have been updated.
- ///
- /// (i.e.: a function definition's arguments)
- ///
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel);
-
- public static void ThrowMultipleScopeDelimiterException(IParserModel parserModel)
+ public static void ThrowMultipleScopeDelimiterException(DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
// 'model.TokenWalker.Current.TextSpan' isn't necessarily the syntax passed to this method.
// TODO: But getting a TextSpan from a general type such as 'ISyntax' is a pain.
//
- parserModel.DiagnosticBag.ReportTodoException(
- parserModel.TokenWalker.Current.TextSpan,
+ diagnosticBag.ReportTodoException(
+ tokenWalker.Current.TextSpan,
"Scope must be set by either OpenBraceToken and CloseBraceToken; or by StatementDelimiterToken, but not both.");
}
- public static void ThrowAlreadyAssignedCodeBlockNodeException(IParserModel parserModel)
+ public static void ThrowAlreadyAssignedCodeBlockNodeException(DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
// 'model.TokenWalker.Current.TextSpan' isn't necessarily the syntax passed to this method.
// TODO: But getting a TextSpan from a general type such as 'ISyntax' is a pain.
//
- parserModel.DiagnosticBag.ReportTodoException(
- parserModel.TokenWalker.Current.TextSpan,
+ diagnosticBag.ReportTodoException(
+ tokenWalker.Current.TextSpan,
$"The {nameof(CodeBlockNode)} was already assigned.");
}
}
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/LockStatementNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/LockStatementNode.cs
index ea340476a..9302bf876 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/LockStatementNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/LockStatementNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -47,47 +48,41 @@ public LockStatementNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/NamespaceStatementNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/NamespaceStatementNode.cs
index 4fa955b80..22bd3580e 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/NamespaceStatementNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/NamespaceStatementNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
@@ -58,47 +59,41 @@ public ImmutableArray GetTopLevelTypeDefinitionNodes()
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- var namespaceString = IdentifierToken.TextSpan.GetText();
- parserModel.Binder.AddNamespaceToCurrentScope(namespaceString, parserModel);
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/SwitchExpressionNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/SwitchExpressionNode.cs
index f039b3252..850242785 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/SwitchExpressionNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/SwitchExpressionNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -41,47 +42,41 @@ public SwitchExpressionNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/SwitchStatementNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/SwitchStatementNode.cs
index b3ba466ba..13f739a06 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/SwitchStatementNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/SwitchStatementNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -47,47 +48,41 @@ public SwitchStatementNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementCatchNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementCatchNode.cs
index 0ff6926a0..81da45ce6 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementCatchNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementCatchNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -48,47 +49,41 @@ public TryStatementCatchNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementFinallyNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementFinallyNode.cs
index fbd687242..dd47dc7e4 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementFinallyNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementFinallyNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -41,47 +42,41 @@ public TryStatementFinallyNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementTryNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementTryNode.cs
index 2b842a443..21c4e07f4 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementTryNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TryStatementTryNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -41,47 +42,41 @@ public TryStatementTryNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TypeDefinitionNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TypeDefinitionNode.cs
index 01c1d6b5d..1239fd693 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TypeDefinitionNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/TypeDefinitionNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -108,40 +109,40 @@ public TypeClauseNode ToTypeClause()
}
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
@@ -149,22 +150,6 @@ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserMode
return this;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- if (PrimaryConstructorFunctionArgumentsListingNode is not null)
- {
- foreach (var argument in PrimaryConstructorFunctionArgumentsListingNode.FunctionArgumentEntryNodeList)
- {
- parserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, parserModel);
-
- /*if (argument.IsOptional)
- parserModel.Binder.BindFunctionOptionalArgument(argument, parserModel);
- else
- parserModel.Binder.BindVariableDeclarationNode(argument.VariableDeclarationNode, parserModel);*/
- }
- }
- }
-
public ICodeBlockOwner SetPrimaryConstructorFunctionArgumentsListingNode(FunctionArgumentsListingNode functionArgumentsListingNode)
{
PrimaryConstructorFunctionArgumentsListingNode = functionArgumentsListingNode;
diff --git a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/WhileStatementNode.cs b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/WhileStatementNode.cs
index a37bb16ac..b61e1f6d7 100644
--- a/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/WhileStatementNode.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Syntax/Nodes/WhileStatementNode.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Interfaces;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Nodes.Enums;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
@@ -47,47 +48,41 @@ public WhileStatementNode(
return null;
}
- public void OnBoundScopeCreatedAndSetAsCurrent(IParserModel parserModel)
- {
- // Do nothing.
- return;
- }
-
// (2024-11-08)
- public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetOpenBraceToken(OpenBraceToken openBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
OpenBraceToken = openBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, IParserModel parserModel)
+ public ICodeBlockOwner SetCloseBraceToken(CloseBraceToken closeBraceToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (StatementDelimiterToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
CloseBraceToken = closeBraceToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, IParserModel parserModel)
+ public ICodeBlockOwner SetStatementDelimiterToken(StatementDelimiterToken statementDelimiterToken, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (OpenBraceToken.ConstructorWasInvoked || CloseBraceToken.ConstructorWasInvoked)
- ICodeBlockOwner.ThrowMultipleScopeDelimiterException(parserModel);
+ ICodeBlockOwner.ThrowMultipleScopeDelimiterException(diagnosticBag, tokenWalker);
StatementDelimiterToken = statementDelimiterToken;
_childListIsDirty = true;
return this;
}
- public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, IParserModel parserModel)
+ public ICodeBlockOwner SetCodeBlockNode(CodeBlockNode codeBlockNode, DiagnosticBag diagnosticBag, TokenWalker tokenWalker)
{
if (CodeBlockNode is not null)
- ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(parserModel);
+ ICodeBlockOwner.ThrowAlreadyAssignedCodeBlockNodeException(diagnosticBag, tokenWalker);
CodeBlockNode = codeBlockNode;
From fd1535f42252b538cf8fcdfda50ee8a2e9690f89 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 18:08:19 -0500
Subject: [PATCH 24/39] Catch exception in SymbolDisplay.razor.cs
---
.../Displays/Internals/SymbolDisplay.razor.cs | 70 ++++++++++++-------
1 file changed, 43 insertions(+), 27 deletions(-)
diff --git a/Source/Lib/TextEditor/TextEditors/Displays/Internals/SymbolDisplay.razor.cs b/Source/Lib/TextEditor/TextEditors/Displays/Internals/SymbolDisplay.razor.cs
index e3529c873..24b00492f 100644
--- a/Source/Lib/TextEditor/TextEditors/Displays/Internals/SymbolDisplay.razor.cs
+++ b/Source/Lib/TextEditor/TextEditors/Displays/Internals/SymbolDisplay.razor.cs
@@ -79,20 +79,28 @@ private Task OpenInEditorOnClick(string filePath)
///
private ISyntaxNode? GetTargetNode(ITextEditorSymbol symbolLocal)
{
- var textEditorModel = TextEditorService.ModelApi.GetOrDefault(symbolLocal.TextSpan.ResourceUri);
- if (textEditorModel is null)
- return null;
-
- var compilerService = textEditorModel.CompilerService;
-
- var compilerServiceResource = compilerService.GetCompilerServiceResourceFor(textEditorModel.ResourceUri);
- if (compilerServiceResource is null)
+ try
+ {
+ var textEditorModel = TextEditorService.ModelApi.GetOrDefault(symbolLocal.TextSpan.ResourceUri);
+ if (textEditorModel is null)
+ return null;
+
+ var compilerService = textEditorModel.CompilerService;
+
+ var compilerServiceResource = compilerService.GetCompilerServiceResourceFor(textEditorModel.ResourceUri);
+ if (compilerServiceResource is null)
+ return null;
+
+ return compilerService.Binder.GetSyntaxNode(
+ symbolLocal.TextSpan.StartingIndexInclusive,
+ compilerServiceResource.ResourceUri,
+ compilerServiceResource);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e);
return null;
-
- return compilerService.Binder.GetSyntaxNode(
- symbolLocal.TextSpan.StartingIndexInclusive,
- compilerServiceResource.ResourceUri,
- compilerServiceResource);
+ }
}
///
@@ -102,23 +110,31 @@ private Task OpenInEditorOnClick(string filePath)
///
private ISyntaxNode? GetDefinitionNode(ITextEditorSymbol symbolLocal, ISyntaxNode targetNode)
{
- if (targetNode is not null)
+ try
{
- switch (targetNode.SyntaxKind)
+ if (targetNode is not null)
{
- case SyntaxKind.ConstructorDefinitionNode:
- case SyntaxKind.FunctionDefinitionNode:
- case SyntaxKind.NamespaceStatementNode:
- case SyntaxKind.TypeDefinitionNode:
- case SyntaxKind.VariableDeclarationNode:
- return targetNode;
+ switch (targetNode.SyntaxKind)
+ {
+ case SyntaxKind.ConstructorDefinitionNode:
+ case SyntaxKind.FunctionDefinitionNode:
+ case SyntaxKind.NamespaceStatementNode:
+ case SyntaxKind.TypeDefinitionNode:
+ case SyntaxKind.VariableDeclarationNode:
+ return targetNode;
+ }
}
+
+ var textEditorModel = TextEditorService.ModelApi.GetOrDefault(symbolLocal.TextSpan.ResourceUri);
+ var compilerService = textEditorModel.CompilerService;
+ var compilerServiceResource = compilerService.GetCompilerServiceResourceFor(textEditorModel.ResourceUri);
+
+ return compilerService.Binder.GetDefinitionNode(symbolLocal.TextSpan, compilerServiceResource);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e);
+ return null;
}
-
- var textEditorModel = TextEditorService.ModelApi.GetOrDefault(symbolLocal.TextSpan.ResourceUri);
- var compilerService = textEditorModel.CompilerService;
- var compilerServiceResource = compilerService.GetCompilerServiceResourceFor(textEditorModel.ResourceUri);
-
- return compilerService.Binder.GetDefinitionNode(symbolLocal.TextSpan, compilerServiceResource);
}
}
\ No newline at end of file
From 6a78c2f39a9a5cfe156eff3a73394c14b163c932 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 18:39:04 -0500
Subject: [PATCH 25/39] All works again?
---
.../CSharp/BinderCase/CSharpBinder.Main.cs | 104 +++++++++++++++++-
.../CSharp/BinderCase/CSharpBinderSession.cs | 4 +-
.../CSharpCompilerService.cs | 8 +-
3 files changed, 104 insertions(+), 12 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
index 5a328b539..320373ba8 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
@@ -19,7 +19,7 @@
namespace Luthetus.CompilerServices.CSharp.BinderCase;
-public partial class CSharpBinder
+public partial class CSharpBinder : IBinder
{
private readonly Dictionary _binderSessionMap = new();
//private readonly object _binderSessionMapLock = new();
@@ -56,6 +56,8 @@ public CSharpBinder()
public IReadOnlyDictionary AllTypeDefinitions => _allTypeDefinitions;
public TextEditorDiagnostic[] DiagnosticsList => Array.Empty();
+ ITextEditorSymbol[] IBinder.SymbolsList => Symbols;
+
///
/// This will return an empty array if the collection is modified during enumeration
/// (specifically this is catching 'InvalidOperationException').
@@ -74,6 +76,9 @@ public ITextEditorSymbol[] Symbols
}
}
}
+
+ IBinderSession IBinder.StartBinderSession(ResourceUri resourceUri) =>
+ StartBinderSession(resourceUri);
///
public CSharpBinderSession StartBinderSession(ResourceUri resourceUri)
@@ -111,6 +116,9 @@ public CSharpBinderSession StartBinderSession(ResourceUri resourceUri)
return cSharpBinderSession;
}
+ void IBinder.FinalizeBinderSession(IBinderSession binderSession) =>
+ FinalizeBinderSession((CSharpBinderSession)binderSession);
+
///
public void FinalizeBinderSession(CSharpBinderSession binderSession)
{
@@ -262,10 +270,16 @@ public void BindFunctionDefinitionNode(
}
}
+ void IBinder.BindFunctionOptionalArgument(FunctionArgumentEntryNode functionArgumentEntryNode, IParserModel parserModel) =>
+ BindFunctionOptionalArgument(functionArgumentEntryNode, compilationUnit: null);
+
public void BindFunctionOptionalArgument(
FunctionArgumentEntryNode functionArgumentEntryNode,
- CSharpCompilationUnit compilationUnit)
+ CSharpCompilationUnit? compilationUnit)
{
+ if (compilationUnit is null)
+ return;
+
var argumentTypeClauseNode = functionArgumentEntryNode.VariableDeclarationNode.TypeClauseNode;
/*
@@ -380,6 +394,9 @@ public InheritanceStatementNode BindInheritanceStatementNode(
return new InheritanceStatementNode(typeClauseNode);
}
+ void IBinder.BindVariableDeclarationNode(IVariableDeclarationNode variableDeclarationNode, IParserModel parserModel) =>
+ BindVariableDeclarationNode(variableDeclarationNode, compilationUnit: null);
+
public void BindVariableDeclarationNode(
IVariableDeclarationNode variableDeclarationNode,
CSharpCompilationUnit compilationUnit)
@@ -646,10 +663,16 @@ public void OpenScope(
compilationUnit.ParserModel.BinderSession.CurrentScopeIndexKey = scope.IndexKey;
}
+ public void AddNamespaceToCurrentScope(string namespaceString, IParserModel parserModel) =>
+ AddNamespaceToCurrentScope(namespaceString, compilationUnit: null);
+
public void AddNamespaceToCurrentScope(
string namespaceString,
- CSharpCompilationUnit compilationUnit)
+ CSharpCompilationUnit? compilationUnit)
{
+ if (compilationUnit is null)
+ return;
+
if (_namespaceGroupNodeMap.TryGetValue(namespaceString, out var namespaceGroupNode) &&
namespaceGroupNode is not null)
{
@@ -1009,11 +1032,17 @@ public bool TryGetVariableDeclarationHierarchically(
return false;
}
+ IScope? IBinder.GetScope(TextEditorTextSpan textSpan) =>
+ GetScope(compilationUnit: null, textSpan);
+
public IScope? GetScope(CSharpCompilationUnit? compilationUnit, TextEditorTextSpan textSpan)
{
return GetScopeByPositionIndex(compilationUnit, textSpan.ResourceUri, textSpan.StartingIndexInclusive);
}
+ IScope? IBinder.GetScopeByPositionIndex(ResourceUri resourceUri, int positionIndex) =>
+ GetScopeByPositionIndex(compilationUnit: null, resourceUri, positionIndex);
+
public IScope? GetScopeByPositionIndex(CSharpCompilationUnit? compilationUnit, ResourceUri resourceUri, int positionIndex)
{
var scopeList = new List();
@@ -1033,6 +1062,9 @@ public bool TryGetVariableDeclarationHierarchically(
return possibleScopes.MinBy(x => positionIndex - x.StartingIndexInclusive);
}
+ IScope? IBinder.GetScopeByScopeIndexKey(ResourceUri resourceUri, int scopeIndexKey) =>
+ GetScopeByScopeIndexKey(compilationUnit: null, resourceUri, scopeIndexKey);
+
public IScope? GetScopeByScopeIndexKey(CSharpCompilationUnit? compilationUnit, ResourceUri resourceUri, int scopeIndexKey)
{
var scopeList = new List();
@@ -1045,6 +1077,9 @@ public bool TryGetVariableDeclarationHierarchically(
return scopeList[scopeIndexKey];
}
+ IScope[]? IBinder.GetScopeList(ResourceUri resourceUri) =>
+ GetScopeList(compilationUnit: null, resourceUri);
+
public IScope[]? GetScopeList(CSharpCompilationUnit? compilationUnit, ResourceUri resourceUri)
{
var scopeList = new List();
@@ -1057,13 +1092,16 @@ public bool TryGetVariableDeclarationHierarchically(
return scopeList.ToArray();
}
+ bool IBinder.TryGetBinderSession(ResourceUri resourceUri, out IBinderSession binderSession) =>
+ TryGetBinderSession(compilationUnit: null, resourceUri, out binderSession);
+
///
/// If the resourceUri is the in progress BinderSession's ResourceUri,
/// then the in progress instance should be returned via the out variable.
///
/// TODO: This is quite confusingly written at the moment.
///
- public bool TryGetBinderSession(CSharpCompilationUnit? compilationUnit, ResourceUri resourceUri, out CSharpBinderSession binderSession)
+ public bool TryGetBinderSession(CSharpCompilationUnit? compilationUnit, ResourceUri resourceUri, out IBinderSession binderSession)
{
if (compilationUnit is not null &&
resourceUri == compilationUnit.ParserModel.BinderSession.ResourceUri)
@@ -1072,9 +1110,14 @@ public bool TryGetBinderSession(CSharpCompilationUnit? compilationUnit, Resource
return true;
}
- return _binderSessionMap.TryGetValue(resourceUri, out binderSession);
+ var success = _binderSessionMap.TryGetValue(resourceUri, out var x);
+ binderSession = x;
+ return success;
}
+ void IBinder.UpsertBinderSession(IBinderSession binderSession) =>
+ UpsertBinderSession((CSharpBinderSession)binderSession);
+
public void UpsertBinderSession(CSharpBinderSession binderSession)
{
try
@@ -1095,6 +1138,9 @@ public bool RemoveBinderSession(ResourceUri resourceUri)
return _binderSessionMap.Remove(resourceUri);
}
+ TypeDefinitionNode[] IBinder.GetTypeDefinitionNodesByScope(ResourceUri resourceUri, int scopeIndexKey) =>
+ GetTypeDefinitionNodesByScope(compilationUnit: null, resourceUri, scopeIndexKey);
+
public TypeDefinitionNode[] GetTypeDefinitionNodesByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1109,6 +1155,9 @@ public TypeDefinitionNode[] GetTypeDefinitionNodesByScope(
.ToArray();
}
+ bool IBinder.TryGetTypeDefinitionNodeByScope(ResourceUri resourceUri, int scopeIndexKey, string typeIdentifierText, out TypeDefinitionNode typeDefinitionNode) =>
+ TryGetTypeDefinitionNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, typeIdentifierText, out typeDefinitionNode);
+
public bool TryGetTypeDefinitionNodeByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1126,6 +1175,9 @@ public bool TryGetTypeDefinitionNodeByScope(
return binderSession.ScopeTypeDefinitionMap.TryGetValue(scopeKeyAndIdentifierText, out typeDefinitionNode);
}
+ bool IBinder.TryAddTypeDefinitionNodeByScope(ResourceUri resourceUri, int scopeIndexKey, string typeIdentifierText, TypeDefinitionNode typeDefinitionNode) =>
+ TryAddTypeDefinitionNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, typeIdentifierText, typeDefinitionNode);
+
public bool TryAddTypeDefinitionNodeByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1140,6 +1192,9 @@ public bool TryAddTypeDefinitionNodeByScope(
return binderSession.ScopeTypeDefinitionMap.TryAdd(scopeKeyAndIdentifierText, typeDefinitionNode);
}
+ void IBinder.SetTypeDefinitionNodeByScope(ResourceUri resourceUri, int scopeIndexKey, string typeIdentifierText, TypeDefinitionNode typeDefinitionNode) =>
+ SetTypeDefinitionNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, typeIdentifierText, typeDefinitionNode);
+
public void SetTypeDefinitionNodeByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1154,6 +1209,9 @@ public void SetTypeDefinitionNodeByScope(
binderSession.ScopeTypeDefinitionMap[scopeKeyAndIdentifierText] = typeDefinitionNode;
}
+ FunctionDefinitionNode[] IBinder.GetFunctionDefinitionNodesByScope(ResourceUri resourceUri, int scopeIndexKey) =>
+ GetFunctionDefinitionNodesByScope(compilationUnit: null, resourceUri, scopeIndexKey);
+
public FunctionDefinitionNode[] GetFunctionDefinitionNodesByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1168,6 +1226,9 @@ public FunctionDefinitionNode[] GetFunctionDefinitionNodesByScope(
.ToArray();
}
+ bool IBinder.TryGetFunctionDefinitionNodeByScope(ResourceUri resourceUri, int scopeIndexKey, string functionIdentifierText, out FunctionDefinitionNode functionDefinitionNode) =>
+ TryGetFunctionDefinitionNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, functionIdentifierText, out functionDefinitionNode);
+
public bool TryGetFunctionDefinitionNodeByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1185,6 +1246,9 @@ public bool TryGetFunctionDefinitionNodeByScope(
return binderSession.ScopeFunctionDefinitionMap.TryGetValue(scopeKeyAndIdentifierText, out functionDefinitionNode);
}
+ bool IBinder.TryAddFunctionDefinitionNodeByScope(ResourceUri resourceUri, int scopeIndexKey, string functionIdentifierText, FunctionDefinitionNode functionDefinitionNode) =>
+ TryAddFunctionDefinitionNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, functionIdentifierText, functionDefinitionNode);
+
public bool TryAddFunctionDefinitionNodeByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1199,6 +1263,9 @@ public bool TryAddFunctionDefinitionNodeByScope(
return binderSession.ScopeFunctionDefinitionMap.TryAdd(scopeKeyAndIdentifierText, functionDefinitionNode);
}
+ void IBinder.SetFunctionDefinitionNodeByScope(ResourceUri resourceUri, int scopeIndexKey, string functionIdentifierText, FunctionDefinitionNode functionDefinitionNode) =>
+ SetFunctionDefinitionNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, functionIdentifierText, functionDefinitionNode);
+
public void SetFunctionDefinitionNodeByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1212,6 +1279,9 @@ public void SetFunctionDefinitionNodeByScope(
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, functionIdentifierText);
binderSession.ScopeFunctionDefinitionMap[scopeKeyAndIdentifierText] = functionDefinitionNode;
}
+
+ IVariableDeclarationNode[] IBinder.GetVariableDeclarationNodesByScope(ResourceUri resourceUri, int scopeIndexKey) =>
+ GetVariableDeclarationNodesByScope(compilationUnit: null, resourceUri, scopeIndexKey);
public IVariableDeclarationNode[] GetVariableDeclarationNodesByScope(
CSharpCompilationUnit? compilationUnit,
@@ -1227,6 +1297,9 @@ public IVariableDeclarationNode[] GetVariableDeclarationNodesByScope(
.ToArray();
}
+ bool IBinder.TryGetVariableDeclarationNodeByScope(ResourceUri resourceUri, int scopeIndexKey, string variableIdentifierText, out IVariableDeclarationNode variableDeclarationNode) =>
+ TryGetVariableDeclarationNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, variableIdentifierText, out variableDeclarationNode);
+
public bool TryGetVariableDeclarationNodeByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1243,6 +1316,9 @@ public bool TryGetVariableDeclarationNodeByScope(
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, variableIdentifierText);
return binderSession.ScopeVariableDeclarationMap.TryGetValue(scopeKeyAndIdentifierText, out variableDeclarationNode);
}
+
+ bool IBinder.TryAddVariableDeclarationNodeByScope(ResourceUri resourceUri, int scopeIndexKey, string variableIdentifierText, IVariableDeclarationNode variableDeclarationNode) =>
+ TryAddVariableDeclarationNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, variableIdentifierText, variableDeclarationNode);
public bool TryAddVariableDeclarationNodeByScope(
CSharpCompilationUnit? compilationUnit,
@@ -1257,6 +1333,9 @@ public bool TryAddVariableDeclarationNodeByScope(
var scopeKeyAndIdentifierText = new ScopeKeyAndIdentifierText(scopeIndexKey, variableIdentifierText);
return binderSession.ScopeVariableDeclarationMap.TryAdd(scopeKeyAndIdentifierText, variableDeclarationNode);
}
+
+ void IBinder.SetVariableDeclarationNodeByScope(ResourceUri resourceUri, int scopeIndexKey, string variableIdentifierText, IVariableDeclarationNode variableDeclarationNode) =>
+ SetVariableDeclarationNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, variableIdentifierText, variableDeclarationNode);
public void SetVariableDeclarationNodeByScope(
CSharpCompilationUnit? compilationUnit,
@@ -1272,6 +1351,9 @@ public void SetVariableDeclarationNodeByScope(
binderSession.ScopeVariableDeclarationMap[scopeKeyAndIdentifierText] = variableDeclarationNode;
}
+ TypeClauseNode? IBinder.GetReturnTypeClauseNodeByScope(ResourceUri resourceUri, int scopeIndexKey) =>
+ GetReturnTypeClauseNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey);
+
public TypeClauseNode? GetReturnTypeClauseNodeByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1286,6 +1368,9 @@ public void SetVariableDeclarationNodeByScope(
return null;
}
+ bool IBinder.TryAddReturnTypeClauseNodeByScope(ResourceUri resourceUri, int scopeIndexKey, TypeClauseNode typeClauseNode) =>
+ TryAddReturnTypeClauseNodeByScope(compilationUnit: null, resourceUri, scopeIndexKey, typeClauseNode);
+
public bool TryAddReturnTypeClauseNodeByScope(
CSharpCompilationUnit? compilationUnit,
ResourceUri resourceUri,
@@ -1301,6 +1386,9 @@ public bool TryAddReturnTypeClauseNodeByScope(
return binderSession.ScopeReturnTypeClauseNodeMap.TryAdd(scopeIndexKey, typeClauseNode);
}
+ public TextEditorTextSpan? GetDefinitionTextSpan(TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource) =>
+ GetDefinitionTextSpan(compilationUnit: null, textSpan, compilerServiceResource);
+
public TextEditorTextSpan? GetDefinitionTextSpan(CSharpCompilationUnit? compilationUnit, TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource)
{
var definitionNode = GetDefinitionNode(compilationUnit, textSpan, compilerServiceResource);
@@ -1321,6 +1409,9 @@ public bool TryAddReturnTypeClauseNodeByScope(
}
}
+ ISyntaxNode? IBinder.GetDefinitionNode(TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource) =>
+ GetDefinitionNode(compilationUnit: null, textSpan, compilerServiceResource);
+
public ISyntaxNode? GetDefinitionNode(CSharpCompilationUnit? compilationUnit, TextEditorTextSpan textSpan, ICompilerServiceResource compilerServiceResource)
{
var boundScope = GetScope(compilationUnit, textSpan);
@@ -1409,6 +1500,9 @@ public bool TryAddReturnTypeClauseNodeByScope(
return null;
}
+ ISyntaxNode? IBinder.GetSyntaxNode(int positionIndex, ResourceUri resourceUri, ICompilerServiceResource? compilerServiceResource) =>
+ GetSyntaxNode(compilationUnit: null, positionIndex, resourceUri, compilerServiceResource);
+
public ISyntaxNode? GetSyntaxNode(CSharpCompilationUnit? compilationUnit, int positionIndex, ResourceUri resourceUri, ICompilerServiceResource? compilerServiceResource)
{
var scope = GetScopeByPositionIndex(compilationUnit, resourceUri, positionIndex);
diff --git a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs
index 6165bb4db..349eaea52 100644
--- a/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs
+++ b/Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinderSession.cs
@@ -8,7 +8,7 @@
namespace Luthetus.CompilerServices.CSharp.BinderCase;
-public class CSharpBinderSession
+public class CSharpBinderSession : IBinderSession
{
///
/// Should 0 be the global scope?
@@ -44,6 +44,8 @@ public CSharpBinderSession(
public Dictionary ScopeFunctionDefinitionMap { get; } = new();
public Dictionary ScopeVariableDeclarationMap { get; } = new();
public Dictionary ScopeReturnTypeClauseNodeMap { get; } = new();
+
+ IBinder IBinderSession.Binder => Binder;
public int GetNextIndexKey()
{
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index 65b888732..527cd0c46 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -31,6 +31,8 @@ public CSharpCompilerService(ITextEditorService textEditorService)
#if DEBUG
++LuthetusDebugSomething.CompilerService_ConstructorInvocationCount;
#endif
+
+ Binder = CSharpBinder;
_compilerServiceOptions = new()
{
@@ -43,12 +45,6 @@ public CSharpCompilerService(ITextEditorService textEditorService)
public override Type? SymbolRendererType { get; protected set; }
public override Type? DiagnosticRendererType { get; protected set; }
- public override IBinder Binder
- {
- get => throw new NotImplementedException("Use {nameof(CSharpBinder)}");
- protected set => throw new NotImplementedException("Use {nameof(CSharpBinder)}");
- }
-
public event Action? CursorMovedInSyntaxTree;
public void SetSymbolRendererType(Type? symbolRendererType)
From 2f8b7288d7abbb5b6a6ac4b275f7abc3adf9bd0a Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 19:17:36 -0500
Subject: [PATCH 26/39] Lexer Inlining some function calls to see what the
effect is
---
.../CSharp/LexerCase/CSharpLexer.cs | 275 +++++++++---------
.../CompilerServices/Interfaces/ILexer.cs | 72 +++++
2 files changed, 206 insertions(+), 141 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index 0fcab474e..92011bad5 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -10,79 +10,7 @@
namespace Luthetus.CompilerServices.CSharp.LexerCase;
-///
-/// Idea...
-/// =======
-///
-/// Preface of the idea:
-/// ====================
-/// The CSharpLexer is constructed within a function invocation,
-/// and is never exposed beyond the scope of that function invocation.
-///
-/// So, perhaps instead of getting the new CSharpLexer() invocations
-/// to be 1 time instead of 1,814 times.
-///
-/// It might be fine to make it a struct.
-///
-/// Issue with the idea:
-/// ====================
-/// I don't want to force every implementation of ILexer to be a struct.
-/// But, at the same time if I reference an ILexer implementation
-/// not by its concrete-struct type, but by the interface,
-/// then that struct will be boxed anyway.
-///
-/// How to continue with the idea:
-/// ==============================
-/// The ICompilerService has the method:
-/// ````public Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier);
-///
-/// Furthermore there is a 'default' implementation of ICompilerService that is available for use by anyone.
-/// It is named 'CompilerService'.
-///
-/// It implements 'ParseAsync(...)' but adds the 'virtual' keyword so that any inheriting type can override it.
-///
-/// Currently, the CSharpCompilerService inherits 'CompilerService' (not the interface).
-///
-/// In order to permit any language to "easily" create an implementation of 'ICompilerService'
-/// they can inherit 'CompilerService' and then override only what they want to be different
-/// from the default setup.
-///
-/// The result of this however is fairly "general" Func<...> that need to be defined
-/// in order to tell the 'CompilerService' how to construct an instance of the language's
-/// ILexer, IParser, IBinder...
-///
-/// So, if one wants to streamline the implementation of 'ICompilerService'
-/// by inheriting 'CompilerService' instead,
-/// then would they be able to avoid the ILexer, IParser, IBinder
-/// requirements of the 'CompilerService' base class?
-/// (Do this in order to avoid boxing of the struct implementation of ILexer or etc...)
-///
-/// The 'CompilerService' only invokes the funcs that provide an instance of ILexer and etc...
-/// from within 'ParseAsync(...)'.
-/// So, one can completely forgo the interface Type and do everything themselves
-/// by overriding 'ParseAsync(...)' in particular.
-/// ("everything" refers to the parsing itself, a lot of defaults are still
-/// being provided by the 'CompilerService' base class).
-///
-/// Side note 1:
-/// ============
-/// What benefits are there to having the parser ask the lexer for the next token
-/// during the lexing process, versus lexing the text entirely and
-/// storing the tokens in a list to then later be given to the parser?
-///
-/// Side note 2:
-/// ============
-/// The CSharpLexer is inheriting 'Lexer' at the moment.
-/// But, this was only done in order provide defaults for someone
-/// who wants to create an ILexer implementation.
-///
-/// The best case scenario is to implement the interface ILexer on CSharpLexer
-/// directly.
-///
-/// Furthermore, if one overrides 'ParseAsync(...)' they don't even
-/// have to implement ILexer at all. They have complete freedom over the 'ParseAsync(...)' method.
-///
-public struct CSharpLexer : ILexer
+public struct CSharpLexer
{
private readonly StringWalker _stringWalker;
private readonly List _syntaxTokenList = new();
@@ -192,98 +120,173 @@ public void Lex()
LexerUtils.LexCharLiteralToken(_stringWalker, _syntaxTokenList, EscapeCharacterList);
break;
case '"':
- LexString(
- _stringWalker,
- _syntaxTokenList,
- countDollarSign: 0,
- useVerbatim: false);
+ LexString(_stringWalker, _syntaxTokenList, countDollarSign: 0, useVerbatim: false);
break;
case '/':
if (_stringWalker.PeekCharacter(1) == '/')
+ {
LexerUtils.LexCommentSingleLineToken(_stringWalker, _syntaxTokenList);
+ }
else if (_stringWalker.PeekCharacter(1) == '*')
+ {
LexerUtils.LexCommentMultiLineToken(_stringWalker, _syntaxTokenList);
+ }
else
- LexerUtils.LexDivisionToken(_stringWalker, _syntaxTokenList);
-
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new DivisionToken(textSpan));
+ }
break;
case '+':
if (_stringWalker.PeekCharacter(1) == '+')
+ {
LexerUtils.LexPlusPlusToken(_stringWalker, _syntaxTokenList);
+ }
else
- LexerUtils.LexPlusToken(_stringWalker, _syntaxTokenList);
-
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new PlusToken(textSpan));
+ }
break;
case '-':
if (_stringWalker.PeekCharacter(1) == '-')
+ {
LexerUtils.LexMinusMinusToken(_stringWalker, _syntaxTokenList);
+ }
else
- LexerUtils.LexMinusToken(_stringWalker, _syntaxTokenList);
-
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new MinusToken(textSpan));
+ }
break;
case '=':
if (_stringWalker.PeekCharacter(1) == '=')
+ {
LexerUtils.LexEqualsEqualsToken(_stringWalker, _syntaxTokenList);
+ }
else
- LexerUtils.LexEqualsToken(_stringWalker, _syntaxTokenList);
-
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new EqualsToken(textSpan));
+ }
break;
case '?':
if (_stringWalker.PeekCharacter(1) == '?')
+ {
LexerUtils.LexQuestionMarkQuestionMarkToken(_stringWalker, _syntaxTokenList);
+ }
else
- LexerUtils.LexQuestionMarkToken(_stringWalker, _syntaxTokenList);
-
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new QuestionMarkToken(textSpan));
+ }
break;
case '*':
- LexerUtils.LexStarToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new StarToken(textSpan));
break;
+ }
case '!':
- LexerUtils.LexBangToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new BangToken(textSpan));
break;
+ }
case ';':
- LexerUtils.LexStatementDelimiterToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new StatementDelimiterToken(textSpan));
break;
+ }
case '(':
- LexerUtils.LexOpenParenthesisToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new OpenParenthesisToken(textSpan));
break;
+ }
case ')':
- LexerUtils.LexCloseParenthesisToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new CloseParenthesisToken(textSpan));
break;
+ }
case '{':
- LexerUtils.LexOpenBraceToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new OpenBraceToken(textSpan));
break;
+ }
case '}':
- LexerUtils.LexCloseBraceToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new CloseBraceToken(textSpan));
break;
+ }
case '<':
- LexerUtils.LexOpenAngleBracketToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new OpenAngleBracketToken(textSpan));
break;
+ }
case '>':
- LexerUtils.LexCloseAngleBracketToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new CloseAngleBracketToken(textSpan));
break;
+ }
case '[':
- LexerUtils.LexOpenSquareBracketToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new OpenSquareBracketToken(textSpan));
break;
+ }
case ']':
- LexerUtils.LexCloseSquareBracketToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new CloseSquareBracketToken(textSpan));
break;
+ }
case '$':
if (_stringWalker.NextCharacter == '"')
{
- LexString(
- _stringWalker,
- _syntaxTokenList,
- countDollarSign: 1,
- useVerbatim: false);
+ LexString(_stringWalker, _syntaxTokenList, countDollarSign: 1, useVerbatim: false);
}
else if (_stringWalker.PeekCharacter(1) == '@' && _stringWalker.PeekCharacter(2) == '"')
{
- LexString(
- _stringWalker,
- _syntaxTokenList,
- countDollarSign: 1,
- useVerbatim: true);
+ LexString(_stringWalker, _syntaxTokenList, countDollarSign: 1, useVerbatim: true);
}
else if (_stringWalker.NextCharacter == '$')
{
@@ -303,12 +306,7 @@ public void Lex()
// Only the last '$' (dollar sign character) will be syntax highlighted
// if this code is NOT included.
- var textSpan = new TextEditorTextSpan(
- entryPositionIndex,
- _stringWalker.PositionIndex,
- (byte)GenericDecorationKind.StringLiteral,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.StringLiteral, _stringWalker.ResourceUri, _stringWalker.SourceText);
_syntaxTokenList.Add(new StringLiteralToken(textSpan));
// From the LexString(...) method:
@@ -317,13 +315,7 @@ public void Lex()
_ = _stringWalker.BacktrackCharacter();
if (_stringWalker.NextCharacter == '"')
- {
- LexString(
- _stringWalker,
- _syntaxTokenList,
- countDollarSign: countDollarSign,
- useVerbatim: false);
- }
+ LexString(_stringWalker, _syntaxTokenList, countDollarSign: countDollarSign, useVerbatim: false);
}
else
{
@@ -332,35 +324,36 @@ public void Lex()
break;
case '@':
if (_stringWalker.NextCharacter == '"')
- {
- LexString(
- _stringWalker,
- _syntaxTokenList,
- countDollarSign: 0,
- useVerbatim: true);
- }
+ LexString(_stringWalker, _syntaxTokenList, countDollarSign: 0, useVerbatim: true);
else if (_stringWalker.PeekCharacter(1) == '$' && _stringWalker.PeekCharacter(2) == '"')
- {
- LexString(
- _stringWalker,
- _syntaxTokenList,
- countDollarSign: 1,
- useVerbatim: true);
- }
+ LexString(_stringWalker, _syntaxTokenList, countDollarSign: 1, useVerbatim: true);
else
- {
LexerUtils.LexAtToken(_stringWalker, _syntaxTokenList);
- }
break;
case ':':
- LexerUtils.LexColonToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new ColonToken(textSpan));
break;
+ }
case '.':
- LexerUtils.LexMemberAccessToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new MemberAccessToken(textSpan));
break;
+ }
case ',':
- LexerUtils.LexCommaToken(_stringWalker, _syntaxTokenList);
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ _syntaxTokenList.Add(new CommaToken(textSpan));
break;
+ }
case '#':
LexerUtils.LexPreprocessorDirectiveToken(_stringWalker, _syntaxTokenList);
break;
diff --git a/Source/Lib/TextEditor/CompilerServices/Interfaces/ILexer.cs b/Source/Lib/TextEditor/CompilerServices/Interfaces/ILexer.cs
index 5cef12749..4cdfb6ef9 100644
--- a/Source/Lib/TextEditor/CompilerServices/Interfaces/ILexer.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Interfaces/ILexer.cs
@@ -4,6 +4,78 @@
namespace Luthetus.TextEditor.RazorLib.CompilerServices.Interfaces;
+///
+/// Idea...
+/// =======
+///
+/// Preface of the idea:
+/// ====================
+/// The CSharpLexer is constructed within a function invocation,
+/// and is never exposed beyond the scope of that function invocation.
+///
+/// So, perhaps instead of getting the new CSharpLexer() invocations
+/// to be 1 time instead of 1,814 times.
+///
+/// It might be fine to make it a struct.
+///
+/// Issue with the idea:
+/// ====================
+/// I don't want to force every implementation of ILexer to be a struct.
+/// But, at the same time if I reference an ILexer implementation
+/// not by its concrete-struct type, but by the interface,
+/// then that struct will be boxed anyway.
+///
+/// How to continue with the idea:
+/// ==============================
+/// The ICompilerService has the method:
+/// ````public Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier);
+///
+/// Furthermore there is a 'default' implementation of ICompilerService that is available for use by anyone.
+/// It is named 'CompilerService'.
+///
+/// It implements 'ParseAsync(...)' but adds the 'virtual' keyword so that any inheriting type can override it.
+///
+/// Currently, the CSharpCompilerService inherits 'CompilerService' (not the interface).
+///
+/// In order to permit any language to "easily" create an implementation of 'ICompilerService'
+/// they can inherit 'CompilerService' and then override only what they want to be different
+/// from the default setup.
+///
+/// The result of this however is fairly "general" Func<...> that need to be defined
+/// in order to tell the 'CompilerService' how to construct an instance of the language's
+/// ILexer, IParser, IBinder...
+///
+/// So, if one wants to streamline the implementation of 'ICompilerService'
+/// by inheriting 'CompilerService' instead,
+/// then would they be able to avoid the ILexer, IParser, IBinder
+/// requirements of the 'CompilerService' base class?
+/// (Do this in order to avoid boxing of the struct implementation of ILexer or etc...)
+///
+/// The 'CompilerService' only invokes the funcs that provide an instance of ILexer and etc...
+/// from within 'ParseAsync(...)'.
+/// So, one can completely forgo the interface Type and do everything themselves
+/// by overriding 'ParseAsync(...)' in particular.
+/// ("everything" refers to the parsing itself, a lot of defaults are still
+/// being provided by the 'CompilerService' base class).
+///
+/// Side note 1:
+/// ============
+/// What benefits are there to having the parser ask the lexer for the next token
+/// during the lexing process, versus lexing the text entirely and
+/// storing the tokens in a list to then later be given to the parser?
+///
+/// Side note 2:
+/// ============
+/// The CSharpLexer is inheriting 'Lexer' at the moment.
+/// But, this was only done in order provide defaults for someone
+/// who wants to create an ILexer implementation.
+///
+/// The best case scenario is to implement the interface ILexer on CSharpLexer
+/// directly.
+///
+/// Furthermore, if one overrides 'ParseAsync(...)' they don't even
+/// have to implement ILexer at all. They have complete freedom over the 'ParseAsync(...)' method.
+///
public interface ILexer
{
public List DiagnosticList { get; }
From 94167509c1c16401ec66ad14e168b05028121c38 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 19:28:46 -0500
Subject: [PATCH 27/39] Create 'LexerKeywords' once
---
Source/Lib/CompilerServices/CSharp/CSharpKeywords.cs | 6 ++++++
Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Source/Lib/CompilerServices/CSharp/CSharpKeywords.cs b/Source/Lib/CompilerServices/CSharp/CSharpKeywords.cs
index 76ddd1244..cdac839ba 100644
--- a/Source/Lib/CompilerServices/CSharp/CSharpKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/CSharpKeywords.cs
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
+using Luthetus.TextEditor.RazorLib.CompilerServices;
namespace Luthetus.CompilerServices.CSharp;
@@ -277,4 +278,9 @@ public class CSharpKeywords
public static readonly ImmutableArray ALL_KEYWORDS = NON_CONTEXTUAL_KEYWORDS
.Union(CONTEXTUAL_KEYWORDS)
.ToImmutableArray();
+
+ public static readonly LexerKeywords LexerKeywords = new LexerKeywords(
+ NON_CONTEXTUAL_KEYWORDS,
+ CONTROL_KEYWORDS,
+ CONTEXTUAL_KEYWORDS);
}
\ No newline at end of file
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index 92011bad5..cffd4eac5 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -24,7 +24,7 @@ public CSharpLexer(ResourceUri resourceUri, string sourceText)
ResourceUri = resourceUri;
SourceText = sourceText;
- LexerKeywords = new LexerKeywords(CSharpKeywords.NON_CONTEXTUAL_KEYWORDS, CSharpKeywords.CONTROL_KEYWORDS, CSharpKeywords.CONTEXTUAL_KEYWORDS);
+ LexerKeywords = CSharpKeywords.LexerKeywords;
_stringWalker = new(resourceUri, sourceText);
}
From 0e6772250d72958024dd8b6960e62ecf11d4774f Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 19:41:59 -0500
Subject: [PATCH 28/39] ALL_KEYWORDS_HASH_SET
---
.../CompilerServices/CSharp/CSharpKeywords.cs | 6 ++-
.../CSharp/LexerCase/CSharpLexer.cs | 49 ++++++++++++++++++-
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/CSharpKeywords.cs b/Source/Lib/CompilerServices/CSharp/CSharpKeywords.cs
index cdac839ba..79ee8cfa4 100644
--- a/Source/Lib/CompilerServices/CSharp/CSharpKeywords.cs
+++ b/Source/Lib/CompilerServices/CSharp/CSharpKeywords.cs
@@ -275,9 +275,11 @@ public class CSharpKeywords
YIELD_KEYWORD,
};
- public static readonly ImmutableArray ALL_KEYWORDS = NON_CONTEXTUAL_KEYWORDS
+ public static readonly string[] ALL_KEYWORDS = NON_CONTEXTUAL_KEYWORDS
.Union(CONTEXTUAL_KEYWORDS)
- .ToImmutableArray();
+ .ToArray();
+
+ public static readonly HashSet ALL_KEYWORDS_HASH_SET = new(ALL_KEYWORDS);
public static readonly LexerKeywords LexerKeywords = new LexerKeywords(
NON_CONTEXTUAL_KEYWORDS,
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index cffd4eac5..0a483a609 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -102,7 +102,7 @@ public void Lex()
case 'Z':
/* Underscore */
case '_':
- LexerUtils.LexIdentifierOrKeywordOrKeywordContextual(_stringWalker, _syntaxTokenList, LexerKeywords);
+ LexIdentifierOrKeywordOrKeywordContextual();
break;
case '0':
case '1':
@@ -612,4 +612,51 @@ private void EscapeCharacterListAdd(TextEditorTextSpan textSpan)
_decorationByteLastEscapeCharacter = textSpan.DecorationByte;
EscapeCharacterList.Add(textSpan);
}
+
+ public void LexIdentifierOrKeywordOrKeywordContextual()
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ while (!_stringWalker.IsEof)
+ {
+ if (!char.IsLetterOrDigit(_stringWalker.CurrentCharacter) &&
+ _stringWalker.CurrentCharacter != '_')
+ {
+ break;
+ }
+
+ _ = _stringWalker.ReadCharacter();
+ }
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.Keyword,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ var textValue = textSpan.GetText();
+
+ if (CSharpKeywords.ALL_KEYWORDS_HASH_SET.Contains(textValue))
+ {
+ if (CSharpKeywords.LexerKeywords.ControlKeywords.Contains(textValue))
+ {
+ textSpan = textSpan with
+ {
+ DecorationByte = (byte)GenericDecorationKind.KeywordControl,
+ };
+ }
+
+ if (CSharpKeywords.LexerKeywords.ContextualKeywords.Contains(textValue))
+ {
+ _syntaxTokenList.Add(new KeywordContextualToken(textSpan, LexerUtils.GetSyntaxKindForContextualKeyword(textSpan)));
+ return;
+ }
+
+ _syntaxTokenList.Add(new KeywordToken(textSpan, LexerUtils.GetSyntaxKindForKeyword(textSpan)));
+ return;
+ }
+
+ _syntaxTokenList.Add(new IdentifierToken(textSpan));
+ }
}
\ No newline at end of file
From 000a0ea293e1214b85d5503e9c8a6a9e14b8f892 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 19:44:45 -0500
Subject: [PATCH 29/39] Fix: accidentally made "everything" a keyword
---
.../CSharp/LexerCase/CSharpLexer.cs | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index 0a483a609..c4a4ddbc1 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -631,7 +631,7 @@ public void LexIdentifierOrKeywordOrKeywordContextual()
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
_stringWalker.PositionIndex,
- (byte)GenericDecorationKind.Keyword,
+ (byte)GenericDecorationKind.None,
_stringWalker.ResourceUri,
_stringWalker.SourceText);
@@ -639,13 +639,15 @@ public void LexIdentifierOrKeywordOrKeywordContextual()
if (CSharpKeywords.ALL_KEYWORDS_HASH_SET.Contains(textValue))
{
+ var decorationByte = (byte)GenericDecorationKind.Keyword;
+
if (CSharpKeywords.LexerKeywords.ControlKeywords.Contains(textValue))
+ decorationByte = (byte)GenericDecorationKind.KeywordControl;
+
+ textSpan = textSpan with
{
- textSpan = textSpan with
- {
- DecorationByte = (byte)GenericDecorationKind.KeywordControl,
- };
- }
+ DecorationByte = decorationByte,
+ };
if (CSharpKeywords.LexerKeywords.ContextualKeywords.Contains(textValue))
{
From 9b3a97d2085829650490e40bae5c47bebd78dda6 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 19:52:28 -0500
Subject: [PATCH 30/39] CSharpLexer.cs: Remove unused function arguments
---
.../CSharp/LexerCase/CSharpLexer.cs | 132 +++++++++---------
1 file changed, 64 insertions(+), 68 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index c4a4ddbc1..201ee3d02 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -120,7 +120,7 @@ public void Lex()
LexerUtils.LexCharLiteralToken(_stringWalker, _syntaxTokenList, EscapeCharacterList);
break;
case '"':
- LexString(_stringWalker, _syntaxTokenList, countDollarSign: 0, useVerbatim: false);
+ LexString(countDollarSign: 0, useVerbatim: false);
break;
case '/':
if (_stringWalker.PeekCharacter(1) == '/')
@@ -282,11 +282,11 @@ public void Lex()
case '$':
if (_stringWalker.NextCharacter == '"')
{
- LexString(_stringWalker, _syntaxTokenList, countDollarSign: 1, useVerbatim: false);
+ LexString(countDollarSign: 1, useVerbatim: false);
}
else if (_stringWalker.PeekCharacter(1) == '@' && _stringWalker.PeekCharacter(2) == '"')
{
- LexString(_stringWalker, _syntaxTokenList, countDollarSign: 1, useVerbatim: true);
+ LexString(countDollarSign: 1, useVerbatim: true);
}
else if (_stringWalker.NextCharacter == '$')
{
@@ -315,7 +315,7 @@ public void Lex()
_ = _stringWalker.BacktrackCharacter();
if (_stringWalker.NextCharacter == '"')
- LexString(_stringWalker, _syntaxTokenList, countDollarSign: countDollarSign, useVerbatim: false);
+ LexString(countDollarSign: countDollarSign, useVerbatim: false);
}
else
{
@@ -324,9 +324,9 @@ public void Lex()
break;
case '@':
if (_stringWalker.NextCharacter == '"')
- LexString(_stringWalker, _syntaxTokenList, countDollarSign: 0, useVerbatim: true);
+ LexString(countDollarSign: 0, useVerbatim: true);
else if (_stringWalker.PeekCharacter(1) == '$' && _stringWalker.PeekCharacter(2) == '"')
- LexString(_stringWalker, _syntaxTokenList, countDollarSign: 1, useVerbatim: true);
+ LexString(countDollarSign: 1, useVerbatim: true);
else
LexerUtils.LexAtToken(_stringWalker, _syntaxTokenList);
break;
@@ -380,99 +380,95 @@ public void Lex()
/// The reason being: you don't know if it is a string until you've read all of the '$' (dollar sign characters).
/// So in order to invoke this method the invoker had to have counted them.
///
- private void LexString(
- StringWalker stringWalker,
- List syntaxTokenList,
- int countDollarSign,
- bool useVerbatim)
+ private void LexString(int countDollarSign, bool useVerbatim)
{
- var entryPositionIndex = stringWalker.PositionIndex;
+ var entryPositionIndex = _stringWalker.PositionIndex;
var useInterpolation = countDollarSign > 0;
if (useInterpolation)
- _ = stringWalker.ReadCharacter(); // Move past the '$' (dollar sign character); awkwardly even if there are many of these it is expected that the last one will not have been consumed.
+ _ = _stringWalker.ReadCharacter(); // Move past the '$' (dollar sign character); awkwardly even if there are many of these it is expected that the last one will not have been consumed.
if (useVerbatim)
- _ = stringWalker.ReadCharacter(); // Move past the '@' (at character)
+ _ = _stringWalker.ReadCharacter(); // Move past the '@' (at character)
var useRaw = false;
int countDoubleQuotes = 0;
- if (!useVerbatim && stringWalker.PeekCharacter(1) == '\"' && stringWalker.PeekCharacter(2) == '\"')
+ if (!useVerbatim && _stringWalker.PeekCharacter(1) == '\"' && _stringWalker.PeekCharacter(2) == '\"')
{
useRaw = true;
// Count the amount of double quotes to be used as the delimiter.
- while (!stringWalker.IsEof)
+ while (!_stringWalker.IsEof)
{
- if (stringWalker.CurrentCharacter != '\"')
+ if (_stringWalker.CurrentCharacter != '\"')
break;
++countDoubleQuotes;
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
}
}
else
{
- _ = stringWalker.ReadCharacter(); // Move past the '"' (double quote character)
+ _ = _stringWalker.ReadCharacter(); // Move past the '"' (double quote character)
}
- while (!stringWalker.IsEof)
+ while (!_stringWalker.IsEof)
{
- if (stringWalker.CurrentCharacter == '\"')
+ if (_stringWalker.CurrentCharacter == '\"')
{
if (useRaw)
{
var matchDoubleQuotes = 0;
- while (!stringWalker.IsEof)
+ while (!_stringWalker.IsEof)
{
- if (stringWalker.CurrentCharacter != '\"')
+ if (_stringWalker.CurrentCharacter != '\"')
break;
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
if (++matchDoubleQuotes == countDoubleQuotes)
goto foundEndDelimiter;
}
continue;
}
- else if (useVerbatim && stringWalker.NextCharacter == '\"')
+ else if (useVerbatim && _stringWalker.NextCharacter == '\"')
{
if (EscapeCharacterList is not null)
{
EscapeCharacterListAdd(new TextEditorTextSpan(
- stringWalker.PositionIndex,
- stringWalker.PositionIndex + 2,
+ _stringWalker.PositionIndex,
+ _stringWalker.PositionIndex + 2,
(byte)GenericDecorationKind.EscapeCharacterPrimary,
- stringWalker.ResourceUri,
- stringWalker.SourceText));
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText));
}
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
}
else
{
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
break;
}
}
- else if (!useVerbatim && stringWalker.CurrentCharacter == '\\')
+ else if (!useVerbatim && _stringWalker.CurrentCharacter == '\\')
{
if (EscapeCharacterList is not null)
{
EscapeCharacterListAdd(new TextEditorTextSpan(
- stringWalker.PositionIndex,
- stringWalker.PositionIndex + 2,
+ _stringWalker.PositionIndex,
+ _stringWalker.PositionIndex + 2,
(byte)GenericDecorationKind.EscapeCharacterPrimary,
- stringWalker.ResourceUri,
- stringWalker.SourceText));
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText));
}
// Presuming the escaped text is 2 characters, then read an extra character.
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
}
- else if (useInterpolation && stringWalker.CurrentCharacter == '{')
+ else if (useInterpolation && _stringWalker.CurrentCharacter == '{')
{
// With raw, one is escaping by way of typing less.
// With normal interpolation, one is escaping by way of typing more.
@@ -480,20 +476,20 @@ private void LexString(
// Thus, these are two separate cases written as an if-else.
if (useRaw)
{
- var interpolationTemporaryPositionIndex = stringWalker.PositionIndex;
+ var interpolationTemporaryPositionIndex = _stringWalker.PositionIndex;
var matchBrace = 0;
- while (!stringWalker.IsEof)
+ while (!_stringWalker.IsEof)
{
- if (stringWalker.CurrentCharacter != '{')
+ if (_stringWalker.CurrentCharacter != '{')
break;
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
if (++matchBrace >= countDollarSign)
{
// Found yet another '{' match beyond what was needed.
// So, this logic will match from the inside to the outside.
- if (stringWalker.CurrentCharacter == '{')
+ if (_stringWalker.CurrentCharacter == '{')
{
++interpolationTemporaryPositionIndex;
}
@@ -503,8 +499,8 @@ private void LexString(
entryPositionIndex,
interpolationTemporaryPositionIndex,
(byte)GenericDecorationKind.StringLiteral,
- stringWalker.ResourceUri,
- stringWalker.SourceText);
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
_syntaxTokenList.Add(new StringLiteralToken(innerTextSpan));
// 'LexInterpolatedExpression' is expected to consume one more after it is finished.
@@ -512,85 +508,85 @@ private void LexString(
// closing double quotes if the expression were the last thing in the string.
//
// So, a backtrack is done.
- LexInterpolatedExpression(stringWalker, syntaxTokenList, countDollarSign);
- entryPositionIndex = stringWalker.PositionIndex;
- stringWalker.BacktrackCharacter();
+ LexInterpolatedExpression(countDollarSign);
+ entryPositionIndex = _stringWalker.PositionIndex;
+ _stringWalker.BacktrackCharacter();
}
}
}
}
else
{
- if (stringWalker.NextCharacter == '{')
+ if (_stringWalker.NextCharacter == '{')
{
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
}
else
{
var innerTextSpan = new TextEditorTextSpan(
entryPositionIndex,
- stringWalker.PositionIndex,
+ _stringWalker.PositionIndex,
(byte)GenericDecorationKind.StringLiteral,
- stringWalker.ResourceUri,
- stringWalker.SourceText);
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
_syntaxTokenList.Add(new StringLiteralToken(innerTextSpan));
// 'LexInterpolatedExpression' is expected to consume one more after it is finished.
// Thus, if this while loop were to consume, it would skip the
// closing double quotes if the expression were the last thing in the string.
- LexInterpolatedExpression(stringWalker, syntaxTokenList, countDollarSign);
- entryPositionIndex = stringWalker.PositionIndex;
+ LexInterpolatedExpression(countDollarSign);
+ entryPositionIndex = _stringWalker.PositionIndex;
continue;
}
}
}
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
}
foundEndDelimiter:
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- stringWalker.PositionIndex,
+ _stringWalker.PositionIndex,
(byte)GenericDecorationKind.StringLiteral,
- stringWalker.ResourceUri,
- stringWalker.SourceText);
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
_syntaxTokenList.Add(new StringLiteralToken(textSpan));
}
- private void LexInterpolatedExpression(StringWalker stringWalker, List syntaxTokenList, int countDollarSign)
+ private void LexInterpolatedExpression(int countDollarSign)
{
- var entryPositionIndex = stringWalker.PositionIndex;
+ var entryPositionIndex = _stringWalker.PositionIndex;
- if (stringWalker.CurrentCharacter == '{')
+ if (_stringWalker.CurrentCharacter == '{')
{
// The normal interpolation will invoke this method with '{' as the current character.
//
// But, raw interpolation will invoke this method 1 index further than the final '{' that
// deliminates the start of the interpolated expression.
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
}
var unmatchedBraceCounter = countDollarSign;
- while (!stringWalker.IsEof)
+ while (!_stringWalker.IsEof)
{
- if (stringWalker.CurrentCharacter == '{')
+ if (_stringWalker.CurrentCharacter == '{')
{
++unmatchedBraceCounter;
}
- else if (stringWalker.CurrentCharacter == '}')
+ else if (_stringWalker.CurrentCharacter == '}')
{
if (--unmatchedBraceCounter <= 0)
break;
}
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
}
- _ = stringWalker.ReadCharacter();
+ _ = _stringWalker.ReadCharacter();
}
private void EscapeCharacterListAdd(TextEditorTextSpan textSpan)
From 6a210fa85f2644e92582c133f3221bbb651b0b88 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 20:43:43 -0500
Subject: [PATCH 31/39] ref struct?
---
.../CSharp/LexerCase/CSharpLexer.cs | 367 ++++++++++++++++--
.../Utility/StringWalkerStruct.cs | 307 +++++++++++++++
.../Lexers/Models/TextEditorTextSpan.cs | 19 +
.../Internals/AutocompleteMenu.razor.cs | 1 -
4 files changed, 664 insertions(+), 30 deletions(-)
create mode 100644 Source/Lib/TextEditor/CompilerServices/Utility/StringWalkerStruct.cs
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index 201ee3d02..ad1a2fe4f 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -12,7 +12,6 @@ namespace Luthetus.CompilerServices.CSharp.LexerCase;
public struct CSharpLexer
{
- private readonly StringWalker _stringWalker;
private readonly List _syntaxTokenList = new();
private readonly DiagnosticBag _diagnosticBag = new();
@@ -25,8 +24,6 @@ public CSharpLexer(ResourceUri resourceUri, string sourceText)
ResourceUri = resourceUri;
SourceText = sourceText;
LexerKeywords = CSharpKeywords.LexerKeywords;
-
- _stringWalker = new(resourceUri, sourceText);
}
private byte _decorationByteLastEscapeCharacter = (byte)GenericDecorationKind.None;
@@ -42,6 +39,8 @@ public CSharpLexer(ResourceUri resourceUri, string sourceText)
public void Lex()
{
+ var _stringWalker = new StringWalkerStruct(ResourceUri, SourceText);
+
while (!_stringWalker.IsEof)
{
switch (_stringWalker.CurrentCharacter)
@@ -102,7 +101,7 @@ public void Lex()
case 'Z':
/* Underscore */
case '_':
- LexIdentifierOrKeywordOrKeywordContextual();
+ LexIdentifierOrKeywordOrKeywordContextual(ref _stringWalker);
break;
case '0':
case '1':
@@ -114,22 +113,22 @@ public void Lex()
case '7':
case '8':
case '9':
- LexerUtils.LexNumericLiteralToken(_stringWalker, _syntaxTokenList);
+ LexNumericLiteralToken(ref _stringWalker);
break;
case '\'':
- LexerUtils.LexCharLiteralToken(_stringWalker, _syntaxTokenList, EscapeCharacterList);
+ LexCharLiteralToken(ref _stringWalker);
break;
case '"':
- LexString(countDollarSign: 0, useVerbatim: false);
+ LexString(ref _stringWalker, countDollarSign: 0, useVerbatim: false);
break;
case '/':
if (_stringWalker.PeekCharacter(1) == '/')
{
- LexerUtils.LexCommentSingleLineToken(_stringWalker, _syntaxTokenList);
+ LexCommentSingleLineToken(ref _stringWalker);
}
else if (_stringWalker.PeekCharacter(1) == '*')
{
- LexerUtils.LexCommentMultiLineToken(_stringWalker, _syntaxTokenList);
+ LexCommentMultiLineToken(ref _stringWalker);
}
else
{
@@ -142,7 +141,7 @@ public void Lex()
case '+':
if (_stringWalker.PeekCharacter(1) == '+')
{
- LexerUtils.LexPlusPlusToken(_stringWalker, _syntaxTokenList);
+ LexPlusPlusToken(ref _stringWalker);
}
else
{
@@ -155,7 +154,7 @@ public void Lex()
case '-':
if (_stringWalker.PeekCharacter(1) == '-')
{
- LexerUtils.LexMinusMinusToken(_stringWalker, _syntaxTokenList);
+ LexMinusMinusToken(ref _stringWalker);
}
else
{
@@ -168,7 +167,7 @@ public void Lex()
case '=':
if (_stringWalker.PeekCharacter(1) == '=')
{
- LexerUtils.LexEqualsEqualsToken(_stringWalker, _syntaxTokenList);
+ LexEqualsEqualsToken(ref _stringWalker);
}
else
{
@@ -181,7 +180,7 @@ public void Lex()
case '?':
if (_stringWalker.PeekCharacter(1) == '?')
{
- LexerUtils.LexQuestionMarkQuestionMarkToken(_stringWalker, _syntaxTokenList);
+ LexQuestionMarkQuestionMarkToken(ref _stringWalker);
}
else
{
@@ -282,11 +281,11 @@ public void Lex()
case '$':
if (_stringWalker.NextCharacter == '"')
{
- LexString(countDollarSign: 1, useVerbatim: false);
+ LexString(ref _stringWalker, countDollarSign: 1, useVerbatim: false);
}
else if (_stringWalker.PeekCharacter(1) == '@' && _stringWalker.PeekCharacter(2) == '"')
{
- LexString(countDollarSign: 1, useVerbatim: true);
+ LexString(ref _stringWalker, countDollarSign: 1, useVerbatim: true);
}
else if (_stringWalker.NextCharacter == '$')
{
@@ -315,20 +314,20 @@ public void Lex()
_ = _stringWalker.BacktrackCharacter();
if (_stringWalker.NextCharacter == '"')
- LexString(countDollarSign: countDollarSign, useVerbatim: false);
+ LexString(ref _stringWalker, countDollarSign: countDollarSign, useVerbatim: false);
}
else
{
- LexerUtils.LexDollarSignToken(_stringWalker, _syntaxTokenList);
+ LexDollarSignToken(ref _stringWalker);
}
break;
case '@':
if (_stringWalker.NextCharacter == '"')
- LexString(countDollarSign: 0, useVerbatim: true);
+ LexString(ref _stringWalker, countDollarSign: 0, useVerbatim: true);
else if (_stringWalker.PeekCharacter(1) == '$' && _stringWalker.PeekCharacter(2) == '"')
- LexString(countDollarSign: 1, useVerbatim: true);
+ LexString(ref _stringWalker, countDollarSign: 1, useVerbatim: true);
else
- LexerUtils.LexAtToken(_stringWalker, _syntaxTokenList);
+ LexAtToken(ref _stringWalker);
break;
case ':':
{
@@ -355,7 +354,7 @@ public void Lex()
break;
}
case '#':
- LexerUtils.LexPreprocessorDirectiveToken(_stringWalker, _syntaxTokenList);
+ LexPreprocessorDirectiveToken(ref _stringWalker);
break;
default:
_ = _stringWalker.ReadCharacter();
@@ -380,7 +379,7 @@ public void Lex()
/// The reason being: you don't know if it is a string until you've read all of the '$' (dollar sign characters).
/// So in order to invoke this method the invoker had to have counted them.
///
- private void LexString(int countDollarSign, bool useVerbatim)
+ private void LexString(ref StringWalkerStruct _stringWalker, int countDollarSign, bool useVerbatim)
{
var entryPositionIndex = _stringWalker.PositionIndex;
@@ -437,7 +436,7 @@ private void LexString(int countDollarSign, bool useVerbatim)
{
if (EscapeCharacterList is not null)
{
- EscapeCharacterListAdd(new TextEditorTextSpan(
+ EscapeCharacterListAdd(ref _stringWalker, new TextEditorTextSpan(
_stringWalker.PositionIndex,
_stringWalker.PositionIndex + 2,
(byte)GenericDecorationKind.EscapeCharacterPrimary,
@@ -457,7 +456,7 @@ private void LexString(int countDollarSign, bool useVerbatim)
{
if (EscapeCharacterList is not null)
{
- EscapeCharacterListAdd(new TextEditorTextSpan(
+ EscapeCharacterListAdd(ref _stringWalker, new TextEditorTextSpan(
_stringWalker.PositionIndex,
_stringWalker.PositionIndex + 2,
(byte)GenericDecorationKind.EscapeCharacterPrimary,
@@ -508,7 +507,7 @@ private void LexString(int countDollarSign, bool useVerbatim)
// closing double quotes if the expression were the last thing in the string.
//
// So, a backtrack is done.
- LexInterpolatedExpression(countDollarSign);
+ LexInterpolatedExpression(ref _stringWalker, countDollarSign);
entryPositionIndex = _stringWalker.PositionIndex;
_stringWalker.BacktrackCharacter();
}
@@ -534,7 +533,7 @@ private void LexString(int countDollarSign, bool useVerbatim)
// 'LexInterpolatedExpression' is expected to consume one more after it is finished.
// Thus, if this while loop were to consume, it would skip the
// closing double quotes if the expression were the last thing in the string.
- LexInterpolatedExpression(countDollarSign);
+ LexInterpolatedExpression(ref _stringWalker, countDollarSign);
entryPositionIndex = _stringWalker.PositionIndex;
continue;
}
@@ -556,7 +555,7 @@ private void LexString(int countDollarSign, bool useVerbatim)
_syntaxTokenList.Add(new StringLiteralToken(textSpan));
}
- private void LexInterpolatedExpression(int countDollarSign)
+ private void LexInterpolatedExpression(ref StringWalkerStruct _stringWalker, int countDollarSign)
{
var entryPositionIndex = _stringWalker.PositionIndex;
@@ -589,7 +588,7 @@ private void LexInterpolatedExpression(int countDollarSign)
_ = _stringWalker.ReadCharacter();
}
- private void EscapeCharacterListAdd(TextEditorTextSpan textSpan)
+ private void EscapeCharacterListAdd(ref StringWalkerStruct _stringWalker, TextEditorTextSpan textSpan)
{
if (EscapeCharacterList.Count > 0)
{
@@ -609,7 +608,7 @@ private void EscapeCharacterListAdd(TextEditorTextSpan textSpan)
EscapeCharacterList.Add(textSpan);
}
- public void LexIdentifierOrKeywordOrKeywordContextual()
+ public void LexIdentifierOrKeywordOrKeywordContextual(ref StringWalkerStruct _stringWalker)
{
var entryPositionIndex = _stringWalker.PositionIndex;
@@ -657,4 +656,314 @@ public void LexIdentifierOrKeywordOrKeywordContextual()
_syntaxTokenList.Add(new IdentifierToken(textSpan));
}
+
+ public void LexNumericLiteralToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ // Declare outside the while loop to avoid overhead of redeclaring each loop? not sure
+ var isNotANumber = false;
+
+ while (!_stringWalker.IsEof)
+ {
+ switch (_stringWalker.CurrentCharacter)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ break;
+ default:
+ isNotANumber = true;
+ break;
+ }
+
+ if (isNotANumber)
+ break;
+
+ _ = _stringWalker.ReadCharacter();
+ }
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.None,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new NumericLiteralToken(textSpan));
+ }
+
+ public void LexCharLiteralToken(ref StringWalkerStruct _stringWalker)
+ {
+ var delimiter = '\'';
+ var escapeCharacter = '\\';
+
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ // Move past the opening delimiter
+ _ = _stringWalker.ReadCharacter();
+
+ while (!_stringWalker.IsEof)
+ {
+ if (_stringWalker.CurrentCharacter == delimiter)
+ {
+ _ = _stringWalker.ReadCharacter();
+ break;
+ }
+ else if (_stringWalker.CurrentCharacter == escapeCharacter)
+ {
+ if (EscapeCharacterList is not null)
+ {
+ EscapeCharacterList.Add(new TextEditorTextSpan(
+ _stringWalker.PositionIndex,
+ _stringWalker.PositionIndex + 2,
+ (byte)GenericDecorationKind.EscapeCharacterPrimary,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText));
+ }
+
+ // Presuming the escaped text is 2 characters,
+ // then read an extra character.
+ _ = _stringWalker.ReadCharacter();
+ }
+
+ _ = _stringWalker.ReadCharacter();
+ }
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.StringLiteral,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new CharLiteralToken(textSpan));
+ }
+
+ public void LexCommentSingleLineToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ // Declare outside the while loop to avoid overhead of redeclaring each loop? not sure
+ var isNewLineCharacter = false;
+
+ while (!_stringWalker.IsEof)
+ {
+ switch (_stringWalker.CurrentCharacter)
+ {
+ case '\r':
+ case '\n':
+ isNewLineCharacter = true;
+ break;
+ default:
+ break;
+ }
+
+ if (isNewLineCharacter)
+ break;
+
+ _ = _stringWalker.ReadCharacter();
+ }
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.CommentSingleLine,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new CommentSingleLineToken(textSpan));
+ }
+
+ public void LexCommentMultiLineToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ // Move past the initial "/*"
+ _ = _stringWalker.ReadRange(2);
+
+ // Declare outside the while loop to avoid overhead of redeclaring each loop? not sure
+ var possibleClosingText = false;
+ var sawClosingText = false;
+
+ while (!_stringWalker.IsEof)
+ {
+ switch (_stringWalker.CurrentCharacter)
+ {
+ case '*':
+ possibleClosingText = true;
+ break;
+ case '/':
+ if (possibleClosingText)
+ sawClosingText = true;
+ break;
+ default:
+ break;
+ }
+
+ _ = _stringWalker.ReadCharacter();
+
+ if (sawClosingText)
+ break;
+ }
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.CommentMultiLine,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new CommentMultiLineToken(textSpan));
+ }
+
+ public void LexPlusPlusToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ // First '+'
+ _stringWalker.ReadCharacter();
+ // Second '+'
+ _stringWalker.ReadCharacter();
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.None,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new PlusPlusToken(textSpan));
+ }
+
+ public void LexMinusMinusToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ // First '-'
+ _stringWalker.ReadCharacter();
+ // Second '-'
+ _stringWalker.ReadCharacter();
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.None,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new MinusMinusToken(textSpan));
+ }
+
+ public void LexEqualsEqualsToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ // First '='
+ _stringWalker.ReadCharacter();
+ // Second '='
+ _stringWalker.ReadCharacter();
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.None,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new EqualsEqualsToken(textSpan));
+ }
+
+ public void LexQuestionMarkQuestionMarkToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ // First '?'
+ _stringWalker.ReadCharacter();
+ // Second '?'
+ _stringWalker.ReadCharacter();
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.None,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new QuestionMarkQuestionMarkToken(textSpan));
+ }
+
+ public void LexDollarSignToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ _stringWalker.ReadCharacter();
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.None,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new DollarSignToken(textSpan));
+ }
+
+ public void LexAtToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ _stringWalker.ReadCharacter();
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.None,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new AtToken(textSpan));
+ }
+
+ public void LexPreprocessorDirectiveToken(ref StringWalkerStruct _stringWalker)
+ {
+ var entryPositionIndex = _stringWalker.PositionIndex;
+
+ // Declare outside the while loop to avoid overhead of redeclaring each loop? not sure
+ var isNewLineCharacter = false;
+
+ while (!_stringWalker.IsEof)
+ {
+ switch (_stringWalker.CurrentCharacter)
+ {
+ case '\r':
+ case '\n':
+ isNewLineCharacter = true;
+ break;
+ default:
+ break;
+ }
+
+ if (isNewLineCharacter)
+ break;
+
+ _ = _stringWalker.ReadCharacter();
+ }
+
+ var textSpan = new TextEditorTextSpan(
+ entryPositionIndex,
+ _stringWalker.PositionIndex,
+ (byte)GenericDecorationKind.None,
+ _stringWalker.ResourceUri,
+ _stringWalker.SourceText);
+
+ _syntaxTokenList.Add(new PreprocessorDirectiveToken(textSpan));
+ }
}
\ No newline at end of file
diff --git a/Source/Lib/TextEditor/CompilerServices/Utility/StringWalkerStruct.cs b/Source/Lib/TextEditor/CompilerServices/Utility/StringWalkerStruct.cs
new file mode 100644
index 000000000..57930ea1c
--- /dev/null
+++ b/Source/Lib/TextEditor/CompilerServices/Utility/StringWalkerStruct.cs
@@ -0,0 +1,307 @@
+using System.Collections.Immutable;
+using System.Text;
+using Luthetus.Common.RazorLib.Keyboards.Models;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Facts;
+using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;
+using Luthetus.TextEditor.RazorLib.Exceptions;
+using Luthetus.TextEditor.RazorLib.Lexers.Models;
+
+namespace Luthetus.TextEditor.RazorLib.CompilerServices.Utility;
+
+/// Provides common API that can be used when implementing an for the .
The marker for an out of bounds read is .
+public struct StringWalkerStruct
+{
+ /// Pass in the of a file, and its text. One can pass in for the if they are only working with the text itself.
+ public StringWalkerStruct(ResourceUri resourceUri, string sourceText)
+ {
+ #if DEBUG
+ ++LuthetusDebugSomething.StringWalker_ConstructorInvocationCount;
+ #endif
+
+ ResourceUri = resourceUri;
+ SourceText = sourceText;
+ }
+
+ /// The character index within the .
+ public int PositionIndex { get; private set; }
+
+ /// The file that the came from.
+ public ResourceUri ResourceUri { get; }
+
+ /// The text which is to be stepped through.
+ public string SourceText { get; }
+
+ /// Returns invoked with the value of zero
+ public char CurrentCharacter => PeekCharacter(0);
+
+ /// Returns invoked with the value of one
+ public char NextCharacter => PeekCharacter(1);
+
+ /// Starting with evaluated at 0 return that and the rest of the
=> SourceText.Substring(PositionIndex);
+ public string RemainingText => SourceText[PositionIndex..];
+
+ /// Returns if the current character is the end of file character
+ public bool IsEof => CurrentCharacter == ParserFacts.END_OF_FILE;
+
+ /// If is within bounds of the .
Then the character within the string at index of is returned and is incremented by one.
Otherwise, is returned and the value of is unchanged.
+ public char ReadCharacter()
+ {
+ if (PositionIndex >= SourceText.Length)
+ return ParserFacts.END_OF_FILE;
+
+ return SourceText[PositionIndex++];
+ }
+
+ /// If ( + ) is within bounds of the .
Then the character within the string at index of ( + ) is returned and is unchanged.
Otherwise, is returned and the value of is unchanged.
offset must be > -1
+ public char PeekCharacter(int offset)
+ {
+ if (offset <= -1)
+ throw new LuthetusTextEditorException($"{nameof(offset)} must be > -1");
+
+ if (PositionIndex + offset >= SourceText.Length)
+ return ParserFacts.END_OF_FILE;
+
+ return SourceText[PositionIndex + offset];
+ }
+
+ /// If being decremented by 1 would result in being less than 0.
Then will be returned and will be left unchanged.
Otherwise, will be decremented by one and the character within the string at index of is returned.
+ public char BacktrackCharacter()
+ {
+ if (PositionIndex == 0)
+ return ParserFacts.END_OF_FILE;
+
+ PositionIndex--;
+
+ return PeekCharacter(0);
+ }
+
+ /// Iterates a counter from 0 until the counter is equal to .
Each iteration will be invoked.
If an iteration's invocation of returned then the method will short circuit and return regardless of whether it finished iterating to or not.
+ public string ReadRange(int length)
+ {
+ var consumeBuilder = new StringBuilder();
+
+ for (var i = 0; i < length; i++)
+ {
+ var currentCharacter = ReadCharacter();
+
+ consumeBuilder.Append(currentCharacter);
+
+ if (currentCharacter == ParserFacts.END_OF_FILE)
+ break;
+ }
+
+ return consumeBuilder.ToString();
+ }
+
+ /// Iterates a counter from 0 until the counter is equal to .
Each iteration will be invoked using the ( + counter).
If an iteration's invocation of returned then the method will short circuit and return regardless of whether it finished iterating to or not.
+ public string PeekRange(int offset, int length)
+ {
+ var peekBuilder = new StringBuilder();
+
+ for (var i = 0; i < length; i++)
+ {
+ var currentCharacter = PeekCharacter(offset + i);
+
+ peekBuilder.Append(currentCharacter);
+
+ if (currentCharacter == ParserFacts.END_OF_FILE)
+ break;
+ }
+
+ return peekBuilder.ToString();
+ }
+
+ /// Iterates a counter from 0 until the counter is equal to .
Each iteration will be invoked using the.
If an iteration's invocation of returned then the method will short circuit and return regardless of whether it finished iterating to or not.
+ public string BacktrackRange(int length)
+ {
+ var backtrackBuilder = new StringBuilder();
+
+ for (var i = 0; i < length; i++)
+ {
+ if (PositionIndex == 0)
+ {
+ backtrackBuilder.Append(ParserFacts.END_OF_FILE);
+ return backtrackBuilder.ToString();
+ }
+
+ var currentCharacter = BacktrackCharacter();
+
+ backtrackBuilder.Append(currentCharacter);
+
+ if (currentCharacter == ParserFacts.END_OF_FILE)
+ break;
+ }
+
+ return backtrackBuilder.ToString();
+ }
+
+ public string PeekNextWord()
+ {
+ var nextWordBuilder = new StringBuilder();
+
+ var i = 0;
+
+ char peekedChar;
+
+ do
+ {
+ peekedChar = PeekCharacter(i++);
+
+ if (WhitespaceFacts.ALL_LIST.Contains(peekedChar) ||
+ KeyboardKeyFacts.IsPunctuationCharacter(peekedChar))
+ {
+ break;
+ }
+
+ nextWordBuilder.Append(peekedChar);
+ } while (peekedChar != ParserFacts.END_OF_FILE);
+
+ return nextWordBuilder.ToString();
+ }
+
+ /// Form a substring of the that starts inclusively at the index and has a maximum length of .Length.
This method uses internally and therefore will return a string that ends with if an index out of bounds read was performed on
+ public bool PeekForSubstring(string substring)
+ {
+ return PeekRange(0, substring.Length) == substring;
+ }
+
+ public bool PeekForSubstringRange(ImmutableArray substringsList, out string? matchedOn)
+ {
+ foreach (var substring in substringsList)
+ {
+ if (PeekForSubstring(substring))
+ {
+ matchedOn = substring;
+ return true;
+ }
+ }
+
+ matchedOn = null;
+ return false;
+ }
+
+ ///
+ /// Provide to override the
+ /// default of what qualifies as whitespace.
+ /// The default whitespace chars are:
+ ///
+ public string ReadWhitespace(IEnumerable? whitespaceOverrideList = null)
+ {
+ var whitespaceCharacterList = whitespaceOverrideList ?? WhitespaceFacts.ALL_LIST;
+
+ var whitespaceBuilder = new StringBuilder();
+
+ while (whitespaceCharacterList.Contains(CurrentCharacter))
+ {
+ var currentCharacter = ReadCharacter();
+
+ whitespaceBuilder.Append(currentCharacter);
+
+ if (currentCharacter == ParserFacts.END_OF_FILE)
+ break;
+ }
+
+ return whitespaceBuilder.ToString();
+ }
+
+ ///
+ /// Ex: '1.73', positive only.
+ /// { 0, ..., 1, ..., 2, ...}
+ ///
+ public NumericLiteralToken ReadUnsignedNumericLiteral()
+ {
+ var startingPosition = PositionIndex;
+ var seenPeriod = false;
+
+ while (!IsEof)
+ {
+ if (!char.IsDigit(CurrentCharacter))
+ {
+ if (CurrentCharacter == '.' && !seenPeriod)
+ seenPeriod = true;
+ else
+ break;
+ }
+
+ _ = ReadCharacter();
+ }
+
+ var numericLiteralTextSpan = new TextEditorTextSpan(startingPosition, this, 0);
+ return new NumericLiteralToken(numericLiteralTextSpan);
+ }
+
+ public string ReadUntil(char deliminator)
+ {
+ var textBuilder = new StringBuilder();
+
+ while (!IsEof)
+ {
+ if (CurrentCharacter == deliminator)
+ break;
+
+ textBuilder.Append(ReadCharacter());
+ }
+
+ return textBuilder.ToString();
+ }
+
+ ///
+ /// The line ending is NOT included in the returned string
+ ///
+ public string ReadLine()
+ {
+ var textBuilder = new StringBuilder();
+
+ while (!IsEof)
+ {
+ if (WhitespaceFacts.LINE_ENDING_CHARACTER_LIST.Contains(CurrentCharacter))
+ break;
+
+ textBuilder.Append(ReadCharacter());
+ }
+
+ return textBuilder.ToString();
+ }
+
+ ///
+ /// This method will return immediately upon encountering whitespace.
+ /// Returns a text span with its equal to '-1' if no word was found.
+ ///
+ public (TextEditorTextSpan textSpan, string value) ReadWordTuple(ImmutableArray? additionalCharactersToBreakOnList = null)
+ {
+ additionalCharactersToBreakOnList ??= ImmutableArray.Empty;
+
+ // The wordBuilder is appended to everytime a character is consumed.
+ var wordBuilder = new StringBuilder();
+
+ // wordBuilderStartingIndexInclusive == -1 is to mean that wordBuilder is empty.
+ var wordBuilderStartingIndexInclusive = -1;
+
+ while (!IsEof)
+ {
+ if (WhitespaceFacts.ALL_LIST.Contains(CurrentCharacter) ||
+ additionalCharactersToBreakOnList.Value.Contains(CurrentCharacter))
+ {
+ break;
+ }
+
+ if (wordBuilderStartingIndexInclusive == -1)
+ {
+ // This is the start of a word as opposed to the continuation of a word
+ wordBuilderStartingIndexInclusive = PositionIndex;
+ }
+
+ wordBuilder.Append(CurrentCharacter);
+
+ _ = ReadCharacter();
+ }
+
+ return (new TextEditorTextSpan(
+ wordBuilderStartingIndexInclusive,
+ PositionIndex,
+ 0,
+ ResourceUri,
+ SourceText),
+ wordBuilder.ToString());
+ }
+}
\ No newline at end of file
diff --git a/Source/Lib/TextEditor/Lexers/Models/TextEditorTextSpan.cs b/Source/Lib/TextEditor/Lexers/Models/TextEditorTextSpan.cs
index 9b6c27943..82f7df04a 100644
--- a/Source/Lib/TextEditor/Lexers/Models/TextEditorTextSpan.cs
+++ b/Source/Lib/TextEditor/Lexers/Models/TextEditorTextSpan.cs
@@ -73,6 +73,25 @@ public TextEditorTextSpan(
}
+ ///
+ /// This constructor is used for text spans where their
+ /// is the current position
+ /// of a .
+ ///
+ public TextEditorTextSpan(
+ int StartingIndexInclusive,
+ StringWalkerStruct stringWalker,
+ byte decorationByte)
+ : this(
+ StartingIndexInclusive,
+ stringWalker.PositionIndex,
+ decorationByte,
+ stringWalker.ResourceUri,
+ stringWalker.SourceText)
+ {
+
+ }
+
///
/// This constructor is being used to
/// experiment with not holding a reference
diff --git a/Source/Lib/TextEditor/TextEditors/Displays/Internals/AutocompleteMenu.razor.cs b/Source/Lib/TextEditor/TextEditors/Displays/Internals/AutocompleteMenu.razor.cs
index 4110f3cba..c73780c8d 100644
--- a/Source/Lib/TextEditor/TextEditors/Displays/Internals/AutocompleteMenu.razor.cs
+++ b/Source/Lib/TextEditor/TextEditors/Displays/Internals/AutocompleteMenu.razor.cs
@@ -237,7 +237,6 @@ private Task SelectMenuOption(Func menuOptionAction)
catch (Exception e)
{
Console.WriteLine(e);
- throw;
}
}, CancellationToken.None);
From 3b50b95f38ff6e63c46dcce1ecaf6665c2100f25 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 20:52:30 -0500
Subject: [PATCH 32/39] ref this?
---
.../TextEditor/CompilerServices/Utility/StringWalkerStruct.cs | 2 +-
Source/Lib/TextEditor/Lexers/Models/TextEditorTextSpan.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Source/Lib/TextEditor/CompilerServices/Utility/StringWalkerStruct.cs b/Source/Lib/TextEditor/CompilerServices/Utility/StringWalkerStruct.cs
index 57930ea1c..684e1938d 100644
--- a/Source/Lib/TextEditor/CompilerServices/Utility/StringWalkerStruct.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Utility/StringWalkerStruct.cs
@@ -226,7 +226,7 @@ public NumericLiteralToken ReadUnsignedNumericLiteral()
_ = ReadCharacter();
}
- var numericLiteralTextSpan = new TextEditorTextSpan(startingPosition, this, 0);
+ var numericLiteralTextSpan = new TextEditorTextSpan(startingPosition, ref this, 0);
return new NumericLiteralToken(numericLiteralTextSpan);
}
diff --git a/Source/Lib/TextEditor/Lexers/Models/TextEditorTextSpan.cs b/Source/Lib/TextEditor/Lexers/Models/TextEditorTextSpan.cs
index 82f7df04a..af5da98fc 100644
--- a/Source/Lib/TextEditor/Lexers/Models/TextEditorTextSpan.cs
+++ b/Source/Lib/TextEditor/Lexers/Models/TextEditorTextSpan.cs
@@ -80,7 +80,7 @@ public TextEditorTextSpan(
///
public TextEditorTextSpan(
int StartingIndexInclusive,
- StringWalkerStruct stringWalker,
+ ref StringWalkerStruct stringWalker,
byte decorationByte)
: this(
StartingIndexInclusive,
From 612c29dbc2839fe93986b83ecd680b337f5a7844 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Thu, 12 Dec 2024 21:09:39 -0500
Subject: [PATCH 33/39] Rename local variable to follow naming convention
---
.../CSharp/LexerCase/CSharpLexer.cs | 520 +++++++++---------
1 file changed, 260 insertions(+), 260 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index ad1a2fe4f..192f385eb 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -39,11 +39,11 @@ public CSharpLexer(ResourceUri resourceUri, string sourceText)
public void Lex()
{
- var _stringWalker = new StringWalkerStruct(ResourceUri, SourceText);
+ var stringWalker = new StringWalkerStruct(ResourceUri, SourceText);
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- switch (_stringWalker.CurrentCharacter)
+ switch (stringWalker.CurrentCharacter)
{
/* Lowercase Letters */
case 'a':
@@ -101,7 +101,7 @@ public void Lex()
case 'Z':
/* Underscore */
case '_':
- LexIdentifierOrKeywordOrKeywordContextual(ref _stringWalker);
+ LexIdentifierOrKeywordOrKeywordContextual(ref stringWalker);
break;
case '0':
case '1':
@@ -113,261 +113,261 @@ public void Lex()
case '7':
case '8':
case '9':
- LexNumericLiteralToken(ref _stringWalker);
+ LexNumericLiteralToken(ref stringWalker);
break;
case '\'':
- LexCharLiteralToken(ref _stringWalker);
+ LexCharLiteralToken(ref stringWalker);
break;
case '"':
- LexString(ref _stringWalker, countDollarSign: 0, useVerbatim: false);
+ LexString(ref stringWalker, countDollarSign: 0, useVerbatim: false);
break;
case '/':
- if (_stringWalker.PeekCharacter(1) == '/')
+ if (stringWalker.PeekCharacter(1) == '/')
{
- LexCommentSingleLineToken(ref _stringWalker);
+ LexCommentSingleLineToken(ref stringWalker);
}
- else if (_stringWalker.PeekCharacter(1) == '*')
+ else if (stringWalker.PeekCharacter(1) == '*')
{
- LexCommentMultiLineToken(ref _stringWalker);
+ LexCommentMultiLineToken(ref stringWalker);
}
else
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new DivisionToken(textSpan));
}
break;
case '+':
- if (_stringWalker.PeekCharacter(1) == '+')
+ if (stringWalker.PeekCharacter(1) == '+')
{
- LexPlusPlusToken(ref _stringWalker);
+ LexPlusPlusToken(ref stringWalker);
}
else
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new PlusToken(textSpan));
}
break;
case '-':
- if (_stringWalker.PeekCharacter(1) == '-')
+ if (stringWalker.PeekCharacter(1) == '-')
{
- LexMinusMinusToken(ref _stringWalker);
+ LexMinusMinusToken(ref stringWalker);
}
else
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new MinusToken(textSpan));
}
break;
case '=':
- if (_stringWalker.PeekCharacter(1) == '=')
+ if (stringWalker.PeekCharacter(1) == '=')
{
- LexEqualsEqualsToken(ref _stringWalker);
+ LexEqualsEqualsToken(ref stringWalker);
}
else
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new EqualsToken(textSpan));
}
break;
case '?':
- if (_stringWalker.PeekCharacter(1) == '?')
+ if (stringWalker.PeekCharacter(1) == '?')
{
- LexQuestionMarkQuestionMarkToken(ref _stringWalker);
+ LexQuestionMarkQuestionMarkToken(ref stringWalker);
}
else
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new QuestionMarkToken(textSpan));
}
break;
case '*':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new StarToken(textSpan));
break;
}
case '!':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new BangToken(textSpan));
break;
}
case ';':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new StatementDelimiterToken(textSpan));
break;
}
case '(':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new OpenParenthesisToken(textSpan));
break;
}
case ')':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new CloseParenthesisToken(textSpan));
break;
}
case '{':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new OpenBraceToken(textSpan));
break;
}
case '}':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new CloseBraceToken(textSpan));
break;
}
case '<':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new OpenAngleBracketToken(textSpan));
break;
}
case '>':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new CloseAngleBracketToken(textSpan));
break;
}
case '[':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new OpenSquareBracketToken(textSpan));
break;
}
case ']':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new CloseSquareBracketToken(textSpan));
break;
}
case '$':
- if (_stringWalker.NextCharacter == '"')
+ if (stringWalker.NextCharacter == '"')
{
- LexString(ref _stringWalker, countDollarSign: 1, useVerbatim: false);
+ LexString(ref stringWalker, countDollarSign: 1, useVerbatim: false);
}
- else if (_stringWalker.PeekCharacter(1) == '@' && _stringWalker.PeekCharacter(2) == '"')
+ else if (stringWalker.PeekCharacter(1) == '@' && stringWalker.PeekCharacter(2) == '"')
{
- LexString(ref _stringWalker, countDollarSign: 1, useVerbatim: true);
+ LexString(ref stringWalker, countDollarSign: 1, useVerbatim: true);
}
- else if (_stringWalker.NextCharacter == '$')
+ else if (stringWalker.NextCharacter == '$')
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// The while loop starts counting from and including the first dollar sign.
var countDollarSign = 0;
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- if (_stringWalker.CurrentCharacter != '$')
+ if (stringWalker.CurrentCharacter != '$')
break;
++countDollarSign;
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
// Only the last '$' (dollar sign character) will be syntax highlighted
// if this code is NOT included.
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.StringLiteral, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.StringLiteral, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new StringLiteralToken(textSpan));
// From the LexString(...) method:
// "awkwardly even if there are many of these it is expected
// that the last one will not have been consumed."
- _ = _stringWalker.BacktrackCharacter();
+ _ = stringWalker.BacktrackCharacter();
- if (_stringWalker.NextCharacter == '"')
- LexString(ref _stringWalker, countDollarSign: countDollarSign, useVerbatim: false);
+ if (stringWalker.NextCharacter == '"')
+ LexString(ref stringWalker, countDollarSign: countDollarSign, useVerbatim: false);
}
else
{
- LexDollarSignToken(ref _stringWalker);
+ LexDollarSignToken(ref stringWalker);
}
break;
case '@':
- if (_stringWalker.NextCharacter == '"')
- LexString(ref _stringWalker, countDollarSign: 0, useVerbatim: true);
- else if (_stringWalker.PeekCharacter(1) == '$' && _stringWalker.PeekCharacter(2) == '"')
- LexString(ref _stringWalker, countDollarSign: 1, useVerbatim: true);
+ if (stringWalker.NextCharacter == '"')
+ LexString(ref stringWalker, countDollarSign: 0, useVerbatim: true);
+ else if (stringWalker.PeekCharacter(1) == '$' && stringWalker.PeekCharacter(2) == '"')
+ LexString(ref stringWalker, countDollarSign: 1, useVerbatim: true);
else
- LexAtToken(ref _stringWalker);
+ LexAtToken(ref stringWalker);
break;
case ':':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new ColonToken(textSpan));
break;
}
case '.':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new MemberAccessToken(textSpan));
break;
}
case ',':
{
- var entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
- var textSpan = new TextEditorTextSpan(entryPositionIndex, _stringWalker.PositionIndex, (byte)GenericDecorationKind.None, _stringWalker.ResourceUri, _stringWalker.SourceText);
+ var entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.ReadCharacter();
+ var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
_syntaxTokenList.Add(new CommaToken(textSpan));
break;
}
case '#':
- LexPreprocessorDirectiveToken(ref _stringWalker);
+ LexPreprocessorDirectiveToken(ref stringWalker);
break;
default:
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
break;
}
}
var endOfFileTextSpan = new TextEditorTextSpan(
- _stringWalker.PositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new EndOfFileToken(endOfFileTextSpan));
}
@@ -379,95 +379,95 @@ public void Lex()
/// The reason being: you don't know if it is a string until you've read all of the '$' (dollar sign characters).
/// So in order to invoke this method the invoker had to have counted them.
///
- private void LexString(ref StringWalkerStruct _stringWalker, int countDollarSign, bool useVerbatim)
+ private void LexString(ref StringWalkerStruct stringWalker, int countDollarSign, bool useVerbatim)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
var useInterpolation = countDollarSign > 0;
if (useInterpolation)
- _ = _stringWalker.ReadCharacter(); // Move past the '$' (dollar sign character); awkwardly even if there are many of these it is expected that the last one will not have been consumed.
+ _ = stringWalker.ReadCharacter(); // Move past the '$' (dollar sign character); awkwardly even if there are many of these it is expected that the last one will not have been consumed.
if (useVerbatim)
- _ = _stringWalker.ReadCharacter(); // Move past the '@' (at character)
+ _ = stringWalker.ReadCharacter(); // Move past the '@' (at character)
var useRaw = false;
int countDoubleQuotes = 0;
- if (!useVerbatim && _stringWalker.PeekCharacter(1) == '\"' && _stringWalker.PeekCharacter(2) == '\"')
+ if (!useVerbatim && stringWalker.PeekCharacter(1) == '\"' && stringWalker.PeekCharacter(2) == '\"')
{
useRaw = true;
// Count the amount of double quotes to be used as the delimiter.
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- if (_stringWalker.CurrentCharacter != '\"')
+ if (stringWalker.CurrentCharacter != '\"')
break;
++countDoubleQuotes;
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
}
else
{
- _ = _stringWalker.ReadCharacter(); // Move past the '"' (double quote character)
+ _ = stringWalker.ReadCharacter(); // Move past the '"' (double quote character)
}
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- if (_stringWalker.CurrentCharacter == '\"')
+ if (stringWalker.CurrentCharacter == '\"')
{
if (useRaw)
{
var matchDoubleQuotes = 0;
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- if (_stringWalker.CurrentCharacter != '\"')
+ if (stringWalker.CurrentCharacter != '\"')
break;
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
if (++matchDoubleQuotes == countDoubleQuotes)
goto foundEndDelimiter;
}
continue;
}
- else if (useVerbatim && _stringWalker.NextCharacter == '\"')
+ else if (useVerbatim && stringWalker.NextCharacter == '\"')
{
if (EscapeCharacterList is not null)
{
- EscapeCharacterListAdd(ref _stringWalker, new TextEditorTextSpan(
- _stringWalker.PositionIndex,
- _stringWalker.PositionIndex + 2,
+ EscapeCharacterListAdd(ref stringWalker, new TextEditorTextSpan(
+ stringWalker.PositionIndex,
+ stringWalker.PositionIndex + 2,
(byte)GenericDecorationKind.EscapeCharacterPrimary,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText));
+ stringWalker.ResourceUri,
+ stringWalker.SourceText));
}
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
else
{
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
break;
}
}
- else if (!useVerbatim && _stringWalker.CurrentCharacter == '\\')
+ else if (!useVerbatim && stringWalker.CurrentCharacter == '\\')
{
if (EscapeCharacterList is not null)
{
- EscapeCharacterListAdd(ref _stringWalker, new TextEditorTextSpan(
- _stringWalker.PositionIndex,
- _stringWalker.PositionIndex + 2,
+ EscapeCharacterListAdd(ref stringWalker, new TextEditorTextSpan(
+ stringWalker.PositionIndex,
+ stringWalker.PositionIndex + 2,
(byte)GenericDecorationKind.EscapeCharacterPrimary,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText));
+ stringWalker.ResourceUri,
+ stringWalker.SourceText));
}
// Presuming the escaped text is 2 characters, then read an extra character.
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
- else if (useInterpolation && _stringWalker.CurrentCharacter == '{')
+ else if (useInterpolation && stringWalker.CurrentCharacter == '{')
{
// With raw, one is escaping by way of typing less.
// With normal interpolation, one is escaping by way of typing more.
@@ -475,20 +475,20 @@ private void LexString(ref StringWalkerStruct _stringWalker, int countDollarSign
// Thus, these are two separate cases written as an if-else.
if (useRaw)
{
- var interpolationTemporaryPositionIndex = _stringWalker.PositionIndex;
+ var interpolationTemporaryPositionIndex = stringWalker.PositionIndex;
var matchBrace = 0;
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- if (_stringWalker.CurrentCharacter != '{')
+ if (stringWalker.CurrentCharacter != '{')
break;
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
if (++matchBrace >= countDollarSign)
{
// Found yet another '{' match beyond what was needed.
// So, this logic will match from the inside to the outside.
- if (_stringWalker.CurrentCharacter == '{')
+ if (stringWalker.CurrentCharacter == '{')
{
++interpolationTemporaryPositionIndex;
}
@@ -498,8 +498,8 @@ private void LexString(ref StringWalkerStruct _stringWalker, int countDollarSign
entryPositionIndex,
interpolationTemporaryPositionIndex,
(byte)GenericDecorationKind.StringLiteral,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new StringLiteralToken(innerTextSpan));
// 'LexInterpolatedExpression' is expected to consume one more after it is finished.
@@ -507,88 +507,88 @@ private void LexString(ref StringWalkerStruct _stringWalker, int countDollarSign
// closing double quotes if the expression were the last thing in the string.
//
// So, a backtrack is done.
- LexInterpolatedExpression(ref _stringWalker, countDollarSign);
- entryPositionIndex = _stringWalker.PositionIndex;
- _stringWalker.BacktrackCharacter();
+ LexInterpolatedExpression(ref stringWalker, countDollarSign);
+ entryPositionIndex = stringWalker.PositionIndex;
+ stringWalker.BacktrackCharacter();
}
}
}
}
else
{
- if (_stringWalker.NextCharacter == '{')
+ if (stringWalker.NextCharacter == '{')
{
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
else
{
var innerTextSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.StringLiteral,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new StringLiteralToken(innerTextSpan));
// 'LexInterpolatedExpression' is expected to consume one more after it is finished.
// Thus, if this while loop were to consume, it would skip the
// closing double quotes if the expression were the last thing in the string.
- LexInterpolatedExpression(ref _stringWalker, countDollarSign);
- entryPositionIndex = _stringWalker.PositionIndex;
+ LexInterpolatedExpression(ref stringWalker, countDollarSign);
+ entryPositionIndex = stringWalker.PositionIndex;
continue;
}
}
}
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
foundEndDelimiter:
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.StringLiteral,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new StringLiteralToken(textSpan));
}
- private void LexInterpolatedExpression(ref StringWalkerStruct _stringWalker, int countDollarSign)
+ private void LexInterpolatedExpression(ref StringWalkerStruct stringWalker, int countDollarSign)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
- if (_stringWalker.CurrentCharacter == '{')
+ if (stringWalker.CurrentCharacter == '{')
{
// The normal interpolation will invoke this method with '{' as the current character.
//
// But, raw interpolation will invoke this method 1 index further than the final '{' that
// deliminates the start of the interpolated expression.
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
var unmatchedBraceCounter = countDollarSign;
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- if (_stringWalker.CurrentCharacter == '{')
+ if (stringWalker.CurrentCharacter == '{')
{
++unmatchedBraceCounter;
}
- else if (_stringWalker.CurrentCharacter == '}')
+ else if (stringWalker.CurrentCharacter == '}')
{
if (--unmatchedBraceCounter <= 0)
break;
}
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
- private void EscapeCharacterListAdd(ref StringWalkerStruct _stringWalker, TextEditorTextSpan textSpan)
+ private void EscapeCharacterListAdd(ref StringWalkerStruct stringWalker, TextEditorTextSpan textSpan)
{
if (EscapeCharacterList.Count > 0)
{
@@ -608,27 +608,27 @@ private void EscapeCharacterListAdd(ref StringWalkerStruct _stringWalker, TextEd
EscapeCharacterList.Add(textSpan);
}
- public void LexIdentifierOrKeywordOrKeywordContextual(ref StringWalkerStruct _stringWalker)
+ public void LexIdentifierOrKeywordOrKeywordContextual(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- if (!char.IsLetterOrDigit(_stringWalker.CurrentCharacter) &&
- _stringWalker.CurrentCharacter != '_')
+ if (!char.IsLetterOrDigit(stringWalker.CurrentCharacter) &&
+ stringWalker.CurrentCharacter != '_')
{
break;
}
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
var textValue = textSpan.GetText();
@@ -657,16 +657,16 @@ public void LexIdentifierOrKeywordOrKeywordContextual(ref StringWalkerStruct _st
_syntaxTokenList.Add(new IdentifierToken(textSpan));
}
- public void LexNumericLiteralToken(ref StringWalkerStruct _stringWalker)
+ public void LexNumericLiteralToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// Declare outside the while loop to avoid overhead of redeclaring each loop? not sure
var isNotANumber = false;
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- switch (_stringWalker.CurrentCharacter)
+ switch (stringWalker.CurrentCharacter)
{
case '0':
case '1':
@@ -687,76 +687,76 @@ public void LexNumericLiteralToken(ref StringWalkerStruct _stringWalker)
if (isNotANumber)
break;
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new NumericLiteralToken(textSpan));
}
- public void LexCharLiteralToken(ref StringWalkerStruct _stringWalker)
+ public void LexCharLiteralToken(ref StringWalkerStruct stringWalker)
{
var delimiter = '\'';
var escapeCharacter = '\\';
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// Move past the opening delimiter
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- if (_stringWalker.CurrentCharacter == delimiter)
+ if (stringWalker.CurrentCharacter == delimiter)
{
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
break;
}
- else if (_stringWalker.CurrentCharacter == escapeCharacter)
+ else if (stringWalker.CurrentCharacter == escapeCharacter)
{
if (EscapeCharacterList is not null)
{
EscapeCharacterList.Add(new TextEditorTextSpan(
- _stringWalker.PositionIndex,
- _stringWalker.PositionIndex + 2,
+ stringWalker.PositionIndex,
+ stringWalker.PositionIndex + 2,
(byte)GenericDecorationKind.EscapeCharacterPrimary,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText));
+ stringWalker.ResourceUri,
+ stringWalker.SourceText));
}
// Presuming the escaped text is 2 characters,
// then read an extra character.
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.StringLiteral,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new CharLiteralToken(textSpan));
}
- public void LexCommentSingleLineToken(ref StringWalkerStruct _stringWalker)
+ public void LexCommentSingleLineToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// Declare outside the while loop to avoid overhead of redeclaring each loop? not sure
var isNewLineCharacter = false;
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- switch (_stringWalker.CurrentCharacter)
+ switch (stringWalker.CurrentCharacter)
{
case '\r':
case '\n':
@@ -769,33 +769,33 @@ public void LexCommentSingleLineToken(ref StringWalkerStruct _stringWalker)
if (isNewLineCharacter)
break;
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.CommentSingleLine,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new CommentSingleLineToken(textSpan));
}
- public void LexCommentMultiLineToken(ref StringWalkerStruct _stringWalker)
+ public void LexCommentMultiLineToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// Move past the initial "/*"
- _ = _stringWalker.ReadRange(2);
+ _ = stringWalker.ReadRange(2);
// Declare outside the while loop to avoid overhead of redeclaring each loop? not sure
var possibleClosingText = false;
var sawClosingText = false;
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- switch (_stringWalker.CurrentCharacter)
+ switch (stringWalker.CurrentCharacter)
{
case '*':
possibleClosingText = true;
@@ -808,7 +808,7 @@ public void LexCommentMultiLineToken(ref StringWalkerStruct _stringWalker)
break;
}
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
if (sawClosingText)
break;
@@ -816,132 +816,132 @@ public void LexCommentMultiLineToken(ref StringWalkerStruct _stringWalker)
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.CommentMultiLine,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new CommentMultiLineToken(textSpan));
}
- public void LexPlusPlusToken(ref StringWalkerStruct _stringWalker)
+ public void LexPlusPlusToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// First '+'
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
// Second '+'
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new PlusPlusToken(textSpan));
}
- public void LexMinusMinusToken(ref StringWalkerStruct _stringWalker)
+ public void LexMinusMinusToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// First '-'
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
// Second '-'
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new MinusMinusToken(textSpan));
}
- public void LexEqualsEqualsToken(ref StringWalkerStruct _stringWalker)
+ public void LexEqualsEqualsToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// First '='
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
// Second '='
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new EqualsEqualsToken(textSpan));
}
- public void LexQuestionMarkQuestionMarkToken(ref StringWalkerStruct _stringWalker)
+ public void LexQuestionMarkQuestionMarkToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// First '?'
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
// Second '?'
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new QuestionMarkQuestionMarkToken(textSpan));
}
- public void LexDollarSignToken(ref StringWalkerStruct _stringWalker)
+ public void LexDollarSignToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new DollarSignToken(textSpan));
}
- public void LexAtToken(ref StringWalkerStruct _stringWalker)
+ public void LexAtToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
- _stringWalker.ReadCharacter();
+ stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new AtToken(textSpan));
}
- public void LexPreprocessorDirectiveToken(ref StringWalkerStruct _stringWalker)
+ public void LexPreprocessorDirectiveToken(ref StringWalkerStruct stringWalker)
{
- var entryPositionIndex = _stringWalker.PositionIndex;
+ var entryPositionIndex = stringWalker.PositionIndex;
// Declare outside the while loop to avoid overhead of redeclaring each loop? not sure
var isNewLineCharacter = false;
- while (!_stringWalker.IsEof)
+ while (!stringWalker.IsEof)
{
- switch (_stringWalker.CurrentCharacter)
+ switch (stringWalker.CurrentCharacter)
{
case '\r':
case '\n':
@@ -954,15 +954,15 @@ public void LexPreprocessorDirectiveToken(ref StringWalkerStruct _stringWalker)
if (isNewLineCharacter)
break;
- _ = _stringWalker.ReadCharacter();
+ _ = stringWalker.ReadCharacter();
}
var textSpan = new TextEditorTextSpan(
entryPositionIndex,
- _stringWalker.PositionIndex,
+ stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
- _stringWalker.ResourceUri,
- _stringWalker.SourceText);
+ stringWalker.ResourceUri,
+ stringWalker.SourceText);
_syntaxTokenList.Add(new PreprocessorDirectiveToken(textSpan));
}
From 9a494de4991e05c954cc92e6e0fe02c3f79fb300 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Fri, 13 Dec 2024 12:43:37 -0500
Subject: [PATCH 34/39] Track how long lexer takes
---
.../CSharp/LexerCase/CSharpLexer.cs | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index 192f385eb..8aac4f749 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -14,6 +14,23 @@ public struct CSharpLexer
{
private readonly List _syntaxTokenList = new();
private readonly DiagnosticBag _diagnosticBag = new();
+ public static TimeSpan LongestLexTimeSpan = TimeSpan.Zero;
+ public static TimeSpan TotalLexTimeSpan = TimeSpan.Zero;
+
+ ///
+ /// There are 1,820 CSharpResource's in the CSharpCompilerService.
+ /// I don't want to bombard my console with noise by
+ /// writing the TotalLexTimeSpan everytime.
+ ///
+ /// So I'll hackily write it out only 20 times by counting
+ /// the amount of Lex invocations.
+ ///
+ /// Preferably this would be once for the final resource,
+ /// but this does not matter, I'm just checking something quickly
+ /// then deleting this code.
+ ///
+ public static int Hacky_Count_Before_Start_ConsoleWrite = 1800;
+ public static int Hacky_Count = 0;
public CSharpLexer(ResourceUri resourceUri, string sourceText)
{
@@ -39,6 +56,10 @@ public CSharpLexer(ResourceUri resourceUri, string sourceText)
public void Lex()
{
+ ++Hacky_Count;
+
+ var startTime = DateTime.UtcNow;
+
var stringWalker = new StringWalkerStruct(ResourceUri, SourceText);
while (!stringWalker.IsEof)
@@ -370,6 +391,20 @@ public void Lex()
stringWalker.SourceText);
_syntaxTokenList.Add(new EndOfFileToken(endOfFileTextSpan));
+
+ /*var totalTimeSpan = DateTime.UtcNow - startTime;
+
+ TotalLexTimeSpan += totalTimeSpan;
+ if (Hacky_Count > Hacky_Count_Before_Start_ConsoleWrite)
+ {
+ Console.WriteLine($"TotalLexTimeSpan: {TotalLexTimeSpan.TotalSeconds:N3}");
+ }
+
+ if (totalTimeSpan > LongestLexTimeSpan)
+ {
+ LongestLexTimeSpan = totalTimeSpan;
+ Console.WriteLine($"LongestLexTimeSpan: {LongestLexTimeSpan.TotalSeconds:N3}");
+ }*/
}
///
From a20399896f247d5c1b1a2808247f2bea86fe7a99 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Fri, 13 Dec 2024 14:07:41 -0500
Subject: [PATCH 35/39] ApplySyntaxHighlighting is the issue it takes 20
seconds
---
.../CSharpCompilerService.cs | 51 ++++++++++++++++---
.../CSharp/LexerCase/CSharpLexer.cs | 1 -
.../CSharp/ParserCase/CSharpParser.cs | 35 +++++++++++++
3 files changed, 80 insertions(+), 7 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index 527cd0c46..9fe4210cb 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -20,6 +20,24 @@ namespace Luthetus.CompilerServices.CSharp.CompilerServiceCase;
public sealed class CSharpCompilerService : CompilerService
{
+ public static TimeSpan LongestParseTimeSpan = TimeSpan.Zero;
+ public static TimeSpan TotalParseTimeSpan = TimeSpan.Zero;
+
+ ///
+ /// There are 1,820 CSharpResource's in the CSharpCompilerService.
+ /// I don't want to bombard my console with noise by
+ /// writing the TotalParseTimeSpan everytime.
+ ///
+ /// So I'll hackily write it out only 20 times by counting
+ /// the amount of Parse invocations.
+ ///
+ /// Preferably this would be once for the final resource,
+ /// but this does not matter, I'm just checking something quickly
+ /// then deleting this code.
+ ///
+ public static int Hacky_Count_Before_Start_ConsoleWrite = 1800;
+ public static int Hacky_Count = 0;
+
///
/// TODO: The CSharpBinder should be private, but for now I'm making it public to be usable in the CompilerServiceExplorer Blazor component.
///
@@ -59,6 +77,9 @@ public void SetDiagnosticRendererType(Type? diagnosticRendererType)
public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier)
{
+ ++Hacky_Count;
+ var startTime = DateTime.UtcNow;
+
var resourceUri = modelModifier.ResourceUri;
if (!_resourceMap.ContainsKey(resourceUri))
@@ -72,7 +93,7 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
var presentationModel = modelModifier.PresentationModelList.First(
x => x.TextEditorPresentationKey == CompilerServiceDiagnosticPresentationFacts.PresentationKey);
-
+
var cSharpCompilationUnit = new CSharpCompilationUnit(resourceUri, CSharpBinder);
cSharpCompilationUnit.Lexer = new CSharpLexer(resourceUri, presentationModel.PendingCalculation.ContentAtRequest);
cSharpCompilationUnit.Lexer.Lex();
@@ -100,7 +121,7 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
resource.CompilationUnit = cSharpCompilationUnit;
}
}
-
+
var diagnosticTextSpans = GetDiagnosticsFor(modelModifier.ResourceUri)
.Select(x => x.TextSpan)
.ToArray();
@@ -109,14 +130,32 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
CompilerServiceDiagnosticPresentationFacts.PresentationKey,
CompilerServiceDiagnosticPresentationFacts.EmptyPresentationModel,
diagnosticTextSpans);
-
- editContext.TextEditorService.ModelApi.ApplySyntaxHighlighting(
+
+ /*editContext.TextEditorService.ModelApi.ApplySyntaxHighlighting(
editContext,
- modelModifier);
+ modelModifier);*/
+
+ // startTime = DateTime.UtcNow;
OnResourceParsed();
+
+ /*{
+ var totalTimeSpan = DateTime.UtcNow - startTime;
+
+ TotalParseTimeSpan += totalTimeSpan;
+ if (Hacky_Count > Hacky_Count_Before_Start_ConsoleWrite)
+ {
+ Console.WriteLine($"aaaTotalCompilerServiceTimeSpan: {TotalParseTimeSpan.TotalSeconds:N3}");
+ }
+
+ if (totalTimeSpan > LongestParseTimeSpan)
+ {
+ LongestParseTimeSpan = totalTimeSpan;
+ Console.WriteLine($"aaaLongestCompilerServiceTimeSpan: {LongestParseTimeSpan.TotalSeconds:N3}");
+ }
+ }*/
}
-
+
return Task.CompletedTask;
}
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index 8aac4f749..df7497697 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -57,7 +57,6 @@ public CSharpLexer(ResourceUri resourceUri, string sourceText)
public void Lex()
{
++Hacky_Count;
-
var startTime = DateTime.UtcNow;
var stringWalker = new StringWalkerStruct(ResourceUri, SourceText);
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index 2642a2826..0dc9a81ac 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -17,6 +17,24 @@ namespace Luthetus.CompilerServices.CSharp.ParserCase;
public struct CSharpParser
{
+ public static TimeSpan LongestParseTimeSpan = TimeSpan.Zero;
+ public static TimeSpan TotalParseTimeSpan = TimeSpan.Zero;
+
+ ///
+ /// There are 1,820 CSharpResource's in the CSharpCompilerService.
+ /// I don't want to bombard my console with noise by
+ /// writing the TotalParseTimeSpan everytime.
+ ///
+ /// So I'll hackily write it out only 20 times by counting
+ /// the amount of Parse invocations.
+ ///
+ /// Preferably this would be once for the final resource,
+ /// but this does not matter, I'm just checking something quickly
+ /// then deleting this code.
+ ///
+ public static int Hacky_Count_Before_Start_ConsoleWrite = 1800;
+ public static int Hacky_Count = 0;
+
public CSharpParser()
{
#if DEBUG
@@ -28,6 +46,9 @@ public CSharpParser()
public void Parse(CSharpCompilationUnit compilationUnit)
{
+ ++Hacky_Count;
+ var startTime = DateTime.UtcNow;
+
var globalCodeBlockBuilder = new CSharpCodeBlockBuilder(null, null);
var currentCodeBlockBuilder = globalCodeBlockBuilder;
var diagnosticBag = new DiagnosticBag();
@@ -248,6 +269,20 @@ public void Parse(CSharpCompilationUnit compilationUnit)
compilationUnit.Binder.FinalizeBinderSession(compilationUnit.BinderSession);
compilationUnit.RootCodeBlockNode = topLevelStatementsCodeBlock;
+
+ /*var totalTimeSpan = DateTime.UtcNow - startTime;
+
+ TotalParseTimeSpan += totalTimeSpan;
+ if (Hacky_Count > Hacky_Count_Before_Start_ConsoleWrite)
+ {
+ Console.WriteLine($"TotalParseTimeSpan: {TotalParseTimeSpan.TotalSeconds:N3}");
+ }
+
+ if (totalTimeSpan > LongestParseTimeSpan)
+ {
+ LongestParseTimeSpan = totalTimeSpan;
+ Console.WriteLine($"LongestParseTimeSpan: {LongestParseTimeSpan.TotalSeconds:N3}");
+ }*/
}
}
From 485b4c005b26bfe02046f1f380be32f028431049 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Fri, 13 Dec 2024 14:11:59 -0500
Subject: [PATCH 36/39] Remove timing code
---
.../CSharpCompilerService.cs | 39 -------------------
.../CSharp/LexerCase/CSharpLexer.cs | 34 ----------------
.../CSharp/ParserCase/CSharpParser.cs | 35 -----------------
3 files changed, 108 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index 9fe4210cb..e97b823f2 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -20,24 +20,6 @@ namespace Luthetus.CompilerServices.CSharp.CompilerServiceCase;
public sealed class CSharpCompilerService : CompilerService
{
- public static TimeSpan LongestParseTimeSpan = TimeSpan.Zero;
- public static TimeSpan TotalParseTimeSpan = TimeSpan.Zero;
-
- ///
- /// There are 1,820 CSharpResource's in the CSharpCompilerService.
- /// I don't want to bombard my console with noise by
- /// writing the TotalParseTimeSpan everytime.
- ///
- /// So I'll hackily write it out only 20 times by counting
- /// the amount of Parse invocations.
- ///
- /// Preferably this would be once for the final resource,
- /// but this does not matter, I'm just checking something quickly
- /// then deleting this code.
- ///
- public static int Hacky_Count_Before_Start_ConsoleWrite = 1800;
- public static int Hacky_Count = 0;
-
///
/// TODO: The CSharpBinder should be private, but for now I'm making it public to be usable in the CompilerServiceExplorer Blazor component.
///
@@ -77,9 +59,6 @@ public void SetDiagnosticRendererType(Type? diagnosticRendererType)
public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier)
{
- ++Hacky_Count;
- var startTime = DateTime.UtcNow;
-
var resourceUri = modelModifier.ResourceUri;
if (!_resourceMap.ContainsKey(resourceUri))
@@ -135,25 +114,7 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
editContext,
modelModifier);*/
- // startTime = DateTime.UtcNow;
-
OnResourceParsed();
-
- /*{
- var totalTimeSpan = DateTime.UtcNow - startTime;
-
- TotalParseTimeSpan += totalTimeSpan;
- if (Hacky_Count > Hacky_Count_Before_Start_ConsoleWrite)
- {
- Console.WriteLine($"aaaTotalCompilerServiceTimeSpan: {TotalParseTimeSpan.TotalSeconds:N3}");
- }
-
- if (totalTimeSpan > LongestParseTimeSpan)
- {
- LongestParseTimeSpan = totalTimeSpan;
- Console.WriteLine($"aaaLongestCompilerServiceTimeSpan: {LongestParseTimeSpan.TotalSeconds:N3}");
- }
- }*/
}
return Task.CompletedTask;
diff --git a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
index df7497697..d8203801f 100644
--- a/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
+++ b/Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
@@ -14,24 +14,7 @@ public struct CSharpLexer
{
private readonly List _syntaxTokenList = new();
private readonly DiagnosticBag _diagnosticBag = new();
- public static TimeSpan LongestLexTimeSpan = TimeSpan.Zero;
- public static TimeSpan TotalLexTimeSpan = TimeSpan.Zero;
- ///
- /// There are 1,820 CSharpResource's in the CSharpCompilerService.
- /// I don't want to bombard my console with noise by
- /// writing the TotalLexTimeSpan everytime.
- ///
- /// So I'll hackily write it out only 20 times by counting
- /// the amount of Lex invocations.
- ///
- /// Preferably this would be once for the final resource,
- /// but this does not matter, I'm just checking something quickly
- /// then deleting this code.
- ///
- public static int Hacky_Count_Before_Start_ConsoleWrite = 1800;
- public static int Hacky_Count = 0;
-
public CSharpLexer(ResourceUri resourceUri, string sourceText)
{
#if DEBUG
@@ -56,9 +39,6 @@ public CSharpLexer(ResourceUri resourceUri, string sourceText)
public void Lex()
{
- ++Hacky_Count;
- var startTime = DateTime.UtcNow;
-
var stringWalker = new StringWalkerStruct(ResourceUri, SourceText);
while (!stringWalker.IsEof)
@@ -390,20 +370,6 @@ public void Lex()
stringWalker.SourceText);
_syntaxTokenList.Add(new EndOfFileToken(endOfFileTextSpan));
-
- /*var totalTimeSpan = DateTime.UtcNow - startTime;
-
- TotalLexTimeSpan += totalTimeSpan;
- if (Hacky_Count > Hacky_Count_Before_Start_ConsoleWrite)
- {
- Console.WriteLine($"TotalLexTimeSpan: {TotalLexTimeSpan.TotalSeconds:N3}");
- }
-
- if (totalTimeSpan > LongestLexTimeSpan)
- {
- LongestLexTimeSpan = totalTimeSpan;
- Console.WriteLine($"LongestLexTimeSpan: {LongestLexTimeSpan.TotalSeconds:N3}");
- }*/
}
///
diff --git a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
index 0dc9a81ac..2642a2826 100644
--- a/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
+++ b/Source/Lib/CompilerServices/CSharp/ParserCase/CSharpParser.cs
@@ -17,24 +17,6 @@ namespace Luthetus.CompilerServices.CSharp.ParserCase;
public struct CSharpParser
{
- public static TimeSpan LongestParseTimeSpan = TimeSpan.Zero;
- public static TimeSpan TotalParseTimeSpan = TimeSpan.Zero;
-
- ///
- /// There are 1,820 CSharpResource's in the CSharpCompilerService.
- /// I don't want to bombard my console with noise by
- /// writing the TotalParseTimeSpan everytime.
- ///
- /// So I'll hackily write it out only 20 times by counting
- /// the amount of Parse invocations.
- ///
- /// Preferably this would be once for the final resource,
- /// but this does not matter, I'm just checking something quickly
- /// then deleting this code.
- ///
- public static int Hacky_Count_Before_Start_ConsoleWrite = 1800;
- public static int Hacky_Count = 0;
-
public CSharpParser()
{
#if DEBUG
@@ -46,9 +28,6 @@ public CSharpParser()
public void Parse(CSharpCompilationUnit compilationUnit)
{
- ++Hacky_Count;
- var startTime = DateTime.UtcNow;
-
var globalCodeBlockBuilder = new CSharpCodeBlockBuilder(null, null);
var currentCodeBlockBuilder = globalCodeBlockBuilder;
var diagnosticBag = new DiagnosticBag();
@@ -269,20 +248,6 @@ public void Parse(CSharpCompilationUnit compilationUnit)
compilationUnit.Binder.FinalizeBinderSession(compilationUnit.BinderSession);
compilationUnit.RootCodeBlockNode = topLevelStatementsCodeBlock;
-
- /*var totalTimeSpan = DateTime.UtcNow - startTime;
-
- TotalParseTimeSpan += totalTimeSpan;
- if (Hacky_Count > Hacky_Count_Before_Start_ConsoleWrite)
- {
- Console.WriteLine($"TotalParseTimeSpan: {TotalParseTimeSpan.TotalSeconds:N3}");
- }
-
- if (totalTimeSpan > LongestParseTimeSpan)
- {
- LongestParseTimeSpan = totalTimeSpan;
- Console.WriteLine($"LongestParseTimeSpan: {LongestParseTimeSpan.TotalSeconds:N3}");
- }*/
}
}
From 3b50db2246a39d510e03ca57c058ef1ea52544b7 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Fri, 13 Dec 2024 15:59:08 -0500
Subject: [PATCH 37/39] Don't syntax highlight during solution wide parse
---
.../CompilerServiceCase/CSharpCompilerService.cs | 11 +++++++----
.../Ide/Ide.RazorLib/Editors/Models/EditorIdeApi.cs | 2 +-
.../Implementations/CompilerService.cs | 4 ++--
.../Implementations/CompilerServiceDoNothing.cs | 2 +-
.../CompilerServices/Interfaces/ICompilerService.cs | 2 +-
5 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
index e97b823f2..101130e64 100644
--- a/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
+++ b/Source/Lib/CompilerServices/CSharp/CompilerServiceCase/CSharpCompilerService.cs
@@ -57,7 +57,7 @@ public void SetDiagnosticRendererType(Type? diagnosticRendererType)
DiagnosticRendererType = diagnosticRendererType;
}
- public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier)
+ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier, bool shouldApplySyntaxHighlighting)
{
var resourceUri = modelModifier.ResourceUri;
@@ -110,9 +110,12 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
CompilerServiceDiagnosticPresentationFacts.EmptyPresentationModel,
diagnosticTextSpans);
- /*editContext.TextEditorService.ModelApi.ApplySyntaxHighlighting(
- editContext,
- modelModifier);*/
+ if (shouldApplySyntaxHighlighting)
+ {
+ editContext.TextEditorService.ModelApi.ApplySyntaxHighlighting(
+ editContext,
+ modelModifier);
+ }
OnResourceParsed();
}
diff --git a/Source/Lib/Ide/Ide.RazorLib/Editors/Models/EditorIdeApi.cs b/Source/Lib/Ide/Ide.RazorLib/Editors/Models/EditorIdeApi.cs
index 72fbb55a0..cc0c7ee6e 100644
--- a/Source/Lib/Ide/Ide.RazorLib/Editors/Models/EditorIdeApi.cs
+++ b/Source/Lib/Ide/Ide.RazorLib/Editors/Models/EditorIdeApi.cs
@@ -153,7 +153,7 @@ public async Task RegisterModelFunc(RegisterModelArgs registerModelArgs)
if (modelModifier is null)
return Task.CompletedTask;
- return compilerService.ParseAsync(editContext, modelModifier);
+ return compilerService.ParseAsync(editContext, modelModifier, shouldApplySyntaxHighlighting: false);
});
if (registerModelArgs.ShouldBlockUntilBackgroundTaskIsCompleted)
diff --git a/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerService.cs b/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerService.cs
index f1990fbd1..dccd1bfd0 100644
--- a/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerService.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerService.cs
@@ -130,7 +130,7 @@ public virtual void ResourceWasModified(ResourceUri resourceUri, IReadOnlyList GetAutocompleteEntries(string word, TextE
return _emptyAutocompleteEntryList;
}
- public virtual Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier)
+ public virtual Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier, bool shouldApplySyntaxHighlighting)
{
_textEditorService.ModelApi.StartPendingCalculatePresentationModel(
editContext,
diff --git a/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerServiceDoNothing.cs b/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerServiceDoNothing.cs
index 6461cfdac..3fcf76e61 100644
--- a/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerServiceDoNothing.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Implementations/CompilerServiceDoNothing.cs
@@ -8,7 +8,7 @@ public CompilerServiceDoNothing() : base(null)
{
}
- public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier)
+ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier, bool shouldApplySyntaxHighlighting)
{
// Intentionally do nothing
return Task.CompletedTask;
diff --git a/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilerService.cs b/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilerService.cs
index 2ec3cb6cd..caa162e9e 100644
--- a/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilerService.cs
+++ b/Source/Lib/TextEditor/CompilerServices/Interfaces/ICompilerService.cs
@@ -87,7 +87,7 @@ public interface ICompilerService
///
public List GetAutocompleteEntries(string word, TextEditorTextSpan textSpan);
- public Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier);
+ public Task ParseAsync(ITextEditorEditContext editContext, TextEditorModelModifier modelModifier, bool shouldApplySyntaxHighlighting);
/// Expected to be concurrency safe with
public void DisposeResource(ResourceUri resourceUri);
From 7afd06fe2a91aa100f8516d3baadae4c3e4694c2 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Fri, 13 Dec 2024 16:43:07 -0500
Subject: [PATCH 38/39] _hasBeenDisplayedAtLeastOnceBefore
---
.../Models/Internals/DisplayTracker.cs | 39 +++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/Source/Lib/TextEditor/TextEditors/Models/Internals/DisplayTracker.cs b/Source/Lib/TextEditor/TextEditors/Models/Internals/DisplayTracker.cs
index c24334e50..742d2429c 100644
--- a/Source/Lib/TextEditor/TextEditors/Models/Internals/DisplayTracker.cs
+++ b/Source/Lib/TextEditor/TextEditors/Models/Internals/DisplayTracker.cs
@@ -3,6 +3,7 @@
using Luthetus.TextEditor.RazorLib.Commands.Models;
using Luthetus.TextEditor.RazorLib.Commands.Models.Defaults;
using Luthetus.TextEditor.RazorLib.Lexers.Models;
+using Luthetus.TextEditor.RazorLib.BackgroundTasks.Models;
namespace Luthetus.TextEditor.RazorLib.TextEditors.Models.Internals;
@@ -29,6 +30,21 @@ public DisplayTracker(
_resourceUri = resourceUri;
_viewModelKey = viewModelKey;
}
+
+ ///
+ /// The initial solution wide parse will no longer apply syntax highlighting.
+ ///
+ /// As a result, the first time a view model is rendered, it needs to
+ /// trigger the syntax highlighting to be applied.
+ ///
+ /// Preferably this would work with a 'SyntaxHighlightingIsDirty'
+ /// sort of pattern.
+ ///
+ /// I couldn't get 'SyntaxHighlightingIsDirty' working and am tired.
+ /// This is too big of an optimization to miss out on
+ /// so I'll do the easier answer and leave this note.
+ ///
+ private bool _hasBeenDisplayedAtLeastOnceBefore;
///
/// refers to a Blazor TextEditorViewModelDisplay having had its OnParametersSet invoked
@@ -100,6 +116,29 @@ public void IncrementLinks()
// Tell the view model what the (already known) font-size measurements and text-editor measurements are.
PostScrollAndRemeasure();
+
+ if (!_hasBeenDisplayedAtLeastOnceBefore)
+ {
+ _hasBeenDisplayedAtLeastOnceBefore = true;
+
+ var uniqueTextEditorWork = new UniqueTextEditorWork(
+ nameof(_hasBeenDisplayedAtLeastOnceBefore),
+ editContext =>
+ {
+ var modelModifier = editContext.GetModelModifier(_resourceUri);
+
+ if (modelModifier is null)
+ return Task.CompletedTask;
+
+ editContext.TextEditorService.ModelApi.ApplySyntaxHighlighting(
+ editContext,
+ modelModifier);
+
+ return Task.CompletedTask;
+ });
+
+ _textEditorService.Post(uniqueTextEditorWork);
+ }
}
}
From 02ccc4585d93acd5362168962f15bb6d84912697 Mon Sep 17 00:00:00 2001
From: Luthetus <45454132+huntercfreeman@users.noreply.github.com>
Date: Fri, 13 Dec 2024 17:35:24 -0500
Subject: [PATCH 39/39] Update IdeInfoDisplay.razor
---
.../LuthetusWebsiteInitializer.razor.cs | 7 +++++++
.../Shareds/Displays/Internals/IdeInfoDisplay.razor | 10 ++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/Source/Lib/Extensions/Extensions.Website/LuthetusWebsiteInitializer.razor.cs b/Source/Lib/Extensions/Extensions.Website/LuthetusWebsiteInitializer.razor.cs
index 505f0a6c7..6a81d9c75 100644
--- a/Source/Lib/Extensions/Extensions.Website/LuthetusWebsiteInitializer.razor.cs
+++ b/Source/Lib/Extensions/Extensions.Website/LuthetusWebsiteInitializer.razor.cs
@@ -38,6 +38,8 @@ public partial class LuthetusWebsiteInitializer : ComponentBase
[Inject]
private ICompilerServiceRegistry CompilerServiceRegistry { get; set; } = null!;
[Inject]
+ private ITextEditorHeaderRegistry TextEditorHeaderRegistry { get; set; } = null!;
+ [Inject]
private IBackgroundTaskService BackgroundTaskService { get; set; } = null!;
[Inject]
private IdeBackgroundTaskApi IdeBackgroundTaskApi { get; set; } = null!;
@@ -136,6 +138,11 @@ await FileSystemProvider.File.WriteAllTextAsync(
var solutionAbsolutePath = EnvironmentProvider.AbsolutePathFactory(
InitialSolutionFacts.SLN_ABSOLUTE_FILE_PATH,
false);
+
+ // This line is also in LuthetusExtensionsDotNetInitializer,
+ // but its duplicated here because the website
+ // won't open the first file correctly without this.
+ TextEditorHeaderRegistry.UpsertHeader("cs", typeof(Luthetus.TextEditor.RazorLib.TextEditors.Displays.Internals.TextEditorCompilerServiceHeaderDisplay));
DotNetBackgroundTaskApi.DotNetSolution.SetDotNetSolution(solutionAbsolutePath);
diff --git a/Source/Lib/Ide/Ide.RazorLib/Shareds/Displays/Internals/IdeInfoDisplay.razor b/Source/Lib/Ide/Ide.RazorLib/Shareds/Displays/Internals/IdeInfoDisplay.razor
index 95e324976..6e9b16e73 100644
--- a/Source/Lib/Ide/Ide.RazorLib/Shareds/Displays/Internals/IdeInfoDisplay.razor
+++ b/Source/Lib/Ide/Ide.RazorLib/Shareds/Displays/Internals/IdeInfoDisplay.razor
@@ -172,9 +172,15 @@
Recent Changes:
-
v 0.9.7.6 (WIP_DATE)
+
v 0.9.7.6 (2024-12-13)
- - WIP_DESCRIPTION
+ - Solution wide parse is 40% faster.
+ -
+ Don't apply syntax highlighting during solution wide parse.
+ Instead, when a file is opened, apply the first syntax highlighting at that point.
+
+ - Reduce object allocation during parses.
+ - Memory improvements.