public void testDeleteInObjectLiteral() { final Script script = parse("var keywords={delete:1}"); assertFalse(reporter.hasErrors()); final VariableDeclaration var = uniqueResult(ASTUtil.select(script, VariableDeclaration.class)); final ObjectInitializer object = (ObjectInitializer) var.getInitializer(); assertEquals(1, object.getInitializers().size()); assertIdentifier("delete", object.getPropertyInitializers()[0].getName()); assertDecimal("1", object.getPropertyInitializers()[0].getValue()); }
@Override public IMatchLocatorValue visitObjectInitializer(ObjectInitializer node) { for (ObjectInitializerPart part : node.getInitializers()) { if (part instanceof Method) { // TODO (alex) handle get & set methods visitMethod((Method) part); } else if (part instanceof PropertyInitializer) { final PropertyInitializer pi = (PropertyInitializer) part; // TODO (alex) handle jsdoc if (pi.getValue() instanceof FunctionStatement) { createFunctionDeclaration((FunctionStatement) pi.getValue(), (Identifier) pi.getName()); } else { addFieldDeclaration(pi.getName(), null /* declaredType */); visit(pi.getValue()); } } } return null; }