Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backwards Merging #358

Merged
merged 29 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5191834
Merge pull request #351 from Luthetus/beta
Luthetus Nov 28, 2024
059fcb8
Merge pull request #45 from Luthetus/staging
huntercfreeman Nov 28, 2024
423a25e
Update versions
huntercfreeman Nov 28, 2024
e2e166e
Goal: Track the OpenBraceToken and CloseBraceToken pairs that occur i…
huntercfreeman Dec 3, 2024
383253d
String interpolated, different color for the expressions
huntercfreeman Dec 4, 2024
d7ac96a
String interpolation: '{{'
huntercfreeman Dec 4, 2024
c389a7e
String interpolation: end with expression edge case
huntercfreeman Dec 4, 2024
5af27c7
Verbatim string
huntercfreeman Dec 4, 2024
518a1d6
LexStringRaw
huntercfreeman Dec 4, 2024
30327fd
LexStringEitherInterpolationAndOrVerbatim(...)
huntercfreeman Dec 4, 2024
c0629ff
interpolated raw progress
huntercfreeman Dec 4, 2024
665d03e
Single interpolation raw string case
huntercfreeman Dec 4, 2024
d1b45a4
Interpolation and raw mixtures
huntercfreeman Dec 4, 2024
50088b0
Raw string final content is interpolated bug fix
huntercfreeman Dec 4, 2024
75a7e04
Alternate escape character syntax highlighting (progress)
huntercfreeman Dec 4, 2024
5fd3647
Alternate colors for contiguous escape characters
huntercfreeman Dec 4, 2024
bd41102
List<TextEditorTextSpan> EscapeCharacterList instead of ImmutableArray
huntercfreeman Dec 5, 2024
401bd2a
All the speed issues were in 'CSharpBinder.Main.StartBinderSession(Re…
huntercfreeman Dec 5, 2024
9b80d11
Change solution wide re-render throttle
huntercfreeman Dec 5, 2024
40ad74a
Update README.md
huntercfreeman Dec 5, 2024
fba5a09
Fix: autocomplete with compiler service
huntercfreeman Dec 5, 2024
5efaef2
Merge pull request #353 from huntercfreeman/optimizations
Luthetus Dec 5, 2024
e12a49c
Merge pull request #354 from Luthetus/staging
Luthetus Dec 5, 2024
a2ef043
Merge pull request #355 from Luthetus/main
Luthetus Dec 5, 2024
53a4a42
Merge pull request #46 from Luthetus/staging
huntercfreeman Dec 5, 2024
ef498b5
Update README.md
huntercfreeman Dec 5, 2024
886f673
Update IdeInfoDisplay.razor
huntercfreeman Dec 5, 2024
c861b3f
Merge pull request #356 from huntercfreeman/optimizations
Luthetus Dec 5, 2024
b48ff8b
Merge pull request #357 from Luthetus/staging
Luthetus Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Images/Ide/memoryToday.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
![Example GIF](./Images/Ide/Gifs/9.5.1BetterGif.gif)
Gif length is 1 minute 35 seconds

![Example GIF](./Images/Ide/memory0_9_7_2_AfterGarbageCollection.png)
Memory usage after parsing the entirety of Luthetus.Ide.sln with its own - from scratch - C# parser (v0.9.7.2)
![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)

## Demo:
https://luthetus.github.io/Luthetus.Ide/
Expand Down
2 changes: 1 addition & 1 deletion Source/Lib/Common/Luthetus.Common.RazorLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Product>Luthetus Common</Product>
<Description>A repository containing Blazor Components I've made which I commonly use in other projects.</Description>
<PackageId>Luthetus.Common</PackageId>
<Version>3.3.0</Version>
<Version>3.4.0</Version>
<Authors>Hunter Freeman</Authors>
<Company />
<PackageTags>DotNet CSharp Blazor RazorComponents</PackageTags>
Expand Down
7 changes: 5 additions & 2 deletions Source/Lib/Common/Reactives/Displays/ProgressBarDisplay.razor
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
fillWidthInPercentage -= cancelButtonWidthInPercentage;
}

<div style="display: flex;">
<div class="luth_progress-bar-time-elapsed">
@($"{localProgressBarModel.GetTimeElapsed().TotalSeconds:N3}") seconds
</div>

<div class="luth_progress-bar" style="display: flex;">
<div class="luth_progress-bar-fill"
style="position: relative; height: 2em; width: @(fillWidthInPercentage)%;">

Expand Down Expand Up @@ -65,7 +69,6 @@
</div>
}
</div>


@if (!string.IsNullOrWhiteSpace(localProgressBarModel.Message))
{
Expand Down
10 changes: 10 additions & 0 deletions Source/Lib/Common/Reactives/Models/ProgressBarModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ public ProgressBarModel(double decimalPercentProgress, string? message)
{
DecimalPercentProgress = decimalPercentProgress;
Message = message;

DateTimeStart = DateTime.UtcNow;
}

private Task? _cancelTask;

public double DecimalPercentProgress { get; private set; }
public string? Message { get; private set; }
public string? SecondaryMessage { get; private set; }
public DateTime DateTimeStart { get; set; }
public DateTime? DateTimeEnd { get; set; }
public bool IsCancellable => OnCancelFunc is not null;
public bool IsCancelled { get; set; }
public bool IntentToCancel { get; private set; }
Expand Down Expand Up @@ -107,12 +111,18 @@ public void Cancel()
}
});
}

public TimeSpan GetTimeElapsed()
{
return (DateTimeEnd ?? DateTime.UtcNow) - DateTimeStart;
}

public void Dispose()
{
lock (_progressLock)
{
IsDisposed = true;
DateTimeEnd = DateTime.UtcNow;
ProgressChanged?.Invoke(true);
}
}
Expand Down
53 changes: 23 additions & 30 deletions Source/Lib/CompilerServices/CSharp/BinderCase/CSharpBinder.Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,39 @@ public CSharpBinder()
// _boundScopes.Add(_globalScope.ResourceUri, new List<IScope> { _globalScope });
}

public ImmutableDictionary<string, NamespaceGroupNode> NamespaceGroupNodes => _namespaceGroupNodeMap.ToImmutableDictionary();
public ImmutableArray<ISymbol> Symbols => _symbolDefinitions.Values.SelectMany(x => x.SymbolReferences).Select(x => x.Symbol).ToImmutableArray();
public IReadOnlyDictionary<string, NamespaceGroupNode> NamespaceGroupNodes => _namespaceGroupNodeMap;
public ITextEditorSymbol[] Symbols => _symbolDefinitions.Values.SelectMany(x => x.SymbolReferences).Select(x => x.Symbol).ToArray();
public Dictionary<string, SymbolDefinition> SymbolDefinitions => _symbolDefinitions;
public ImmutableDictionary<NamespaceAndTypeIdentifiers, TypeDefinitionNode> AllTypeDefinitions => _allTypeDefinitions.ToImmutableDictionary();
public ImmutableArray<TextEditorDiagnostic> DiagnosticsList => ImmutableArray<TextEditorDiagnostic>.Empty;
public IReadOnlyDictionary<NamespaceAndTypeIdentifiers, TypeDefinitionNode> AllTypeDefinitions => _allTypeDefinitions;
public TextEditorDiagnostic[] DiagnosticsList => Array.Empty<TextEditorDiagnostic>();

ImmutableArray<ITextEditorSymbol> IBinder.SymbolsList => Symbols
.Select(s => (ITextEditorSymbol)s)
.ToImmutableArray();
ITextEditorSymbol[] IBinder.SymbolsList => Symbols;

/// <summary><see cref="FinalizeBinderSession"/></summary>
public IBinderSession StartBinderSession(ResourceUri resourceUri)
{
foreach (var namespaceGroupNodeKvp in _namespaceGroupNodeMap)
{
var keepStatements = namespaceGroupNodeKvp.Value.NamespaceStatementNodeList
.Where(x => x.IdentifierToken.TextSpan.ResourceUri != resourceUri)
.ToImmutableArray();

_namespaceGroupNodeMap[namespaceGroupNodeKvp.Key] =
new NamespaceGroupNode(
namespaceGroupNodeKvp.Value.NamespaceString,
keepStatements);
for (int i = namespaceGroupNodeKvp.Value.NamespaceStatementNodeList.Count - 1; i >= 0; i--)
{
var x = namespaceGroupNodeKvp.Value.NamespaceStatementNodeList[i];

if (x.IdentifierToken.TextSpan.ResourceUri == resourceUri)
namespaceGroupNodeKvp.Value.NamespaceStatementNodeList.RemoveAt(i);
}
}

foreach (var symbolDefinition in _symbolDefinitions)
{
var keep = symbolDefinition.Value.SymbolReferences
.Where(x => x.Symbol.TextSpan.ResourceUri != resourceUri)
.ToList();

_symbolDefinitions[symbolDefinition.Key] =
symbolDefinition.Value with
{
SymbolReferences = keep
};
for (int i = symbolDefinition.Value.SymbolReferences.Count - 1; i >= 0; i--)
{
var x = symbolDefinition.Value.SymbolReferences[i];

if (x.Symbol.TextSpan.ResourceUri == resourceUri)
symbolDefinition.Value.SymbolReferences.RemoveAt(i);
}
}

// TODO: Why '_globalScope.IndexKey'? Shouldn't this just be 0, its starting the counter fresh?
var cSharpBinderSession = new CSharpBinderSession(
resourceUri,
this,
Expand Down Expand Up @@ -330,9 +324,8 @@ public void BindNamespaceStatementNode(

if (_namespaceGroupNodeMap.TryGetValue(namespaceString, out var inNamespaceGroupNode))
{
var outNamespaceStatementNodeList = inNamespaceGroupNode.NamespaceStatementNodeList
.Add(namespaceStatementNode)
.ToImmutableArray();
var outNamespaceStatementNodeList = new List<NamespaceStatementNode>(inNamespaceGroupNode.NamespaceStatementNodeList);
outNamespaceStatementNodeList.Add(namespaceStatementNode);

var outNamespaceGroupNode = new NamespaceGroupNode(
inNamespaceGroupNode.NamespaceString,
Expand All @@ -344,7 +337,7 @@ public void BindNamespaceStatementNode(
{
_namespaceGroupNodeMap.Add(namespaceString, new NamespaceGroupNode(
namespaceString,
new NamespaceStatementNode[] { namespaceStatementNode }.ToImmutableArray()));
new List<NamespaceStatementNode> { namespaceStatementNode }));
}
}

Expand Down Expand Up @@ -872,7 +865,7 @@ public void ClearStateByResourceUri(ResourceUri resourceUri)
{
var keepStatements = namespaceGroupNodeKvp.Value.NamespaceStatementNodeList
.Where(x => x.IdentifierToken.TextSpan.ResourceUri != resourceUri)
.ToImmutableArray();
.ToList();

_namespaceGroupNodeMap[namespaceGroupNodeKvp.Key] =
new NamespaceGroupNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ public void SetDiagnosticRendererType(Type? diagnosticRendererType)
DiagnosticRendererType = diagnosticRendererType;
}

public override ImmutableArray<AutocompleteEntry> GetAutocompleteEntries(string word, TextEditorTextSpan textSpan)
public override List<AutocompleteEntry> GetAutocompleteEntries(string word, TextEditorTextSpan textSpan)
{
var boundScope = CSharpBinder.GetScope(null, textSpan);

if (boundScope is null)
return ImmutableArray<AutocompleteEntry>.Empty;
return base._emptyAutocompleteEntryList;

var autocompleteEntryList = new List<AutocompleteEntry>();

Expand Down Expand Up @@ -191,7 +191,7 @@ public override ImmutableArray<AutocompleteEntry> GetAutocompleteEntries(string

AddSnippets(autocompleteEntryList, word, textSpan);

return autocompleteEntryList.DistinctBy(x => x.DisplayName).ToImmutableArray();
return autocompleteEntryList.DistinctBy(x => x.DisplayName).ToList();
}

private void AddSnippets(List<AutocompleteEntry> autocompleteEntryList, string word, TextEditorTextSpan textSpan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public CSharpResource(ResourceUri resourceUri, CSharpCompilerService cSharpCompi
{
}

public ImmutableArray<TextEditorTextSpan> EscapeCharacterList { get; internal set; }
public IReadOnlyList<TextEditorTextSpan> EscapeCharacterList { get; internal set; }

public override ImmutableArray<TextEditorTextSpan> GetTokenTextSpans()
public override IReadOnlyList<TextEditorTextSpan> GetTokenTextSpans()
{
var tokenTextSpanList = new List<TextEditorTextSpan>();

tokenTextSpanList.AddRange(SyntaxTokenList.Select(st => st.TextSpan));
tokenTextSpanList.AddRange(EscapeCharacterList);

return tokenTextSpanList.ToImmutableArray();
return tokenTextSpanList;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public static Dictionary<string, NamespaceGroupNode> GetInitialBoundNamespaceSta
{
SystemNamespaceIdentifier,
new NamespaceGroupNode(SystemNamespaceIdentifier,
new NamespaceStatementNode[]
new List<NamespaceStatementNode>
{
new NamespaceStatementNode(
new(new(0, 0, 0, ResourceUri.Empty, string.Empty), SyntaxKind.UnrecognizedTokenKeyword),
new(new(0, SystemNamespaceIdentifier.Length, 0, ResourceUri.Empty, SystemNamespaceIdentifier)),
new CodeBlockNode(ImmutableArray<ISyntax>.Empty))
}.ToImmutableArray())
new CodeBlockNode(Array.Empty<ISyntax>()))
})
}
};
}
Expand All @@ -37,7 +37,7 @@ public static NamespaceStatementNode GetTopLevelNamespaceStatementNode()
return new NamespaceStatementNode(
new(new(0, 0, 0, ResourceUri.Empty, string.Empty), SyntaxKind.UnrecognizedTokenKeyword),
new(new(0, TopLevelNamespaceIdentifier.Length, 0, ResourceUri.Empty, TopLevelNamespaceIdentifier)),
new CodeBlockNode(ImmutableArray<ISyntax>.Empty));
new CodeBlockNode(Array.Empty<ISyntax>()));
}
}
}
Loading
Loading