Skip to content

Conversation

@davidwengier
Copy link
Member

Fixes #8536

@davidwengier davidwengier requested a review from a team as a code owner May 17, 2023 05:34
Comment on lines 54 to 64
protected virtual bool TreatAnyAttributePositionAsAttributeName { get; } = false;

/// <summary>
/// If <see cref="TreatAnyAttributePositionAsAttributeName "/> is <see langword="true"/>, returns whether the position was adjusted
/// </summary>
protected bool DidTreatAttributePositionAsAttributeName { get; private set; }

/// <summary>
/// If <see cref="TreatAnyAttributePositionAsAttributeName "/> is <see langword="true"/>, returns the range of the full attribute
/// </summary>
protected Range OriginalAttributeRange { get; private set; }
Copy link
Member Author

Choose a reason for hiding this comment

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

This class is getting a little big IMO, and doing a few things, but I couldn't see a nice way to split it up, and more importantly I couldn't come up with a nice name for a class that could sit in the middle of the hierarchy and provide this functionality. AbstractRazorDelegatingEndpointThatAdjustsCaretPositionToAttributeNamesIfPossible is just silly :)

I don't think this is too egregious that we can't merge this, but its on a slippery slope. Open to feedback.


protected override string CustomMessageTarget => RazorLanguageServerCustomMessageTargets.RazorImplementationEndpointName;

protected override bool PreferCSharpOverHtmlIfPossible => true;
Copy link
Member Author

Choose a reason for hiding this comment

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

This strictly out of scope, and was an oversight from a previous PR that turned this on for Go To Def that I just noticed, but seemed simple enough to fix.

Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

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

Love the testing and explanations, but the design seems a little bit clunky. Is there a way we can make this more isolated, or generalize more? In the base it seems VERY targeted right now

@davidwengier
Copy link
Member Author

@ryzngard Check out the latest commit, I moved the caret projection logic into a different class, and allowed specific endpoints to provide their preferred strategy. In future we could also move the PreferCSharpOverHtmlIfPossible feature to this system, but there are annoying Rename tests that use mocks badly that prevent that happening now. Can either do it if you think this approach is better, or in a follow up, or we can keep thinking.

@davidwengier
Copy link
Member Author

ping @dotnet/razor-tooling for reviews :D

@davidwengier davidwengier merged commit 11cad1b into dotnet:main May 31, 2023
@davidwengier davidwengier deleted the AttributePrefixAndSuffix branch May 31, 2023 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interacting with component attribute prefixes and suffixes could be better

2 participants