junichi11 commented on code in PR #6665:
URL: https://github.com/apache/netbeans/pull/6665#discussion_r1385733159
##########
php/php.editor/src/org/netbeans/modules/php/editor/csl/FoldingScanner.java:
##########
@@ -179,7 +179,7 @@ public Map<String, List<OffsetRange>> 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);
Review Comment:
@mbien
Or, change to `true` only when we test?
```diff
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 fb565eb64a..730455feb3 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
@@ -141,6 +141,7 @@ public final class FoldingScanner {
private static final String LAST_CORRECT_FOLDING_PROPERTY =
"LAST_CORRECT_FOLDING_PROPERY"; //NOI18N
private static final boolean FOLD_PHPTAG =
!Boolean.getBoolean("nb.php.editor.doNotFoldPhptag"); // NOI18N NETBEANS-5480
+ static volatile boolean IS_UNIT_TEST = false;
public static FoldingScanner create() {
return new FoldingScanner();
@@ -179,7 +180,8 @@ public final class FoldingScanner {
program.accept(new FoldingVisitor(folds));
Source source = phpParseResult.getSnapshot().getSource();
assert source != null : "source was null";
- Document doc = source.getDocument(true);
+ // avoid getting `null` in unit testing
+ Document doc = source.getDocument(IS_UNIT_TEST);
if (FOLD_PHPTAG) {
processPHPTags(folds, doc);
}
diff --git
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/FoldingTest.java
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/FoldingTest.java
index 083d201589..b7ad8a515c 100644
---
a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/FoldingTest.java
+++
b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/FoldingTest.java
@@ -30,6 +30,12 @@ public class FoldingTest extends PHPTestBase {
super(testName);
}
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ FoldingScanner.IS_UNIT_TEST = true;
+ }
+
public void testFoldingMethod() throws Exception {
checkFolds("testfiles/parser/foldingMethod.php");
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists