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.processing;
019:
020: import spoon.reflect.declaration.CtElement;
021:
022: /**
023: * This interface represents the environment in which Spoon is launched -
024: * accessible through {@link spoon.reflect.Factory#getEnvironment()}. Its
025: * primary use is to report messages, warnings, and errors.
026: */
027: public interface Environment extends FactoryAccessor {
028:
029: /**
030: * Gets the Java version compliance level.
031: */
032: public int getComplianceLevel();
033:
034: /**
035: * Sets the Java version compliance level.
036: */
037: public void setComplianceLevel(int level);
038:
039: /**
040: * This method should be called to print out a message with a source
041: * position link during the processing.
042: */
043: public void debugMessage(String message);
044:
045: /**
046: * Returns the default file generator for this environment (gives the
047: * default output directory for the created files).
048: */
049: public FileGenerator<? extends CtElement> getDefaultFileGenerator();
050:
051: /**
052: * Gets the processing manager.
053: */
054: ProcessingManager getManager();
055:
056: /**
057: * Returns the properties for a given processor.
058: */
059: ProcessorProperties getProcessorProperties(String processorName)
060: throws Exception;
061:
062: /**
063: * Sets the properties for a given processor.
064: */
065: void setProcessorProperties(String processorName,
066: ProcessorProperties prop);
067:
068: /**
069: * Returns true if Spoon is in debug mode.
070: */
071: public boolean isDebug();
072:
073: /**
074: * Tells if the processing is stopped, generally because one of the
075: * processors called {@link #setProcessingStopped(boolean)} after reporting
076: * an error.
077: */
078: public boolean isProcessingStopped();
079:
080: /**
081: * Returns true if Spoon is in verbose mode.
082: */
083: public boolean isVerbose();
084:
085: /**
086: * Helper method called by a processor to report an error, warning or
087: * message as dictated by the severity parameter. Note that this does not
088: * stop the processing or any remaing task. To do so, use
089: * {@link #setProcessingStopped(boolean)}.
090: *
091: * @param processor
092: * The processor that report this message. Can be null.
093: * @param severity
094: * The severity of the report
095: * @param element
096: * The CtElement to which the report is associated
097: * @param message
098: * The message to report
099: */
100: public void report(Processor<?> processor, Severity severity,
101: CtElement element, String message);
102:
103: /**
104: * Helper method called by a processor to report an error, warning or
105: * message as dictated by the severity parameter. Note that this does not
106: * stop the processing or any remaining task. To do so, use
107: * {@link #setProcessingStopped(boolean)}.
108: *
109: * @param processor
110: * The processor that report this message. Can be null.
111: * @param severity
112: * The severity of the report
113: * @param element
114: * The CtElement to which the report is associated
115: * @param message
116: * The message to report
117: * @param fixes
118: * The problem fixer(s) to correct this problem
119: */
120: public void report(Processor<?> processor, Severity severity,
121: CtElement element, String message, ProblemFixer<?>... fixes);
122:
123: /**
124: * This method should be called to print out a message during the
125: * processing.
126: *
127: * @param processor
128: * The processor that report this message. Can be null.
129: * @param severity
130: * The severity of the report
131: * @param message
132: * The message to report
133: */
134: public void report(Processor<?> processor, Severity severity,
135: String message);
136:
137: /**
138: * This method should be called to report the end of the processing.
139: */
140: public void reportEnd();
141:
142: /**
143: * This method should be called to print out a progress message during the
144: * processing. On contrary to regular messages, progress messages are not
145: * meant to remain in the message logs and just indicate to the user some
146: * task progression information.
147: */
148: public void reportProgressMessage(String message);
149:
150: /**
151: * Sets the debug mode.
152: */
153: public void setDebug(boolean debug);
154:
155: /**
156: * Sets the default file generator for this environment.
157: */
158: void setDefaultFileGenerator(
159: FileGenerator<? extends CtElement> generator);
160:
161: /**
162: * Sets the processing manager of this environment.
163: */
164: void setManager(ProcessingManager manager);
165:
166: /**
167: * This method can be called to stop the processing and all the remaining
168: * tasks. In general, a processor calls it after reporting a fatal error.
169: */
170: void setProcessingStopped(boolean processingStopped);
171:
172: /**
173: * Sets/unsets the verbose mode.
174: */
175: void setVerbose(boolean verbose);
176:
177: /**
178: * Tells if the code generation use code fragments.
179: */
180: boolean isUsingSourceCodeFragments();
181:
182: /**
183: * Sets the code generation to use code fragments.
184: */
185: void useSourceCodeFragments(boolean b);
186:
187: /**
188: * Gets the size of the tabulations in the generated source code.
189: */
190: int getTabulationSize();
191:
192: /**
193: * Sets the size of the tabulations in the generated source code.
194: */
195: void setTabulationSize(int size);
196:
197: /**
198: * Tells if Spoon uses tabulations in the source code.
199: */
200: boolean isUsingTabulations();
201:
202: /**
203: * Sets Spoon to use tabulations in the source code.
204: */
205: void useTabulations(boolean b);
206:
207: /**
208: * Gets the current input path
209: */
210: String getSourcePath();
211:
212: }
|