Skip to content

Commit

Permalink
Merge pull request #388 from Luthetus/main
Browse files Browse the repository at this point in the history
Backwards merging
  • Loading branch information
Luthetus authored Dec 18, 2024
2 parents e5d6173 + f73d4c9 commit 4cc2ba9
Show file tree
Hide file tree
Showing 19 changed files with 330 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,14 @@ public IExpressionNode EmptyMergeToken(
var returnStatementNode = new ReturnStatementNode((KeywordToken)token, EmptyExpressionNode.Empty);
parserModel.ExpressionList.Add((SyntaxKind.EndOfFileToken, returnStatementNode));
return EmptyExpressionNode.Empty;
case SyntaxKind.BangToken:
case SyntaxKind.PipeToken:
case SyntaxKind.PipePipeToken:
case SyntaxKind.AmpersandToken:
case SyntaxKind.AmpersandAmpersandToken:
case SyntaxKind.PlusPlusToken:
case SyntaxKind.MinusMinusToken:
return emptyExpressionNode;
default:
return new BadExpressionNode(CSharpFacts.Types.Void.ToTypeClause(), emptyExpressionNode, token);
}
Expand Down Expand Up @@ -1321,9 +1329,11 @@ public IExpressionNode TypeClauseMergeToken(
}

goto default;
case SyntaxKind.WithTokenContextualKeyword:
Console.WriteLine("case SyntaxKind.WithTokenContextualKeyword)");
goto default;
case SyntaxKind.OpenSquareBracketToken:
typeClauseNode.ArrayRank++;
return typeClauseNode;
case SyntaxKind.CloseSquareBracketToken:
return typeClauseNode;
default:
if (UtilityApi.IsConvertibleToIdentifierToken(token.SyntaxKind))
{
Expand Down
47 changes: 45 additions & 2 deletions Source/Lib/CompilerServices/CSharp/LexerCase/CSharpLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,40 @@ public static CSharpLexerOutput Lex(ResourceUri resourceUri, string sourceText)
lexerOutput.SyntaxTokenList.Add(new QuestionMarkToken(textSpan));
}
break;
case '|':
if (stringWalker.PeekCharacter(1) == '|')
{
var entryPositionIndex = stringWalker.PositionIndex;
stringWalker.ReadCharacter();
stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
lexerOutput.SyntaxTokenList.Add(new PipePipeToken(textSpan));
}
else
{
var entryPositionIndex = stringWalker.PositionIndex;
stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
lexerOutput.SyntaxTokenList.Add(new PipeToken(textSpan));
}
break;
case '&':
if (stringWalker.PeekCharacter(1) == '&')
{
var entryPositionIndex = stringWalker.PositionIndex;
stringWalker.ReadCharacter();
stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
lexerOutput.SyntaxTokenList.Add(new AmpersandAmpersandToken(textSpan));
}
else
{
var entryPositionIndex = stringWalker.PositionIndex;
stringWalker.ReadCharacter();
var textSpan = new TextEditorTextSpan(entryPositionIndex, stringWalker.PositionIndex, (byte)GenericDecorationKind.None, stringWalker.ResourceUri, stringWalker.SourceText);
lexerOutput.SyntaxTokenList.Add(new AmpersandToken(textSpan));
}
break;
case '*':
{
var entryPositionIndex = stringWalker.PositionIndex;
Expand Down Expand Up @@ -907,6 +941,7 @@ public static void LexPreprocessorDirectiveToken(ref CSharpLexerOutput lexerOutp

// Declare outside the while loop to avoid overhead of redeclaring each loop? not sure
var isNewLineCharacter = false;
var firstWhitespaceCharacterPositionIndex = -1;

while (!stringWalker.IsEof)
{
Expand All @@ -916,6 +951,11 @@ public static void LexPreprocessorDirectiveToken(ref CSharpLexerOutput lexerOutp
case '\n':
isNewLineCharacter = true;
break;
case '\t':
case ' ':
if (firstWhitespaceCharacterPositionIndex == -1)
firstWhitespaceCharacterPositionIndex = stringWalker.PositionIndex;
break;
default:
break;
}
Expand All @@ -925,11 +965,14 @@ public static void LexPreprocessorDirectiveToken(ref CSharpLexerOutput lexerOutp

_ = stringWalker.ReadCharacter();
}

if (firstWhitespaceCharacterPositionIndex == -1)
firstWhitespaceCharacterPositionIndex = stringWalker.PositionIndex;

var textSpan = new TextEditorTextSpan(
entryPositionIndex,
stringWalker.PositionIndex,
(byte)GenericDecorationKind.None,
firstWhitespaceCharacterPositionIndex,
(byte)GenericDecorationKind.PreprocessorDirective,
stringWalker.ResourceUri,
stringWalker.SourceText);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@
<div class="luth_ide_test-explorer-top"
style="height: 1.8em;"
title="Sln: @(renderBatchValidated.TestExplorerState.SolutionFilePath ?? "null");">

@{
var iconDriver = new IconDriver(
AppOptionsStateWrap.Value.Options.IconSizeInPixels,
AppOptionsStateWrap.Value.Options.IconSizeInPixels);
}

<button class="luth_button"
style="display: inline;"
title="Discover tests for all projects"
@onclick="DispatchShouldInitializeEffect">
@IconRefreshFragment.Render(iconDriver)
</button>

Total: @(renderBatchValidated.TestExplorerState.TotalTestCount);
<span class="luth_tree-view-warning">NotRan: @(renderBatchValidated.TestExplorerState.NotRanTestHashSet.Count);</span>
<em class="luth_em">Passed: @(renderBatchValidated.TestExplorerState.PassedTestHashSet.Count);</em>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected override void OnInitialized()

base.OnInitialized();
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
Expand Down Expand Up @@ -136,4 +137,9 @@ private void RegisterDetailsTextEditor(TextEditorModel model)
return Task.CompletedTask;
});
}

private void DispatchShouldInitializeEffect()
{
Dispatcher.Dispatch(new TestExplorerState.ShouldInitializeEffect());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ public Effector(
_dotNetSolutionStateWrap = dotNetSolutionStateWrap;
}

/// <summary>
/// Each time the user opens the 'Test Explorer' panel,
/// a check is done to see if the data being displayed
/// is in sync with the user's selected .NET solution.
///
/// If it is not in sync, then it starts discovering tests for each of the
/// projects in the solution.
///
/// But, if the user cancels this task, if they change panel tabs
/// from the 'Test Explorer' to something else, when they return
/// it will once again try to discover tests in all the projects for the solution.
///
/// This is very annoying from a user perspective.
/// So this field will track whether we've already started
/// the task to discover tests in all the projects for the solution or not.
///
/// This is fine because there is a button in the top left of the panel that
/// has a 'refresh' icon and it will start this task if the
/// user manually clicks it, (even if they cancelled the automatic invocation).
/// </summary>
private string _intentToDiscoverTestsInSolutionFilePath = string.Empty;

[EffectMethod(typeof(DotNetSolutionState.StateHasChanged))]
public Task HandleDotNetSolutionStateStateHasChanged(IDispatcher dispatcher)
{
Expand All @@ -46,8 +68,12 @@ public Task HandleUserInterfaceWasInitializedEffect(IDispatcher dispatcher)

var testExplorerState = _testExplorerStateWrap.Value;

if (dotNetSolutionModel.AbsolutePath.Value != testExplorerState.SolutionFilePath)
if (dotNetSolutionModel.AbsolutePath.Value != testExplorerState.SolutionFilePath &&
_intentToDiscoverTestsInSolutionFilePath != dotNetSolutionModel.AbsolutePath.Value)
{
_intentToDiscoverTestsInSolutionFilePath = dotNetSolutionModel.AbsolutePath.Value;
dispatcher.Dispatch(new TestExplorerState.ShouldInitializeEffect());
}

return Task.CompletedTask;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Lib/Ide/Ide.RazorLib/Luthetus.Ide.RazorLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.7.9</Version>
<Version>0.9.7.10</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,30 @@
Recent Changes:
<div>
<div>
<div>v <em class="luth_em">0.9.7.9 </em> (WIP_DATE)</div>
<div>v <em class="luth_em">0.9.7.10 </em> (2024-12-18)</div>
<ul>
<li>
Lex preprocessor directive
</li>
<li>
Lex Pipe, PipePipe, Ampersand, AmpersandAmpersand
</li>
<li>
Skip over BangToken without causing a BadExpressionNode
</li>
<li>
Show array in type clause node tooltip
</li>
<li>
Parse array type definition
</li>
<li>
Add button: Test rediscovery only happens once
</li>
</ul>
</div>
<div>
<div>v <em class="luth_em">0.9.7.9 </em> (2024-12-17)</div>
<ul>
<li>
Fix: 'this' keyword in function arguments listing.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@inherits Fluxor.Blazor.Web.Components.FluxorComponent

@{
@{
var localStartupControlState = StartupControlStateWrap.Value;
bool isExecuting;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public string Map(byte decorationByte)
GenericDecorationKind.CommentSingleLine => "luth_te_comment",
GenericDecorationKind.CommentMultiLine => "luth_te_comment",
GenericDecorationKind.Function => "luth_te_method",
GenericDecorationKind.PreprocessorDirective => "luth_te_keyword",
GenericDecorationKind.PreprocessorDirective => "luth_te_preprocessor-directive",
GenericDecorationKind.DeliminationExtended => "luth_te_string-literal",
GenericDecorationKind.Type => "luth_te_type",
_ => string.Empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public TypeClauseNode(
TypeClauseNode IExpressionNode.ResultTypeClauseNode => TypeFacts.Pseudo.ToTypeClause();

public bool HasQuestionMark { get; set; }
public int ArrayRank { get; set; }

/// <summary>
/// TODO: Change this attribute node property.
Expand Down
4 changes: 4 additions & 0 deletions Source/Lib/TextEditor/CompilerServices/Syntax/SyntaxKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public enum SyntaxKind
EqualsEqualsToken,
QuestionMarkToken,
QuestionMarkQuestionMarkToken,
PipeToken,
PipePipeToken,
AmpersandToken,
AmpersandAmpersandToken,
BangToken,
StatementDelimiterToken,
ArraySyntaxToken,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Luthetus.TextEditor.RazorLib.Lexers.Models;

namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;

public struct AmpersandAmpersandToken : ISyntaxToken
{
public AmpersandAmpersandToken(TextEditorTextSpan textSpan)
{
ConstructorWasInvoked = true;
TextSpan = textSpan;
}

public TextEditorTextSpan TextSpan { get; }
public SyntaxKind SyntaxKind => SyntaxKind.AmpersandAmpersandToken;
public bool IsFabricated { get; init; }
public bool ConstructorWasInvoked { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Luthetus.TextEditor.RazorLib.Lexers.Models;

namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;

public struct AmpersandToken : ISyntaxToken
{
public AmpersandToken(TextEditorTextSpan textSpan)
{
ConstructorWasInvoked = true;
TextSpan = textSpan;
}

public TextEditorTextSpan TextSpan { get; }
public SyntaxKind SyntaxKind => SyntaxKind.AmpersandToken;
public bool IsFabricated { get; init; }
public bool ConstructorWasInvoked { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Luthetus.TextEditor.RazorLib.Lexers.Models;

namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;

public struct PipePipeToken : ISyntaxToken
{
public PipePipeToken(TextEditorTextSpan textSpan)
{
ConstructorWasInvoked = true;
TextSpan = textSpan;
}

public TextEditorTextSpan TextSpan { get; }
public SyntaxKind SyntaxKind => SyntaxKind.PipePipeToken;
public bool IsFabricated { get; init; }
public bool ConstructorWasInvoked { get; }
}
17 changes: 17 additions & 0 deletions Source/Lib/TextEditor/CompilerServices/Syntax/Tokens/PipeToken.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Luthetus.TextEditor.RazorLib.Lexers.Models;

namespace Luthetus.TextEditor.RazorLib.CompilerServices.Syntax.Tokens;

public struct PipeToken : ISyntaxToken
{
public PipeToken(TextEditorTextSpan textSpan)
{
ConstructorWasInvoked = true;
TextSpan = textSpan;
}

public TextEditorTextSpan TextSpan { get; }
public SyntaxKind SyntaxKind => SyntaxKind.PipeToken;
public bool IsFabricated { get; init; }
public bool ConstructorWasInvoked { get; }
}
Loading

0 comments on commit 4cc2ba9

Please sign in to comment.