01: package spoon.reflect.declaration;
02:
03: import spoon.support.builder.CtSnippetCompilationError;
04:
05: /**
06: * This interface represents snippets of source code that can be used in the AST
07: * to represent complex code without having to build the corresponding program
08: * model structure. It is mainly provided on simplification purpose in order to
09: * avoid having to build the program's model. Code snippets should be compiled
10: * to validate their contents and the result of the compilation should be used
11: * to replace the code snippet in the final AST.
12: *
13: * @see CtType#compileAndReplaceSnippets()
14: */
15: public interface CtCodeSnippet {
16:
17: /**
18: * Sets the textual value of the code.
19: */
20: void setValue(String value);
21:
22: /**
23: * Gets the textual value of the code.
24: */
25: String getValue();
26:
27: /**
28: * Compiles this code snippet to produce the corresponding AST expression.
29: *
30: * @return an AST Node ({@link CtElement})
31: * @throws CtSnippetCompilationError
32: * when the current snippet is not valid Java code
33: */
34: CtElement compile() throws CtSnippetCompilationError;
35: }
|