< prev index next >

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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2014, 2018, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2014, 2017, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 57,66 **** --- 57,67 ---- import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Position; + import static com.sun.tools.javac.parser.Tokens.TokenKind.IDENTIFIER; /** * This is a subclass of JavacParser which overrides one method with a modified * verson of that method designed to allow parsing of one "snippet" of Java * code without the surrounding context of class, method, etc. * Accepts an expression, a statement, an import, or the declaration of a
*** 176,188 **** } //fall-through default: JCModifiers mods = modifiersOpt(pmods); if (token.kind == CLASS || token.kind == INTERFACE || token.kind == ENUM) { ! return List.<JCTree>of(classOrInterfaceOrEnumDeclaration(mods, dc)); } else { int pos = token.pos; List<JCTypeParameter> typarams = typeParametersOpt(); // if there are type parameters but no modifiers, save the start // position of the method in the modifiers. --- 177,190 ---- } //fall-through default: JCModifiers mods = modifiersOpt(pmods); if (token.kind == CLASS + || token.kind == IDENTIFIER && token.name() == names.record || token.kind == INTERFACE || token.kind == ENUM) { ! return List.<JCTree>of(classOrRecordOrInterfaceOrEnumDeclaration(mods, dc)); } else { int pos = token.pos; List<JCTypeParameter> typarams = typeParametersOpt(); // if there are type parameters but no modifiers, save the start // position of the method in the modifiers.
*** 226,236 **** if (token.kind == LPAREN) { // method declaration //mods.flags |= Flags.STATIC; return List.of(methodDeclaratorRest( pos, mods, t, name, typarams, ! false, isVoid, dc)); } else if (!isVoid && typarams.isEmpty()) { // variable declaration //mods.flags |= Flags.STATIC; List<JCTree> defs = variableDeclaratorsRest(pos, mods, t, name, false, dc, --- 228,238 ---- if (token.kind == LPAREN) { // method declaration //mods.flags |= Flags.STATIC; return List.of(methodDeclaratorRest( pos, mods, t, name, typarams, ! false, isVoid, false, dc)); } else if (!isVoid && typarams.isEmpty()) { // variable declaration //mods.flags |= Flags.STATIC; List<JCTree> defs = variableDeclaratorsRest(pos, mods, t, name, false, dc,
< prev index next >