Package: IAstAssistantFactory

IAstAssistantFactory

Coverage

1: /*
2: * #%~
3: * The Overture Abstract Syntax Tree
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ast.assistant;
23:
24: import org.overture.ast.analysis.intf.IAnswer;
25: import org.overture.ast.assistant.definition.PAccessSpecifierAssistant;
26: import org.overture.ast.assistant.definition.PDefinitionAssistant;
27: import org.overture.ast.assistant.pattern.PPatternAssistant;
28: import org.overture.ast.assistant.type.AUnionTypeAssistant;
29: import org.overture.ast.assistant.type.PTypeAssistant;
30: import org.overture.ast.assistant.type.SNumericBasicTypeAssistant;
31: import org.overture.ast.lex.LexNameList;
32: import org.overture.ast.types.SNumericBasicType;
33:
34: /**
35: * The {@link IAstAssistantFactory} defines the main interface for assistant factories. Assistants are responsible for
36: * providing generic functionality that is required on multiple occasions and that (for various reasons) cannot be
37: * implemented directly in the visitors. <br>
38: * <br>
39: * Factories are responsible for providing users with extensible access to the assistant functionality. Each module that
40: * needs assistants should create a factory and access a visitor by calling factory.createXAssistant where X is the node
41: * type that the functionality acts upon. <br>
42: * <br>
43: * All factories should subclass either this interface or one of its subclasses. These classes are in a straight
44: * hierarchy chain as follows: {@link IAstAssistantFactory} <- ITypeCheckerAssistantFactory <- *PluginLevelFactory <br>
45: * <br>
46: * By following this inheritance chain, at every level a single factory can provide all assistants. Extensions should
47: * hook into the hierarchy by subclassing their extension superclass, if one extist. Otherwise, subclass their Overture
48: * counterpart.
49: *
50: * @author ldc, kel, gkanos, pvj
51: */
52: public interface IAstAssistantFactory
53: {
54:         /**
55:          * Creates a new {@link PAccessSpecifierAssistant}. This assistant provides functionality to check if an
56:          * PAccessSpecifier is a "static", "public" specifier, etc.
57:          *
58:          * @return the p access specifier assistant
59:          */
60:         PAccessSpecifierAssistant createPAccessSpecifierAssistant();
61:
62:         /**
63:          * Creates a new {@link PDefinitionAssistant}. This assistant provides functionality for getting the name of a
64:          * definition and for setting its internal class definition.
65:          *
66:          * @return the p definition assistant
67:          */
68:         PDefinitionAssistant createPDefinitionAssistant();
69:
70:         /**
71:          * Creates a new {@link PPatternAssistant}. This assistant provides functionality for extracting variable names from
72:          * the pattern.
73:          * @param fromModule TODO
74:          *
75:          * @return the p pattern assistant
76:          */
77:         PPatternAssistant createPPatternAssistant(String fromModule);
78:
79:         /**
80:          * Creates a new {@link ABracketTypeAssistant}. This assistant does nothing and is probably a candidate for
81:          * deletion.
82:          *
83:          * @return the a bracket type assistant
84:          */
85:         // @Deprecated
86:         // ABracketTypeAssistant createABracketTypeAssistant();
87:
88:         /**
89:          * Creates a new ANamedInvariantTypeAssistant. This assistant does nothing and is probably a candidate for deletion.
90:          *
91:          * @return the a named invariant type assistant
92:          */
93:         // @Deprecated
94:         // ANamedInvariantTypeAssistant createANamedInvariantTypeAssistant();
95:
96:         /**
97:          * Creates a new {@link AOptionalTypeAssistant}. This assistant does nothing and is probably a candidate for
98:          * deletion.
99:          *
100:          * @return the a optional type assistant
101:          */
102:         // @Deprecated
103:         // AOptionalTypeAssistant createAOptionalTypeAssistant();
104:
105:         /**
106:          * Creates a new {@link AParameterTypeAssistant}. This assistant does nothing and is probably a candidate for
107:          * deletion.
108:          *
109:          * @return the a parameter type assistant
110:          */
111:         // @Deprecated
112:         // AParameterTypeAssistant createAParameterTypeAssistant();
113:
114:         /**
115:          * Creates a new {@link AUnionTypeAssistant}. This assistant provides functionality for expanding a Union type and
116:          * checking if it's numeric.
117:          *
118:          * @return the a union type assistant
119:          */
120:         AUnionTypeAssistant createAUnionTypeAssistant();
121:
122:         /**
123:          * Creates a new {@link AUnknownTypeAssistant}. This assistant does nothing and is probably a candidate for
124:          * deletion.
125:          *
126:          * @return the a unknown type assistant
127:          */
128:         // @Deprecated
129:         // AUnknownTypeAssistant createAUnknownTypeAssistant();
130:
131:         /**
132:          * Creates a new {@link PTypeAssistant}. This assistant provides functionality to get a type's name and check if a
133:          * type is numeric.
134:          *
135:          * @return the p type assistant
136:          */
137:         PTypeAssistant createPTypeAssistant();
138:
139:         /**
140:          * Creates a new {@link SNumericBasicTypeAssistant}. This assistant provides functionality to get the weight of a
141:          * numeric type.
142:          *
143:          * @return the s numeric basic type assistant
144:          */
145:         SNumericBasicTypeAssistant createSNumericBasicTypeAssistant();
146:
147:         /**
148:          * Returns the visitor for locating all variable names in a pattern.
149:          * @param fromModule TODO
150:          *
151:          * @return the all variable name locator
152:          */
153:         IAnswer<LexNameList> getAllVariableNameLocator(String fromModule);
154:
155:         /**
156:          * Returns the visitor to check if a type is numeric. Probably needs a better name.
157:          * @param fromModule TODO
158:          *
159:          * @return the numeric finder
160:          */
161:         IAnswer<Boolean> getNumericFinder(String fromModule);
162:
163:         /**
164:          * Returns the visitor that, given a numeric type, gets the the actual {@link SNumericBasicType} associated with it.
165:          * @param fromModule TODO
166:          *
167:          * @return the numeric basis checker
168:          */
169:         IAnswer<SNumericBasicType> getNumericBasisChecker(String fromModule);
170:
171:         /**
172:          * Return the visitor that gets the hashcode of a type.
173:          *
174:          * @return the hash checker
175:          */
176:         IAnswer<Integer> getHashChecker();
177: }