| /** |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * 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: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| * |
| * This copyright notice shows up in the generated Java code |
| */ |
| package org.eclipse.osbp.xtext.action.scoping; |
| |
| import com.google.common.base.Objects; |
| import java.util.ArrayList; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.EReference; |
| import org.eclipse.osbp.xtext.action.ActionButton; |
| import org.eclipse.osbp.xtext.action.ActionDSLPackage; |
| import org.eclipse.osbp.xtext.functionlibrarydsl.FunctionLibraryFunction; |
| import org.eclipse.osbp.xtext.functionlibrarydsl.FunctionLibraryGroup; |
| import org.eclipse.osbp.xtext.functionlibrarydsl.FunctionLibraryParameter; |
| import org.eclipse.osbp.xtext.messagedsl.MessageItem; |
| import org.eclipse.xtend2.lib.StringConcatenation; |
| import org.eclipse.xtext.common.types.JvmParameterizedTypeReference; |
| import org.eclipse.xtext.naming.QualifiedName; |
| import org.eclipse.xtext.resource.IEObjectDescription; |
| import org.eclipse.xtext.scoping.IScope; |
| import org.eclipse.xtext.scoping.Scopes; |
| import org.eclipse.xtext.xbase.annotations.typesystem.XbaseWithAnnotationsBatchScopeProvider; |
| import org.eclipse.xtext.xbase.lib.CollectionLiterals; |
| import org.eclipse.xtext.xbase.lib.InputOutput; |
| |
| @SuppressWarnings("all") |
| public class ActionScopeProvider extends XbaseWithAnnotationsBatchScopeProvider { |
| public IScope getScope(final EObject context, final EReference reference) { |
| boolean _equals = Objects.equal(reference, ActionDSLPackage.Literals.ACTION_BUTTON__CANEXECUTE); |
| if (_equals) { |
| return this.getScope_ActionButtonCanExecute(((ActionButton) context), reference); |
| } else { |
| boolean _equals_1 = Objects.equal(reference, ActionDSLPackage.Literals.ACTION_BUTTON__EXECUTEPARAMETER); |
| if (_equals_1) { |
| return this.getScope_ActionButtonExecuteParameter(((ActionButton) context), reference); |
| } |
| } |
| return super.getScope(context, reference); |
| } |
| |
| public IScope getScope_ActionButtonCanExecute(final ActionButton context, final EReference reference) { |
| IScope parentScope = super.getScope(context, reference); |
| ArrayList<EObject> result = CollectionLiterals.<EObject>newArrayList(); |
| FunctionLibraryGroup _group = context.getGroup(); |
| EList<FunctionLibraryFunction> _functions = ((FunctionLibraryGroup) _group).getFunctions(); |
| for (final FunctionLibraryFunction function : _functions) { |
| boolean _or = false; |
| EList<FunctionLibraryParameter> _params = function.getParams(); |
| boolean _equals = Objects.equal(_params, null); |
| if (_equals) { |
| _or = true; |
| } else { |
| EList<FunctionLibraryParameter> _params_1 = function.getParams(); |
| int _size = _params_1.size(); |
| boolean _equals_1 = (_size == 0); |
| _or = _equals_1; |
| } |
| if (_or) { |
| JvmParameterizedTypeReference _oftype = function.getOftype(); |
| String ofType = _oftype.getSimpleName(); |
| boolean _equals_2 = "boolean".equals(ofType); |
| if (_equals_2) { |
| result.add(function); |
| } |
| } |
| } |
| return Scopes.scopeFor(result, parentScope); |
| } |
| |
| public IScope getScope_ActionButtonExecuteParameter(final ActionButton context, final EReference reference) { |
| IScope parentScope = super.getScope(context, reference); |
| ArrayList<EObject> result = CollectionLiterals.<EObject>newArrayList(); |
| FunctionLibraryGroup _group = context.getGroup(); |
| EList<FunctionLibraryFunction> _functions = ((FunctionLibraryGroup) _group).getFunctions(); |
| for (final FunctionLibraryFunction function : _functions) { |
| boolean _or = false; |
| EList<FunctionLibraryParameter> _params = function.getParams(); |
| boolean _equals = Objects.equal(_params, null); |
| if (_equals) { |
| _or = true; |
| } else { |
| EList<FunctionLibraryParameter> _params_1 = function.getParams(); |
| int _size = _params_1.size(); |
| boolean _equals_1 = (_size == 0); |
| _or = _equals_1; |
| } |
| if (_or) { |
| result.add(function); |
| } |
| } |
| return Scopes.scopeFor(result, parentScope); |
| } |
| |
| public IScope getScope_ActionButtonMessage(final ActionButton context, final EReference reference) { |
| IScope parentScope = super.getScope(context, reference); |
| Iterable<IEObjectDescription> elements = parentScope.getAllElements(); |
| for (final IEObjectDescription element : elements) { |
| { |
| QualifiedName elementname = element.getName(); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("elementname: "); |
| _builder.append(elementname, ""); |
| InputOutput.<String>println(_builder.toString()); |
| } |
| } |
| ArrayList<EObject> result = CollectionLiterals.<EObject>newArrayList(); |
| MessageItem _message = context.getMessage(); |
| MessageItem message = ((MessageItem) _message); |
| EObject eObj = message.eContainer(); |
| boolean _notEquals = (!Objects.equal(message, null)); |
| if (_notEquals) { |
| result.add(message); |
| } |
| return Scopes.scopeFor(result, parentScope); |
| } |
| } |