net.sourceforge.plantuml.tim.TimLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.tim;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.DefinitionsContainer;
import net.sourceforge.plantuml.log.Logme;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.FileWithSuffix;
import net.sourceforge.plantuml.preproc.ImportedFiles;
import net.sourceforge.plantuml.text.StringLocated;
public class TimLoader {
private final TContext context;
private final TMemory global = new TMemoryGlobal();
private boolean preprocessorError;
private List resultList;
public TimLoader(ImportedFiles importedFiles, Defines defines, Charset charset,
DefinitionsContainer definitionsContainer) {
this.context = new TContext(importedFiles, defines, charset, definitionsContainer);
try {
defines.copyTo(global);
} catch (EaterException e) {
Logme.error(e);
}
}
public Set load(List list) {
// CodeIteratorImpl.indentNow(list);
try {
context.executeLines(global, list, null, false);
} catch (EaterExceptionLocated e) {
context.getResultList().add(e.getLocation().withErrorPreprocessor(e.getMessage()));
changeLastLine(context.getDebug(), e.getMessage());
this.preprocessorError = true;
}
this.resultList = context.getResultList();
return context.getFilesUsedCurrent();
}
private void changeLastLine(List list, String message) {
final int num = list.size() - 1;
final StringLocated last = list.get(num);
list.set(num, last.withErrorPreprocessor(message));
}
public final List getResultList() {
return resultList;
}
public final List getDebug() {
return context.getDebug();
}
public final boolean isPreprocessorError() {
return preprocessorError;
}
}