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

Lsp code action #81

Merged
merged 8 commits into from
Jan 31, 2025
Merged

Lsp code action #81

merged 8 commits into from
Jan 31, 2025

Conversation

alexander-hert
Copy link
Collaborator

No description provided.

Copy link
Contributor

@georghinkel georghinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, ich befürchte ich habe das Feature falsch verstanden. Das sind Quick Fixes. Die sind auch gut, aber ich hatte eher an sowas gedacht wie Unit Tests direkt vom Code heraus zu starten. Das werden wohl eher die Code Lenses sein.

So wie es momentan implementiert ist, würde das bedeuten, dass wir eine feste Menge von Code Actions haben, die wir immer abfragen und denen die Ranges mitgeben.

AnyText/AnyText.Core/Grammars/Grammar.cs Outdated Show resolved Hide resolved
AnyText/AnyText.Core/WorkspaceEdit.cs Outdated Show resolved Hide resolved
AnyText/AnyText.Lsp/LspServer.CodeAction.cs Outdated Show resolved Hide resolved
/// Dictionary of executable actions.
/// The key is the action identifier, and the value is the action executor.
/// </summary>
public virtual Dictionary<string, Func<object[], object>> ExecutableCodeActions { get; } = new Dictionary<string, Func<object[], object>>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mit object[] verlieren wir jegliche Typsicherheit! Außerdem kann jeder das Dictionary zu jedem Zeitpunkt löschen. Virtual macht hier glaube ich auch mehr Schaden als Nutzen. Daher würde ich gern

  1. Das Dictionary entweder mindestens mal protected machen
  2. Das virtual rausnehmen
  3. Eine passendere Signatur als Func<object[],object>
  4. Alternativ könnte man auch nur Methoden protected anbieten, um Code Actions hinzuzufügen.

@alexander-hert
Copy link
Collaborator Author

Die CodeActions hängen jetzt nur an den Regeln. Ich könnte auch noch, falls nötig, die CodeLenses einfügen, da die sehr ähnlich zu den CodeActions funktionieren.

@georghinkel
Copy link
Contributor

Code Lenses wären super :)

Copy link
Contributor

@georghinkel georghinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sieht sehr gut aus, ich habe aber trotzdem noch ein paar Kommentare :)

AnyText/AnyText.Core/Rules/Rule.cs Outdated Show resolved Hide resolved
AnyText/AnyText.Core/Rules/Rule.cs Outdated Show resolved Hide resolved
AnyText/AnyText.Core/Rules/RuleApplication.cs Outdated Show resolved Hide resolved
AnyText/AnyText.Core/Rules/RuleApplication.cs Show resolved Hide resolved
/// <inheritdoc />
public override void AddCodeLenses(ICollection<CodeLensInfo> codeLenses)
{
if (Inner != null && Inner.IsActive)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Der Check für IsActive ist wegen Lookaheads? Ich glaube das wäre einen Kommentar wert.

AnyText/AnyText.Lsp/LspServer.CodeAction.cs Outdated Show resolved Hide resolved
AnyText/AnyText/Grammars/AnyTextGrammar.manual.Actions.cs Outdated Show resolved Hide resolved
@georghinkel georghinkel merged commit 32e3c45 into anytext Jan 31, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants