ExpressionsScopeProvider.xtend 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * Copyright (c) 2015 committers of YAKINDU and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. * Contributors:
  8. * committers of YAKINDU - initial API and implementation
  9. *
  10. */
  11. package org.yakindu.base.expressions.scoping
  12. import org.eclipse.emf.ecore.EObject
  13. import org.eclipse.emf.ecore.EReference
  14. import org.eclipse.xtext.scoping.Scopes
  15. import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider
  16. import org.yakindu.base.expressions.expressions.ElementReferenceExpression
  17. import org.yakindu.base.expressions.expressions.FeatureCall
  18. import org.yakindu.base.types.Operation
  19. import org.yakindu.base.expressions.expressions.Argument
  20. import org.eclipse.xtext.scoping.IScope
  21. /**
  22. *
  23. * @author andreas muelder - Initial contribution and API
  24. *
  25. */
  26. class ExpressionsScopeProvider extends AbstractDeclarativeScopeProvider {
  27. def scope_Argument_parameter(Argument object, EReference ref) {
  28. var parameters = object?.eContainer?.operation?.parameters
  29. return if(parameters != null) Scopes.scopeFor(parameters) else IScope.NULLSCOPE;
  30. }
  31. def scope_Argument_parameter(ElementReferenceExpression exp, EReference ref) {
  32. var parameters = exp?.operation?.parameters
  33. return if(parameters != null) Scopes.scopeFor(parameters) else IScope.NULLSCOPE;
  34. }
  35. def scope_Argument_parameter(FeatureCall fc, EReference ref) {
  36. var parameters = fc?.operation?.parameters
  37. return if(parameters != null) Scopes.scopeFor(parameters) else IScope.NULLSCOPE;
  38. }
  39. def dispatch getOperation(ElementReferenceExpression it) {
  40. return if (reference instanceof Operation)
  41. reference as Operation
  42. else
  43. null
  44. }
  45. def dispatch getOperation(FeatureCall it) {
  46. return if (feature instanceof Operation)
  47. feature as Operation
  48. else
  49. null
  50. }
  51. def dispatch getOperation(EObject object) {
  52. }
  53. }