@@ -15,15 +15,15 @@ import LanguageServerProtocol
1515import RegexBuilder
1616
1717/// Represents url of macro expansion reference document as follows:
18- /// `sourcekit-lsp://swift-macro-expansion/LaCb-LcCd.swift?parent=& fromLine=&fromColumn=&toLine=&toColumn=&bufferName=`
18+ /// `sourcekit-lsp://swift-macro-expansion/LaCb-LcCd.swift?fromLine=&fromColumn=&toLine=&toColumn=&bufferName=&parent =`
1919///
2020/// Here,
2121/// - `LaCb-LcCd.swift`, the `displayName`, represents where the macro will expand to or
2222/// replace in the source file (i.e. `macroExpansionEditRange`)
23- /// - `parent` denoting the URI of the document from which the macro was expanded. For a first-level macro expansion,
24- /// this is a file URI. For nested macro expansions, this is a `sourcekit-lsp://swift-macro-expansion` URL.
2523/// - `fromLine`, `fromColumn`, `toLine`, `toColumn` represents the cursor's `selectionRange`
2624/// - `bufferName` denotes the buffer name of the specific macro expansion edit
25+ /// - `parent` denoting the URI of the document from which the macro was expanded. For a first-level macro expansion,
26+ /// this is a file URI. For nested macro expansions, this is a `sourcekit-lsp://swift-macro-expansion` URL.
2727package struct MacroExpansionReferenceDocumentURLData {
2828 package static let documentType = " swift-macro-expansion "
2929
@@ -47,7 +47,7 @@ package struct MacroExpansionReferenceDocumentURLData {
4747 ///
4848 /// Generated content of reference document url:
4949 /// URL:
50- /// `sourcekit-lsp://swift-macro-expansion/L3C7-L3C23.swift?primaryFilePath=/path/to/swift_file.swift& fromLine=3&fromColumn=8&toLine=3&toColumn=8&bufferName=@__swift_macro_..._Stringify_.swift`
50+ /// `sourcekit-lsp://swift-macro-expansion/L3C7-L3C23.swift?fromLine=3&fromColumn=8&toLine=3&toColumn=8&bufferName=@__swift_macro_..._Stringify_.swift&parent=/path/to/swift_file .swift`
5151 /// ```swift
5252 /// (a + b, "a + b")
5353 /// ```
@@ -78,13 +78,17 @@ package struct MacroExpansionReferenceDocumentURLData {
7878 }
7979
8080 package var queryItems : [ URLQueryItem ] {
81- return [
82- URLQueryItem ( name: Parameters . parent, value: parent. stringValue) ,
81+ [
8382 URLQueryItem ( name: Parameters . fromLine, value: String ( selectionRange. lowerBound. line) ) ,
8483 URLQueryItem ( name: Parameters . fromColumn, value: String ( selectionRange. lowerBound. utf16index) ) ,
8584 URLQueryItem ( name: Parameters . toLine, value: String ( selectionRange. upperBound. line) ) ,
8685 URLQueryItem ( name: Parameters . toColumn, value: String ( selectionRange. upperBound. utf16index) ) ,
8786 URLQueryItem ( name: Parameters . bufferName, value: bufferName) ,
87+
88+ // *Note*: Having `parent` as the last parameter will ensure that the url's parameters aren't mistaken to be its
89+ // `parent`'s parameters in certain environments where percent encoding gets removed or added
90+ // unnecessarily (for example: VS Code)
91+ URLQueryItem ( name: Parameters . parent, value: parent. stringValue) ,
8892 ]
8993 }
9094
@@ -121,7 +125,7 @@ package struct MacroExpansionReferenceDocumentURLData {
121125 ///
122126 /// Generated content of reference document url:
123127 /// URL:
124- /// `sourcekit-lsp://swift-macro-expansion/L3C7-L3C23.swift?primaryFilePath=/path/to/swift_file.swift& fromLine=3&fromColumn=8&toLine=3&toColumn=8&bufferName=@__swift_macro_..._Stringify_.swift`
128+ /// `sourcekit-lsp://swift-macro-expansion/L3C7-L3C23.swift?fromLine=3&fromColumn=8&toLine=3&toColumn=8&bufferName=@__swift_macro_..._Stringify_.swift&parent=/path/to/swift_file .swift`
125129 /// ```swift
126130 /// (a + b, "a + b")
127131 /// ```
0 commit comments