8284908: Refine diagnostic positions for DCErroneous
Reviewed-by: jjg
This commit is contained in:
parent
fa04d1f832
commit
d6b5a63577
src/jdk.compiler/share/classes/com/sun/tools/javac/parser
test/langtools/tools/javac/doctree
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -1199,9 +1199,10 @@ public class DocCommentParser {
|
||||
nextChar();
|
||||
return m.at(pos).newDocRootTree();
|
||||
}
|
||||
final int savedPos = bp;
|
||||
inlineText(WhitespaceRetentionPolicy.REMOVE_ALL); // skip unexpected content
|
||||
nextChar();
|
||||
throw new ParseException(pos, "dc.unexpected.content");
|
||||
throw new ParseException(savedPos, "dc.unexpected.content");
|
||||
}
|
||||
},
|
||||
|
||||
@ -1256,9 +1257,10 @@ public class DocCommentParser {
|
||||
nextChar();
|
||||
return m.at(pos).newInheritDocTree();
|
||||
}
|
||||
final int errorPos = bp;
|
||||
inlineText(WhitespaceRetentionPolicy.REMOVE_ALL); // skip unexpected content
|
||||
nextChar();
|
||||
throw new ParseException(pos, "dc.unexpected.content");
|
||||
throw new ParseException(errorPos, "dc.unexpected.content");
|
||||
}
|
||||
},
|
||||
|
||||
@ -1308,7 +1310,7 @@ public class DocCommentParser {
|
||||
|
||||
if (typaram) {
|
||||
if (ch != '>')
|
||||
throw new ParseException("dc.gt.expected");
|
||||
throw new ParseException(bp, "dc.gt.expected");
|
||||
nextChar();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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 8241780 8273244
|
||||
* @bug 7021614 8241780 8273244 8284908
|
||||
* @summary extend com.sun.source API to support parsing javadoc comments
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -140,7 +140,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
/*
|
||||
DocComment[DOC_COMMENT, pos:0
|
||||
firstSentence: 1
|
||||
Erroneous[ERRONEOUS, pos:0
|
||||
Erroneous[ERRONEOUS, pos:0, prefPos:20
|
||||
code: compiler.err.dc.unterminated.inline.tag
|
||||
body: {@code_if_(a_<_b)_{_}
|
||||
]
|
||||
@ -156,7 +156,7 @@ DocComment[DOC_COMMENT, pos:0
|
||||
/*
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 1
|
||||
Erroneous[ERRONEOUS, pos:1
|
||||
Erroneous[ERRONEOUS, pos:1, prefPos:34
|
||||
code: compiler.err.dc.unterminated.inline.tag
|
||||
body: {@code_if_(a_<_b...)_{_}|_@author_jjg
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -727,7 +727,9 @@ public class DocCommentTester {
|
||||
*/
|
||||
void header(DocTree node) {
|
||||
indent();
|
||||
out.println(simpleClassName(node) + "[" + node.getKind() + ", pos:" + ((DCTree) node).pos);
|
||||
var n = (DCTree) node;
|
||||
out.println(simpleClassName(node) + "[" + node.getKind() + ", pos:" + n.pos +
|
||||
(n.getPreferredPosition() != n.pos ? ", prefPos:" + n.getPreferredPosition() : ""));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -76,7 +76,7 @@ DocComment[DOC_COMMENT, pos:0
|
||||
DocComment[DOC_COMMENT, pos:0
|
||||
firstSentence: 2
|
||||
Text[TEXT, pos:0, abc_]
|
||||
Erroneous[ERRONEOUS, pos:4
|
||||
Erroneous[ERRONEOUS, pos:4, prefPos:14
|
||||
code: compiler.err.dc.unexpected.content
|
||||
body: {@docRoot_junk}
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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 8273244
|
||||
* @bug 7021614 8273244 8284908
|
||||
* @summary extend com.sun.source API to support parsing javadoc comments
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -138,7 +138,7 @@ DocComment[DOC_COMMENT, pos:2
|
||||
DocComment[DOC_COMMENT, pos:2
|
||||
firstSentence: 3
|
||||
Text[TEXT, pos:2, abc_]
|
||||
Erroneous[ERRONEOUS, pos:6
|
||||
Erroneous[ERRONEOUS, pos:6, prefPos:10
|
||||
code: compiler.err.dc.missing.semicolon
|
||||
body: 
|
||||
]
|
||||
@ -156,7 +156,7 @@ DocComment[DOC_COMMENT, pos:2
|
||||
DocComment[DOC_COMMENT, pos:2
|
||||
firstSentence: 3
|
||||
Text[TEXT, pos:2, abc_]
|
||||
Erroneous[ERRONEOUS, pos:6
|
||||
Erroneous[ERRONEOUS, pos:6, prefPos:12
|
||||
code: compiler.err.dc.missing.semicolon
|
||||
body: Ī
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, 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 8078320 8273244
|
||||
* @bug 8078320 8273244 8284908
|
||||
* @summary extend com.sun.source API to support parsing javadoc comments
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -172,7 +172,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 2
|
||||
Text[TEXT, pos:1, abc_]
|
||||
Erroneous[ERRONEOUS, pos:5
|
||||
Erroneous[ERRONEOUS, pos:5, prefPos:10
|
||||
code: compiler.err.dc.unterminated.inline.tag
|
||||
body: {@code
|
||||
]
|
||||
@ -188,7 +188,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 2
|
||||
Text[TEXT, pos:1, abc_]
|
||||
Erroneous[ERRONEOUS, pos:5
|
||||
Erroneous[ERRONEOUS, pos:5, prefPos:14
|
||||
code: compiler.err.dc.unterminated.inline.tag
|
||||
body: {@code_abc
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, 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 8144287 8273244
|
||||
* @bug 8144287 8273244 8284908
|
||||
* @summary extend com.sun.source API to support parsing javadoc comments
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -246,7 +246,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 2
|
||||
Text[TEXT, pos:1, abc_]
|
||||
Erroneous[ERRONEOUS, pos:5
|
||||
Erroneous[ERRONEOUS, pos:5, prefPos:11
|
||||
code: compiler.err.dc.no.content
|
||||
body: {@index
|
||||
]
|
||||
@ -266,7 +266,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 2
|
||||
Text[TEXT, pos:1, abc_]
|
||||
Erroneous[ERRONEOUS, pos:5
|
||||
Erroneous[ERRONEOUS, pos:5, prefPos:22
|
||||
code: compiler.err.dc.no.content
|
||||
body: {@index_"xyz_}_def
|
||||
]
|
||||
@ -282,7 +282,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 3
|
||||
Text[TEXT, pos:1, abc_]
|
||||
Erroneous[ERRONEOUS, pos:5
|
||||
Erroneous[ERRONEOUS, pos:5, prefPos:11
|
||||
code: compiler.err.dc.no.content
|
||||
body: {@index
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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
|
||||
@ -76,7 +76,7 @@ DocComment[DOC_COMMENT, pos:0
|
||||
DocComment[DOC_COMMENT, pos:0
|
||||
firstSentence: 2
|
||||
Text[TEXT, pos:0, abc_]
|
||||
Erroneous[ERRONEOUS, pos:4
|
||||
Erroneous[ERRONEOUS, pos:4, prefPos:17
|
||||
code: compiler.err.dc.unexpected.content
|
||||
body: {@inheritDoc_junk}
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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 8241780 8273244
|
||||
* @bug 7021614 8241780 8273244 8284908
|
||||
* @summary extend com.sun.source API to support parsing javadoc comments
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -120,7 +120,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
/*
|
||||
DocComment[DOC_COMMENT, pos:0
|
||||
firstSentence: 1
|
||||
Erroneous[ERRONEOUS, pos:0
|
||||
Erroneous[ERRONEOUS, pos:0, prefPos:23
|
||||
code: compiler.err.dc.unterminated.inline.tag
|
||||
body: {@literal_if_(a_<_b)_{_}
|
||||
]
|
||||
@ -136,7 +136,7 @@ DocComment[DOC_COMMENT, pos:0
|
||||
/*
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 1
|
||||
Erroneous[ERRONEOUS, pos:1
|
||||
Erroneous[ERRONEOUS, pos:1, prefPos:37
|
||||
code: compiler.err.dc.unterminated.inline.tag
|
||||
body: {@literal_if_(a_...<_b)_{_}|_@author_jjg
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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 8273244
|
||||
* @bug 7021614 8273244 8284908
|
||||
* @summary extend com.sun.source API to support parsing javadoc comments
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -67,6 +67,21 @@ DocComment[DOC_COMMENT, pos:1
|
||||
Text[TEXT, pos:10, description]
|
||||
]
|
||||
]
|
||||
*/
|
||||
/**
|
||||
* @param <T type
|
||||
*/
|
||||
<T> void type_param(int x) { }
|
||||
/*
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: empty
|
||||
body: empty
|
||||
block tags: 1
|
||||
Erroneous[ERRONEOUS, pos:1, prefPos:10
|
||||
code: compiler.err.dc.gt.expected
|
||||
body: @param_<T_type
|
||||
]
|
||||
]
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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 8031212 8273244
|
||||
* @bug 7021614 8031212 8273244 8284908
|
||||
* @summary extend com.sun.source API to support parsing javadoc comments
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -168,7 +168,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
Text[TEXT, pos:1, abc.]
|
||||
body: empty
|
||||
block tags: 1
|
||||
Erroneous[ERRONEOUS, pos:7
|
||||
Erroneous[ERRONEOUS, pos:7, prefPos:19
|
||||
code: compiler.err.dc.unexpected.content
|
||||
body: @see_123_text
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2022, 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 5076751 8273244
|
||||
* @bug 5076751 8273244 8284908
|
||||
* @summary System properties documentation needed in javadocs
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -59,7 +59,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 3
|
||||
Text[TEXT, pos:1, abc_]
|
||||
Erroneous[ERRONEOUS, pos:5
|
||||
Erroneous[ERRONEOUS, pos:5, prefPos:26
|
||||
code: compiler.err.dc.unexpected.content
|
||||
body: {@systemProperty_xyz_q
|
||||
]
|
||||
@ -77,7 +77,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 3
|
||||
Text[TEXT, pos:1, abc_]
|
||||
Erroneous[ERRONEOUS, pos:5
|
||||
Erroneous[ERRONEOUS, pos:5, prefPos:20
|
||||
code: compiler.err.dc.no.content
|
||||
body: {@systemProperty
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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 8078320 8273244
|
||||
* @bug 7021614 8078320 8273244 8284908
|
||||
* @summary extend com.sun.source API to support parsing javadoc comments
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -93,7 +93,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: empty
|
||||
body: empty
|
||||
block tags: 1
|
||||
Erroneous[ERRONEOUS, pos:1
|
||||
Erroneous[ERRONEOUS, pos:1, prefPos:5
|
||||
code: compiler.err.dc.no.tag.name
|
||||
body: @_abc
|
||||
]
|
||||
@ -141,7 +141,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
/*
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 2
|
||||
Erroneous[ERRONEOUS, pos:1
|
||||
Erroneous[ERRONEOUS, pos:1, prefPos:2
|
||||
code: compiler.err.dc.no.tag.name
|
||||
body: {@
|
||||
]
|
||||
@ -175,7 +175,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
/*
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 1
|
||||
Erroneous[ERRONEOUS, pos:1
|
||||
Erroneous[ERRONEOUS, pos:1, prefPos:13
|
||||
code: compiler.err.dc.unterminated.inline.tag
|
||||
body: {@abc_def_ghi
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, 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 8273244
|
||||
* @bug 7021614 8273244 8284908
|
||||
* @summary extend com.sun.source API to support parsing javadoc comments
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
@ -92,7 +92,7 @@ DocComment[DOC_COMMENT, pos:1
|
||||
DocComment[DOC_COMMENT, pos:1
|
||||
firstSentence: 3
|
||||
Text[TEXT, pos:1, abc_]
|
||||
Erroneous[ERRONEOUS, pos:5
|
||||
Erroneous[ERRONEOUS, pos:5, prefPos:32
|
||||
code: compiler.err.dc.unexpected.content
|
||||
body: {@value_java.awt.Color#RED_j
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user