xref: /aosp_15_r20/build/make/tools/ide_query/prober_scripts/cpp/general.cc (revision 9e94795a3d4ef5c1d47486f9a02bb378756cea8a)
1 // Copyright (C) 2024 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <vector>
16 
17 #include "foo.pb.h"
18 
19 using ide_query::prober_scripts::ProtoMsg;
20 
Foo(int x,double y)21 void Foo(int x, double y) {}
Foo(float x,float y)22 float Foo(float x, float y) { return 0.0f; }
23 
TestCompletion()24 void TestCompletion() {
25   // Test completion on protos and fuzzy matching of completion suggestions.
26 
27   ProtoMsg foo;
28 
29   // ^
30 
31   // step
32   // workspace.waitForReady()
33   // type("f")
34   // completion.trigger()
35   // assert completion.items.filter(label="foo")
36   // delline()
37   // type("foo.sf")
38   // completion.trigger()
39   // assert completion.items.filter(
40   //  label="some_field.*",
41   //  insertText="some_field.*",
42   // )
43   // delline()
44 
45   std::vector<int> v;
46 
47   // ^
48 
49   // step
50   // workspace.waitForReady()
51   // type("v.push")
52   // completion.trigger()
53   // assert completion.items.filter(label="push_back.*")
54   // delline()
55 }
56 
TestNavigation()57 void TestNavigation() {
58   std::vector<int> ints;
59   //               |   | ints
60   //      ^
61 
62   // step
63   // ; Test navigation to definition on STL types.
64   // workspace.waitForReady()
65   // navigation.trigger()
66   // assert navigation.items.filter(path=".*/vector")
67 
68   ints.push_back(0);
69   // ^
70 
71   // step
72   // ; Test navigation to definition on local symbols.
73   // workspace.waitForReady()
74   // navigation.trigger()
75   // assert navigation.items.filter(path=".*/general.cc", range=ints)
76 
77   ProtoMsg msg;
78   msg.set_some_field(0);
79   //          ^
80 
81   // step
82   // ; Test navigation to definition on proto fields. We do not check for a
83   // ; specific target as it can be in generated code.
84   // workspace.waitForReady()
85   // navigation.trigger()
86   // assert navigation.items
87 }
88 
TestParameterInfo()89 void TestParameterInfo() {
90   std::vector<int> v;
91   v.push_back(0);
92   //          ^
93 
94   // step
95   // ; Test the signature help for STL functions. We do not check for a specific
96   // ; text as it can be implementation-dependent.
97   // workspace.waitForReady()
98   // paraminfo.trigger()
99   // assert paraminfo.items
100 
101   Foo(0, 0.0);
102   //      ^
103 
104   // step
105   // ; Test the signature help for the function 'Foo' having two overloads.
106   // workspace.waitForReady()
107   // paraminfo.trigger()
108   // assert paraminfo.items.filter(
109   //  active=true,
110   //  label="Foo\\(int x, double y\\) -> void",
111   //  selection="double y",
112   // )
113   // assert paraminfo.items.filter(
114   //  active=false,
115   //  label="Foo\\(float x, float y\\) -> float",
116   // )
117 }
118 
main()119 int main() { return 0; }
120