1 | /* |
---|
2 | * generated by Xtext |
---|
3 | */ |
---|
4 | package com.framsticks.framclipse.ui.outline; |
---|
5 | |
---|
6 | import java.util.ArrayList; |
---|
7 | import java.util.List; |
---|
8 | |
---|
9 | import org.eclipse.emf.common.util.EList; |
---|
10 | import org.eclipse.emf.ecore.EObject; |
---|
11 | import org.eclipse.xtext.ui.editor.outline.transformer.AbstractDeclarativeSemanticModelTransformer; |
---|
12 | |
---|
13 | import com.framsticks.framclipse.framScript.Code; |
---|
14 | import com.framsticks.framclipse.framScript.Function; |
---|
15 | import com.framsticks.framclipse.framScript.Model; |
---|
16 | import com.framsticks.framclipse.framScript.Property; |
---|
17 | import com.framsticks.framclipse.framScript.State; |
---|
18 | import com.framsticks.framclipse.framScript.VariableDeclarations; |
---|
19 | |
---|
20 | /** |
---|
21 | * customization of the default outline structure |
---|
22 | */ |
---|
23 | public class FramScriptTransformer extends AbstractDeclarativeSemanticModelTransformer { |
---|
24 | |
---|
25 | public List<EObject> getChildren(Function e) { |
---|
26 | return NO_CHILDREN; |
---|
27 | } |
---|
28 | |
---|
29 | public List<EObject> getChildren(Model e) { |
---|
30 | List<EObject> children = new ArrayList<EObject>(); |
---|
31 | for (EObject child : e.eContents()) { |
---|
32 | if (child instanceof Code) { |
---|
33 | addCodeContents(children, (Code) child); |
---|
34 | } else if (child instanceof Property |
---|
35 | || child instanceof State) { |
---|
36 | children.add(child); |
---|
37 | } |
---|
38 | } |
---|
39 | return children; |
---|
40 | } |
---|
41 | |
---|
42 | private void addCodeContents(List<EObject> children, Code code) { |
---|
43 | if (code != null) { |
---|
44 | children.addAll(code.getIncludes()); |
---|
45 | EList<VariableDeclarations> globals = code.getGlobals(); |
---|
46 | for (VariableDeclarations declarations : globals) { |
---|
47 | children.addAll(declarations.getVars()); |
---|
48 | } |
---|
49 | children.addAll(code.getFunctions()); |
---|
50 | } |
---|
51 | } |
---|
52 | } |
---|