-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathCommand.java
More file actions
438 lines (339 loc) · 10.7 KB
/
Command.java
File metadata and controls
438 lines (339 loc) · 10.7 KB
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
/*******************************************************************************
* Copyright (c) 2009-2015 CWI
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI
* * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl
* * Paul Klint - Paul.Klint@cwi.nl - CWI
* * Mark Hills - Mark.Hills@cwi.nl (CWI)
* * Arnold Lankamp - Arnold.Lankamp@cwi.nl
* * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI
*******************************************************************************/
package org.rascalmpl.ast;
import io.usethesource.vallang.IConstructor;
import io.usethesource.vallang.ISourceLocation;
@SuppressWarnings(value = {"unused"})
public abstract class Command extends AbstractAST {
public Command(ISourceLocation src, IConstructor node) {
super(src /* we forget node on purpose */);
}
public boolean hasDeclaration() {
return false;
}
public org.rascalmpl.ast.Declaration getDeclaration() {
throw new UnsupportedOperationException();
}
public boolean hasExpression() {
return false;
}
public org.rascalmpl.ast.Expression getExpression() {
throw new UnsupportedOperationException();
}
public boolean hasImported() {
return false;
}
public org.rascalmpl.ast.Import getImported() {
throw new UnsupportedOperationException();
}
public boolean hasCommand() {
return false;
}
public org.rascalmpl.ast.ShellCommand getCommand() {
throw new UnsupportedOperationException();
}
public boolean hasStatement() {
return false;
}
public org.rascalmpl.ast.Statement getStatement() {
throw new UnsupportedOperationException();
}
public boolean isDeclaration() {
return false;
}
static public class Declaration extends Command {
// Production: sig("Declaration",[arg("org.rascalmpl.ast.Declaration","declaration")],breakable=false)
private final org.rascalmpl.ast.Declaration declaration;
public Declaration(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Declaration declaration) {
super(src, node);
this.declaration = declaration;
}
@Override
public boolean isDeclaration() {
return true;
}
@Override
public <T> T accept(IASTVisitor<T> visitor) {
return visitor.visitCommandDeclaration(this);
}
@Override
protected void addForLineNumber(int $line, java.util.List<AbstractAST> $result) {
if (getLocation().getBeginLine() == $line) {
$result.add(this);
}
ISourceLocation $l;
$l = declaration.getLocation();
if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) {
declaration.addForLineNumber($line, $result);
}
if ($l.getBeginLine() > $line) {
return;
}
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Declaration)) {
return false;
}
Declaration tmp = (Declaration) o;
return true && tmp.declaration.equals(this.declaration) ;
}
@Override
public int hashCode() {
return 857 + 509 * declaration.hashCode() ;
}
@Override
public org.rascalmpl.ast.Declaration getDeclaration() {
return this.declaration;
}
@Override
public boolean hasDeclaration() {
return true;
}
@Override
public Object clone() {
return newInstance(getClass(), src, (IConstructor) null , clone(declaration));
}
}
public boolean isExpression() {
return false;
}
static public class Expression extends Command {
// Production: sig("Expression",[arg("org.rascalmpl.ast.Expression","expression")],breakable=false)
private final org.rascalmpl.ast.Expression expression;
public Expression(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Expression expression) {
super(src, node);
this.expression = expression;
}
@Override
public boolean isExpression() {
return true;
}
@Override
public <T> T accept(IASTVisitor<T> visitor) {
return visitor.visitCommandExpression(this);
}
@Override
protected void addForLineNumber(int $line, java.util.List<AbstractAST> $result) {
if (getLocation().getBeginLine() == $line) {
$result.add(this);
}
ISourceLocation $l;
$l = expression.getLocation();
if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) {
expression.addForLineNumber($line, $result);
}
if ($l.getBeginLine() > $line) {
return;
}
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Expression)) {
return false;
}
Expression tmp = (Expression) o;
return true && tmp.expression.equals(this.expression) ;
}
@Override
public int hashCode() {
return 7 + 173 * expression.hashCode() ;
}
@Override
public org.rascalmpl.ast.Expression getExpression() {
return this.expression;
}
@Override
public boolean hasExpression() {
return true;
}
@Override
public Object clone() {
return newInstance(getClass(), src, (IConstructor) null , clone(expression));
}
}
public boolean isImport() {
return false;
}
static public class Import extends Command {
// Production: sig("Import",[arg("org.rascalmpl.ast.Import","imported")],breakable=false)
private final org.rascalmpl.ast.Import imported;
public Import(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Import imported) {
super(src, node);
this.imported = imported;
}
@Override
public boolean isImport() {
return true;
}
@Override
public <T> T accept(IASTVisitor<T> visitor) {
return visitor.visitCommandImport(this);
}
@Override
protected void addForLineNumber(int $line, java.util.List<AbstractAST> $result) {
if (getLocation().getBeginLine() == $line) {
$result.add(this);
}
ISourceLocation $l;
$l = imported.getLocation();
if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) {
imported.addForLineNumber($line, $result);
}
if ($l.getBeginLine() > $line) {
return;
}
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Import)) {
return false;
}
Import tmp = (Import) o;
return true && tmp.imported.equals(this.imported) ;
}
@Override
public int hashCode() {
return 827 + 941 * imported.hashCode() ;
}
@Override
public org.rascalmpl.ast.Import getImported() {
return this.imported;
}
@Override
public boolean hasImported() {
return true;
}
@Override
public Object clone() {
return newInstance(getClass(), src, (IConstructor) null , clone(imported));
}
}
public boolean isShell() {
return false;
}
static public class Shell extends Command {
// Production: sig("Shell",[arg("org.rascalmpl.ast.ShellCommand","command")],breakable=false)
private final org.rascalmpl.ast.ShellCommand command;
public Shell(ISourceLocation src, IConstructor node , org.rascalmpl.ast.ShellCommand command) {
super(src, node);
this.command = command;
}
@Override
public boolean isShell() {
return true;
}
@Override
public <T> T accept(IASTVisitor<T> visitor) {
return visitor.visitCommandShell(this);
}
@Override
protected void addForLineNumber(int $line, java.util.List<AbstractAST> $result) {
if (getLocation().getBeginLine() == $line) {
$result.add(this);
}
ISourceLocation $l;
$l = command.getLocation();
if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) {
command.addForLineNumber($line, $result);
}
if ($l.getBeginLine() > $line) {
return;
}
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Shell)) {
return false;
}
Shell tmp = (Shell) o;
return true && tmp.command.equals(this.command) ;
}
@Override
public int hashCode() {
return 199 + 661 * command.hashCode() ;
}
@Override
public org.rascalmpl.ast.ShellCommand getCommand() {
return this.command;
}
@Override
public boolean hasCommand() {
return true;
}
@Override
public Object clone() {
return newInstance(getClass(), src, (IConstructor) null , clone(command));
}
}
public boolean isStatement() {
return false;
}
static public class Statement extends Command {
// Production: sig("Statement",[arg("org.rascalmpl.ast.Statement","statement")],breakable=false)
private final org.rascalmpl.ast.Statement statement;
public Statement(ISourceLocation src, IConstructor node , org.rascalmpl.ast.Statement statement) {
super(src, node);
this.statement = statement;
}
@Override
public boolean isStatement() {
return true;
}
@Override
public <T> T accept(IASTVisitor<T> visitor) {
return visitor.visitCommandStatement(this);
}
@Override
protected void addForLineNumber(int $line, java.util.List<AbstractAST> $result) {
if (getLocation().getBeginLine() == $line) {
$result.add(this);
}
ISourceLocation $l;
$l = statement.getLocation();
if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) {
statement.addForLineNumber($line, $result);
}
if ($l.getBeginLine() > $line) {
return;
}
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Statement)) {
return false;
}
Statement tmp = (Statement) o;
return true && tmp.statement.equals(this.statement) ;
}
@Override
public int hashCode() {
return 487 + 59 * statement.hashCode() ;
}
@Override
public org.rascalmpl.ast.Statement getStatement() {
return this.statement;
}
@Override
public boolean hasStatement() {
return true;
}
@Override
public Object clone() {
return newInstance(getClass(), src, (IConstructor) null , clone(statement));
}
}
}