Java Code Examples for org.eclipse.xtext.scoping.Scopes#scopeFor()
The following examples show how to use
org.eclipse.xtext.scoping.Scopes#scopeFor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyntheticResourceAwareScopeProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public IScope scope_Codetemplates_language(Codetemplates templates, EReference reference) { if (TemplateResourceProvider.SYNTHETIC_SCHEME.equals(templates.eResource().getURI().scheme())) { ResourceSet resourceSet = templates.eResource().getResourceSet(); List<Grammar> grammars = Lists.newArrayListWithExpectedSize(1); for(Resource resource: resourceSet.getResources()) { EObject root = resource.getContents().get(0); if (root instanceof Grammar) { grammars.add((Grammar) root); } } return Scopes.scopeFor(grammars, new Function<Grammar, QualifiedName>() { @Override public QualifiedName apply(Grammar from) { return qualifiedNameConverter.toQualifiedName(from.getName()); } }, IScope.NULLSCOPE); } else { return delegateGetScope(templates, reference); } }
Example 2
Source File: AbstractTypeScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public IScope createMemberScope(JvmType containerType, Predicate<JvmMember> filter, Function<JvmMember, QualifiedName> names, IScope outer) { if (containerType == null || containerType.eIsProxy()) return outer; if (containerType instanceof JvmDeclaredType) { IScope result = outer; List<JvmTypeReference> superTypes = ((JvmDeclaredType) containerType).getSuperTypes(); for(JvmTypeReference superType: superTypes) { if (superType.getType() != null) result = createMemberScope(superType.getType(), filter, names, result); } List<JvmMember> members = ((JvmDeclaredType) containerType).getMembers(); return Scopes.scopeFor(Iterables.filter(members, filter), names, result); } return outer; }
Example 3
Source File: Bug291022TestLanguageRuntimeModule.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IScope getScope(EObject context, EReference reference) { if (Bug291022TestLanguagePackage.Literals.MODEL_ELEMENT__SECOND_REFERENCE == reference) { List<EObject> scope = Lists.newArrayList(); if (context instanceof ModelElement) { ModelElement modelElement = (ModelElement) context; if (modelElement.getFirstReference() != null && !modelElement.getFirstReference().eIsProxy()) scope.add(modelElement.getFirstReference()); } return Scopes.scopeFor(scope); } return super.getScope(context, reference); }
Example 4
Source File: CodetemplatesScopeProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public IScope scope_Codetemplate_context(Codetemplate template, EReference reference) { Codetemplates root = EcoreUtil2.getContainerOfType(template, Codetemplates.class); if (root != null && root.getLanguage() != null) { Grammar grammar = root.getLanguage(); if (!grammar.eIsProxy()) { LinkedHashSet<AbstractRule> usedRules = Sets.newLinkedHashSet(); new UsedRulesFinder(usedRules).compute(grammar); return Scopes.scopeFor(Iterables.filter(usedRules, ParserRule.class)); } } return IScope.NULLSCOPE; }
Example 5
Source File: ArithmeticsScopeProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private IScope getModuleScope(EObject context, EReference reference, Module module, IScope parent) { Iterable<Definition> allDefinitions = IterableExtensions.filter(module.getStatements(), Definition.class); if (context instanceof FunctionCall) { Iterable<Definition> matchingDefs = IterableExtensions.filter(allDefinitions, (d) -> ((FunctionCall) context).getArgs().size() == d.getArgs().size()); return Scopes.scopeFor(matchingDefs, parent); } else { return Scopes.scopeFor(allDefinitions, parent); } }
Example 6
Source File: ArithmeticsScopeProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private IScope getDefinitionScope(EObject context, EReference reference, IScope parent) { Definition containingDef = EcoreUtil2.getContainerOfType(context, Definition.class); if (containingDef == null) { return parent; } return Scopes.scopeFor(containingDef.getArgs(), parent); }
Example 7
Source File: Bug311337TestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public IScope scope_Reference_refChild(NestedRef context, EReference ref) { EList<Child> childList = null; Child child = context.getLeft().getRefChild(); childList = child.getLink().getChild(); IScope newScope = Scopes.scopeFor(childList); return newScope; }
Example 8
Source File: Bug311337TestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public IScope scope_Reference_refChild(Reference context, EReference ref) { Definition localClass = null; EList<Child> childList = null; localClass = EcoreUtil2.getContainerOfType(context, Definition.class); childList = localClass.getChild(); IScope newScope = Scopes.scopeFor(childList); return newScope; }
Example 9
Source File: CheckCfgScopeProvider.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public IScope getScope(final EObject context, final EReference reference) { if (reference == CheckcfgPackage.Literals.CONFIGURED_CHECK__CHECK) { // Note that context object can be either a configured check (if 'optional' keyword has been provided // so that a new instance is created and the configured catalog does not contain any configured checks // yet) or a configured catalog (in all other cases) final ConfiguredCatalog configuredCatalog = EcoreUtil2.getContainerOfType(context, ConfiguredCatalog.class); if (configuredCatalog == null || configuredCatalog.getCatalog() == null) { return IScope.NULLSCOPE; } CheckCatalog catalog = configuredCatalog.getCatalog(); return Scopes.scopeFor(catalog.getAllChecks(), checkQualifiedNameProvider, IScope.NULLSCOPE); } else if (reference == CheckcfgPackage.Literals.CONFIGURED_PARAMETER__PARAMETER) { // a new list of FormalParameters to scope to EList<FormalParameter> parameters = ECollections.newBasicEList(); final ConfiguredCheck configuredCheck = EcoreUtil2.getContainerOfType(context, ConfiguredCheck.class); if (configuredCheck != null) { // add FormalParameter definitions from linked check parameters.addAll(configuredCheck.getCheck().getFormalParameters()); } // add inferred FormalParameters (properties) final CheckConfiguration checkConfiguration = EcoreUtil2.getContainerOfType(context, CheckConfiguration.class); parameters.addAll(checkConfiguration.getProperties()); return Scopes.scopeFor(parameters, checkQualifiedNameProvider, IScope.NULLSCOPE); } return super.getScope(context, reference); }
Example 10
Source File: ExpressionsScopeProvider.java From xsemantics with Eclipse Public License 1.0 | 5 votes |
public IScope scope_Variable(Variable variable, EReference ref) { // only the variables declared before this one Model model = EcoreUtil2.getContainerOfType(variable, Model.class); if (model == null) return IScope.NULLSCOPE; EList<Variable> variables = model.getVariables(); return Scopes .scopeFor(variables.subList(0, variables.indexOf(variable))); }
Example 11
Source File: Bug287941TestLanguageRuntimeModule.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public IScope scope_AttributeWhereEntry_attribute(AttributeWhereEntry entry, EReference ref) { return Scopes.scopeFor(entry.getAlias().getType().getEAllStructuralFeatures()); }
Example 12
Source File: SGenTestScopeProvider.java From statecharts with Eclipse Public License 1.0 | 4 votes |
@Override protected IScope scope_GeneratorEntry_elementRef(EObject context, EReference reference) { return Scopes.scopeFor(Lists.newArrayList(createDummyModel(), createDummyDomain())); }
Example 13
Source File: FJScopeProvider.java From xsemantics with Eclipse Public License 1.0 | 4 votes |
public IScope scope_Member(Selection sel, EReference ref) { return Scopes .scopeFor(getMembers(getExpressionClass(sel.getReceiver()))); }
Example 14
Source File: FjXsemanticsBasedScopeProvider.java From xsemantics with Eclipse Public License 1.0 | 4 votes |
public IScope scope_Member(Selection sel, EReference ref) { return Scopes.scopeFor(fjAux.getMembers(getExpressionClass(sel .getReceiver()))); }