@@ -3,10 +3,6 @@ package sourcemapper
3
3
import (
4
4
"bufio"
5
5
"io"
6
- "net/url"
7
- "path/filepath"
8
- "regexp"
9
- "runtime"
10
6
"strconv"
11
7
"strings"
12
8
@@ -35,14 +31,12 @@ type InoLine struct {
35
31
36
32
// InoToCppLine converts a source (.ino) line into a target (.cpp) line
37
33
func (s * InoMapper ) InoToCppLine (sourceURI lsp.DocumentURI , line int ) int {
38
- file := uriToPath (sourceURI )
39
- return s .toCpp [InoLine {file , line }]
34
+ return s .toCpp [InoLine {sourceURI .Unbox (), line }]
40
35
}
41
36
42
37
// InoToCppLineOk converts a source (.ino) line into a target (.cpp) line
43
38
func (s * InoMapper ) InoToCppLineOk (sourceURI lsp.DocumentURI , line int ) (int , bool ) {
44
- file := uriToPath (sourceURI )
45
- res , ok := s .toCpp [InoLine {file , line }]
39
+ res , ok := s .toCpp [InoLine {sourceURI .Unbox (), line }]
46
40
return res , ok
47
41
}
48
42
@@ -193,26 +187,3 @@ func copyMappings(sourceLineMap, targetLineMap, newMappings map[int]int) {
193
187
}
194
188
}
195
189
}
196
-
197
- var expDriveID = regexp .MustCompile ("[a-zA-Z]:" )
198
-
199
- func uriToPath (uri lsp.DocumentURI ) string {
200
- urlObj , err := url .Parse (string (uri ))
201
- if err != nil {
202
- return string (uri )
203
- }
204
- path := ""
205
- segments := strings .Split (urlObj .Path , "/" )
206
- for _ , segment := range segments {
207
- decoded , err := url .PathUnescape (segment )
208
- if err != nil {
209
- decoded = segment
210
- }
211
- if runtime .GOOS == "windows" && expDriveID .MatchString (decoded ) {
212
- path += strings .ToUpper (decoded )
213
- } else if len (decoded ) > 0 {
214
- path += string (filepath .Separator ) + decoded
215
- }
216
- }
217
- return path
218
- }
0 commit comments