Skip to content

Commit 3ff5a78

Browse files
8317693: Unused parameter to Tokens.Token.comment method
Reviewed-by: iris, jlahoda
1 parent 508fa71 commit 3ff5a78

File tree

5 files changed

+24
-26
lines changed

5 files changed

+24
-26
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import com.sun.tools.javac.code.Source.Feature;
4141
import com.sun.tools.javac.file.PathFileObject;
4242
import com.sun.tools.javac.parser.Tokens.*;
43-
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
4443
import com.sun.tools.javac.resources.CompilerProperties.Errors;
4544
import com.sun.tools.javac.resources.CompilerProperties.Fragments;
4645
import com.sun.tools.javac.resources.CompilerProperties.Warnings;
@@ -2819,7 +2818,7 @@ List<JCStatement> blockStatement() {
28192818
return List.of(parseSimpleStatement());
28202819
case MONKEYS_AT:
28212820
case FINAL: {
2822-
dc = token.comment(CommentStyle.JAVADOC);
2821+
dc = token.docComment();
28232822
JCModifiers mods = modifiersOpt();
28242823
if (isDeclaration()) {
28252824
return List.of(classOrRecordOrInterfaceOrEnumDeclaration(mods, dc));
@@ -2829,19 +2828,19 @@ List<JCStatement> blockStatement() {
28292828
}
28302829
}
28312830
case ABSTRACT: case STRICTFP: {
2832-
dc = token.comment(CommentStyle.JAVADOC);
2831+
dc = token.docComment();
28332832
JCModifiers mods = modifiersOpt();
28342833
return List.of(classOrRecordOrInterfaceOrEnumDeclaration(mods, dc));
28352834
}
28362835
case INTERFACE:
28372836
case CLASS:
2838-
dc = token.comment(CommentStyle.JAVADOC);
2837+
dc = token.docComment();
28392838
return List.of(classOrRecordOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
28402839
case ENUM:
28412840
if (!allowRecords) {
28422841
log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.LocalEnum);
28432842
}
2844-
dc = token.comment(CommentStyle.JAVADOC);
2843+
dc = token.docComment();
28452844
return List.of(classOrRecordOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
28462845
case IDENTIFIER:
28472846
if (token.name() == names.yield && allowYieldStatement) {
@@ -2898,17 +2897,17 @@ List<JCStatement> blockStatement() {
28982897
nextToken();
28992898
nextToken();
29002899
nextToken();
2901-
return List.of(classOrRecordOrInterfaceOrEnumDeclaration(modifiersOpt(), token.comment(CommentStyle.JAVADOC)));
2900+
return List.of(classOrRecordOrInterfaceOrEnumDeclaration(modifiersOpt(), token.docComment()));
29022901
} else if (isSealedClassStart(true)) {
29032902
checkSourceLevel(Feature.SEALED_CLASSES);
29042903
log.error(token.pos, Errors.SealedOrNonSealedLocalClassesNotAllowed);
29052904
nextToken();
2906-
return List.of(classOrRecordOrInterfaceOrEnumDeclaration(modifiersOpt(), token.comment(CommentStyle.JAVADOC)));
2905+
return List.of(classOrRecordOrInterfaceOrEnumDeclaration(modifiersOpt(), token.docComment()));
29072906
}
29082907
}
29092908
}
29102909
if (isRecordStart() && allowRecords) {
2911-
dc = token.comment(CommentStyle.JAVADOC);
2910+
dc = token.docComment();
29122911
return List.of(recordDeclaration(F.at(pos).Modifiers(0), dc));
29132912
} else {
29142913
Token prevToken = token;
@@ -3911,7 +3910,7 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
39113910
JCExpression pid = qualident(false);
39123911
accept(SEMI);
39133912
JCPackageDecl pd = toP(F.at(packagePos).PackageDecl(annotations, pid));
3914-
attach(pd, firstToken.comment(CommentStyle.JAVADOC));
3913+
attach(pd, firstToken.docComment());
39153914
consumedToplevelDoc = true;
39163915
defs.append(pd);
39173916
}
@@ -3946,9 +3945,9 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
39463945
seenImport = true;
39473946
defs.append(importDeclaration());
39483947
} else {
3949-
Comment docComment = token.comment(CommentStyle.JAVADOC);
3948+
Comment docComment = token.docComment();
39503949
if (firstTypeDecl && !seenImport && !seenPackage) {
3951-
docComment = firstToken.comment(CommentStyle.JAVADOC);
3950+
docComment = firstToken.docComment();
39523951
consumedToplevelDoc = true;
39533952
}
39543953
if (mods != null || token.kind != SEMI)
@@ -4015,7 +4014,7 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
40154014
List<JCTree> topLevelDefs = isUnnamedClass ? constructUnnamedClass(defs.toList()) : defs.toList();
40164015
JCTree.JCCompilationUnit toplevel = F.at(firstToken.pos).TopLevel(topLevelDefs);
40174016
if (!consumedToplevelDoc)
4018-
attach(toplevel, firstToken.comment(CommentStyle.JAVADOC));
4017+
attach(toplevel, firstToken.docComment());
40194018
if (defs.isEmpty())
40204019
storeEnd(toplevel, S.prevToken().endPos);
40214020
if (keepDocComments)
@@ -4500,7 +4499,7 @@ private enum EnumeratorEstimate {
45004499
/** EnumeratorDeclaration = AnnotationsOpt [TypeArguments] IDENTIFIER [ Arguments ] [ "{" ClassBody "}" ]
45014500
*/
45024501
JCTree enumeratorDeclaration(Name enumName) {
4503-
Comment dc = token.comment(CommentStyle.JAVADOC);
4502+
Comment dc = token.docComment();
45044503
int flags = Flags.PUBLIC|Flags.STATIC|Flags.FINAL|Flags.ENUM;
45054504
if (token.deprecatedFlag()) {
45064505
flags |= Flags.DEPRECATED;
@@ -4605,7 +4604,7 @@ protected List<JCTree> classOrInterfaceOrRecordBodyDeclaration(JCModifiers mods,
46054604
nextToken();
46064605
return List.nil();
46074606
} else {
4608-
Comment dc = token.comment(CommentStyle.JAVADOC);
4607+
Comment dc = token.docComment();
46094608
int pos = token.pos;
46104609
mods = modifiersOpt(mods);
46114610
if (isDeclaration()) {
@@ -4738,7 +4737,7 @@ private List<JCTree> constructorOrMethodOrFieldDeclaration(JCModifiers mods, Nam
47384737
private List<JCTree> topLevelMethodOrFieldDeclaration(JCModifiers mods) throws AssertionError {
47394738
int topPos = token.pos;
47404739
int pos = token.pos;
4741-
Comment dc = token.comment(CommentStyle.JAVADOC);
4740+
Comment dc = token.docComment();
47424741
List<JCTypeParameter> typarams = typeParametersOpt();
47434742

47444743
// if there are type parameters but no modifiers, save the start

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public int radix() {
358358
* Preserve classic semantics - if multiple javadocs are found on the token
359359
* the last one is returned
360360
*/
361-
public Comment comment(Comment.CommentStyle style) {
361+
public Comment docComment() {
362362
List<Comment> comments = getComments(Comment.CommentStyle.JAVADOC);
363363
return comments.isEmpty() ?
364364
null :

src/jdk.jshell/share/classes/jdk/jshell/ReplParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
3030
import com.sun.tools.javac.code.TypeTag;
3131
import com.sun.tools.javac.parser.JavacParser;
3232
import com.sun.tools.javac.parser.Tokens.Comment;
33-
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
3433
import com.sun.tools.javac.parser.Tokens.Token;
3534
import com.sun.tools.javac.resources.CompilerProperties.Errors;
3635
import static com.sun.tools.javac.parser.Tokens.TokenKind.CLASS;
@@ -115,9 +114,9 @@ public JCCompilationUnit parseCompilationUnit() {
115114
seenImport = true;
116115
defs.append(importDeclaration());
117116
} else {
118-
Comment docComment = token.comment(CommentStyle.JAVADOC);
117+
Comment docComment = token.docComment();
119118
if (firstTypeDecl && !seenImport && !seenPackage) {
120-
docComment = firstToken.comment(CommentStyle.JAVADOC);
119+
docComment = firstToken.docComment();
121120
}
122121
List<? extends JCTree> udefs = replUnit(mods, docComment);
123122
// if (def instanceof JCExpressionStatement)

test/langtools/jdk/javadoc/tool/sampleapi/lib/sampleapi/generator/Documentifier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -114,7 +114,7 @@ private Comment comment(String docString) {
114114
Scanner scanner = scanners.newScanner(docComment, true);
115115
scanner.nextToken();
116116
Token token = scanner.token();
117-
return token.comment(CommentStyle.JAVADOC);
117+
return token.docComment();
118118
}
119119

120120
// provide package comment data ONLY

test/langtools/tools/javac/parser/extend/TrialParser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -95,7 +95,7 @@ public JCCompilationUnit parseCompilationUnit() {
9595
JCExpression pid = qualident(false);
9696
accept(SEMI);
9797
JCPackageDecl pd = F.at(packagePos).PackageDecl(annotations, pid);
98-
attach(pd, firstToken.comment(CommentStyle.JAVADOC));
98+
attach(pd, firstToken.docComment());
9999
storeEnd(pd, token.pos);
100100
defs.append(pd);
101101
}
@@ -114,9 +114,9 @@ public JCCompilationUnit parseCompilationUnit() {
114114
defs.append(importDeclaration());
115115
break;
116116
} else {
117-
Comment docComment = token.comment(CommentStyle.JAVADOC);
117+
Comment docComment = token.docComment();
118118
if (firstTypeDecl && !seenImport && !seenPackage) {
119-
docComment = firstToken.comment(CommentStyle.JAVADOC);
119+
docComment = firstToken.docComment();
120120
}
121121
List<? extends JCTree> udefs = aUnit(mods, docComment);
122122
for (JCTree def : udefs) {

0 commit comments

Comments
 (0)