-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Implement find all references to preprocessing symbols #66425
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
Conversation
|
Can you explain why you you needed to make the compiler level changes here? |
|
The symbol finder uses a mechanism to determine the documents to search for, which is also determined by the containing assembly of the symbol (if I understood correctly), which I thought required implementing the appropriate properties, and also enhancing resolution of certain properties of the nodes and tokens. |
|
The symbol finder can do whatever it needs on a per symbol basis. In other words, the logic can be entirely different depending on what type of symbol is being searched for. It's not clear to me yet what it would need those properties for in the case of pp symbols. Thanks! |
|
It seems like the finder is flexible enough, so if I understand correctly it would be best avoided to implement the containing assembly and module symbols, if possible. However, from what I've seen the symbol visitors need to stay in place and be implemented during traversal. |
|
Not sure what you are referring to when you say "symbol visitor" |
|
I'm referring to the |
src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerTests.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferenceCache.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex.ContextInfo.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
Outdated
Show resolved
Hide resolved
| @@ -1,5 +1,6 @@ | |||
| *REMOVED*override abstract Microsoft.CodeAnalysis.CompilationOptions.GetHashCode() -> int | |||
| *REMOVED*static Microsoft.CodeAnalysis.ModuleMetadata.CreateFromMetadata(System.IntPtr metadata, int size, System.IDisposable! owner, bool disposeOwner) -> Microsoft.CodeAnalysis.ModuleMetadata! | |||
| abstract Microsoft.CodeAnalysis.SemanticModel.GetPreprocessingSymbolInfoCore(Microsoft.CodeAnalysis.SyntaxToken token) -> Microsoft.CodeAnalysis.PreprocessingSymbolInfo | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to go through API review process for proposed public API addition.
https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md
Tagging @333fred as FYI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's even more coming, will push my progress tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rekkonnect please follow our public API process before proposing PRs, as we documented in the process: https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md#pull-requests.
AlekseyTs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (commit 89), pending new API review.
|
@dotnet/roslyn-compiler For the second review. |
|
@dotnet/roslyn-compiler the API proposal was approved, pending second review |
|
@dotnet/roslyn-compiler For the second review |
2 similar comments
|
@dotnet/roslyn-compiler For the second review |
|
@dotnet/roslyn-compiler For the second review |
|
@333fred, @dotnet/roslyn-compiler For the second review for a community PR |
333fred
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler changes lgtm
|
This has two compiler sign offs, and IDE sign off. My intent is to check this in tomorrow. Just giving it time in case anyone is surpirsed by that and wanted to bring up any final issues. |
Closes #66009
Implementation Notes
This implementation adds support for finding references to preprocessing symbols.
A new symbol reference finder was added for preprocessing symbols. The projects that the finder is performed on are not filtered, just like namespaces. This decision was made as the name of the preprocessing symbol is the only factor determining equality against another preprocessing symbol.
Preprocessing symbols now implement
Accept(SymbolVisitor)methods to support the visitor that yields the FAR results to the LSP. Also, more support was added for preprocessing symbols in LSP content, including the classification type.CanBeReferencedByNamealso supports preprocessing symbols.OrderLocationsnow compares against nullable location instances, to correctly enable ordering of location instances. This was required for cases where a symbol does not have a single source definition like global namespaces, assembly or module symbols. Thus,Locationis marked as nullable inVSInternalReferenceItem, and is treated as such in code that may include null Location instances.Public API
An API proposal has been opened to cover the newly introduced public APIs: #66510
Only
CreatePreprocessingSymbolis added in this PR and is mentioned in the API proposal.CreatePreprocessingSymbolis useful for the resolution of the symbol inPreprocessingSymbolKey, as well as the retrieval of the preprocessing symbol in the custom implementation of getting the preprocessing symbol at the given syntax node, in Workspaces.Tests
There are unit tests covering:
#define,#undefand#Conststatements#Constassignment expression#if,#elif,#If,#ElseIfstatements#region,#endregion,#pragma warning disable/restoreGetPreprocessingSymbolInforeturns info when inside#pragma warningdirective #72907 is resolved