mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-26 06:46:45 +00:00
This commit is contained in:
parent
c0a51633ce
commit
e823b5f00f
@ -65,54 +65,58 @@ public class DirWatcher {
|
|||||||
public List<GeneratedImage> buildCreatedFiles() throws IOException, InterruptedException {
|
public List<GeneratedImage> buildCreatedFiles() throws IOException, InterruptedException {
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
final List<GeneratedImage> result = new ArrayList<>();
|
final List<GeneratedImage> result = new ArrayList<>();
|
||||||
for (File f : dir.listFiles()) {
|
if (dir.listFiles() != null)
|
||||||
if (error) {
|
for (File f : dir.listFiles()) {
|
||||||
continue;
|
if (error)
|
||||||
}
|
continue;
|
||||||
if (f.isFile() == false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (fileToProcess(f.getName()) == false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final FileWatcher watcher = modifieds.get(f);
|
|
||||||
|
|
||||||
if (watcher == null || watcher.hasChanged()) {
|
if (f.isFile() == false)
|
||||||
final SourceFileReader sourceFileReader = new SourceFileReader(Defines.createWithFileName(f), f,
|
continue;
|
||||||
option.getOutputDir(), option.getConfig(), option.getCharset(), option.getFileFormatOption());
|
|
||||||
final Set<File> files = FileWithSuffix.convert(sourceFileReader.getIncludedFiles());
|
if (fileToProcess(f.getName()) == false)
|
||||||
files.add(f);
|
continue;
|
||||||
for (GeneratedImage g : sourceFileReader.getGeneratedImages()) {
|
|
||||||
result.add(g);
|
final FileWatcher watcher = modifieds.get(f);
|
||||||
if (option.isFailfastOrFailfast2() && g.lineErrorRaw() != -1) {
|
|
||||||
error = true;
|
if (watcher == null || watcher.hasChanged()) {
|
||||||
|
final SourceFileReader sourceFileReader = new SourceFileReader(Defines.createWithFileName(f), f,
|
||||||
|
option.getOutputDir(), option.getConfig(), option.getCharset(),
|
||||||
|
option.getFileFormatOption());
|
||||||
|
final Set<File> files = FileWithSuffix.convert(sourceFileReader.getIncludedFiles());
|
||||||
|
files.add(f);
|
||||||
|
for (GeneratedImage g : sourceFileReader.getGeneratedImages()) {
|
||||||
|
result.add(g);
|
||||||
|
if (option.isFailfastOrFailfast2() && g.lineErrorRaw() != -1) {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
modifieds.put(f, new FileWatcher(files));
|
||||||
}
|
}
|
||||||
modifieds.put(f, new FileWatcher(files));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Collections.sort(result);
|
Collections.sort(result);
|
||||||
return Collections.unmodifiableList(result);
|
return Collections.unmodifiableList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getErrorFile() throws IOException, InterruptedException {
|
public File getErrorFile() throws IOException, InterruptedException {
|
||||||
for (File f : dir.listFiles()) {
|
if (dir.listFiles() != null)
|
||||||
if (f.isFile() == false) {
|
for (File f : dir.listFiles()) {
|
||||||
continue;
|
if (f.isFile() == false)
|
||||||
}
|
continue;
|
||||||
if (fileToProcess(f.getName()) == false) {
|
|
||||||
continue;
|
if (fileToProcess(f.getName()) == false)
|
||||||
}
|
continue;
|
||||||
final FileWatcher watcher = modifieds.get(f);
|
|
||||||
|
final FileWatcher watcher = modifieds.get(f);
|
||||||
|
|
||||||
|
if (watcher == null || watcher.hasChanged()) {
|
||||||
|
final SourceFileReader sourceFileReader = new SourceFileReader(Defines.createWithFileName(f), f,
|
||||||
|
option.getOutputDir(), option.getConfig(), option.getCharset(),
|
||||||
|
option.getFileFormatOption());
|
||||||
|
if (sourceFileReader.hasError())
|
||||||
|
return f;
|
||||||
|
|
||||||
if (watcher == null || watcher.hasChanged()) {
|
|
||||||
final SourceFileReader sourceFileReader = new SourceFileReader(Defines.createWithFileName(f), f,
|
|
||||||
option.getOutputDir(), option.getConfig(), option.getCharset(), option.getFileFormatOption());
|
|
||||||
if (sourceFileReader.hasError()) {
|
|
||||||
return f;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,14 +71,14 @@ public class DirWatcher2 {
|
|||||||
|
|
||||||
public Map<File, Future<List<GeneratedImage>>> buildCreatedFiles() throws IOException, InterruptedException {
|
public Map<File, Future<List<GeneratedImage>>> buildCreatedFiles() throws IOException, InterruptedException {
|
||||||
final Map<File, Future<List<GeneratedImage>>> result = new TreeMap<File, Future<List<GeneratedImage>>>();
|
final Map<File, Future<List<GeneratedImage>>> result = new TreeMap<File, Future<List<GeneratedImage>>>();
|
||||||
if (dir.listFiles() != null) {
|
if (dir.listFiles() != null)
|
||||||
for (final File f : dir.listFiles()) {
|
for (final File f : dir.listFiles()) {
|
||||||
if (f.isFile() == false) {
|
if (f.isFile() == false)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (fileToProcess(f.getName()) == false) {
|
if (fileToProcess(f.getName()) == false)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
final FileWatcher watcher = modifieds.get(f);
|
final FileWatcher watcher = modifieds.get(f);
|
||||||
|
|
||||||
if (watcher == null || watcher.hasChanged()) {
|
if (watcher == null || watcher.hasChanged()) {
|
||||||
@ -106,7 +106,6 @@ public class DirWatcher2 {
|
|||||||
result.put(f, value);
|
result.put(f, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return Collections.unmodifiableMap(result);
|
return Collections.unmodifiableMap(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,13 +57,13 @@ public class FileGroup {
|
|||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
this.excluded = excluded;
|
this.excluded = excluded;
|
||||||
this.option = option;
|
this.option = option;
|
||||||
if (pattern.indexOf("*") == -1 && pattern.indexOf("?") == -1) {
|
if (pattern.indexOf("*") == -1 && pattern.indexOf("?") == -1)
|
||||||
initNoStar();
|
initNoStar();
|
||||||
} else if (pattern.indexOf("**") != -1) {
|
else if (pattern.indexOf("**") != -1)
|
||||||
recurse();
|
recurse();
|
||||||
} else {
|
else
|
||||||
initWithSimpleStar();
|
initWithSimpleStar();
|
||||||
}
|
|
||||||
Collections.sort(result);
|
Collections.sort(result);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -71,54 +71,53 @@ public class FileGroup {
|
|||||||
private void recurse() {
|
private void recurse() {
|
||||||
final Matcher2 m = predirPath.matcher(pattern);
|
final Matcher2 m = predirPath.matcher(pattern);
|
||||||
final boolean ok = m.find();
|
final boolean ok = m.find();
|
||||||
if (ok == false) {
|
if (ok == false)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
|
||||||
final File parent;
|
final File parent;
|
||||||
if (m.group(1) == null) {
|
if (m.group(1) == null)
|
||||||
parent = new File(".");
|
parent = new File(".");
|
||||||
} else {
|
else
|
||||||
parent = new File(m.group(1));
|
parent = new File(m.group(1));
|
||||||
}
|
|
||||||
initWithDoubleStar(parent);
|
initWithDoubleStar(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initNoStar() {
|
private void initNoStar() {
|
||||||
final File f = new File(pattern);
|
final File f = new File(pattern);
|
||||||
if (f.isDirectory()) {
|
if (f.isDirectory())
|
||||||
addSimpleDirectory(f);
|
addSimpleDirectory(f);
|
||||||
} else if (f.isFile()) {
|
else if (f.isFile())
|
||||||
addResultFile(f);
|
addResultFile(f);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addResultFile(final File f) {
|
private void addResultFile(final File f) {
|
||||||
final String path = getNormalizedPath(f);
|
final String path = getNormalizedPath(f);
|
||||||
for (String x : excluded) {
|
for (String x : excluded)
|
||||||
if (path.matches(toRegexp(x))) {
|
if (path.matches(toRegexp(x)))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
result.add(f);
|
result.add(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSimpleDirectory(File dir) {
|
private void addSimpleDirectory(File dir) {
|
||||||
if (OptionFlags.getInstance().isWord()) {
|
if (OptionFlags.getInstance().isWord())
|
||||||
addSimpleDirectory(dir, "(?i)^.*_extr\\d+\\.txt$");
|
addSimpleDirectory(dir, "(?i)^.*_extr\\d+\\.txt$");
|
||||||
} else {
|
else
|
||||||
addSimpleDirectory(dir, option.getPattern());
|
addSimpleDirectory(dir, option.getPattern());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSimpleDirectory(File dir, String pattern) {
|
private void addSimpleDirectory(File dir, String pattern) {
|
||||||
if (dir.isDirectory() == false) {
|
if (dir.isDirectory() == false)
|
||||||
throw new IllegalArgumentException("dir=" + dir);
|
throw new IllegalArgumentException("dir=" + dir);
|
||||||
}
|
|
||||||
for (File f : dir.listFiles()) {
|
if (dir.listFiles() != null)
|
||||||
if (f.getName().matches(pattern)) {
|
for (File f : dir.listFiles())
|
||||||
addResultFile(f);
|
if (f.getName().matches(pattern))
|
||||||
}
|
addResultFile(f);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getNormalizedPath(File f) {
|
private static String getNormalizedPath(File f) {
|
||||||
@ -146,17 +145,16 @@ public class FileGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initWithDoubleStar(File currentDir) {
|
private void initWithDoubleStar(File currentDir) {
|
||||||
for (File f : currentDir.listFiles()) {
|
if (currentDir.listFiles() != null)
|
||||||
if (f.isDirectory()) {
|
for (File f : currentDir.listFiles()) {
|
||||||
initWithDoubleStar(f);
|
if (f.isDirectory()) {
|
||||||
} else if (f.isFile()) {
|
initWithDoubleStar(f);
|
||||||
final String path = getNormalizedPath(f);
|
} else if (f.isFile()) {
|
||||||
if (path.matches(toRegexp(pattern))) {
|
final String path = getNormalizedPath(f);
|
||||||
addResultFile(f);
|
if (path.matches(toRegexp(pattern)))
|
||||||
|
addResultFile(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandActivityLong3;
|
|||||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandArrow3;
|
import net.sourceforge.plantuml.activitydiagram3.command.CommandArrow3;
|
||||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandArrowLong3;
|
import net.sourceforge.plantuml.activitydiagram3.command.CommandArrowLong3;
|
||||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandBackward3;
|
import net.sourceforge.plantuml.activitydiagram3.command.CommandBackward3;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.command.CommandBackwardLong3;
|
||||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandBreak;
|
import net.sourceforge.plantuml.activitydiagram3.command.CommandBreak;
|
||||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandCase;
|
import net.sourceforge.plantuml.activitydiagram3.command.CommandCase;
|
||||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandCircleSpot3;
|
import net.sourceforge.plantuml.activitydiagram3.command.CommandCircleSpot3;
|
||||||
@ -125,6 +126,7 @@ public class ActivityDiagramFactory3 extends PSystemCommandFactory {
|
|||||||
cmds.add(new CommandRepeatWhile3());
|
cmds.add(new CommandRepeatWhile3());
|
||||||
cmds.add(new CommandRepeatWhile3Multilines());
|
cmds.add(new CommandRepeatWhile3Multilines());
|
||||||
cmds.add(new CommandBackward3());
|
cmds.add(new CommandBackward3());
|
||||||
|
cmds.add(new CommandBackwardLong3());
|
||||||
cmds.add(new CommandWhile3());
|
cmds.add(new CommandWhile3());
|
||||||
cmds.add(new CommandWhileEnd3());
|
cmds.add(new CommandWhileEnd3());
|
||||||
|
|
||||||
|
@ -79,9 +79,7 @@ public class CommandActivityLong3 extends CommandMultilines2<ActivityDiagram3> {
|
|||||||
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
|
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
|
||||||
final Colors colors = color().getColor(diagram.getSkinParam().getThemeStyle(), line0,
|
final Colors colors = color().getColor(diagram.getSkinParam().getThemeStyle(), line0,
|
||||||
diagram.getSkinParam().getIHtmlColorSet());
|
diagram.getSkinParam().getIHtmlColorSet());
|
||||||
// final HtmlColor color =
|
|
||||||
// diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR",
|
|
||||||
// 0));
|
|
||||||
final BoxStyle style = BoxStyle.fromChar(lines.getLastChar());
|
final BoxStyle style = BoxStyle.fromChar(lines.getLastChar());
|
||||||
lines = lines.removeStartingAndEnding(line0.get("DATA", 0), 1);
|
lines = lines.removeStartingAndEnding(line0.get("DATA", 0), 1);
|
||||||
return diagram.addActivity(lines.toDisplay(), style, null, colors, null);
|
return diagram.addActivity(lines.toDisplay(), style, null, colors, null);
|
||||||
|
@ -0,0 +1,98 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* PlantUML : a free UML diagram generator
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* (C) Copyright 2009-2020, Arnaud Roques
|
||||||
|
*
|
||||||
|
* Project Info: http://plantuml.com
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||||
|
* 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.activitydiagram3.command;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
|
||||||
|
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
|
||||||
|
import net.sourceforge.plantuml.command.BlocLines;
|
||||||
|
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||||
|
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||||
|
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||||
|
import net.sourceforge.plantuml.command.regex.IRegex;
|
||||||
|
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||||
|
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||||
|
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||||
|
import net.sourceforge.plantuml.graphic.color.ColorParser;
|
||||||
|
import net.sourceforge.plantuml.graphic.color.ColorType;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
|
||||||
|
|
||||||
|
public class CommandBackwardLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||||
|
|
||||||
|
public CommandBackwardLong3() {
|
||||||
|
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPatternEnd() {
|
||||||
|
return "^(.*)" + CommandActivity3.endingGroup() + "$";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ColorParser color() {
|
||||||
|
return ColorParser.simpleColor(ColorType.BACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
static IRegex getRegexConcat() {
|
||||||
|
return RegexConcat.build(CommandBackwardLong3.class.getName(), RegexLeaf.start(), //
|
||||||
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
|
new RegexLeaf("backward"), //
|
||||||
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
|
new RegexLeaf(":"), //
|
||||||
|
RegexLeaf.spaceZeroOrMore(), //
|
||||||
|
new RegexLeaf("DATA", "(.*)"), //
|
||||||
|
RegexLeaf.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) throws NoSuchColorException {
|
||||||
|
lines = lines.removeEmptyColumns();
|
||||||
|
final RegexResult line0 = getStartingPattern().matcher(lines.getFirst().getTrimmed().getString());
|
||||||
|
// final Colors colors = color().getColor(diagram.getSkinParam().getThemeStyle(), line0,
|
||||||
|
// diagram.getSkinParam().getIHtmlColorSet());
|
||||||
|
//
|
||||||
|
final BoxStyle style = BoxStyle.fromChar(lines.getLastChar());
|
||||||
|
lines = lines.removeStartingAndEnding(line0.get("DATA", 0), 1);
|
||||||
|
|
||||||
|
final LinkRendering in = LinkRendering.none();
|
||||||
|
final LinkRendering out = LinkRendering.none();
|
||||||
|
|
||||||
|
// return diagram.addActivity(lines.toDisplay(), style, null, colors, null);
|
||||||
|
|
||||||
|
return diagram.backward(lines.toDisplay(), style, in, out);
|
||||||
|
|
||||||
|
// return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
}
|
@ -244,18 +244,19 @@ public class PlantUmlTask extends Task {
|
|||||||
this.log(s);
|
this.log(s);
|
||||||
throw new BuildException(s);
|
throw new BuildException(s);
|
||||||
}
|
}
|
||||||
for (File f : dir.listFiles()) {
|
if (dir.listFiles() != null)
|
||||||
if (f.isFile() == false) {
|
for (File f : dir.listFiles()) {
|
||||||
continue;
|
if (f.isFile() == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (fileToProcess(f.getName()) == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
final boolean error = processingSingleFile(f);
|
||||||
|
if (error)
|
||||||
|
return f;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (fileToProcess(f.getName()) == false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final boolean error = processingSingleFile(f);
|
|
||||||
if (error) {
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +172,9 @@ public class SFile implements Comparable<SFile> {
|
|||||||
|
|
||||||
public Collection<SFile> listFiles() {
|
public Collection<SFile> listFiles() {
|
||||||
final File[] tmp = internal.listFiles();
|
final File[] tmp = internal.listFiles();
|
||||||
|
if (tmp == null)
|
||||||
|
return Collections.emptyList();
|
||||||
|
|
||||||
final List<SFile> result = new ArrayList<>(tmp.length);
|
final List<SFile> result = new ArrayList<>(tmp.length);
|
||||||
for (File f : tmp) {
|
for (File f : tmp) {
|
||||||
result.add(new SFile(f));
|
result.add(new SFile(f));
|
||||||
|
@ -80,7 +80,7 @@ public class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int beta() {
|
public static int beta() {
|
||||||
final int beta = 0;
|
final int beta = 1;
|
||||||
return beta;
|
return beta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user