Here you can find the source of getPropertyName(AstNode propKeyNode)
Parameter | Description |
---|---|
propKeyNode | The AST node for the property key. |
public static final String getPropertyName(AstNode propKeyNode)
//package com.java2s; /*/*w w w . ja va2 s.c o m*/ * 06/05/2014 * * Copyright (C) 2014 Robert Futrell * robert_futrell at users.sourceforge.net * http://fifesoft.com/rsyntaxtextarea * * This library is distributed under a modified BSD license. See the included * RSTALanguageSupport.License.txt file for details. */ import org.mozilla.javascript.ast.AstNode; import org.mozilla.javascript.ast.Name; import org.mozilla.javascript.ast.StringLiteral; public class Main { /** * Property keys in object literals can be identifiers or string literals. * This method takes an AST node that was the key of an * <code>ObjectProperty</code> and returns its value, no matter what the * concrete AST node's type. * * @param propKeyNode The AST node for the property key. * @return The property key's value. */ public static final String getPropertyName(AstNode propKeyNode) { // TODO: Does Rhino use any other node type for this? return (propKeyNode instanceof Name) ? ((Name) propKeyNode).getIdentifier() : ((StringLiteral) propKeyNode).getValue(); } }