001: /*
002: * Spoon - http://spoon.gforge.inria.fr/
003: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
004: *
005: * This software is governed by the CeCILL-C License under French law and
006: * abiding by the rules of distribution of free software. You can use, modify
007: * and/or redistribute the software under the terms of the CeCILL-C license as
008: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
009: *
010: * This program is distributed in the hope that it will be useful, but WITHOUT
011: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
013: *
014: * The fact that you are presently reading this means that you have had
015: * knowledge of the CeCILL-C license and that you accept its terms.
016: */
017:
018: package spoon.support.reflect.code;
019:
020: import java.util.ArrayList;
021: import java.util.List;
022:
023: import spoon.reflect.code.CtBlock;
024: import spoon.reflect.code.CtExpression;
025: import spoon.reflect.code.CtInvocation;
026: import spoon.reflect.code.CtStatement;
027: import spoon.reflect.code.CtStatementList;
028: import spoon.reflect.declaration.CtElement;
029: import spoon.reflect.reference.CtExecutableReference;
030: import spoon.reflect.visitor.CtVisitor;
031:
032: public class CtInvocationImpl<T> extends
033: CtTargetedExpressionImpl<T, CtExpression<?>> implements
034: CtInvocation<T> {
035: private static final long serialVersionUID = 1L;
036:
037: List<CtExpression<?>> arguments = new ArrayList<CtExpression<?>>();
038:
039: CtBlock<?> block;
040:
041: CtExecutableReference<T> executable;
042:
043: List<CtExpression<Integer>> indexExpressions = new ArrayList<CtExpression<Integer>>();
044:
045: public void accept(CtVisitor visitor) {
046: visitor.visitCtInvocation(this );
047: }
048:
049: @Override
050: public void setTarget(CtExpression<?> target) {
051: // TODO Auto-generated method stub
052: super .setTarget(target);
053: }
054:
055: public List<CtExpression<?>> getArguments() {
056: return arguments;
057: }
058:
059: public CtExecutableReference<T> getExecutable() {
060: return executable;
061: }
062:
063: public List<CtExpression<Integer>> getIndexExpressions() {
064: return indexExpressions;
065: }
066:
067: public void insertAfter(CtStatement statement) {
068: CtStatementImpl.insertAfter(this , statement);
069: }
070:
071: public void insertBefore(CtStatement statement) {
072: CtStatementImpl.insertBefore(this , statement);
073: }
074:
075: public void insertAfter(CtStatementList<?> statements) {
076: CtStatementImpl.insertAfter(this , statements);
077: }
078:
079: public void insertBefore(CtStatementList<?> statements) {
080: CtStatementImpl.insertBefore(this , statements);
081: }
082:
083: public void replace(CtElement element) {
084: if (element instanceof CtStatementList) {
085: CtStatementImpl.replace(this , (CtStatementList<?>) element);
086: } else {
087: super .replace(element);
088: }
089: }
090:
091: public boolean isArrayOperation() {
092: return indexExpressions.size() > 0;
093: };
094:
095: public void setArguments(List<CtExpression<?>> arguments) {
096: this .arguments = arguments;
097: }
098:
099: public void setExecutable(CtExecutableReference<T> executable) {
100: this .executable = executable;
101: }
102:
103: public void setIndexExpressions(
104: List<CtExpression<Integer>> indexExpressions) {
105: this .indexExpressions = indexExpressions;
106: }
107:
108: String label;
109:
110: public String getLabel() {
111: return label;
112: }
113:
114: public void setLabel(String label) {
115: this.label = label;
116: }
117:
118: }
|