001/* 002 * Copyright (c) 2012-2021 Institut National des Sciences Appliquées de Lyon (INSA Lyon) and others 003 * 004 * This program and the accompanying materials are made available under the 005 * terms of the Eclipse Public License 2.0 which is available at 006 * http://www.eclipse.org/legal/epl-2.0. 007 * 008 * SPDX-License-Identifier: EPL-2.0 009 */ 010 011package gololang.ir; 012 013import static java.util.Objects.requireNonNull; 014 015/** 016 * Empty IR node. 017 */ 018public final class Noop extends GoloStatement<Noop> implements ToplevelGoloElement { 019 020 private final String comment; 021 022 private Noop(String comment) { 023 this.comment = requireNonNull(comment); 024 } 025 026 public static Noop of(Object comment) { 027 return new Noop(comment == null ? "" : comment.toString()); 028 } 029 030 protected Noop self() { return this; } 031 032 public String comment() { 033 return this.comment; 034 } 035 036 @Override 037 public void accept(GoloIrVisitor visitor) { 038 visitor.visitNoop(this); 039 } 040 041 @Override 042 public void replaceElement(GoloElement<?> original, GoloElement<?> newElement) { 043 throw cantReplace(); 044 } 045}