Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from plantuml:master #93

Merged
merged 6 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Warning, "version" should be the same in gradle.properties and Version.java
# Any idea anyone how to magically synchronize those :-) ?
version = 1.2024.4beta1
version = 1.2024.4beta5
org.gradle.workers.max = 3
2 changes: 1 addition & 1 deletion src/net/sourceforge/plantuml/BlockUml.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public BlockUml(List<StringLocated> strings, Defines defines, ISkinSimple skinPa
this.data = new ArrayList<>(strings);
} else {
final TimLoader timLoader = new TimLoader(mode.getImportedFiles(), defines, charset,
(DefinitionsContainer) mode);
(DefinitionsContainer) mode, strings.get(0));
this.included.addAll(timLoader.load(strings));
this.data = timLoader.getResultList();
this.debug = timLoader.getDebug();
Expand Down
43 changes: 21 additions & 22 deletions src/net/sourceforge/plantuml/preproc/Defines.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import net.sourceforge.plantuml.security.SFile;
import net.sourceforge.plantuml.security.SecurityProfile;
import net.sourceforge.plantuml.security.SecurityUtils;
import net.sourceforge.plantuml.text.StringLocated;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.tim.TMemory;
import net.sourceforge.plantuml.tim.TVariableScope;
Expand All @@ -81,11 +82,11 @@ public static Defines createEmpty() {
return new Defines();
}

public void copyTo(TMemory memory) throws EaterException {
public void copyTo(TMemory memory, StringLocated location) throws EaterException {
for (Entry<String, Define> ent : values.entrySet()) {
final String name = ent.getKey();
final Define def = ent.getValue();
memory.putVariable(name, def.asTVariable(), TVariableScope.GLOBAL);
memory.putVariable(name, def.asTVariable(), TVariableScope.GLOBAL, location);
}

}
Expand Down Expand Up @@ -114,10 +115,10 @@ public static Defines createWithFileName(SFile file) {
final Defines result = createEmpty();
result.overrideFilename(file.getName());
result.environment.put("filedate", new Date(file.lastModified()).toString());
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) {
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE)
result.environment.put("dirpath",
file.getAbsoluteFile().getParentFile().getAbsolutePath().replace('\\', '/'));
}

return result;
}

Expand All @@ -126,10 +127,10 @@ public static Defines createWithFileName(java.io.File file) {
final Defines result = createEmpty();
result.overrideFilename(file.getName());
result.environment.put("filedate", new Date(file.lastModified()).toString());
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE) {
if (SecurityUtils.getSecurityProfile() == SecurityProfile.UNSECURE)
result.environment.put("dirpath",
file.getAbsoluteFile().getParentFile().getAbsolutePath().replace('\\', '/'));
}

return result;
}

Expand All @@ -147,9 +148,9 @@ public String getEnvironmentValue(String key) {

private static String nameNoExtension(String name) {
final int x = name.lastIndexOf('.');
if (x == -1) {
if (x == -1)
return name;
}

return name.substring(0, x);
}

Expand All @@ -169,11 +170,10 @@ public boolean isDefine(String expression) {
}

public boolean isTrue(String name) {
for (String key : values.keySet()) {
if (key.equals(name) || key.startsWith(name + "(")) {
for (String key : values.keySet())
if (key.equals(name) || key.startsWith(name + "("))
return true;
}
}

return false;
}

Expand All @@ -192,9 +192,9 @@ public List<String> applyDefines(String line) {
}

private String method1(String line) {
for (Define def : values.values()) {
for (Define def : values.values())
line = def.apply(line);
}

return line;
}

Expand All @@ -215,18 +215,17 @@ private Map<String, Collection<Define>> getAll() {

private String method2(String line) {
final Set<String> words = words(line);
if (magic == null) {
if (magic == null)
magic = getAll();

}
for (String w : words) {
Collection<Define> tmp = magic.get(w);
if (tmp == null) {
if (tmp == null)
continue;
}
for (Define def : tmp) {

for (Define def : tmp)
line = def.apply(line);
}

}
return line;
}
Expand All @@ -236,9 +235,9 @@ private Set<String> words(String line) {
Pattern p = Pattern.compile(ID);
Matcher m = p.matcher(line);
final Set<String> words = new HashSet<>();
while (m.find()) {
while (m.find())
words.add(m.group(0));
}

return words;
}

Expand Down
6 changes: 3 additions & 3 deletions src/net/sourceforge/plantuml/preproc/Stdlib.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public static void extractStdLib() throws IOException {
}
}

private static Collection<String> getAll() throws IOException {
public static Collection<String> getAll() throws IOException {
final Set<String> result = new TreeSet<>();
final InputStream home = getInternalInputStream("home", ".repx");
if (home == null)
Expand Down Expand Up @@ -451,11 +451,11 @@ public static void addInfoVersion(List<String> strings, boolean details) {
}
}

private String getVersion() {
public String getVersion() {
return info.get("VERSION");
}

private String getSource() {
public String getSource() {
return info.get("SOURCE");
}

Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/plantuml/preproc/Sub.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import net.sourceforge.plantuml.tim.TMemory;

public class Sub {
// ::remove folder when __HAXE__
// ::remove folder when __HAXE__

private final String name;
private final List<StringLocated> lines = new ArrayList<>();
Expand Down
1 change: 1 addition & 0 deletions src/net/sourceforge/plantuml/preproc/Truth.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
package net.sourceforge.plantuml.preproc;

public interface Truth {

public boolean isTrue(String name);

}
11 changes: 5 additions & 6 deletions src/net/sourceforge/plantuml/preproc2/PreprocessorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import net.sourceforge.plantuml.security.SURL;
import net.sourceforge.plantuml.text.StringLocated;
import net.sourceforge.plantuml.tim.EaterException;
import net.sourceforge.plantuml.utils.LineLocation;
import net.sourceforge.plantuml.utils.Log;

public class PreprocessorUtils {
Expand Down Expand Up @@ -139,21 +138,21 @@ public static ReadLine getReaderIncludeUrl(final SURL url, StringLocated s, Stri
if (StartDiagramExtractReader.containsStartDiagram(url, s, charset))
return StartDiagramExtractReader.build(url, s, suf, charset);

return getReaderInclude(url, s.getLocation(), charset);
return getReaderInclude(url, s, charset);
} catch (IOException e) {
Logme.error(e);
throw EaterException.located("Cannot open URL " + e.getMessage());
throw new EaterException("Cannot open URL " + e.getMessage(), s);
}

}

public static ReadLine getReaderInclude(SURL url, LineLocation lineLocation, Charset charset)
public static ReadLine getReaderInclude(SURL url, StringLocated s, Charset charset)
throws EaterException, UnsupportedEncodingException {
final InputStream is = url.openStream();
if (is == null)
throw EaterException.located("Cannot open URL");
throw new EaterException("Cannot open URL", s);

return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), lineLocation);
return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation());
}

}
4 changes: 4 additions & 0 deletions src/net/sourceforge/plantuml/text/StringLocated.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,8 @@ public int length() {
return s.length();
}

public char charAt(int i) {
return s.charAt(i);
}

}
Loading
Loading