Skip to content

Commit

Permalink
fix: log-link regex now handles parentheses in the links
Browse files Browse the repository at this point in the history
This solves issue #57
  • Loading branch information
sillydan1 committed Dec 7, 2022
1 parent 6ae4327 commit 6d70988
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/main/java/dk/cs/aau/huppaal/logging/LogRegex.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ private static Pattern getPattern() {
sb.append(sep).append(quantifier.name().toLowerCase());
}
// For humans:
// [<display>](<quantifier>:<ref1>/<ref2>?)
var x = "\\[(?<display>[^]]+)]\\((?<quantifier>"+sb+"):(?<link>(?<component>[^/]+)/?(?<identifier>\\S+)?)\\)";
return Pattern.compile(x);
// [<display>](<quantifier>:<component>/<identifier>?)
var z = "\\[(?<display>[^]]+)]\\((?<quantifier>"+sb+"):(?<link>((?<component>[^/]+?)/)?(?<identifier>(\\([^)]*\\))|[^(]+?)+?)\\)";
return Pattern.compile(z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ private void onLinkClick(Hyperlink link) {
throw new RuntimeException("Not a valid %s link pattern: '%s'".formatted(BuildConfig.NAME,link.getLink()));
// TODO: When syntactic elements have UUIDs to identify them, we should look at those IDs (instead/aswell)
var regexLink = matcher.group("link");
System.out.println(regexLink);
var regexComponent = matcher.group("component");
System.out.println(regexComponent);
var regexIdentifier = Optional.ofNullable(matcher.group("identifier"));
System.out.println(regexIdentifier);
var notValidLink = "Not a valid %s link: %s".formatted(link.getQuantifier().name().toLowerCase(), link.getLink());
switch (link.getQuantifier()) {
case LOCATION -> {
Expand All @@ -62,7 +65,7 @@ private void onLinkClick(Hyperlink link) {
var component = SelectHelper.selectComponent(regexComponent);
regexIdentifier.ifPresent(s -> SelectHelper.selectLocation(component, s));
}
case COMPONENT -> SelectHelper.selectComponent(regexComponent);
case COMPONENT -> SelectHelper.selectComponent(regexLink);
case SUBCOMPONENT -> {
if(regexIdentifier.isEmpty())
Log.addWarning(notValidLink);
Expand Down

0 comments on commit 6d70988

Please sign in to comment.