1 | package uk.co.zonetora.fj.model; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.Deque; |
5 | import java.util.HashSet; |
6 | import java.util.List; |
7 | import java.util.Set; |
8 | |
9 | import uk.co.zonetora.fj.typecheck.TypeCheck; |
10 | |
11 | public class MethodInvocation implements Term { |
12 | |
13 | private final Term path; |
14 | private final MethodName methodName; |
15 | private final List<Term> arguments; |
16 | |
17 | public MethodInvocation(Term path, MethodName methodName, List<Term> arguments) { |
18 | this.path = path; |
19 | this.methodName = methodName; |
20 | this.arguments = arguments; |
21 | } |
22 | |
23 | public Set<ClassName> getAllReferencedClassNames() { |
24 | Set<ClassName> allReferencedClassNames = new HashSet<ClassName>(); |
25 | allReferencedClassNames.addAll(path.getAllReferencedClassNames()); |
26 | for(Term t : arguments) { |
27 | allReferencedClassNames.addAll(t.getAllReferencedClassNames()); |
28 | } |
29 | return allReferencedClassNames; |
30 | } |
31 | |
32 | public void visit(TypeCheck check) { |
33 | check.appyRule(this); |
34 | } |
35 | |
36 | public Term getPath() { |
37 | return this.path; |
38 | } |
39 | |
40 | public MethodName getMethodName() { |
41 | return this.methodName; |
42 | } |
43 | |
44 | public List<Term> getArguments() { |
45 | return new ArrayList<Term>(this.arguments); |
46 | } |
47 | } |