1 /* |
1 /* |
2 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
30 import com.sun.tools.javac.parser.JavacParser; |
30 import com.sun.tools.javac.parser.JavacParser; |
31 import com.sun.tools.javac.parser.ParserFactory; |
31 import com.sun.tools.javac.parser.ParserFactory; |
32 import com.sun.tools.javac.parser.Tokens.Comment; |
32 import com.sun.tools.javac.parser.Tokens.Comment; |
33 import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; |
33 import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; |
34 import com.sun.tools.javac.parser.Tokens.Token; |
34 import com.sun.tools.javac.parser.Tokens.Token; |
|
35 import com.sun.tools.javac.resources.CompilerProperties; |
|
36 import com.sun.tools.javac.resources.CompilerProperties.Errors; |
35 import static com.sun.tools.javac.parser.Tokens.TokenKind.CLASS; |
37 import static com.sun.tools.javac.parser.Tokens.TokenKind.CLASS; |
36 import static com.sun.tools.javac.parser.Tokens.TokenKind.COLON; |
38 import static com.sun.tools.javac.parser.Tokens.TokenKind.COLON; |
37 import static com.sun.tools.javac.parser.Tokens.TokenKind.ENUM; |
39 import static com.sun.tools.javac.parser.Tokens.TokenKind.ENUM; |
38 import static com.sun.tools.javac.parser.Tokens.TokenKind.EOF; |
40 import static com.sun.tools.javac.parser.Tokens.TokenKind.EOF; |
39 import static com.sun.tools.javac.parser.Tokens.TokenKind.IMPORT; |
41 import static com.sun.tools.javac.parser.Tokens.TokenKind.IMPORT; |
242 pos = token.pos; |
244 pos = token.pos; |
243 List<JCTree> err = isVoid |
245 List<JCTree> err = isVoid |
244 ? List.of(toP(F.at(pos).MethodDef(mods, name, t, typarams, |
246 ? List.of(toP(F.at(pos).MethodDef(mods, name, t, typarams, |
245 List.nil(), List.nil(), null, null))) |
247 List.nil(), List.nil(), null, null))) |
246 : null; |
248 : null; |
247 return List.<JCTree>of(syntaxError(token.pos, err, "expected", LPAREN)); |
249 return List.<JCTree>of(syntaxError(token.pos, err, Errors.Expected(LPAREN))); |
248 } |
250 } |
249 } else if (!typarams.isEmpty()) { |
251 } else if (!typarams.isEmpty()) { |
250 // type parameters on non-variable non-method -- error |
252 // type parameters on non-variable non-method -- error |
251 return List.<JCTree>of(syntaxError(token.pos, "illegal.start.of.type")); |
253 return List.<JCTree>of(syntaxError(token.pos, Errors.IllegalStartOfType)); |
252 } else { |
254 } else { |
253 // expression-statement or expression to evaluate |
255 // expression-statement or expression to evaluate |
254 JCExpressionStatement expr = toP(F.at(pos).Exec(t)); |
256 JCExpressionStatement expr = toP(F.at(pos).Exec(t)); |
255 return List.<JCTree>of(expr); |
257 return List.<JCTree>of(expr); |
256 } |
258 } |