Skip to content

Commit f00c1a4

Browse files
authored
Merge pull request #8046 from junichi11/php-fix-npe
Prevent NPE
2 parents 7d38f33 + a3f691c commit f00c1a4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

php/php.editor/src/org/netbeans/modules/php/editor/csl/OccurrencesFinderImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public void setCaretPosition(int position) {
6868

6969
@Override
7070
public Map<OffsetRange, ColoringAttributes> getOccurrences() {
71-
return range2Attribs;
71+
// must not return null
72+
return Collections.unmodifiableMap(range2Attribs);
7273
}
7374

7475
@Override
@@ -99,9 +100,11 @@ public void run(Result result, SchedulerEvent event) {
99100
return;
100101
}
101102

102-
if (!node.getBoolean(MarkOccurencesSettings.KEEP_MARKS, true) || localRange2Attribs.size() > 0) {
103-
//store the occurrences if not empty, return null in getOccurrences() otherwise
103+
if (!node.getBoolean(MarkOccurencesSettings.KEEP_MARKS, true) || !localRange2Attribs.isEmpty()) {
104+
//store the occurrences if not empty
104105
range2Attribs = localRange2Attribs;
106+
} else {
107+
range2Attribs = Collections.emptyMap();
105108
}
106109
}
107110

0 commit comments

Comments
 (0)