1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-22 09:54:53 +00:00
plantuml/src/net/sourceforge/plantuml/preproc/Preprocessor.java

98 lines
3.4 KiB
Java
Raw Normal View History

2010-11-15 20:35:36 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2016-01-09 12:15:40 +00:00
* (C) Copyright 2009-2017, Arnaud Roques
2010-11-15 20:35:36 +00:00
*
2016-03-06 16:47:34 +00:00
* Project Info: http://plantuml.com
2010-11-15 20:35:36 +00:00
*
2017-03-15 19:13:31 +00:00
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
2010-11-15 20:35:36 +00:00
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
2013-12-10 19:36:50 +00:00
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
2010-11-15 20:35:36 +00:00
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.preproc;
2011-01-29 15:09:35 +00:00
import java.io.File;
2010-11-15 20:35:36 +00:00
import java.io.IOException;
2015-06-07 10:23:10 +00:00
import java.util.Collections;
2015-04-07 18:18:37 +00:00
import java.util.List;
2011-01-29 15:09:35 +00:00
import java.util.Set;
2010-11-15 20:35:36 +00:00
2015-06-20 10:54:49 +00:00
import net.sourceforge.plantuml.CharSequence2;
2017-04-05 17:37:42 +00:00
import net.sourceforge.plantuml.DefinitionsContainer;
2018-07-27 21:56:46 +00:00
import net.sourceforge.plantuml.Log;
2015-04-07 18:18:37 +00:00
2018-07-27 21:56:46 +00:00
public class Preprocessor extends ReadLineInstrumented implements ReadLine {
2010-11-15 20:35:36 +00:00
2018-07-27 21:56:46 +00:00
private final PreprocessorInclude include;
2017-11-20 16:10:36 +00:00
private final SubPreprocessor subPreprocessor;
2018-07-27 21:56:46 +00:00
private final String description;
2010-11-15 20:35:36 +00:00
2017-11-20 16:10:36 +00:00
public Sub getSub(String blocname) {
return subPreprocessor.getSub(blocname);
}
2018-07-27 21:56:46 +00:00
// public Preprocessor(List<String> config, ReadLine reader, String charset, Defines defines, File newCurrentDir,
// DefinitionsContainer definitionsContainer) {
//
// final ReadLine source2 = new IfManager(reader, defines);
// final ReadLineInsertable source3 = new ReadLineInsertable(source2);
// final ReadLine source4 = new PreprocessorDefine(defines, source3);
// this.include = new PreprocessorInclude(config, source4, defines, charset, newCurrentDir, definitionsContainer);
// this.subPreprocessor = new SubPreprocessor(config, charset, defines, definitionsContainer, include);
// }
2017-11-20 16:10:36 +00:00
public Preprocessor(List<String> config, ReadLine reader, String charset, Defines defines, File newCurrentDir,
2017-04-05 17:37:42 +00:00
DefinitionsContainer definitionsContainer) {
2018-07-27 21:56:46 +00:00
this.description = reader.toString();
this.include = new PreprocessorInclude(config, reader, defines, charset, newCurrentDir, definitionsContainer);
final ReadLine source2 = new IfManager(include, defines);
final ReadLineInsertable source3 = new ReadLineInsertable(source2);
final ReadLine source4 = new PreprocessorDefine(defines, source3);
this.subPreprocessor = new SubPreprocessor(config, charset, defines, definitionsContainer, source4);
2010-11-15 20:35:36 +00:00
}
2018-07-27 21:56:46 +00:00
@Override
CharSequence2 readLineInst() throws IOException {
2017-11-20 16:10:36 +00:00
return subPreprocessor.readLine();
}
2010-11-15 20:35:36 +00:00
public int getLineNumber() {
2018-07-27 21:56:46 +00:00
return include.getLineNumber();
2010-11-15 20:35:36 +00:00
}
2018-07-27 21:56:46 +00:00
@Override
void closeInst() throws IOException {
// Log.info("Closing preprocessor of " + description);
include.close();
subPreprocessor.close();
2010-11-15 20:35:36 +00:00
}
2015-09-28 20:42:17 +00:00
public Set<FileWithSuffix> getFilesUsed() {
2018-07-27 21:56:46 +00:00
return Collections.unmodifiableSet(include.getFilesUsedGlobal());
2015-06-07 10:23:10 +00:00
}
2017-11-20 16:10:36 +00:00
2017-06-05 11:27:21 +00:00
}