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

Changing the "# References" to display before the set of attributes(if any) #1938

Closed
wants to merge 11 commits into from

Conversation

akshita31
Copy link
Contributor

Fixes: #429

To display the # of references before the set of attributes, the provideCodeLens must return a range for the attributes of the node. So changed the omnisharpLens object to contain two ranges - one the actualRange of the node ( to be consumed by the resolveCodeLens method) and the other attributeRange that will be consumed to determine the position to display the references.
Also added attributeSpantoRange helper to convert span to a range in the document.

@akshita31
Copy link
Contributor Author

Omnisharp-roslyn side : OmniSharp/omnisharp-roslyn#1075

@akshita31
Copy link
Contributor Author

akshita31 commented Dec 27, 2017

codelens1

The "run test" and "debug test" now show up as a separate codelens.
@rchande Do we need to shift that as well alongside the reference codelens?

@rchande
Copy link

rchande commented Jan 2, 2018

@akshita31 Yes, we need to move the test codelens too.

Copy link

@rchande rchande left a comment

Choose a reason for hiding this comment

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

Minor nits

let column = document.positionAt(node.AttributeSpanStart).character;
let endLine = document.positionAt(node.AttributeSpanEnd).line;
let endColumn = document.positionAt(node.AttributeSpanEnd).character;
return new Range(line, column, endLine, endColumn);
Copy link

Choose a reason for hiding this comment

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

I think there's a range constructor that takes 2 Positionss (instead of 2 l,c coordinates)

this.fileName = fileName;
this.actualRange = actualrange;
Copy link

Choose a reason for hiding this comment

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

casing doesn't match that of attributeRange

return [];
}

return serverUtils.currentFileMembersAsTree(this._server, { FileName: document.fileName }, token).then(tree => {
let ret: vscode.CodeLens[] = [];
tree.TopLevelTypeDefinitions.forEach(node => this._convertQuickFix(ret, document.fileName, node));
tree.TopLevelTypeDefinitions.forEach(node => this._convertQuickFix(ret, document, node));
Copy link

Choose a reason for hiding this comment

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

Not your fault, but can we make this method async (and thus not having to do the then chaining)?

@filipw
Copy link
Contributor

filipw commented Jan 3, 2018

I love this change, but AFAIR the idea was to not diverge the VS Code experience from full VS. Is that not the case anymore?

@rchande
Copy link

rchande commented Jan 5, 2018

@filipw From talking to other Roslyn folks at lunch, it sounds like people are generally in favor of the change. I'm not aware of any requirement that the VS Code experience exactly match the VS one. Thoughts @DustinCampbell ? I would argue that if this is a better experience (and I think it is) that we should do it.

@DustinCampbell
Copy link
Member

This requires a new OmniSharp build, correct?

@DustinCampbell
Copy link
Member

@rchande : The experience for C# in VS vs. VS Code doesn't need to be precisely the same, but that is our starting point for designing the experience. If we decide that the experience should be different, we need to be able to articulate why, and also understand we aren't changing VS to match.

I would not split references from the test code lenses here. That looks pretty bad to me. IMO, all of the code lenses should be above the attributes to match VS unless we've got a reason not to change VS.

@rchande
Copy link

rchande commented Jan 24, 2018

@DustinCampbell It looks like VS currently puts the codelens adornment underneath attributes. I'll sync with the IDE folks to see what they think and determine if they want to make the same change in VS.

image

@DustinCampbell
Copy link
Member

@rchande : Yes, that was a conscious decision, and I think we should keep it there. When we implemented CodeLens in VS, I was the one who made the case for keeping the adornment directly above the method declaration and not allowing it to drift above the attributes. Here's an example of why we made that decision from the Roslyn code base:

image

It's an extreme case, but it's a real concern.

@DustinCampbell
Copy link
Member

cc @jinujoseph and @kuhlenh for consistency between VS and VS Code.

@DustinCampbell
Copy link
Member

I'm also curious to know if any thought has been given to XML doc comments, which are defined grammatically to appear above attributes. Does this still look good when the code lens is between XML doc comments and attributes?

@DustinCampbell
Copy link
Member

Also cc'ing @Pilchie in case he remembers any other reasons why we chose the position of code lens in VS that we did.

@Pilchie
Copy link
Member

Pilchie commented Jan 25, 2018

@DustinCampbell's comments match my recollection.

@akshita31 akshita31 closed this Jan 25, 2018
@akshita31 akshita31 deleted the reference_pos branch February 23, 2018 23:13
@danielsig
Copy link

This is marked as "Blocked on OmniSharp".
What's blocking this? I want this!

@filipw
Copy link
Contributor

filipw commented Feb 26, 2021

it was "Blocked on OmniSharp" because it required a corresponding change in the Omnisharp language server.
however, it was decided that this change will not be implemented for reasons listed in the discussion above

@danielsig
Copy link

That's very disappointing to hear ☹️. I've been wanting this to be fixed for ages, but haven't voiced my frustration until now. Can't we just have a configurable attribute line limit with a default value of 0? If the number of lines occupied by attributes is above that limit, # references is displayed as it is now. This would allow the same behavior as it is now by default yet still allow people like me to configure this the way we think is best for our use cases 😃

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.

# of references display modification
6 participants