File tree Expand file tree Collapse file tree 6 files changed +53
-0
lines changed
java/ql/integration-tests/java/lambda-expression-buildless-recovery Expand file tree Collapse file tree 6 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ | Frontend errors in file: (2 errors during annotation processing) | 2 |
2+ | Frontend errors in file: Test.java (7 javac errors) | 2 |
3+ | Unknown errors in file: Test.java (5) | 2 |
Original file line number Diff line number Diff line change 1+ Diagnostics/ExtractionErrors.ql
Original file line number Diff line number Diff line change 1+ // The import below is intentionally commented out to test buildless recovery.
2+ // import java.util.stream.Stream;
3+
4+ public class LambdaBuildlessRecoveryTest {
5+
6+ private Stream <String > getStringStream () {
7+ return getStringStream ();
8+ }
9+
10+ public void testSimpleLambdaExpression () {
11+ int unused = 0 ;
12+ Stream <String > s = getStringStream ();
13+ Stream <String > mapped = s .map (x -> x );
14+ mapped .forEach (System .out ::println );
15+ }
16+
17+ public void testLambdaWithBlockBody () {
18+ int unused = 42 ;
19+ Stream <String > s = getStringStream ();
20+ Stream <String > filtered = s .filter (item -> {
21+ int unused = 42 ;
22+ String proc = item .toUpperCase ();
23+ return proc .length () > 0 ;
24+ });
25+ filtered .forEach (System .out ::println );
26+ }
27+
28+ public void testVariableCapture () {
29+ int unused = 99 ;
30+ String prefix = "proc_" ;
31+ Stream <String > s = getStringStream ();
32+ Stream <String > result = s .map (item -> prefix + item );
33+ result .forEach (System .out ::println );
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ def test (codeql , java , use_java_17 ):
2+ codeql .database .create (
3+ build_mode = "none" ,
4+ source_root = "."
5+ )
Original file line number Diff line number Diff line change 1+ | Test.java:11:9:11:23 | int unused |
2+ | Test.java:18:9:18:24 | int unused |
3+ | Test.java:21:13:21:28 | int unused |
4+ | Test.java:29:9:29:24 | int unused |
Original file line number Diff line number Diff line change 1+ import java
2+
3+ from LocalVariableDecl v
4+ where not exists ( v .getAnAccess ( ) ) and exists ( v .getFile ( ) .getRelativePath ( ) )
5+ select v
You can’t perform that action at this time.
0 commit comments