source: java/Framclipse/com.framsticks.framclipse/src/com/framsticks/framclipse/resource/FramScriptResourceDescription.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.8 KB
Line 
1package com.framsticks.framclipse.resource;
2
3import java.util.List;
4
5import org.eclipse.emf.ecore.EObject;
6import org.eclipse.emf.ecore.resource.Resource;
7import org.eclipse.xtext.naming.IQualifiedNameProvider;
8import org.eclipse.xtext.resource.IEObjectDescription;
9import org.eclipse.xtext.resource.impl.DefaultResourceDescription;
10
11import com.framsticks.framclipse.framScript.Code;
12import com.framsticks.framclipse.framScript.Property;
13import com.framsticks.framclipse.framScript.State;
14import com.framsticks.framclipse.framScript.VariableDeclaration;
15import com.google.common.base.Predicate;
16import com.google.common.collect.Iterables;
17import com.google.common.collect.Lists;
18
19public class FramScriptResourceDescription extends DefaultResourceDescription {
20
21        public FramScriptResourceDescription(Resource resource,
22                        IQualifiedNameProvider nameProvider) {
23                super(resource, nameProvider);
24        }
25
26        @Override
27        protected List<IEObjectDescription> computeExportedObjects() {
28                List<IEObjectDescription> objects = super.computeExportedObjects();
29                Iterable<IEObjectDescription> filter = Iterables.filter(objects,
30                                new Predicate<IEObjectDescription>() {
31
32                                        @Override
33                                        public boolean apply(IEObjectDescription desc) {
34                                                EObject input = desc.getEObjectOrProxy();
35                                                return shouldExport(input);
36                                        }
37
38                                });
39                return Lists.newArrayList(filter);
40        }
41
42        protected boolean shouldExport(EObject input) {
43                return input instanceof com.framsticks.framclipse.framScript.Function
44                                || input instanceof Property || input instanceof State
45                                || isGlobal(input);
46        }
47
48        private boolean isGlobal(EObject input) {
49                if (input instanceof VariableDeclaration) {
50                        VariableDeclaration dec = (VariableDeclaration) input;
51                        return dec.eContainer().eContainer() instanceof Code;
52                }
53                return false;
54        }
55
56}
Note: See TracBrowser for help on using the repository browser.