/* * Copyright (c) 2015, 2021, 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 * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/** * The Key is unique for a given signature. Used internal to the implementation * to group signature matched Snippets. Snippet kinds without a signature * (for example expressions) each have their own UniqueKey. * @author Robert Field
*/ abstractclass Key {
/** * The unique index for this Key
*/ privatefinalint index;
/** * The JShell corresponding to this Key
*/ privatefinal JShell state;
/** * The unique numeric identifier for the snippet. Snippets which replace or * redefine existing snippets take on the same key index as the replaced or * redefined snippet. * The index values are monotonically increasing integers. * @return the Key index
*/ int index() { return index; }
/** * The kind for the key. Indicates the subinterface of Key. * @return the Kind of the Key
*/ abstract Kind kind();
/** * Grouping for snippets which persist and influence future code. * They are keyed off at least the name. They may be Modified/Replaced * with new input.
*/ abstractstaticclass PersistentKey extends Key {
privatefinal String name;
PersistentKey(JShell state, String name) { super(state); this.name = name;
} /** * Name of the snippet. * * @return the name of the snippet.
*/
String name() { return name; }
}
/** * Grouping for snippets which reference declarations
*/ abstractstaticclass DeclarationKey extends PersistentKey {
/** * The parameter types of the method. Because of overloading of methods, * the parameter types are part of the key. * * @return a String representation of the parameter types of the method.
*/
String parameterTypes() { return parameterTypes; }
/** * Grouping for snippets which are the key for only one input -- even if the * exactly same entry is made again. The referenced snippets are thus * unmodifiable.
*/ abstractstaticclass UniqueKey extends Key {
UniqueKey(JShell state) { super(state);
}
}
/** * Key for a statement snippet. Keys of STATEMENT. Uniquely keyed, see * UniqueKey.
*/ staticclass StatementKey extends UniqueKey {
StatementKey(JShell state) { super(state);
}
@Override public Kind kind() { return Kind.STATEMENT;
}
@Override public String toString() { return"StatementKey#" + index(); }
}
/** * Key for an expression. Keys of EXPRESSION. Uniquely keyed, see * UniqueKey.
*/ staticclass ExpressionKey extends UniqueKey {
@Override public Kind kind() { return Kind.EXPRESSION; }
/** * Variable name which is the value of the expression. Since the * expression is either just an identifier which is a variable or it is * an assignment to a variable, there is always a variable which is the * subject of the expression. All other expression snippets become * temporary variables referenced by a VariableKey. * * @return the name of the variable which is the subject of the * expression.
*/
String name() { return name; }
/** * Type of the expression * * @return String representation of the type of the expression.
*/
String typeName() { return typeName; }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.