Skip to content

Commit

Permalink
Merge pull request #375 from Luthetus/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
Luthetus authored Dec 15, 2024
2 parents 15f46f5 + 0b21d6f commit 3a5e647
Show file tree
Hide file tree
Showing 23 changed files with 1,347 additions and 1,730 deletions.
Binary file added Images/Ide/Gifs/parseSolutionWideUpdated.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Luthetus.Ide (In Development)
![Example GIF](./Images/Ide/Gifs/9.5.1BetterGif.gif)
Gif length is 1 minute 35 seconds
The above Gif length is 1 minute 35 seconds

![Example GIF](./Images/Ide/memoryToday.png)
Only 362 MB Memory usage after opening the source code in a published executable of itself and parsing the entire solution with its own - from scratch - C# parser (v0.9.7.4)
![Example GIF](./Images/Ide/Gifs/parseSolutionWideUpdated.gif)

Only 287.1 MB Memory usage after opening the source code in a published executable of itself and parsing the entire solution with its own - from scratch - C# parser (v0.9.7.7)

The gif is sped up by cutting the frames in half.

## Demo:
https://luthetus.github.io/Luthetus.Ide/
Expand Down
371 changes: 193 additions & 178 deletions Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Expressions.cs

Large diffs are not rendered by default.

138 changes: 71 additions & 67 deletions Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ public CSharpCompilationUnit(
}

public ResourceUri ResourceUri { get; set; }
public CSharpLexer Lexer { get; set; }
public CSharpParser Parser { get; set; }
public CSharpParserModel ParserModel { get; set; }
public CSharpLexerOutput LexerOutput { get; set; }
public CSharpBinder Binder { get; set; }
public CSharpBinderSession BinderSession { get; set; }
public CodeBlockNode RootCodeBlockNode { get; set; }

/// <summary>
/// This seems to no longer get set (noticed this on 2024-12-14).
/// </summary>
public ImmutableArray<TextEditorDiagnostic> DiagnosticsList { get; init; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,15 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
x => x.TextEditorPresentationKey == CompilerServiceDiagnosticPresentationFacts.PresentationKey);

var cSharpCompilationUnit = new CSharpCompilationUnit(resourceUri, CSharpBinder);
cSharpCompilationUnit.Lexer = new CSharpLexer(resourceUri, presentationModel.PendingCalculation.ContentAtRequest);
cSharpCompilationUnit.Lexer.Lex();

cSharpCompilationUnit.LexerOutput = CSharpLexer.Lex(resourceUri, presentationModel.PendingCalculation.ContentAtRequest);

// Even if the parser throws an exception, be sure to
// make use of the Lexer to do whatever syntax highlighting is possible.
try
{
cSharpCompilationUnit.BinderSession = (CSharpBinderSession)CSharpBinder.StartBinderSession(resourceUri);
var parser = new CSharpParser();
parser.Parse(cSharpCompilationUnit);
CSharpParser.Parse(cSharpCompilationUnit);
}
finally
{
Expand All @@ -93,8 +92,8 @@ public override Task ParseAsync(ITextEditorEditContext editContext, TextEditorMo
{
var resource = (CSharpResource)_resourceMap[resourceUri];

resource.EscapeCharacterList = cSharpCompilationUnit.Lexer.EscapeCharacterList;
resource.SyntaxTokenList = cSharpCompilationUnit.Lexer.SyntaxTokenList;
resource.EscapeCharacterList = cSharpCompilationUnit.LexerOutput.EscapeCharacterList;
resource.SyntaxTokenList = cSharpCompilationUnit.LexerOutput.SyntaxTokenList;

if (cSharpCompilationUnit is not null)
resource.CompilationUnit = cSharpCompilationUnit;
Expand Down
235 changes: 102 additions & 133 deletions Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexerOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Luthetus.TextEditor.RazorLib.CompilerServices;
using Luthetus.TextEditor.RazorLib.CompilerServices.Syntax;
using Luthetus.TextEditor.RazorLib.Lexers.Models;

namespace Luthetus.CompilerServices.CSharp.LexerCase;

public struct CSharpLexerOutput
{
public CSharpLexerOutput()
{
#if DEBUG
++LuthetusDebugSomething.Lexer_ConstructorInvocationCount;
#endif

SyntaxTokenList = new();
EscapeCharacterList = new();
DiagnosticBag = new();
}

public List<ISyntaxToken> SyntaxTokenList { get; }
public List<TextEditorTextSpan> EscapeCharacterList { get; }
public DiagnosticBag DiagnosticBag { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ public CSharpDeferredChildScope(

public int TokenIndexToRestore { get; private set; }

public void PrepareMainParserLoop(int tokenIndexToRestore, CSharpCompilationUnit compilationUnit)
public void PrepareMainParserLoop(int tokenIndexToRestore, CSharpCompilationUnit compilationUnit, ref CSharpParserModel parserModel)
{
TokenIndexToRestore = tokenIndexToRestore;
compilationUnit.ParserModel.CurrentCodeBlockBuilder.PermitInnerPendingCodeBlockOwnerToBeParsed = true;
parserModel.CurrentCodeBlockBuilder.PermitInnerPendingCodeBlockOwnerToBeParsed = true;

compilationUnit.ParserModel.CurrentCodeBlockBuilder.DequeuedIndexForChildList = null;
parserModel.CurrentCodeBlockBuilder.DequeuedIndexForChildList = null;

compilationUnit.ParserModel.TokenWalker.DeferredParsing(
parserModel.TokenWalker.DeferredParsing(
OpenTokenIndex,
CloseTokenIndex,
TokenIndexToRestore);

compilationUnit.ParserModel.SyntaxStack.Push(PendingCodeBlockOwner);
compilationUnit.ParserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = PendingCodeBlockOwner;
parserModel.SyntaxStack.Push(PendingCodeBlockOwner);
parserModel.CurrentCodeBlockBuilder.InnerPendingCodeBlockOwner = PendingCodeBlockOwner;
}
}
Loading

0 comments on commit 3a5e647

Please sign in to comment.