1 | package com.framsticks.framclipse.framScript; |
---|
2 | |
---|
3 | import java.util.LinkedHashMap; |
---|
4 | import java.util.Map; |
---|
5 | |
---|
6 | import com.framsticks.framclipse.framScript.impl.VariableDeclarationImpl; |
---|
7 | import com.framsticks.framclipse.script.model.Element; |
---|
8 | import com.framsticks.framclipse.script.model.Type; |
---|
9 | |
---|
10 | public class ProposableVariableDeclarationImpl extends VariableDeclarationImpl implements Proposable { |
---|
11 | |
---|
12 | private final boolean type; |
---|
13 | private final String display, proposal; |
---|
14 | private final Map<String, String> description = new LinkedHashMap<String, String>(); |
---|
15 | |
---|
16 | public ProposableVariableDeclarationImpl(Element element) { |
---|
17 | assert !element.isFunction(); |
---|
18 | type = false; |
---|
19 | name = element.getName(); |
---|
20 | proposal = name; |
---|
21 | display = name + " : " + element.returnType(); |
---|
22 | createDescription(element); |
---|
23 | } |
---|
24 | |
---|
25 | public ProposableVariableDeclarationImpl(Type type) { |
---|
26 | this.type = true; |
---|
27 | name = type.getName(); |
---|
28 | proposal = name + "."; |
---|
29 | display = name; |
---|
30 | createDescription(type); |
---|
31 | } |
---|
32 | |
---|
33 | private void createDescription(Element element) { |
---|
34 | description.put("Description", element.getDescription()); |
---|
35 | description.put("Returns", element.returnType()); |
---|
36 | } |
---|
37 | |
---|
38 | private void createDescription(Type type) { |
---|
39 | description.put("Description", type.getDescription()); |
---|
40 | description.put("Context", type.getContext()); |
---|
41 | } |
---|
42 | |
---|
43 | @Override |
---|
44 | public String display() { |
---|
45 | return display; |
---|
46 | } |
---|
47 | |
---|
48 | @Override |
---|
49 | public String proposal() { |
---|
50 | return proposal; |
---|
51 | } |
---|
52 | |
---|
53 | @Override |
---|
54 | public Map<String, String> description() { |
---|
55 | return description; |
---|
56 | } |
---|
57 | |
---|
58 | public boolean isType() { |
---|
59 | return type; |
---|
60 | } |
---|
61 | |
---|
62 | } |
---|