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

spoon.reflect.visitor.CtInheritanceScanner Maven / Gradle / Ivy

Go to download

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

The newest version!
/* 
 * Spoon - http://spoon.gforge.inria.fr/
 * Copyright (C) 2006 INRIA Futurs 
 * 
 * This software is governed by the CeCILL-C License under French law and
 * abiding by the rules of distribution of free software. You can use, modify 
 * and/or redistribute the software under the terms of the CeCILL-C license as 
 * circulated by CEA, CNRS and INRIA at http://www.cecill.info. 
 * 
 * This program 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 CeCILL-C License for more details.
 *  
 * The fact that you are presently reading this means that you have had
 * knowledge of the CeCILL-C license and that you accept its terms.
 */

package spoon.reflect.visitor;

import java.lang.annotation.Annotation;
import java.util.Collection;

import spoon.reflect.code.CtAbstractInvocation;
import spoon.reflect.code.CtAnnotationFieldAccess;
import spoon.reflect.code.CtArrayAccess;
import spoon.reflect.code.CtAssert;
import spoon.reflect.code.CtAssignment;
import spoon.reflect.code.CtBinaryOperator;
import spoon.reflect.code.CtBlock;
import spoon.reflect.code.CtBreak;
import spoon.reflect.code.CtCFlowBreak;
import spoon.reflect.code.CtCase;
import spoon.reflect.code.CtCatch;
import spoon.reflect.code.CtCodeElement;
import spoon.reflect.code.CtCodeSnippetExpression;
import spoon.reflect.code.CtCodeSnippetStatement;
import spoon.reflect.code.CtConditional;
import spoon.reflect.code.CtContinue;
import spoon.reflect.code.CtDo;
import spoon.reflect.code.CtExpression;
import spoon.reflect.code.CtFor;
import spoon.reflect.code.CtForEach;
import spoon.reflect.code.CtIf;
import spoon.reflect.code.CtInvocation;
import spoon.reflect.code.CtLiteral;
import spoon.reflect.code.CtLocalVariable;
import spoon.reflect.code.CtLoop;
import spoon.reflect.code.CtNewArray;
import spoon.reflect.code.CtNewClass;
import spoon.reflect.code.CtOperatorAssignment;
import spoon.reflect.code.CtReturn;
import spoon.reflect.code.CtStatement;
import spoon.reflect.code.CtStatementList;
import spoon.reflect.code.CtSwitch;
import spoon.reflect.code.CtSynchronized;
import spoon.reflect.code.CtTargetedAccess;
import spoon.reflect.code.CtTargetedExpression;
import spoon.reflect.code.CtThisAccess;
import spoon.reflect.code.CtThrow;
import spoon.reflect.code.CtTry;
import spoon.reflect.code.CtUnaryOperator;
import spoon.reflect.code.CtVariableAccess;
import spoon.reflect.code.CtWhile;
import spoon.reflect.declaration.CtAnnotation;
import spoon.reflect.declaration.CtAnnotationType;
import spoon.reflect.declaration.CtAnonymousExecutable;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtConstructor;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.declaration.CtEnum;
import spoon.reflect.declaration.CtExecutable;
import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtGenericElement;
import spoon.reflect.declaration.CtInterface;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtModifiable;
import spoon.reflect.declaration.CtNamedElement;
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtSimpleType;
import spoon.reflect.declaration.CtType;
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.declaration.CtTypedElement;
import spoon.reflect.declaration.CtVariable;
import spoon.reflect.declaration.ModifierKind;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtFieldReference;
import spoon.reflect.reference.CtGenericElementReference;
import spoon.reflect.reference.CtLocalVariableReference;
import spoon.reflect.reference.CtPackageReference;
import spoon.reflect.reference.CtParameterReference;
import spoon.reflect.reference.CtReference;
import spoon.reflect.reference.CtTypeParameterReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.reference.CtVariableReference;

/**
 * This class provides an abstract implementation of the visitor that allows its
 * subclasses to scans the metamodel elements by recursively using their
 * (abstract) supertype scanning methods.
 */
public abstract class CtInheritanceScanner implements CtVisitor {

	/**
	 * Default constructor.
	 */
	public CtInheritanceScanner() {
	}

	public  void visitCtCodeSnippetExpression(
			CtCodeSnippetExpression expression) {
	}

	public void visitCtCodeSnippetStatement(CtCodeSnippetStatement statement) {
	}

	/**
	 * Generically scans a collection of meta-model elements.
	 */
	public void scan(Collection elements) {
		if (elements != null) {
			for (CtElement e : elements) {
				scan(e);
			}
		}
	}

	/**
	 * Generically scans a meta-model element.
	 */
	public void scan(CtElement element) {
		if (element != null)
			element.accept(this);
	}

	/**
	 * Generically scans a meta-model element reference.
	 */
	public void scan(CtReference reference) {
		if (reference != null)
			reference.accept(this);
	}

	/**
	 * Scans an abstract invocation.
	 */
	public  void scanCtAbstractInvocation(CtAbstractInvocation a) {
	}

	/**
	 * Scans an abstract control flow break.
	 */
	public void scanCtCFlowBreak(CtCFlowBreak flowBreak) {
		scanCtCodeElement(flowBreak);
	}

	/**
	 * Scans an abstract code element.
	 */
	public void scanCtCodeElement(CtCodeElement e) {
		scanCtElement(e);
	}

	/**
	 * Scans an abstract element.
	 */
	public void scanCtElement(CtElement e) {
	}

	/**
	 * Scans an abstract executable.
	 */
	public  void scanCtExecutable(CtExecutable e) {
		scanCtGenericElement(e);
		scanCtNamedElement(e);
	}

	/**
	 * Scans an abstract expression.
	 */
	public  void scanCtExpression(CtExpression expression) {
		scanCtCodeElement(expression);
		scanCtTypedElement(expression);
	}

	/**
	 * Scans an abstract generic element.
	 */
	public void scanCtGenericElement(CtGenericElement e) {
		scanCtElement(e);
	}

	/**
	 * Scans an abstract generic element reference.
	 */
	public void scanCtGenericElementReference(
			CtGenericElementReference reference) {
	}

	/**
	 * Scans an abstract loop.
	 */
	public void scanCtLoop(CtLoop loop) {
		scanCtStatement(loop);
	}

	/**
	 * Scans an abstract modifiable element.
	 */
	public void scanCtModifiable(CtModifiable m) {
		for (ModifierKind modifier : m.getModifiers()) {
			scanCtModifier(modifier);
		}
	}

	/**
	 * Scans a modifier (enumeration).
	 */
	public void scanCtModifier(ModifierKind m) {
	}

	/**
	 * Scans an abstract named element.
	 */
	public void scanCtNamedElement(CtNamedElement e) {
		scanCtElement(e);
		scanCtModifiable(e);
	}

	/**
	 * Scans an abstract reference.
	 */
	public void scanCtReference(CtReference reference) {

	}

	/**
	 * Scans an abstract simple type.
	 */
	public  void scanCtSimpleType(CtSimpleType t) {
		scanCtNamedElement(t);
	}

	/**
	 * Scans an abstract statement.
	 */
	public void scanCtStatement(CtStatement s) {
		scanCtCodeElement(s);
	}

	/**
	 * Scans an abstract targeted expression.
	 */
	public > void scanCtTargetedExpression(
			CtTargetedExpression targetedExpression) {
		scanCtExpression(targetedExpression);
	}

	/**
	 * Scans an abstract type.
	 */
	public  void scanCtType(CtType type) {
		scanCtSimpleType(type);
		scanCtGenericElement(type);
	}

	/**
	 * Scans an abstract typed element.
	 */
	public  void scanCtTypedElement(CtTypedElement e) {
	}

	/**
	 * Scans an abstract variable declaration.
	 */
	public  void scanCtVariable(CtVariable v) {
		scanCtNamedElement(v);
		scanCtTypedElement(v);
	}

	/**
	 * Scans an abstract variable reference.
	 */
	public  void scanCtVariableReference(CtVariableReference reference) {
		scanCtReference(reference);
	}

	/**
	 * Generically scans a collection of meta-model references.
	 */
	public void scanReferences(Collection references) {
		if (references != null) {
			for (CtReference r : references) {
				scan(r);
			}
		}
	}

	public  void visitCtAnnotation(
			CtAnnotation annotation) {
		scanCtElement(annotation);
	}

	public  void visitCtAnnotationType(
			CtAnnotationType annotationType) {
		scanCtSimpleType(annotationType);
	}

	public void visitCtAnonymousExecutable(CtAnonymousExecutable e) {
		scanCtElement(e);
		scanCtModifiable(e);
	}

	public > void visitCtArrayAccess(
			CtArrayAccess arrayAccess) {
		scanCtTargetedExpression(arrayAccess);
	}

	public  void visitCtArrayTypeReference(CtArrayTypeReference reference) {
		visitCtTypeReference(reference);
	}

	public  void visitCtAssert(CtAssert asserted) {
		scanCtStatement(asserted);
	}

	public  void visitCtAssignment(
			CtAssignment assignement) {
		scanCtExpression(assignement);
		scanCtStatement(assignement);
	}

	public  void visitCtBinaryOperator(CtBinaryOperator operator) {
		scanCtExpression(operator);
	}

	public  void visitCtBlock(CtBlock block) {
		scanCtStatement(block);
	}

	public void visitCtBreak(CtBreak breakStatement) {
		scanCtCFlowBreak(breakStatement);
	}

	public  void visitCtCase(CtCase caseStatement) {
		scanCtStatement(caseStatement);
	}

	public void visitCtCatch(CtCatch catchBlock) {
		scanCtCodeElement(catchBlock);
	}

	public  void visitCtClass(CtClass ctClass) {
		scanCtType(ctClass);
	}

	public  void visitCtConditional(CtConditional conditional) {
		scanCtExpression(conditional);
	}

	public  void visitCtConstructor(CtConstructor c) {
		scanCtExecutable(c);
	}

	public void visitCtContinue(CtContinue continueStatement) {
		scanCtCFlowBreak(continueStatement);
	}

	public void visitCtDo(CtDo doLoop) {
		scanCtLoop(doLoop);
	}

	public > void visitCtEnum(CtEnum ctEnum) {
		visitCtClass(ctEnum);
	}

	public  void visitCtExecutableReference(
			CtExecutableReference reference) {
		scanCtReference(reference);
		scanCtGenericElementReference(reference);
	}

	public  void visitCtField(CtField f) {
		scanCtNamedElement(f);
		scanCtVariable(f);
	}

	public  void visitCtTargetedAccess(CtTargetedAccess targetedAccess) {
		scanCtTargetedExpression(targetedAccess);
		visitCtVariableAccess(targetedAccess);
	}

	public  void visitCtThisAccess(CtThisAccess thisAccess) {
		scanCtExpression(thisAccess);
	}

	public  void visitCtFieldReference(CtFieldReference reference) {
		scanCtVariableReference(reference);
	}

	public void visitCtFor(CtFor forLoop) {
		scanCtLoop(forLoop);
	}

	public void visitCtForEach(CtForEach foreach) {
		scanCtLoop(foreach);
	}

	public void visitCtIf(CtIf ifElement) {
		scanCtStatement(ifElement);
	}

	public  void visitCtInterface(CtInterface intrface) {
		scanCtType(intrface);
	}

	public  void visitCtInvocation(CtInvocation invocation) {
		scanCtTargetedExpression(invocation);
		scanCtStatement(invocation);
		scanCtAbstractInvocation(invocation);
	}

	public  void visitCtLiteral(CtLiteral literal) {
		scanCtExpression(literal);
	}

	public  void visitCtLocalVariable(CtLocalVariable localVariable) {
		scanCtVariable(localVariable);
		scanCtStatement(localVariable);
	}

	public  void visitCtLocalVariableReference(
			CtLocalVariableReference reference) {
		scanCtVariableReference(reference);
	}

	public  void visitCtMethod(CtMethod m) {
		scanCtExecutable(m);
		scanCtTypedElement(m);
	}

	public  void visitCtNewArray(CtNewArray newArray) {
		scanCtExpression(newArray);
	}

	public  void visitCtNewClass(CtNewClass newClass) {
		scanCtAbstractInvocation(newClass);
		scanCtTypedElement(newClass);
		scanCtTargetedExpression(newClass);
	}

	public  void visitCtOperatorAssignement(
			CtOperatorAssignment assignment) {
		visitCtAssignment(assignment);
	}

	public void visitCtPackage(CtPackage ctPackage) {
		scanCtNamedElement(ctPackage);
	}

	public void visitCtPackageReference(CtPackageReference reference) {
		scanCtReference(reference);
	}

	public  void visitCtParameter(CtParameter parameter) {
		scanCtNamedElement(parameter);
		scanCtVariable(parameter);
	}

	public  void visitCtParameterReference(CtParameterReference reference) {
		scanCtVariableReference(reference);
	}

	public  void visitCtReturn(CtReturn returnStatement) {
		scanCtCFlowBreak(returnStatement);
	}

	public  void visitCtStatementList(CtStatementList statements) {
		scanCtCodeElement(statements);
	}

	public  void visitCtSwitch(CtSwitch switchStatement) {
		scanCtStatement(switchStatement);
	}

	public void visitCtSynchronized(CtSynchronized synchro) {
		scanCtStatement(synchro);
	}

	public void visitCtThrow(CtThrow throwStatement) {
		scanCtCFlowBreak(throwStatement);
	}

	public void visitCtTry(CtTry tryBlock) {
		scanCtStatement(tryBlock);
	}

	public void visitCtTypeParameter(CtTypeParameter typeParameter) {
		scanCtElement(typeParameter);
	}

	public void visitCtTypeParameterReference(CtTypeParameterReference ref) {
		visitCtTypeReference(ref);
	}

	public  void visitCtTypeReference(CtTypeReference reference) {
		scanCtGenericElementReference(reference);
		scanCtReference(reference);
	}

	public  void visitCtUnaryOperator(CtUnaryOperator operator) {
		scanCtExpression(operator);
	}

	public  void visitCtVariableAccess(CtVariableAccess variableAccess) {
		scanCtExpression(variableAccess);
	}

	public  void visitCtAnnotationFieldAccess(
			CtAnnotationFieldAccess annotationFieldAccess) {
		scanCtTargetedExpression(annotationFieldAccess);
		visitCtVariableAccess(annotationFieldAccess);
	}

	public void visitCtWhile(CtWhile whileLoop) {
		scanCtLoop(whileLoop);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy