Skip to content

Method: getStartPosition()

1: package de.fhdw.wtf.common.exception.walker;
2:
3: import de.fhdw.wtf.common.ast.Name;
4: import de.fhdw.wtf.common.exception.editor.EditorMarkable;
5: import de.fhdw.wtf.common.exception.editor.EditorMarker;
6: import de.fhdw.wtf.common.token.Position;
7: import de.fhdw.wtf.common.token.Token;
8:
9: /**
10: * Will be thrown if the {@link de.fhdw.wtf.walker.tasks.CyclicInheritanceCheck} found a cycle in the
11: * inheritance-structur.
12: *
13: */
14: public final class CyclicInheritanceException extends TaskException implements EditorMarkable {
15:         
16:         /**
17:          * generated.
18:          */
19:         private static final long serialVersionUID = 3858521011605735153L;
20:         
21:         /**
22:          * First-Token.
23:          */
24:         private final Token firstToken;
25:         
26:         /**
27:          * Last-Token.
28:          */
29:         private final Token lastToken;
30:         
31:         /**
32:          * Constructor of {@link CyclicInheritanceException}.
33:          *
34:          * @param name
35:          * name of the class
36:          * @param firstToken
37:          * firstToken
38:          * @param lastToken
39:          * lastToken
40:          */
41:         private CyclicInheritanceException(final Name name, final Token firstToken, final Token lastToken) {
42:                 super(de.fhdw.wtf.common.constants.walker.ExceptionConstants.CYCLIC_INHERITANCE_MESSAGE + name);
43:                 this.firstToken = firstToken;
44:                 this.lastToken = lastToken;
45:         }
46:         
47:         /**
48:          * Creates a {@link CyclicInheritanceException}-Object.
49:          *
50:          * @param name
51:          * name of the class
52:          * @param firstToken
53:          * firstToken
54:          * @param lastToken
55:          * lastToken
56:          * @return The {@link CyclicInheritanceException}-Object.
57:          */
58:         public static CyclicInheritanceException create(final Name name, final Token firstToken, final Token lastToken) {
59:                 return new CyclicInheritanceException(name, firstToken, lastToken);
60:         }
61:         
62:         @Override
63:         public Position getStartPosition() {
64:                 return this.firstToken.getPosition();
65:         }
66:         
67:         @Override
68:         public String getDescription() {
69:                 return this.getMessage();
70:         }
71:         
72:         @Override
73:         public Position getEndPos() {
74:                 return this.lastToken.getPosition();
75:         }
76:         
77:         @Override
78:         public EditorMarker getMarker() {
79:                 return EditorMarker.CYCLIC_INHERITANCE_MARKER;
80:         }
81:         
82: }