From 49cda01b0caaed36a8a87874750efd20f5995052 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Tue, 7 Nov 2023 05:48:25 +0100 Subject: [PATCH] Fix php tag fold test (attempt 2) --- .../src/org/netbeans/modules/csl/api/test/CslTestBase.java | 7 ------- .../netbeans/modules/php/editor/csl/FoldingScanner.java | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java b/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java index 6f5ab184b6be..2e523dbfae46 100644 --- a/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java +++ b/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java @@ -2146,13 +2146,6 @@ protected void checkFolds(String relFilePath) throws Exception { ParserManager.parse(Collections.singleton(testSource), new UserTask() { public @Override void run(ResultIterator resultIterator) throws Exception { - // FoldingScanner#folds calls source.getDocument(false) and receive non null values on JDK 8. - // On JDK 11+ however the document is null which leads to test failures in FoldingTest#testPHPTags. - // This is likely a race condition which is more likely to occur on JDK 11+ since the test can be - // brute forced to passing on linux if restarted often enough. - // This fixes it by making sure the document is open before folds are computed - assertNotNull(resultIterator.getSnapshot().getSource().getDocument(true)); - StructureScanner analyzer = getStructureScanner(); assertNotNull("getStructureScanner must be implemented", analyzer); diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/csl/FoldingScanner.java b/php/php.editor/src/org/netbeans/modules/php/editor/csl/FoldingScanner.java index f82fa74f4a50..fb565eb64a14 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/csl/FoldingScanner.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/csl/FoldingScanner.java @@ -179,7 +179,7 @@ public Map> folds(ParserResult info) { program.accept(new FoldingVisitor(folds)); Source source = phpParseResult.getSnapshot().getSource(); assert source != null : "source was null"; - Document doc = source.getDocument(false); + Document doc = source.getDocument(true); if (FOLD_PHPTAG) { processPHPTags(folds, doc); }