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

#378: RST importer #386

Merged
merged 41 commits into from
Jun 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
23811d5
#378: Incomplete: extracted common parser code.
redcatbear Feb 16, 2024
935990f
#378: Added missing JavaDoc.
redcatbear Feb 16, 2024
8dcc48f
Merge branch 'main' into feature/378_rst_importer
kaklakariada Feb 16, 2024
e9af239
Increment version number
Feb 16, 2024
cc47c49
Implement review findings
Feb 16, 2024
ac67dc1
Fix coverage collection
Feb 16, 2024
86bb4c7
Generate XML report for sonar
Feb 16, 2024
b77943e
Fix indentation
Feb 16, 2024
076a990
Cleanup pom
Feb 16, 2024
9c8d7a5
#342: Improved logo transparency.
redcatbear Feb 17, 2024
6e1706c
Merge remote-tracking branch 'origin/main'
redcatbear Feb 17, 2024
55c52b1
Merge remote-tracking branch 'origin/main' into feature/378_rst_importer
redcatbear Feb 17, 2024
68ee1c1
Revert changes to Jacoco configuration
Feb 17, 2024
83633c5
Merge remote-tracking branch 'origin/main' into feature/378_rst_importer
kaklakariada Feb 17, 2024
5e4d322
#342: Started RST importer
redcatbear Feb 19, 2024
e4c0971
Merge remote-tracking branch 'origin/feature/378_rst_importer' into f…
redcatbear Feb 25, 2024
46787ea
#342: Added RST importer factory. RST parser test cases still missing.
redcatbear Mar 6, 2024
e1f28a2
Merge branch 'main' of https://github.com/itsallcode/openfasttrace
redcatbear Mar 6, 2024
83156a9
Merge branch 'main' into feature/378_rst_importer
redcatbear Mar 6, 2024
a6f2cac
#342: Reverted accidental changes in the change log entry of 3.8.0.
redcatbear Mar 6, 2024
7a8ee0b
#342: Started replacing tests for Markdown importer.
redcatbear Mar 10, 2024
1fab988
#378: Refactored MarkdownImporter removed legacy ID. Broke Spec-Objec…
redcatbear Mar 21, 2024
c63c5e7
#378: Fixed tests. Self-trace broken.
redcatbear Apr 16, 2024
045f854
Merge branch 'main' of https://github.com/itsallcode/openfasttrace
redcatbear Apr 20, 2024
6683f78
Merge branch 'main' into feature/378_rst_importer
redcatbear Apr 20, 2024
3ba7687
#378: Unfinishend refactoring with unresolvable symbol.
redcatbear Apr 20, 2024
2668947
Update Eclipse config files to Java 17
kaklakariada Apr 20, 2024
829fc26
Update doc/changes/changes_4.0.0.md
redcatbear Apr 20, 2024
73caec5
Merge branch 'feature/378_rst_importer' of https://github.com/itsallc…
kaklakariada Apr 20, 2024
7240d9b
Remove unnecessary logger
kaklakariada Apr 20, 2024
99981ae
Move AbstractLightWeightMarkupImporterTest to testutil (#407)
kaklakariada May 5, 2024
800c1ff
Merge remote-tracking branch 'origin/main' into feature/378_rst_importer
kaklakariada May 5, 2024
a159583
Fix merge errors
kaklakariada May 5, 2024
6bc3a71
Fix codeql build
kaklakariada May 5, 2024
9ad93ae
Apply suggestions from code review
kaklakariada May 30, 2024
633d775
Implement review findings
kaklakariada May 30, 2024
380436b
Update Eclipse configuration for new module
kaklakariada May 30, 2024
32c966d
Fix self trace
kaklakariada May 30, 2024
c3231f3
Fix path under Windows
kaklakariada May 30, 2024
9b8e5ef
Fix formatting
May 31, 2024
efb776b
Fix parsing of underlined headers (#411)
kaklakariada Jun 2, 2024
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
Prev Previous commit
Next Next commit
#378: Added missing JavaDoc.
redcatbear committed Feb 16, 2024
commit 935990f496a2f764523b590f9bb3f1d400e02d11
2 changes: 2 additions & 0 deletions api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
exports org.itsallcode.openfasttrace.api.importer.tag.config;
exports org.itsallcode.openfasttrace.api.exporter;
exports org.itsallcode.openfasttrace.api.report;
// Workaround: Required for the EqualsVerifier
opens org.itsallcode.openfasttrace.api.core;

requires java.logging;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
package org.itsallcode.openfasttrace.importer.lightweightmarkup;

/**
* This enum defines the state the line parser for lightweight markup languages can be in.
*/
public enum LineParserState
{
START, OUTSIDE, SPEC_ITEM, DESCRIPTION, COVERS, DEPENDS, RATIONALE, COMMENT, NEEDS, EOF, TITLE, TAGS
/** Parser started (at beginning of the file) */
START,
/** We are outside any specification item */
OUTSIDE,
/** Inside a specification item */
SPEC_ITEM,
/** Inside a description section */
DESCRIPTION,
/** Inside a provided coverage section */
COVERS,
/** Inside a section describing dependencies */
DEPENDS,
/** Inside a rationale section */
RATIONALE,
/** Inside a comment section */
COMMENT,
/** Inside a section defining the required coverage */
NEEDS,
/** Reached the end of the file */
EOF,
/** Found a title */
TITLE,
/** Found tags */
TAGS
}
Original file line number Diff line number Diff line change
@@ -5,15 +5,16 @@
import java.util.regex.Matcher;

/**
* This machine implements the core of a state based parser
*
* This machine implements the core of a state based parser.
* <p>
* Before the state machine is run, it needs to be configured with a transition
* table in the constructor.
*
* </p><p>
* Each step of the state machine gets a portion of the text to be imported as
* input. The machine checks the current state and the input on each step and
* decides on resulting state and action depending on the configuration provided
* in the transition table.
* </p>
*/
public class LineParserStateMachine
{
@@ -50,7 +51,7 @@ public void step(final String line)
if ((this.state == entry.getFrom()) && matchToken(line, entry))
{
LOG.finest(() -> entry + " : '" + line + "'");
entry.getTransition().transit();
entry.getTransitionAction().transit();
this.state = entry.getTo();
break;
}
@@ -60,7 +61,7 @@ public void step(final String line)
private boolean matchToken(final String line, final Transition entry)
{
boolean matches = false;
final Matcher matcher = entry.getMarkdownPattern().getPattern().matcher(line);
final Matcher matcher = entry.getLinePattern().getPattern().matcher(line);
if (matcher.matches())
{
this.lastToken = (matcher.groupCount() == 0) ? "" : matcher.group(1);
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
package org.itsallcode.openfasttrace.importer.lightweightmarkup;

/**
* Transition in the line parser statemachine.
*/
public class Transition
{
private final LineParserState from;
private final LineParserState to;
private final LinePattern markdownPattern;
private final LinePattern linePattern;
private final TransitionAction transitionAction;

public Transition(final LineParserState from, final LineParserState to, final LinePattern markdownPattern,
/**
* Create a new instance of a {@link Transition}.
*
* @param from state the statemachine comes from
* @param to state the machine will switch to if the pattern matches
* @param linePattern pattern the line must match for the transition to happen
* @param transitionAction action that will be executed as result of the transition
*/
public Transition(final LineParserState from, final LineParserState to, final LinePattern linePattern,
final TransitionAction transitionAction)
{
this.from = from;
this.to = to;
this.markdownPattern = markdownPattern;
this.linePattern = linePattern;
this.transitionAction = transitionAction;
}

/**
* Get the origin state of this transition.
*
* @return origin state
*/
public LineParserState getFrom()
{
return this.from;
}

/**
* Get the target state of this transition.
*
* @return target state
*/
public LineParserState getTo()
{
return this.to;
}

public LinePattern getMarkdownPattern()
/**
* Get the regular expression pattern that needs to be matched in order for the transition to happen.
*
* @return line pattern to be matched
*/
public LinePattern getLinePattern()
{
return this.markdownPattern;
return this.linePattern;
}

public TransitionAction getTransition()
/**
* Get the action that is executed when the transition happens.
*
* @return action that is executed as result of the transition
*/
public TransitionAction getTransitionAction()
{
return this.transitionAction;
}
@@ -40,6 +71,6 @@ public TransitionAction getTransition()
public String toString()
{
return "Transition [from=" + this.from + ", to=" + this.to + ", markdownPattern="
+ this.markdownPattern + "]";
+ this.linePattern + "]";
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package org.itsallcode.openfasttrace.importer.lightweightmarkup;

/**
* Action that is executed as a result of a state transition in the line parser.
*/
@FunctionalInterface
public interface TransitionAction
{
/**
* Execute the transition action.
*/
void transit();
}
14 changes: 2 additions & 12 deletions parent/pom.xml
Original file line number Diff line number Diff line change
@@ -375,14 +375,9 @@
<useModulePath>true</useModulePath>
<argLine>
<!-- Required for Jacoco coverage -->
@{argLine}
<!-- @{argLine} -->
<!-- Required for Java 18 -->
${test.args}
<!-- Required to fix failing EqualsVerifier test:
TestTracedLink.testEqualsAndHashContract:22 EqualsVerifier found a problem in class org.itsallcode.openfasttrace.api.core.TracedLink.
-> Unable to make field private final org.itsallcode.openfasttrace.api.core.LinkedSpecificationItem org.itsallcode.openfasttrace.api.core.TracedLink.otherLinkEnd accessible:
module org.itsallcode.openfasttrace.api does not "opens org.itsallcode.openfasttrace.api.core" to unnamed module @48ae9b55 -->
--add-opens org.itsallcode.openfasttrace.api/org.itsallcode.openfasttrace.api.core=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
@@ -398,14 +393,9 @@
<useModulePath>true</useModulePath>
<argLine>
<!-- Required for Jacoco coverage -->
@{argLine}
<!-- @{argLine} -->
<!-- Required for Java 18 -->
${test.args}
<!-- Required to fix failing EqualsVerifier test:
TestTracedLink.testEqualsAndHashContract:22 EqualsVerifier found a problem in class org.itsallcode.openfasttrace.api.core.TracedLink.
-> Unable to make field private final org.itsallcode.openfasttrace.api.core.LinkedSpecificationItem org.itsallcode.openfasttrace.api.core.TracedLink.otherLinkEnd accessible:
module org.itsallcode.openfasttrace.api does not "opens org.itsallcode.openfasttrace.api.core" to unnamed module @48ae9b55 -->
--add-opens org.itsallcode.openfasttrace.api/org.itsallcode.openfasttrace.api.core=ALL-UNNAMED
</argLine>
</configuration>
<executions>