Skip to content

Package: CommentState

CommentState

nameinstructionbranchcomplexitylinemethod
CommentState(String, Position)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
accept(ScannerStateVisitor)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
create(Position)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
finish(TokenStream)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%

Coverage

1: package de.fhdw.wtf.dsl.scanner.modelScanner.state;
2:
3: import de.fhdw.wtf.common.stream.TokenStream;
4: import de.fhdw.wtf.common.token.CommentTextToken;
5: import de.fhdw.wtf.common.token.Position;
6:
7: /**
8: * ScannerState for recognition of Comments.<br>
9: * Comments are initiated using the {@link CommentState#COMMENT_OPEN} symbol <br>
10: * and cosed using the {@link CommentState#COMMENT_CLOSE} symbol.<br>
11: * The commenttext is not restricted in any way.
12: *
13: * @author tajoa
14: */
15: public final class CommentState extends MultiCharState {
16:         
17:         /**
18:          * Constant for creation.
19:          */
20:         private static final String INITIAL_COMMENT = "";
21:         
22:         /**
23:          * Comment open char.
24:          */
25:         public static final char COMMENT_OPEN = '#';
26:         
27:         /**
28:          * Comment close char.
29:          */
30:         public static final char COMMENT_CLOSE = '#';
31:         
32:         /**
33:          * <b>PRIVATE</b> Constructor.
34:          *
35:          * @param currentComment
36:          * initial comment
37:          * @param firstPosition
38:          * of the first char.
39:          */
40:         private CommentState(final String currentComment, final Position firstPosition) {
41:                 super(currentComment, firstPosition);
42:         }
43:         
44:         @Override
45:         public void finish(final TokenStream outputStream) {
46:                 outputStream.add(CommentTextToken.create(
47:                                 this.getCurrentInput().concat(Character.toString(CommentState.COMMENT_CLOSE)),
48:                                 this.getFirstPosition()));
49:         }
50:         
51:         /**
52:          * Factory for {@link CommentState}.
53:          *
54:          * @param firstPosition
55:          * of the first char.
56:          * @return {@link CommentState}
57:          */
58:         public static CommentState create(final Position firstPosition) {
59:                 return new CommentState(INITIAL_COMMENT, firstPosition);
60:         }
61:         
62:         @Override
63:         public boolean accept(final ScannerStateVisitor visitor) {
64:                 return visitor.handleCommentState();
65:         }
66:         
67: }