-
Notifications
You must be signed in to change notification settings - Fork 36
added coverage of multiple ids in tags #553
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -708,7 +708,7 @@ To avoid conflict with the formats actual contents, you embed these definitions | |
| Tags have the following format: | ||
|
|
||
| ``` | ||
| [ <covered-artifact-type> -> <specification-object-id> ] | ||
| [ <covered-artifact-type> -> <list-of-specification-object-ids> ] | ||
| ``` | ||
|
|
||
| Spaces above were only added for readability. They are optional. In fact usually people prefer a more compact form. | ||
|
|
@@ -737,7 +737,7 @@ Examples: | |
| // [impl~validate-password~2->dsn~validate-authentication-request~1] | ||
| ``` | ||
|
|
||
| ##### Forwarding Requirements | ||
| ##### Needed Coverage | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good find. 👍 Compliance: I am guessing you are using an LLM to help with the work. Please note that according to our contribution guideline, LLM-assisted PR must state that. |
||
|
|
||
| When using UML models as design document files like UML models it is useful to add needed coverage as well. To do this, you can use the following format: | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,9 @@ | |
|
|
||
| import static java.util.Collections.emptyList; | ||
|
|
||
| import java.util.*; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.function.Predicate; | ||
| import java.util.logging.Logger; | ||
| import java.util.regex.Matcher; | ||
|
|
@@ -23,18 +25,21 @@ class LongTagImportingLineConsumer extends AbstractRegexLineConsumer | |
| private static final String OPTIONAL_WHITESPACE = "\\s*"; | ||
| private static final String TAG_PREFIX = "\\["; | ||
| private static final String TAG_SUFFIX = "\\]"; | ||
| private static final String NEEDS_COVERAGE = ">>" + OPTIONAL_WHITESPACE + "(\\p{Alpha}+(?:" | ||
| + OPTIONAL_WHITESPACE | ||
| + "," + OPTIONAL_WHITESPACE + "\\p{Alpha}+)*)"; | ||
| private static final String COVERED_IDS = SpecificationItemId.ID_PATTERN + "(?:" | ||
| + OPTIONAL_WHITESPACE + "," + OPTIONAL_WHITESPACE + SpecificationItemId.ID_PATTERN | ||
| + ")*"; | ||
| private static final String NEEDS_COVERAGE = ">>" + OPTIONAL_WHITESPACE | ||
| + "(?<neededArtifactTypes>\\p{Alpha}+(?:" + OPTIONAL_WHITESPACE + "," | ||
| + OPTIONAL_WHITESPACE + "\\p{Alpha}+)*)"; | ||
| private static final String TAG_REGEX = TAG_PREFIX + OPTIONAL_WHITESPACE// | ||
| + "(" + COVERING_ARTIFACT_TYPE_PATTERN + ")" | ||
| + "(?<artifactType>" + COVERING_ARTIFACT_TYPE_PATTERN + ")" | ||
| + "(?:" + SpecificationItemId.ARTIFACT_TYPE_SEPARATOR | ||
| // [impl->dsn~import.full-coverage-tag-with-name-and-revision~1] | ||
| + "(" + SpecificationItemId.ITEM_NAME_PATTERN + ")?" | ||
| + "(?<customName>" + SpecificationItemId.ITEM_NAME_PATTERN + ")?" | ||
| + SpecificationItemId.REVISION_SEPARATOR | ||
| + SpecificationItemId.ITEM_REVISION_PATTERN + ")?" // | ||
| + "(?<revision>" + SpecificationItemId.ITEM_REVISION_PATTERN + "))?" // | ||
| + OPTIONAL_WHITESPACE + "->" + OPTIONAL_WHITESPACE // | ||
| + "(" + SpecificationItemId.ID_PATTERN + ")" // | ||
| + "(?<coveredIds>" + COVERED_IDS + ")" // | ||
| + OPTIONAL_WHITESPACE + "(?:" + NEEDS_COVERAGE + OPTIONAL_WHITESPACE + ")?" // | ||
| + TAG_SUFFIX; | ||
|
|
||
|
|
@@ -50,21 +55,40 @@ class LongTagImportingLineConsumer extends AbstractRegexLineConsumer | |
|
|
||
| @Override | ||
| public void processMatch(final Matcher matcher, final int lineNumber, final int lineMatchCount) | ||
| { | ||
| final List<SpecificationItemId> coveredIds = parseCoveredIds(matcher.group("coveredIds")); | ||
| final List<String> neededArtifactTypes = parseNeededArtifactTypes(matcher.group("neededArtifactTypes")); | ||
|
|
||
| final List<SpecificationItemId> generatedIds = createItemIds(matcher, lineNumber, lineMatchCount, coveredIds, | ||
| neededArtifactTypes); | ||
|
|
||
| if (generatedIds.size() > 1) | ||
| { | ||
| assert generatedIds.size() == coveredIds.size(); | ||
| for (int i = 0; i < generatedIds.size(); i++) | ||
| { | ||
| addSpecificationItem(lineNumber, generatedIds.get(i), List.of(coveredIds.get(i)), neededArtifactTypes); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| addSpecificationItem(lineNumber, generatedIds.get(0), coveredIds, neededArtifactTypes); | ||
| } | ||
| } | ||
|
|
||
| private void addSpecificationItem(final int lineNumber, final SpecificationItemId generatedId, | ||
| final List<SpecificationItemId> coveredIds, final List<String> neededArtifactTypes) | ||
| { | ||
| this.listener.beginSpecificationItem(); | ||
| this.listener.setLocation(this.file.getPath(), lineNumber); | ||
| final SpecificationItemId coveredId = SpecificationItemId.parseId(matcher.group(5)); | ||
| final List<String> neededArtifactTypes = parseCommaSeparatedList(matcher.group(9)); | ||
| final SpecificationItemId generatedId = createItemId(matcher, lineNumber, lineMatchCount, coveredId, | ||
| neededArtifactTypes); | ||
| logItem(lineNumber, coveredId, neededArtifactTypes, generatedId); | ||
| this.listener.setId(generatedId); | ||
| this.listener.addCoveredId(coveredId); | ||
| neededArtifactTypes.forEach(listener::addNeededArtifactType); | ||
| coveredIds.forEach(this.listener::addCoveredId); | ||
| neededArtifactTypes.forEach(this.listener::addNeededArtifactType); | ||
| this.listener.endSpecificationItem(); | ||
| logItem(lineNumber, coveredIds, neededArtifactTypes, generatedId); | ||
| } | ||
|
|
||
| private static List<String> parseCommaSeparatedList(final String input) | ||
| private static List<SpecificationItemId> parseCoveredIds(final String input) | ||
| { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Safety: Add null handling, please. |
||
| if (input == null) | ||
| { | ||
|
|
@@ -74,32 +98,56 @@ private static List<String> parseCommaSeparatedList(final String input) | |
| return Arrays.stream(input.split(",")) | ||
| .map(String::trim) | ||
| .filter(Predicate.not(String::isEmpty)) | ||
| .map(SpecificationItemId::parseId) | ||
| .toList(); | ||
| } | ||
|
|
||
| private SpecificationItemId createItemId(final Matcher matcher, final int lineNumber, final int lineMatchCount, | ||
| final SpecificationItemId coveredId, final List<String> neededArtifactTypes) | ||
| private static List<String> parseNeededArtifactTypes(final String input) | ||
| { | ||
| final String artifactType = matcher.group(1); | ||
| final String customName = matcher.group(2); | ||
| final String revision = matcher.group(4); | ||
| final String name = customName != null ? customName | ||
| : getItemName(lineNumber, lineMatchCount, coveredId, neededArtifactTypes); | ||
| return SpecificationItemId.createId(artifactType, name, parseRevision(revision)); | ||
| if (input == null) | ||
| { | ||
| return emptyList(); | ||
| } | ||
|
|
||
| return Arrays.stream(input.split(",")) | ||
| .map(String::trim) | ||
| .filter(Predicate.not(String::isEmpty)) | ||
| .toList(); | ||
| } | ||
|
|
||
| private List<SpecificationItemId> createItemIds(final Matcher matcher, final int lineNumber, | ||
| final int lineMatchCount, | ||
| final List<SpecificationItemId> coveredIds, final List<String> neededArtifactTypes) | ||
| { | ||
| final String artifactType = matcher.group("artifactType"); | ||
| final String customName = matcher.group("customName"); | ||
| final String revision = matcher.group("revision"); | ||
| if (customName != null) | ||
| { | ||
| return List.of(SpecificationItemId.createId(artifactType, customName, parseRevision(revision))); | ||
| } | ||
|
|
||
| final List<SpecificationItemId> result = new java.util.ArrayList<>(coveredIds.size()); | ||
| for (final SpecificationItemId coveredId : coveredIds) | ||
| { | ||
| final String name = getItemName(lineNumber, lineMatchCount, coveredId, neededArtifactTypes); | ||
| result.add(SpecificationItemId.createId(artifactType, name, parseRevision(revision))); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| private void logItem(final int lineNumber, final SpecificationItemId coveredId, | ||
| private void logItem(final int lineNumber, final List<SpecificationItemId> coveredIds, | ||
| final List<String> neededArtifactTypes, final SpecificationItemId generatedId) | ||
| { | ||
| if (neededArtifactTypes.isEmpty()) | ||
| { | ||
| LOG.finest(() -> "File " + this.file + ":" + lineNumber + ": found '" + generatedId | ||
| + "' covering id '" + coveredId); | ||
| + "' covering ids " + coveredIds); | ||
| } | ||
| else | ||
| { | ||
| LOG.finest(() -> "File " + this.file + ":" + lineNumber + ": found '" + generatedId | ||
| + "' covering id '" + coveredId + "', needs artifact types " | ||
| + "' covering ids " + coveredIds + ", needs artifact types " | ||
| + neededArtifactTypes); | ||
| } | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Completeness: Please also add tests that the features with requiring coverage and partial spec item definition still work in combination with the comma-separated covered IDs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Davidius86 for the PR. I am started reviewing it. I will update main to 2.6.0 and create the release letter in another PR, so that we have a place where we can mention the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completeness: Please also add a short example of the syntax to
.agents/skills/openfasttrace/SKILL.md.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completeness: Please add an short entry for this in the change log too (we are currently working towards 4.6.0).