All Downloads are FREE. Search and download functionalities are using the official Maven repository.

spoon.reflect.code.CtStatement Maven / Gradle / Ivy

Go to download

Spoon is a tool for meta-programming, analysis and transformation of Java programs.

There is a newer version: 11.1.1-beta-14
Show newest version
/*
 * SPDX-License-Identifier: (MIT OR CECILL-C)
 *
 * Copyright (C) 2006-2023 INRIA and contributors
 *
 * Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
 */
package spoon.reflect.code;

import spoon.reflect.declaration.ParentNotInitializedException;
import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;

import static spoon.reflect.path.CtRole.LABEL;

/**
 * This abstract code element represents all the statements, which can be part
 * of a block.
 *
 * @see spoon.reflect.code.CtBlock
 */
public interface CtStatement extends CtCodeElement {

	/**
	 * Inserts a statement after the current statement.
	 */
	 T insertAfter(CtStatement statement) throws ParentNotInitializedException;

	/**
	 * Inserts a statement list before the current statement.
	 */
	 T insertAfter(CtStatementList statements) throws ParentNotInitializedException;

	/**
	 * Inserts a statement given as parameter before the current statement
	 * (this).
	 */
	 T insertBefore(CtStatement statement) throws ParentNotInitializedException;

	/**
	 * Inserts a statement list before the current statement.
	 */
	 T insertBefore(CtStatementList statements) throws ParentNotInitializedException;

	/**
	 * Gets the label of this statement if defined.
	 *
	 * @return the label's name (null if undefined)
	 */
	@PropertyGetter(role = LABEL)
	String getLabel();

	/**
	 * Sets the label of this statement.
	 */
	@PropertySetter(role = LABEL)
	 T setLabel(String label);

	/**
	 * Comments the statement (eg `// call()`). Implemented as a replacement of the statement with a CtComment having the statement as text.
	 */
	void comment();

	@Override
	CtStatement clone();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy