source: java/Framclipse/com.framsticks.framclipse.ui/src/com/framsticks/framclipse/ui/outline/FramScriptTransformer.java @ 437

Last change on this file since 437 was 437, checked in by Mateusz Poszwa, 9 years ago

Added Framclipse as developed by Bartosz Kukawka and Tomek Maciejewski in 2010

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1/*
2 * generated by Xtext
3 */
4package com.framsticks.framclipse.ui.outline;
5
6import java.util.ArrayList;
7import java.util.List;
8
9import org.eclipse.emf.common.util.EList;
10import org.eclipse.emf.ecore.EObject;
11import org.eclipse.xtext.ui.editor.outline.transformer.AbstractDeclarativeSemanticModelTransformer;
12
13import com.framsticks.framclipse.framScript.Code;
14import com.framsticks.framclipse.framScript.Function;
15import com.framsticks.framclipse.framScript.Model;
16import com.framsticks.framclipse.framScript.Property;
17import com.framsticks.framclipse.framScript.State;
18import com.framsticks.framclipse.framScript.VariableDeclarations;
19
20/**
21 * customization of the default outline structure
22 */
23public 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}
Note: See TracBrowser for help on using the repository browser.