-
Notifications
You must be signed in to change notification settings - Fork 3
/
TestServiceProvider.java
269 lines (228 loc) · 6.64 KB
/
TestServiceProvider.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/*******************************************************************************
* Copyright (c) 2015, 2023 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.acceleo.query.tests.runtime.lookup.basic;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.eclipse.acceleo.query.ast.Call;
import org.eclipse.acceleo.query.runtime.IReadOnlyQueryEnvironment;
import org.eclipse.acceleo.query.runtime.IService;
import org.eclipse.acceleo.query.runtime.IServiceProvider;
import org.eclipse.acceleo.query.runtime.IValidationResult;
import org.eclipse.acceleo.query.runtime.impl.AbstractService;
import org.eclipse.acceleo.query.runtime.impl.ValidationServices;
import org.eclipse.acceleo.query.validation.type.ClassType;
import org.eclipse.acceleo.query.validation.type.IType;
/**
* Lower priority lower type {@link IServiceProvider}.
*
* @author <a href="mailto:yvan.lussaud@obeo.fr">Yvan Lussaud</a>
*/
public class TestServiceProvider implements IServiceProvider {
public static final String SERVICE_NAME = "service";
public class Service1 extends AbstractService<Object> {
/**
* @param serviceOrigin
*/
protected Service1(Object serviceOrigin) {
super(serviceOrigin);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getName()
*/
@Override
public String getName() {
return SERVICE_NAME;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getShortSignature()
*/
@Override
public String getShortSignature() {
return SERVICE_NAME;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getLongSignature()
*/
@Override
public String getLongSignature() {
return SERVICE_NAME;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getParameterTypes(org.eclipse.acceleo.query.runtime.IReadOnlyQueryEnvironment)
*/
@Override
public List<IType> getParameterTypes(IReadOnlyQueryEnvironment queryEnvironment) {
final List<IType> result = new ArrayList<IType>();
result.add(new ClassType(queryEnvironment, type1));
return result;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getNumberOfParameters()
*/
@Override
public int getNumberOfParameters() {
return 1;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getPriority()
*/
@Override
public int getPriority() {
return priority1;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getType(org.eclipse.acceleo.query.ast.Call,
* org.eclipse.acceleo.query.runtime.impl.ValidationServices,
* org.eclipse.acceleo.query.runtime.IValidationResult,
* org.eclipse.acceleo.query.runtime.IReadOnlyQueryEnvironment, java.util.List)
*/
@Override
public Set<IType> getType(Call call, ValidationServices services, IValidationResult validationResult,
IReadOnlyQueryEnvironment queryEnvironment, List<IType> argTypes) {
return null;
}
@Override
public Set<IType> getType(IReadOnlyQueryEnvironment queryEnvironment) {
return null;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.impl.AbstractService#internalInvoke(java.lang.Object[])
*/
@Override
protected Object internalInvoke(Object[] arguments) throws Exception {
return null;
}
}
public class Service2 extends AbstractService<Object> {
/**
* @param serviceOrigin
*/
protected Service2(Object serviceOrigin) {
super(serviceOrigin);
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getName()
*/
@Override
public String getName() {
return SERVICE_NAME;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getShortSignature()
*/
@Override
public String getShortSignature() {
return SERVICE_NAME;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getLongSignature()
*/
@Override
public String getLongSignature() {
return SERVICE_NAME;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getParameterTypes(org.eclipse.acceleo.query.runtime.IReadOnlyQueryEnvironment)
*/
@Override
public List<IType> getParameterTypes(IReadOnlyQueryEnvironment queryEnvironment) {
final List<IType> result = new ArrayList<IType>();
result.add(new ClassType(queryEnvironment, type2));
return result;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getNumberOfParameters()
*/
@Override
public int getNumberOfParameters() {
return 1;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getPriority()
*/
@Override
public int getPriority() {
return priority2;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.IService#getType(org.eclipse.acceleo.query.ast.Call,
* org.eclipse.acceleo.query.runtime.impl.ValidationServices,
* org.eclipse.acceleo.query.runtime.IValidationResult,
* org.eclipse.acceleo.query.runtime.IReadOnlyQueryEnvironment, java.util.List)
*/
@Override
public Set<IType> getType(Call call, ValidationServices services, IValidationResult validationResult,
IReadOnlyQueryEnvironment queryEnvironment, List<IType> argTypes) {
return null;
}
@Override
public Set<IType> getType(IReadOnlyQueryEnvironment queryEnvironment) {
return null;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.acceleo.query.runtime.impl.AbstractService#internalInvoke(java.lang.Object[])
*/
@Override
protected Object internalInvoke(Object[] arguments) throws Exception {
return null;
}
}
private final int priority1;
private final Class<?> type1;
private final int priority2;
private final Class<?> type2;
public TestServiceProvider(int priority1, Class<?> type1, int priority2, Class<?> type2) {
this.priority1 = priority1;
this.type1 = type1;
this.priority2 = priority2;
this.type2 = type2;
}
@Override
public List<IService<?>> getServices(IReadOnlyQueryEnvironment queryEnvironment, boolean forWorkspace) {
final List<IService<?>> result = new ArrayList<IService<?>>();
result.add(new Service1(new Object()));
result.add(new Service2(new Object()));
return result;
}
}