Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8b047af01e59d834c721e77ed3257687d3758eed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * <copyright>
 *
 * Copyright (c) 2005-2006 Sven Efftinge (http://www.efftinge.de) and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Sven Efftinge (http://www.efftinge.de) - Initial API and implementation
 *
 * </copyright>
 */
package org.eclipse.xtend.shared.ui.expression;

import java.util.Map;

import org.eclipse.xtend.expression.ExecutionContextImpl;
import org.eclipse.xtend.expression.Resource;
import org.eclipse.xtend.expression.ResourceManager;
import org.eclipse.xtend.expression.ResourceParser;
import org.eclipse.xtend.expression.TypeSystemImpl;
import org.eclipse.xtend.expression.Variable;
import org.eclipse.xtend.shared.ui.core.IXtendXpandProject;
import org.eclipse.xtend.shared.ui.core.PluginExecutionContext;

public class PluginExecutionContextImpl extends ExecutionContextImpl implements PluginExecutionContext {
    private final IXtendXpandProject project;

    public PluginExecutionContextImpl(final IXtendXpandProject xp, final TypeSystemImpl ts) {
        super(new PluginResourceManager (xp), ts, null);
        project = xp;
    }

    protected PluginExecutionContextImpl (ResourceManager resourceManager, Resource currentResource, TypeSystemImpl typeSystem, Map<String, Variable> vars, 
            Map<String, Variable> globalVars, IXtendXpandProject xp) {
        super (resourceManager, currentResource, typeSystem, vars, globalVars, null, null, null, null,null);
        project = xp;
    }
    
    @Override
    public PluginExecutionContextImpl cloneContext() {
        final PluginExecutionContextImpl result = new PluginExecutionContextImpl (resourceManager, currentResource(), typeSystem, getVisibleVariables(), getGlobalVariables(), project);
        return result;
    }


    public static  class PluginResourceManager implements ResourceManager {
        private IXtendXpandProject project;

        public PluginResourceManager(final IXtendXpandProject project) {
            this.project = project;
        }

        public Resource loadResource(final String fullyQualifiedName, final String extension) {
            return project.findExtXptResource(fullyQualifiedName,extension);
        }

        public void setFileEncoding(final String fileEncoding) {
        }

        public void registerParser(final String template_extension, final ResourceParser parser) {
        }
    }

}

Back to the top