OpenJDK / jdk / hs
changeset 29775:dc7df633fea1
8076026: DocTree should parse hyphenated attributes correctly
Reviewed-by: jjg, ksrini
author | bpatel |
---|---|
date | Sat, 28 Mar 2015 10:18:27 -0700 |
parents | 9d438163db79 |
children | 984a79b71cfe |
files | langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java langtools/test/tools/javac/doctree/AttrTest.java |
diffstat | 2 files changed, 36 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Fri Mar 27 10:11:21 2015 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Sat Mar 28 10:18:27 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -797,7 +797,7 @@ loop: while (isIdentifierStart(ch)) { int namePos = bp; - Name name = readIdentifier(); + Name name = readAttributeName(); skipWhitespace(); List<DCTree> value = null; ValueKind vkind = ValueKind.EMPTY; @@ -905,6 +905,14 @@ return names.fromChars(buf, start, bp - start); } + protected Name readAttributeName() { + int start = bp; + nextChar(); + while (bp < buflen && (Character.isUnicodeIdentifierPart(ch) || ch == '-')) + nextChar(); + return names.fromChars(buf, start, bp - start); + } + protected Name readTagName() { int start = bp; nextChar();
--- a/langtools/test/tools/javac/doctree/AttrTest.java Fri Mar 27 10:11:21 2015 -0700 +++ b/langtools/test/tools/javac/doctree/AttrTest.java Sat Mar 28 10:18:27 2015 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7021614 + * @bug 7021614 8076026 * @summary extend com.sun.source API to support parsing javadoc comments * @build DocCommentTester * @run main DocCommentTester AttrTest.java @@ -55,6 +55,30 @@ */ /** + * <a name-test=hyphened>foo</a> + */ + void hyphened_attr() { } +/* +DocComment[DOC_COMMENT, pos:1 + firstSentence: 3 + StartElement[START_ELEMENT, pos:1 + name:a + attributes: 1 + Attribute[ATTRIBUTE, pos:4 + name: name-test + vkind: UNQUOTED + value: 1 + Text[TEXT, pos:14, hyphened] + ] + ] + Text[TEXT, pos:23, foo] + EndElement[END_ELEMENT, pos:26, a] + body: empty + block tags: empty +] +*/ + + /** * <a name="double_quoted">foo</a> */ void double_quoted_attr() { }