diff --git a/php.editor/src/org/netbeans/modules/php/editor/parser/PHPDocCommentParser.java b/php.editor/src/org/netbeans/modules/php/editor/parser/PHPDocCommentParser.java --- a/php.editor/src/org/netbeans/modules/php/editor/parser/PHPDocCommentParser.java +++ b/php.editor/src/org/netbeans/modules/php/editor/parser/PHPDocCommentParser.java @@ -267,8 +267,11 @@ } private List findTypes(String description, int startDescription, String originalComment, int originalCommentStart, boolean isReturnTag) { + if (StringUtils.isEmpty(description)) { + return Collections.emptyList(); + } + List result = new ArrayList<>(); - for (String stype : getTypes(description, isReturnTag)) { stype = removeHTMLTags(stype); int startDocNode = findStartOfDocNode(originalComment, originalCommentStart, stype, startDescription); diff --git a/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/PHPDocCommentParserTest/testIssue257953.pass b/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/PHPDocCommentParserTest/testIssue257953.pass new file mode 100644 --- /dev/null +++ b/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/PHPDocCommentParserTest/testIssue257953.pass @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/PHPDocCommentParserTest.java b/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/PHPDocCommentParserTest.java --- a/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/PHPDocCommentParserTest.java +++ b/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/PHPDocCommentParserTest.java @@ -342,6 +342,12 @@ perform(comment, "Issue197946"); } + public void testIssue257953() throws Exception { + // types should be an empty list + String comment = " * @param"; + perform(comment, "testIssue257953"); + } + public void perform(String comment, String filename) throws Exception { PHPDocCommentParser parser = new PHPDocCommentParser(); PHPDocBlock block = parser.parse(0, comment.length(), comment); diff --git a/spellchecker.bindings.php/src/org/netbeans/modules/spellchecker/bindings/php/PHPTokenList.java b/spellchecker.bindings.php/src/org/netbeans/modules/spellchecker/bindings/php/PHPTokenList.java --- a/spellchecker.bindings.php/src/org/netbeans/modules/spellchecker/bindings/php/PHPTokenList.java +++ b/spellchecker.bindings.php/src/org/netbeans/modules/spellchecker/bindings/php/PHPTokenList.java @@ -47,6 +47,7 @@ import javax.swing.text.BadLocationException; import javax.swing.text.Document; import org.netbeans.api.lexer.TokenSequence; +import org.netbeans.modules.php.api.util.StringUtils; import org.netbeans.modules.php.editor.lexer.LexUtilities; import org.netbeans.modules.php.editor.lexer.PHPTokenId; import org.netbeans.modules.php.editor.parser.PHPDocCommentParser; @@ -272,12 +273,19 @@ List types = docTypeTag.getTypes(); PHPDocTypeNode lastType = null; for (PHPDocTypeNode type : types) { + String value = type.getValue(); + if (StringUtils.isEmpty(value)) { + continue; + } if (lastType == null || lastType.getEndOffset() < type.getEndOffset()) { lastType = type; } } if (lastType != null) { - currentOffsetInComment = lastType.getEndOffset(); + int endOffset = lastType.getEndOffset(); + if (currentOffsetInComment < endOffset) { + currentOffsetInComment = endOffset; + } } if (docTypeTag instanceof PHPDocMethodTag) { @@ -291,7 +299,10 @@ } } if (lastParam != null) { - currentOffsetInComment = lastParam.getEndOffset(); + int endOffset = lastParam.getEndOffset(); + if (currentOffsetInComment < endOffset) { + currentOffsetInComment = endOffset; + } } else { // ignore method name PHPDocNode methodName = methodTag.getMethodName(); @@ -301,7 +312,7 @@ currentOffsetInComment, LetterType.MethodName ); - if (data.first().equals(methodName.getValue())) { + if (data != null && data.first().equals(methodName.getValue())) { currentOffsetInComment = getCurrentOffsetInComment(data); } } diff --git a/spellchecker.bindings.php/test/unit/src/org/netbeans/modules/spellchecker/bindings/php/PHPTokenListTest.java b/spellchecker.bindings.php/test/unit/src/org/netbeans/modules/spellchecker/bindings/php/PHPTokenListTest.java --- a/spellchecker.bindings.php/test/unit/src/org/netbeans/modules/spellchecker/bindings/php/PHPTokenListTest.java +++ b/spellchecker.bindings.php/test/unit/src/org/netbeans/modules/spellchecker/bindings/php/PHPTokenListTest.java @@ -64,6 +64,11 @@ super(name); } + @Override + protected int timeOut() { + return 10000; + } + public void testSimpleWordBroker() throws Exception { tokenListTest( " /**\n" @@ -131,6 +136,14 @@ ); } + public void testIssue257953() throws Exception { + tokenListTest( + " /**\n" + + " * @param\n" + + " */" + ); + } + public void testMethodTagHandling() throws Exception { tokenListTest( " /**\n"