@@ -29,58 +29,54 @@ import (
29
29
30
30
// PlatformSearch FIXMEDOC
31
31
func PlatformSearch (req * rpc.PlatformSearchRequest ) (* rpc.PlatformSearchResponse , error ) {
32
- searchArgs := strings .TrimSpace (req .SearchArgs )
33
- allVersions := req .AllVersions
34
32
pme , release := commands .GetPackageManagerExplorer (req )
35
33
if pme == nil {
36
34
return nil , & arduino.InvalidInstanceError {}
37
35
}
38
36
defer release ()
39
37
40
38
res := []* cores.PlatformRelease {}
41
- if isUsb , _ := regexp .MatchString ("[0-9a-f]{4}:[0-9a-f]{4}" , searchArgs ); isUsb {
42
- vid , pid := searchArgs [:4 ], searchArgs [5 :]
39
+ if isUsb , _ := regexp .MatchString ("[0-9a-f]{4}:[0-9a-f]{4}" , req . SearchArgs ); isUsb {
40
+ vid , pid := req . SearchArgs [:4 ], req . SearchArgs [5 :]
43
41
res = pme .FindPlatformReleaseProvidingBoardsWithVidPid (vid , pid )
44
42
} else {
45
-
43
+ searchArgs := utils .SearchTermsFromQueryString (req .SearchArgs )
44
+ allVersions := req .AllVersions
46
45
for _ , targetPackage := range pme .GetPackages () {
47
46
for _ , platform := range targetPackage .Platforms {
48
- // discard invalid platforms
49
47
// Users can install platforms manually in the Sketchbook hardware folder,
50
48
// the core search command must operate only on platforms installed through
51
49
// the PlatformManager, thus we skip the manually installed ones.
52
50
if platform == nil || platform .Name == "" || platform .ManuallyInstalled {
53
51
continue
54
52
}
55
53
56
- // discard invalid releases
57
- platformRelease := platform .GetLatestRelease ()
58
- if platformRelease == nil {
54
+ // Discard platforms with no releases
55
+ latestRelease := platform .GetLatestRelease ()
56
+ if latestRelease == nil {
59
57
continue
60
58
}
61
59
62
60
// Gather all strings that can be used for searching
63
- toTest := []string {
64
- platform .String (),
65
- platform .Name ,
66
- platform .Architecture ,
67
- targetPackage .Name ,
68
- targetPackage .Maintainer ,
69
- targetPackage .WebsiteURL ,
70
- }
71
- for _ , board := range platformRelease .BoardsManifest {
72
- toTest = append (toTest , board .Name )
61
+ toTest := platform .String () + " " +
62
+ platform .Name + " " +
63
+ platform .Architecture + " " +
64
+ targetPackage .Name + " " +
65
+ targetPackage .Maintainer + " " +
66
+ targetPackage .WebsiteURL
67
+ for _ , board := range latestRelease .BoardsManifest {
68
+ toTest += board .Name + " "
73
69
}
74
70
75
71
// Search
76
- if ! utils .MatchAny ( searchArgs , toTest ) {
72
+ if ! utils .Match ( toTest , searchArgs ) {
77
73
continue
78
74
}
79
75
80
76
if allVersions {
81
77
res = append (res , platform .GetAllReleases ()... )
82
78
} else {
83
- res = append (res , platformRelease )
79
+ res = append (res , latestRelease )
84
80
}
85
81
}
86
82
}
0 commit comments