• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package jvm;
18 
19 import jvm.other.Other;
20 
21 /** Foo class. */
22 public final class Foo {
23 //               ^  ^ foo_def
24 
testParameterInfo()25   void testParameterInfo() {
26     // Test signature help for type parameters.
27 
28     Bar<Integer, Double> b = new Bar<>();
29     //                               ^ ctor
30     //     ^ decl_1
31     //              ^ decl_2
32     System.out.println(b);
33 
34     // step at ctor
35     // workspace.waitForReady()
36     // paraminfo.trigger()
37     // assert paraminfo.items.filter(
38     //  label="K extends Number, V extends Number",
39     //  selection="K extends Number",
40     // )
41 
42     // step at decl_1
43     // workspace.waitForReady()
44     // paraminfo.trigger()
45     // assert paraminfo.items.filter(
46     //  label="K extends Number, V extends Number",
47     //  selection="K extends Number",
48     // )
49 
50     // step at decl_2
51     // workspace.waitForReady()
52     // paraminfo.trigger()
53     // assert paraminfo.items.filter(
54     //  label="K extends Number, V extends Number",
55     //  selection="V extends Number",
56     // )
57 
58     // Test signature help for constructor parameters.
59 
60     Other other = new Other(123, "foo");
61     //                       ^ param_1
62     //                             ^ param_2
63     System.out.println(other);
64 
65     // step at param_1
66     // workspace.waitForReady()
67     // paraminfo.trigger()
68     // assert paraminfo.items.filter(
69     //  label="\\(int first, String second\\)",
70     //  selection="int first",
71     // )
72 
73     // step at param_2
74     // workspace.waitForReady()
75     // paraminfo.trigger()
76     // assert paraminfo.items.empty()
77   }
78 
testCompletion()79   void testCompletion() {
80     Bar<Integer, Double> b = new Bar<>();
81     System.out.println(b);
82 
83     // ^
84 
85     // step
86     // ; Test completion on types from the same package.
87     // workspace.waitForReady()
88     // type("b.")
89     // completion.trigger()
90     // assert completion.items.filter(label="foo.*")
91     // delline()
92 
93     Other other = new Other(1, "foo");
94     System.out.println(other);
95 
96     // ^
97 
98     // step
99     // ; Test completion on types from a different package.
100     // workspace.waitForReady()
101     // type("other.")
102     // completion.trigger()
103     // apply(completion.items.filter(label="other.*").first())
104     // type(".")
105     // completion.trigger()
106     // apply(completion.items.filter(label="other.*").first())
107     // delline()
108   }
109 
testDiagnostics()110   void testDiagnostics() {
111 
112     // ^
113 
114     // step
115     // ; Test diagnostics about wrong type argument bounds.
116     // workspace.waitForReady()
117     // type("Bar<String, Double> b;")
118     // assert diagnostics.items.filter(
119     //  message="type argument .* is not within bounds .*",
120     //  code="compiler.err.not.within.bounds",
121     // )
122     // delline()
123   }
124 }
125