1 package de.fhdw.wtf.common.ast;
2
3 import de.fhdw.wtf.common.ast.visitor.NameReturnVisitor;
4 import de.fhdw.wtf.common.ast.visitor.NameVisitor;
5 import de.fhdw.wtf.common.ast.visitor.NameVisitorReturnBoolean;
6 import de.fhdw.wtf.common.ast.visitor.NameVisitorReturnName;
7 import de.fhdw.wtf.common.ast.visitor.NameVisitorReturnNameException;
8 import de.fhdw.wtf.common.exception.referencer.InvalidTypeReferenceException;
9 import de.fhdw.wtf.common.token.IdentifierToken;
10 import de.fhdw.wtf.common.token.Token;
11
12 /**
13 * This class represents either a qualified name({@link QualifiedName}) or an unqualified name({@link UnqualifiedName}).
14 *
15 */
16 public interface Name extends SyntaxObjectInterface {
17
18 /**
19 * Add the identifierToken to the given hierarchy. Uses dummy-token as lastToken
20 *
21 * @param identifierToken
22 * new token to add.
23 * @return Name with added identifierToken
24 */
25 Name addName(IdentifierToken identifierToken);
26
27 /**
28 * Add the identifierToken to the given hierarchy.
29 *
30 * @param lastToken
31 * token to use as lastToken for Name
32 * @param identifierToken
33 * new token to add.
34 * @return Name with added identifierToken
35 */
36 Name addName(IdentifierToken identifierToken, Token lastToken);
37
38 /**
39 * Visit-method for the {@link NameVisitorReturnName}-Visitor.
40 *
41 * @param v
42 * : NameVisitorForConcat
43 * @return : Name.
44 */
45 Name visit(NameVisitorReturnName v);
46
47 /**
48 * Visit-method for the {@link NameVisitor}-Visitor.
49 *
50 * @param v
51 * : NameVisitor.
52 * @throws InvalidTypeReferenceException
53 * possible Exception
54 */
55 void visit(NameVisitor v) throws InvalidTypeReferenceException;
56
57 /**
58 * Visit-method for the {@link NameVisitorReturnBoolean}-Visitor.
59 *
60 * @param v
61 * : NameVisitor.
62 * @return Boolean
63 */
64 boolean visit(NameVisitorReturnBoolean v);
65
66 /**
67 * Visit-method for the {@link NameVisitorReturnNameException}-Visitor.
68 *
69 * @param v
70 * : NameVisitorException.
71 * @return Name
72 * @throws InvalidTypeReferenceException
73 * possible Exception
74 */
75 Name visit(NameVisitorReturnNameException<InvalidTypeReferenceException> v) throws InvalidTypeReferenceException;
76
77 /**
78 * Visit-method for the {@link NameReturnVisitor}-Visitor.
79 *
80 * @param v
81 * Visitor
82 * @param <X>
83 * ReturnType
84 * @return X
85 */
86 <X> X visit(NameReturnVisitor<X> v);
87
88 /**
89 * Concats <code>this</code> with the parameter <code>name</code>. Returns a new Name.
90 *
91 * @param name
92 * : Name.
93 * @return : Name.
94 */
95 Name concat(Name name);
96
97 /**
98 * This method returns true, if the last added name to <code>this</code> equals the first added part of
99 * <code>name</code>. False otherwise.
100 *
101 * @param name
102 * : Name.
103 * @return : boolean.
104 */
105 boolean equalsPartial(Name name);
106
107 /**
108 * Returns the last part of <code>this</code>.<br/>
109 * If <code>this</code> is an {@link UnqualifiedName} it will return itself.<br/>
110 * If <code>this</code> is a {@link QualifiedName} it will return the last UnqualifiedName of the QualifiedName.
111 *
112 * @return : UnqualifiedName.
113 */
114 UnqualifiedName getLastAddedName();
115 }