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.reflect;
019:
020: import java.lang.annotation.Annotation;
021:
022: import spoon.reflect.code.CtArrayAccess;
023: import spoon.reflect.code.CtAssert;
024: import spoon.reflect.code.CtAssignment;
025: import spoon.reflect.code.CtBinaryOperator;
026: import spoon.reflect.code.CtBlock;
027: import spoon.reflect.code.CtBreak;
028: import spoon.reflect.code.CtCase;
029: import spoon.reflect.code.CtCatch;
030: import spoon.reflect.code.CtCodeSnippetExpression;
031: import spoon.reflect.code.CtCodeSnippetStatement;
032: import spoon.reflect.code.CtConditional;
033: import spoon.reflect.code.CtContinue;
034: import spoon.reflect.code.CtDo;
035: import spoon.reflect.code.CtExpression;
036: import spoon.reflect.code.CtFieldAccess;
037: import spoon.reflect.code.CtFor;
038: import spoon.reflect.code.CtForEach;
039: import spoon.reflect.code.CtIf;
040: import spoon.reflect.code.CtInvocation;
041: import spoon.reflect.code.CtLiteral;
042: import spoon.reflect.code.CtLocalVariable;
043: import spoon.reflect.code.CtNewArray;
044: import spoon.reflect.code.CtNewClass;
045: import spoon.reflect.code.CtOperatorAssignment;
046: import spoon.reflect.code.CtReturn;
047: import spoon.reflect.code.CtStatementList;
048: import spoon.reflect.code.CtSwitch;
049: import spoon.reflect.code.CtSynchronized;
050: import spoon.reflect.code.CtThrow;
051: import spoon.reflect.code.CtTry;
052: import spoon.reflect.code.CtUnaryOperator;
053: import spoon.reflect.code.CtVariableAccess;
054: import spoon.reflect.code.CtWhile;
055: import spoon.reflect.cu.CompilationUnit;
056: import spoon.reflect.cu.SourcePosition;
057: import spoon.reflect.declaration.CtAnnotation;
058: import spoon.reflect.declaration.CtAnnotationType;
059: import spoon.reflect.declaration.CtAnonymousExecutable;
060: import spoon.reflect.declaration.CtClass;
061: import spoon.reflect.declaration.CtConstructor;
062: import spoon.reflect.declaration.CtEnum;
063: import spoon.reflect.declaration.CtField;
064: import spoon.reflect.declaration.CtInterface;
065: import spoon.reflect.declaration.CtMethod;
066: import spoon.reflect.declaration.CtPackage;
067: import spoon.reflect.declaration.CtParameter;
068: import spoon.reflect.declaration.CtTypeParameter;
069: import spoon.reflect.reference.CtArrayTypeReference;
070: import spoon.reflect.reference.CtExecutableReference;
071: import spoon.reflect.reference.CtFieldReference;
072: import spoon.reflect.reference.CtLocalVariableReference;
073: import spoon.reflect.reference.CtPackageReference;
074: import spoon.reflect.reference.CtParameterReference;
075: import spoon.reflect.reference.CtTypeParameterReference;
076: import spoon.reflect.reference.CtTypeReference;
077:
078: /**
079: * This interface defines the core creation methods for the meta-model (to be
080: * implemented so that Spoon can manipulate other meta-model implementations).
081: * <p>
082: * <b>Important</b>: a required post-condition for all the created elements is
083: * that the factory (see {@link spoon.processing.FactoryAccessor#getFactory()})
084: * is correctly initialized with the main factory returned by
085: * {@link #getMainFactory()}, which cannot be null.
086: */
087: public interface CoreFactory {
088:
089: /**
090: * Recursively clones a given element of the metamodel and all its child
091: * elements.
092: *
093: * @param <T>
094: * the element's type
095: * @param element
096: * the element
097: * @return a clone of <code>element</code>
098: */
099: <T> T clone(T element);
100:
101: /**
102: * Creates an annotation.
103: */
104: <A extends Annotation> CtAnnotation<A> createAnnotation();
105:
106: /**
107: * Creates an annotation type.
108: */
109: <T extends Annotation> CtAnnotationType<T> createAnnotationType();
110:
111: /**
112: * Creates an anonymous executable.
113: */
114: CtAnonymousExecutable createAnonymousExecutable();
115:
116: /**
117: * Creates an array access expression.
118: */
119: <T, E extends CtExpression<?>> CtArrayAccess<T, E> createArrayAccess();
120:
121: /**
122: * Creates an array type reference.
123: */
124: <T> CtArrayTypeReference<T> createArrayTypeReference();
125:
126: /**
127: * Creates an <code>assert</code> statement.
128: */
129: <T> CtAssert<T> createAssert();
130:
131: /**
132: * Creates an assignment expression.
133: */
134: <T, A extends T> CtAssignment<T, A> createAssignment();
135:
136: /**
137: * Creates a binary operator.
138: */
139: <T> CtBinaryOperator<T> createBinaryOperator();
140:
141: /**
142: * Creates a block.
143: */
144: <R> CtBlock<R> createBlock();
145:
146: /**
147: * Creates a <code>break</code> statement.
148: */
149: CtBreak createBreak();
150:
151: /**
152: * Creates a <code>case</code> clause.
153: */
154: <S> CtCase<S> createCase();
155:
156: /**
157: * Creates a <code>catch</code> clause.
158: */
159: CtCatch createCatch();
160:
161: /**
162: * Creates a class.
163: */
164: <T> CtClass<T> createClass();
165:
166: /**
167: * Creates a conditional expression (<code>boolExpr?ifTrue:ifFalse</code>).
168: */
169: <T> CtConditional<T> createConditional();
170:
171: /**
172: * Creates a constructor.
173: */
174: <T> CtConstructor<T> createConstructor();
175:
176: /**
177: * Creates a <code>continue</code> statement.
178: */
179: CtContinue createContinue();
180:
181: /**
182: * Creates a <code>do</code> loop.
183: */
184: CtDo createDo();
185:
186: /**
187: * Creates an enum.
188: */
189: <T extends Enum<?>> CtEnum<T> createEnum();
190:
191: /**
192: * Creates an executable reference.
193: */
194: <T> CtExecutableReference<T> createExecutableReference();
195:
196: /**
197: * Creates a field.
198: */
199: <T> CtField<T> createField();
200:
201: /**
202: * Creates a field access expression.
203: */
204: <T> CtFieldAccess<T> createFieldAccess();
205:
206: /**
207: * Creates a field reference.
208: */
209: <T> CtFieldReference<T> createFieldReference();
210:
211: /**
212: * Creates a <code>for</code> loop.
213: */
214: CtFor createFor();
215:
216: /**
217: * Creates a <code>foreach</code> loop.
218: */
219: CtForEach createForEach();
220:
221: /**
222: * Creates an <code>if</code> statement.
223: */
224: CtIf createIf();
225:
226: /**
227: * Creates an interface.
228: */
229: <T> CtInterface<T> createInterface();
230:
231: /**
232: * Creates an invocation expression.
233: */
234: <T> CtInvocation<T> createInvocation();
235:
236: /**
237: * Creates a literal expression.
238: */
239: <T> CtLiteral<T> createLiteral();
240:
241: /**
242: * Creates a local variable declaration statement.
243: */
244: <T> CtLocalVariable<T> createLocalVariable();
245:
246: /**
247: * Creates a local variable reference.
248: */
249: <T> CtLocalVariableReference<T> createLocalVariableReference();
250:
251: /**
252: * Creates a method.
253: */
254: <T> CtMethod<T> createMethod();
255:
256: /**
257: * Creates a new array expression.
258: */
259: <T> CtNewArray<T> createNewArray();
260:
261: /**
262: * Creates a new anonymous class expression.
263: */
264: <T> CtNewClass<T> createNewClass();
265:
266: /**
267: * Creates a new operator assignement (like +=).
268: */
269: <T, A extends T> CtOperatorAssignment<T, A> createOperatorAssignment();
270:
271: /**
272: * Creates a package.
273: */
274: CtPackage createPackage();
275:
276: /**
277: * Creates a package reference.
278: */
279: CtPackageReference createPackageReference();
280:
281: /**
282: * Creates a parameter.
283: */
284: <T> CtParameter<T> createParameter();
285:
286: /**
287: * Creates a parameter reference.
288: */
289: <T> CtParameterReference<T> createParameterReference();
290:
291: /**
292: * Creates a <code>return</code> statement.
293: */
294: <R> CtReturn<R> createReturn();
295:
296: /**
297: * Creates a source position.
298: */
299: SourcePosition createSourcePosition(
300: CompilationUnit compilationUnit, int start, int end,
301: int[] lineSeparatorPositions);
302:
303: /**
304: * Creates a statement list.
305: */
306: <R> CtStatementList<R> createStatementList();
307:
308: /**
309: * Creates a <code>switch</code> statement.
310: */
311: <S> CtSwitch<S> createSwitch();
312:
313: /**
314: * Creates a <code>synchronized</code> statement.
315: */
316: CtSynchronized createSynchronized();
317:
318: /**
319: * Creates a <code>throw</code> statement.
320: */
321: CtThrow createThrow();
322:
323: /**
324: * Creates a <code>try</code> block.
325: */
326: CtTry createTry();
327:
328: /**
329: * Creates a type parameter.
330: */
331: CtTypeParameter createTypeParameter();
332:
333: /**
334: * Creates a type parameter reference.
335: */
336: CtTypeParameterReference createTypeParameterReference();
337:
338: /**
339: * Creates a type reference.
340: */
341: <T> CtTypeReference<T> createTypeReference();
342:
343: /**
344: * Creates a unary operator expression.
345: */
346: <T> CtUnaryOperator<T> createUnaryOperator();
347:
348: /**
349: * Creates a variable access expression.
350: */
351: <T> CtVariableAccess<T> createVariableAccess();
352:
353: /**
354: * Creates a <code>while</code> loop.
355: */
356: CtWhile createWhile();
357:
358: /**
359: * Creates a code snippet expression.
360: */
361: <T> CtCodeSnippetExpression<T> createCodeSnippetExpression();
362:
363: /**
364: * Creates a code snippet statement.
365: */
366: CtCodeSnippetStatement createCodeSnippetStatement();
367:
368: /**
369: * Gets the main factory of that core factory (cannot be <code>null</code>).
370: */
371: Factory getMainFactory();
372:
373: /**
374: * Sets the main factory of that core factory.
375: */
376: void setMainFactory(Factory mainFactory);
377:
378: /**
379: * Creates a compilation unit.
380: */
381: CompilationUnit createCompilationUnit();
382:
383: /**
384: * Creates a virtual compilation unit.
385: */
386: CompilationUnit createVirtualCompilationUnit();
387:
388: }
|