This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 269997
Collapse All | Expand All

(-)a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java (-9 / +49 lines)
Lines 125-130 Link Here
125
import java.util.List;
125
import java.util.List;
126
import java.util.Map;
126
import java.util.Map;
127
import java.util.concurrent.CountDownLatch;
127
import java.util.concurrent.CountDownLatch;
128
import java.util.concurrent.Future;
128
import java.util.concurrent.TimeUnit;
129
import java.util.concurrent.TimeUnit;
129
import java.util.logging.Handler;
130
import java.util.logging.Handler;
130
import java.util.logging.Level;
131
import java.util.logging.Level;
Lines 1369-1375 Link Here
1369
        assertNotNull("getOccurrencesFinder must be implemented", finder);
1370
        assertNotNull("getOccurrencesFinder must be implemented", finder);
1370
        finder.setCaretPosition(caretOffset);
1371
        finder.setCaretPosition(caretOffset);
1371
1372
1372
        ParserManager.parse(Collections.singleton(testSource), new UserTask() {
1373
        UserTask task = new UserTask() {
1373
            public @Override void run(ResultIterator resultIterator) throws Exception {
1374
            public @Override void run(ResultIterator resultIterator) throws Exception {
1374
                Parser.Result r = resultIterator.getParserResult(caretOffset);
1375
                Parser.Result r = resultIterator.getParserResult(caretOffset);
1375
                if (r instanceof ParserResult) {
1376
                if (r instanceof ParserResult) {
Lines 1395-1401 Link Here
1395
                    }
1396
                    }
1396
                }
1397
                }
1397
            }
1398
            }
1398
        });
1399
        };
1400
        if (classPathsForTest == null || classPathsForTest.isEmpty()) {
1401
            ParserManager.parse(Collections.singleton(testSource), task);
1402
        } else {
1403
            Future<Void> future = ParserManager.parseWhenScanFinished(Collections.singleton(testSource), task);
1404
            if (!future.isDone()) {
1405
                future.get();
1406
            }
1407
        }
1399
    }
1408
    }
1400
1409
1401
    protected String annotateFinderResult(Snapshot snapshot, Map<OffsetRange, ColoringAttributes> highlights, int caretOffset) throws Exception {
1410
    protected String annotateFinderResult(Snapshot snapshot, Map<OffsetRange, ColoringAttributes> highlights, int caretOffset) throws Exception {
Lines 1484-1490 Link Here
1484
            enforceCaretOffset(testSource, caretOffset);
1493
            enforceCaretOffset(testSource, caretOffset);
1485
        }
1494
        }
1486
1495
1487
        ParserManager.parse(Collections.singleton(testSource), new UserTask() {
1496
        UserTask task = new UserTask() {
1488
            public @Override void run(ResultIterator resultIterator) throws Exception {
1497
            public @Override void run(ResultIterator resultIterator) throws Exception {
1489
                Parser.Result r = resultIterator.getParserResult();
1498
                Parser.Result r = resultIterator.getParserResult();
1490
                assertTrue(r instanceof ParserResult);
1499
                assertTrue(r instanceof ParserResult);
Lines 1506-1512 Link Here
1506
                String annotatedSource = annotateSemanticResults(doc, highlights);
1515
                String annotatedSource = annotateSemanticResults(doc, highlights);
1507
                assertDescriptionMatches(relFilePath, annotatedSource, false, ".semantic");
1516
                assertDescriptionMatches(relFilePath, annotatedSource, false, ".semantic");
1508
            }
1517
            }
1509
        });
1518
        };
1519
1520
        if (classPathsForTest == null || classPathsForTest.isEmpty()) {
1521
            ParserManager.parse(Collections.singleton(testSource), task);
1522
        } else {
1523
            Future<Void> future = ParserManager.parseWhenScanFinished(Collections.singleton(testSource), task);
1524
            if (!future.isDone()) {
1525
                future.get();
1526
            }
1527
        }
1528
1510
    }
1529
    }
1511
1530
1512
    protected void checkNoOverlaps(Set<OffsetRange> ranges, Document doc) throws BadLocationException {
1531
    protected void checkNoOverlaps(Set<OffsetRange> ranges, Document doc) throws BadLocationException {
Lines 2796-2802 Link Here
2796
        if (classPathsForTest == null || classPathsForTest.isEmpty()) {
2815
        if (classPathsForTest == null || classPathsForTest.isEmpty()) {
2797
            ParserManager.parse(Collections.singleton(testSource), task);
2816
            ParserManager.parse(Collections.singleton(testSource), task);
2798
        } else {
2817
        } else {
2799
            ParserManager.parseWhenScanFinished(Collections.singleton(testSource), task);
2818
            Future<Void> future = ParserManager.parseWhenScanFinished(Collections.singleton(testSource), task);
2819
            if (!future.isDone()) {
2820
                future.get();
2821
            }
2800
        }
2822
        }
2801
    }
2823
    }
2802
2824
Lines 4135-4141 Link Here
4135
        }
4157
        }
4136
4158
4137
        final ComputedHints [] result = new ComputedHints[] { null };
4159
        final ComputedHints [] result = new ComputedHints[] { null };
4138
        ParserManager.parse(Collections.singleton(testSource), new UserTask() {
4160
        UserTask task = new UserTask() {
4139
            public @Override void run(ResultIterator resultIterator) throws Exception {
4161
            public @Override void run(ResultIterator resultIterator) throws Exception {
4140
                Parser.Result r = resultIterator.getParserResult();
4162
                Parser.Result r = resultIterator.getParserResult();
4141
                assertTrue(r instanceof ParserResult);
4163
                assertTrue(r instanceof ParserResult);
Lines 4252-4258 Link Here
4252
                    }
4274
                    }
4253
                }
4275
                }
4254
            }
4276
            }
4255
        });
4277
        };
4278
4279
        if (classPathsForTest == null || classPathsForTest.isEmpty()) {
4280
            ParserManager.parse(Collections.singleton(testSource), task);
4281
        } else {
4282
            Future<Void> future = ParserManager.parseWhenScanFinished(Collections.singleton(testSource), task);
4283
            if (!future.isDone()) {
4284
                future.get();
4285
            }
4286
        }
4256
4287
4257
        return result[0];
4288
        return result[0];
4258
    }
4289
    }
Lines 4507-4513 Link Here
4507
        enforceCaretOffset(testSource, caretOffset);
4538
        enforceCaretOffset(testSource, caretOffset);
4508
4539
4509
        final DeclarationLocation [] location = new DeclarationLocation[] { null };
4540
        final DeclarationLocation [] location = new DeclarationLocation[] { null };
4510
        ParserManager.parse(Collections.singleton(testSource), new UserTask() {
4541
        UserTask task = new UserTask() {
4511
            public @Override void run(ResultIterator resultIterator) throws Exception {
4542
            public @Override void run(ResultIterator resultIterator) throws Exception {
4512
                Parser.Result r = resultIterator.getParserResult();
4543
                Parser.Result r = resultIterator.getParserResult();
4513
                assertTrue(r instanceof ParserResult);
4544
                assertTrue(r instanceof ParserResult);
Lines 4516-4522 Link Here
4516
                DeclarationFinder finder = getFinder();
4547
                DeclarationFinder finder = getFinder();
4517
                location[0] = finder.findDeclaration(pr, caretOffset);
4548
                location[0] = finder.findDeclaration(pr, caretOffset);
4518
            }
4549
            }
4519
        });
4550
        };
4551
4552
        if (classPathsForTest == null || classPathsForTest.isEmpty()) {
4553
            ParserManager.parse(Collections.singleton(testSource), task);
4554
        } else {
4555
            Future<Void> future = ParserManager.parseWhenScanFinished(Collections.singleton(testSource), task);
4556
            if (!future.isDone()) {
4557
                future.get();
4558
            }
4559
        }
4520
4560
4521
        return location[0];
4561
        return location[0];
4522
    }
4562
    }

Return to bug 269997