org.eclipse.xtext.naming.IQualifiedNameProvider Java Examples
The following examples show how to use
org.eclipse.xtext.naming.IQualifiedNameProvider.
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: DefaultResourceDescriptionManagerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws Exception { EObject copy = EcoreUtil.copy(EcorePackage.eINSTANCE); resource = new ResourceImpl(); resource.getContents().add(copy); IQualifiedNameProvider nameProvider = new IQualifiedNameProvider.AbstractImpl() { @Override public QualifiedName getFullyQualifiedName(EObject obj) { if (obj instanceof ENamedElement) return QualifiedName.create(((ENamedElement) obj).getName()); return null; } }; DefaultResourceDescriptionStrategy descriptionStrategy = new DefaultResourceDescriptionStrategy(); descriptionStrategy.setQualifiedNameProvider(nameProvider); resourceDescription = new DefaultResourceDescription(resource, descriptionStrategy) { @Override public Iterable<QualifiedName> getImportedNames() { return importedNames; } }; manager = new DefaultResourceDescriptionManager(); importedNames = Collections.emptySet(); }
Example #2
Source File: TypeCompareLogic.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** Same as {@link #compare(IQualifiedNameProvider, TypeArgument, TypeArgument)}, but for several type arguments. */ /* package */ static <T extends TypeArgument> int compareTypeArguments(IQualifiedNameProvider fqnProvider, Iterable<T> tvs1, Iterable<T> tvs2) { final Iterator<T> iter1 = tvs1.iterator(); final Iterator<T> iter2 = tvs2.iterator(); while (iter1.hasNext() && iter2.hasNext()) { final int c = compare(fqnProvider, iter1.next(), iter2.next()); if (c != 0) { return c; } } if (iter1.hasNext()) { return 1; } if (iter2.hasNext()) { return -1; } return 0; }
Example #3
Source File: TypeCompareLogic.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** Same as {@link #compare(IQualifiedNameProvider, Type, Type)}, but for several types. */ /* package */ static <T extends Type> int compareTypes(IQualifiedNameProvider fqnProvider, Iterable<T> tvs1, Iterable<T> tvs2) { final Iterator<T> iter1 = tvs1.iterator(); final Iterator<T> iter2 = tvs2.iterator(); while (iter1.hasNext() && iter2.hasNext()) { final int c = compare(fqnProvider, iter1.next(), iter2.next()); if (c != 0) { return c; } } if (iter1.hasNext()) { return 1; } if (iter2.hasNext()) { return -1; } return 0; }
Example #4
Source File: CheckMarkerHelpExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
@Override protected void doUpdateExtension(final CheckCatalog catalog, final IPluginExtension extension, final Iterable<IPluginElement> elements) throws CoreException { final IQualifiedNameProvider nameProvider = getFromServiceProvider(IQualifiedNameProvider.class, catalog); // Get current marker help element context IDs for this catalog List<String> catalogContextIds = Lists.newArrayList(); for (final Check check : catalog.getAllChecks()) { catalogContextIds.add(getQualifiedContextId(extension, check)); } // Remove elements of this catalog for (IPluginElement e : elements) { if (e.getAttribute(CONTEXT_ID_ATTRIBUTE_TAG) != null) { String contextId = e.getAttribute(CONTEXT_ID_ATTRIBUTE_TAG).getValue(); if (isCatalogContextId(nameProvider.apply(catalog), EcoreUtil.getURI(catalog), extension, contextId)) { extension.remove(e); } } } // Add new elements Iterable<? extends IPluginObject> updatedElements = getElements(catalog, extension); for (IPluginObject object : updatedElements) { extension.add(object); } }
Example #5
Source File: DefaultResourceDescriptionTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testGetExportedObject_1() throws Exception { strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() { @Override public QualifiedName getFullyQualifiedName(EObject obj) { if (obj instanceof EPackage) return QualifiedName.create(((EPackage) obj).getName()); return null; } }); Iterable<IEObjectDescription> iterable = description.getExportedObjects(); ArrayList<IEObjectDescription> list = Lists.newArrayList(iterable); assertEquals(1, list.size()); assertEquals(pack.getName(), list.get(0).getName().toString()); assertEquals(pack, list.get(0).getEObjectOrProxy()); }
Example #6
Source File: SCTXtextIntegrationModule.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Override public void configure(Binder binder) { binder.bind(IResourceValidator.class).to(SCTResourceValidatorImpl.class); binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("sct"); binder.bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class); binder.bind(IQualifiedNameProvider.class).to(StextNameProvider.class); binder.bind(org.eclipse.jface.viewers.ILabelProvider.class) .annotatedWith(org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider.class) .to(DefaultDescriptionLabelProvider.class); binder.bind(IDefaultResourceDescriptionStrategy.class).to(SCTResourceDescriptionStrategy.class); binder.bind(MarkerCreator.class).to(SCTMarkerCreator.class); binder.bind(MarkerTypeProvider.class).to(SCTMarkerTypeProvider.class); binder.bind(IDiagnosticConverter.class).to(SCTDiagnosticConverterImpl.class); binder.bind(IURIEditorOpener.class).annotatedWith(LanguageSpecific.class).to(SCTFileEditorOpener.class); binder.bind(IMarkerContributor.class).to(TaskMarkerContributor.class); binder.bind(ITaskFinder.class).to(DomainSpecificTaskFinder.class); binder.bind(TaskMarkerCreator.class).to(SCTTaskMarkerCreator.class); binder.bind(TaskMarkerTypeProvider.class).to(SCTTaskMarkerTypeProvider.class); }
Example #7
Source File: EcoreResourceDescriptionStrategy.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected boolean createEObjectDescriptions(IQualifiedNameProvider qualifiedNameProvider, boolean isNsURI, EObject eObject, IAcceptor<IEObjectDescription> acceptor) { try { QualifiedName qualifiedName = qualifiedNameProvider.getFullyQualifiedName(eObject); if (qualifiedName != null) { Map<String, String> userData = Maps.newHashMapWithExpectedSize(1); userData.put(NS_URI_INDEX_ENTRY, Boolean.toString(isNsURI)); IEObjectDescription description = EObjectDescription.create(qualifiedName, eObject, userData); acceptor.accept(description); return true; } } catch (Exception exc) { LOG.error(exc.getMessage(), exc); } return false; }
Example #8
Source File: QualifiedNamesFragment2.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void generate() { new GuiceModuleAccess.BindingFactory() .addTypeToType(TypeReference.typeRef(IQualifiedNameProvider.class), TypeReference.typeRef(DefaultDeclarativeQualifiedNameProvider.class)) .contributeTo(getLanguage().getRuntimeGenModule()); new GuiceModuleAccess.BindingFactory() .addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher"), TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.FQNPrefixMatcher")) .addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator"), TypeReference .typeRef("org.eclipse.xtext.ui.refactoring.impl.DefaultDependentElementsCalculator")) .contributeTo(getLanguage().getEclipsePluginGenModule()); new GuiceModuleAccess.BindingFactory() .addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.IPrefixMatcher"), TypeReference.typeRef("org.eclipse.xtext.ide.editor.contentassist.FQNPrefixMatcher")) .contributeTo(getLanguage().getIdeGenModule()); }
Example #9
Source File: DefaultResourceDescriptionTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testGetExportedObject_2() throws Exception { strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() { @Override public QualifiedName getFullyQualifiedName(EObject obj) { if (obj instanceof EClassifier) return QualifiedName.create(((EClassifier) obj).getName()); return null; } }); Iterable<IEObjectDescription> iterable = description.getExportedObjects(); ArrayList<IEObjectDescription> list = Lists.newArrayList(iterable); assertEquals(2, list.size()); assertEquals(eClass.getName(), list.get(0).getName().toString()); assertEquals(eClass, list.get(0).getEObjectOrProxy()); assertEquals(dtype.getName(), list.get(1).getName().toString()); assertEquals(dtype, list.get(1).getEObjectOrProxy()); }
Example #10
Source File: LinkingService.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Register a name as imported. * * @param context * context object within which a reference is being set to some object, must not be {@code null} * @param target * the associated target eObject. Its exported name is recorded as imported, must not be {@code null} * @param type * the lookup type, may be {@code null} */ public void importObject(final EObject context, final EObject target, final EClass type) { Resource eResource = target.eResource(); QualifiedName targetName = null; if (eResource instanceof LazyLinkingResource2) { IQualifiedNameProvider nameProvider = ((LazyLinkingResource2) eResource).getService(IQualifiedNameProvider.class); if (nameProvider != null) { targetName = nameProvider.getFullyQualifiedName(target); } } else { final IResourceDescriptions resourceDescriptions = provider.getResourceDescriptions(context.eResource()); Iterator<IEObjectDescription> exports = resourceDescriptions.getExportedObjectsByObject(target).iterator(); if (exports.hasNext()) { targetName = exports.next().getName(); } } if (targetName != null && !targetName.isEmpty()) { registerNamedType(context, targetName.toLowerCase(), type); // NOPMD targetName not a String! } }
Example #11
Source File: AbstractResourceDescriptionStrategy.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** {@inheritDoc} */ @Override public boolean createEObjectDescriptions(final EObject from, final IAcceptor<IEObjectDescription> acceptor) { final IQualifiedNameProvider nameProvider = getQualifiedNameProvider(); if (nameProvider == null) { return false; } try { return doCreateEObjectDescriptions(from, acceptor); // CHECKSTYLE:OFF (IllegalCatch) } catch (final Exception e) { // We need to catch arbitrary exceptions here, otherwise building may fail spectacularly; // and the cause may be very hard to find (likely some bug in an export specification). // CHECKSTYLE:ON LOGGER.error(MessageFormat.format(Messages.AbstractSdkResourceDescription_OBJECT_DESCRIPTION_FAILURE, EObjectUtil.getLocationString(from)), e); } return true; }
Example #12
Source File: ResourceSetBasedResourceDescriptionsTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws Exception { resourceSet = new ResourceSetImpl(); IQualifiedNameProvider qualifiedNameProvider = new IQualifiedNameProvider.AbstractImpl() { @Override public QualifiedName getFullyQualifiedName(EObject obj) { return QualifiedName.create(((ENamedElement) obj).getName()); } @Override public QualifiedName apply(EObject from) { return QualifiedName.create(((ENamedElement) from).getName()); } }; resourceDescriptionManager = new DefaultResourceDescriptionManager(); resourceDescriptionManager.setCache(IResourceScopeCache.NullImpl.INSTANCE); DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy(); strategy.setQualifiedNameProvider(qualifiedNameProvider); resourceDescriptionManager.setStrategy(strategy); resDescs = new ResourceSetBasedResourceDescriptions(); resDescs.setContext(resourceSet); resDescs.setRegistry(this); container = new ResourceDescriptionsBasedContainer(resDescs); }
Example #13
Source File: TypeSystemAwareScope.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public TypeSystemAwareScope(IScope parent, ITypeSystem typeSystemAccess, IQualifiedNameProvider qualifiedNameProvider, EClass eClass) { super(parent, false); this.typeSystem = typeSystemAccess; this.qualifiedNameProvider = qualifiedNameProvider; this.eClass = eClass; }
Example #14
Source File: TypeCompareLogic.java From n4js with Eclipse Public License 1.0 | 5 votes |
private static int compareFormalParameters(IQualifiedNameProvider fqnProvider, TFormalParameter p1, TFormalParameter p2) { if (p1 == p2) { return 0; } if (p1 == null) { return -1; } if (p2 == null) { return 1; } int c; // name c = compareComparables(p1.getName(), p2.getName()); if (c != 0) { return c; } // type c = compare(fqnProvider, p1.getTypeRef(), p2.getTypeRef()); if (c != 0) { return c; } // optional c = Boolean.compare(p1.isOptional(), p2.isOptional()); if (c != 0) { return c; } // variadic c = Boolean.compare(p1.isVariadic(), p2.isVariadic()); if (c != 0) { return c; } return 0; }
Example #15
Source File: TypeSystemAwareScope.java From solidity-ide with Eclipse Public License 1.0 | 5 votes |
public TypeSystemAwareScope(IScope parent, ITypeSystem typeSystemAccess, IQualifiedNameProvider qualifiedNameProvider, EClass eClass) { super(parent, false); this.typeSystem = typeSystemAccess; this.qualifiedNameProvider = qualifiedNameProvider; this.eClass = eClass; }
Example #16
Source File: GamlScopeProvider.java From gama with GNU General Public License v3.0 | 5 votes |
@Override protected ISelectable getAllDescriptions(final Resource resource) { final GamlMultimapBasedSelectable result = new GamlMultimapBasedSelectable(); final IQualifiedNameProvider provider = getNameProvider(); final Iterator<EObject> iterator = resource.getAllContents(); while (iterator.hasNext()) { final EObject from = iterator.next(); final QualifiedName qualifiedName = provider.apply(from); if (qualifiedName != null) { result.add(qualifiedName, new EObjectDescription(qualifiedName, from, null)); } } return result; }
Example #17
Source File: CheckMarkerHelpExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public void removeExtensionFromPluginBase(final IPluginModelBase base, final IPluginExtension extension, final CheckCatalog catalog, final ExtensionType type) throws CoreException { final IQualifiedNameProvider nameProvider = getFromServiceProvider(IQualifiedNameProvider.class, catalog); if (extension.getChildCount() == Iterables.size(getElements(nameProvider.apply(catalog), catalog.eResource().getURI(), extension))) { // remove whole extension, all existing marker elements belong to this catalog base.getPluginBase().remove(extension); } else { // only remove elements of this catalog, other catalogs have marker elements for (IPluginElement e : getElements(nameProvider.apply(catalog), catalog.eResource().getURI(), extension)) { extension.remove(e); } } }
Example #18
Source File: N4JSResourceDescription.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new description for the given resource. */ public N4JSResourceDescription(N4JSCrossReferenceComputer crossReferenceComputer, TypeHelper typeHelper, IQualifiedNameProvider qualifiedNameProvider, Resource resource, N4JSResourceDescriptionStrategy strategy, IResourceScopeCache cache) { super(resource, strategy, cache); this.crossReferenceComputer = crossReferenceComputer; this.qualifiedNameProvider = qualifiedNameProvider; this.typeHelper = typeHelper; this.strategy = strategy; }
Example #19
Source File: ImportedNamespaceAwareLocalScopeProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public ImportedNamespaceAwareLocalScopeProvider(IGlobalScopeProvider globalScopeProvider, IQualifiedNameProvider qualifiedNameProvider, IQualifiedNameConverter qualifiedNameConverter, ICaseInsensitivityHelper caseInsensitivityHelper) { super(globalScopeProvider, caseInsensitivityHelper); this.qualifiedNameProvider = qualifiedNameProvider; this.qualifiedNameConverter = qualifiedNameConverter; }
Example #20
Source File: DefaultResourceDescriptionTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Before public void setUp() throws Exception { resource = new XMLResourceImpl(); resource.setURI(URI.createURI("foo:/test")); nameProvider = new IQualifiedNameProvider.AbstractImpl() { @Override public QualifiedName getFullyQualifiedName(EObject obj) { if (obj instanceof ENamedElement) return QualifiedName.create(((ENamedElement) obj).getName()); return null; } }; strategy = new DefaultResourceDescriptionStrategy(); strategy.setQualifiedNameProvider(nameProvider); description = new DefaultResourceDescription(resource, strategy); EcoreFactory f = EcoreFactory.eINSTANCE; pack = f.createEPackage(); pack.setName("MyPackage"); eClass = f.createEClass(); eClass.setName("MyEClass"); dtype = f.createEDataType(); dtype.setName("MyDatatype"); pack.getEClassifiers().add(eClass); pack.getEClassifiers().add(dtype); resource.getContents().add(pack); }
Example #21
Source File: N4TSQualifiedNameProvider.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Static case: Returns the matching (internal) name of the polyfill matching the given classifier. There are no * polyfills of polyfills, so the returned name is independent from the polyfill flag of the given classifier. */ public static QualifiedName getStaticPolyfillFQN(TClassifier tClassifier, IQualifiedNameProvider qualifiedNameProvider) { QualifiedName prefix = qualifiedNameProvider.getFullyQualifiedName(EcoreUtil.getRootContainer(tClassifier)); // if ("n4ts".equals(tClassifier.eResource().getURI().fileExtension())) { // } instanceof TObjectPrototype) { // prefix = append(prefix, GLOBAL_NAMESPACE_SEGMENT); // // TODO this has to be removed, instead, also n4ts files should use "#" as global namespace segment // } prefix = prepend(MODULE_POLYFILL_SEGMENT, prefix); prefix = append(prefix, POLYFILL_SEGMENT); return append(prefix, tClassifier.getName()); }
Example #22
Source File: N4TSQualifiedNameProvider.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Returns the matching (internal) name of the polyfill matching the given classifier. There are no polyfills of * polyfills, so the returned name is independent from the polyfill flag of the given classifier. */ public static QualifiedName getPolyfillFQN(TClassifier tClassifier, IQualifiedNameProvider qualifiedNameProvider) { QualifiedName prefix = qualifiedNameProvider.getFullyQualifiedName(EcoreUtil.getRootContainer(tClassifier)); if ("n4ts".equals(tClassifier.eResource().getURI().fileExtension())) { // } instanceof TObjectPrototype) { prefix = append(prefix, GLOBAL_NAMESPACE_SEGMENT); // TODO this has to be removed, instead, also n4ts files should use "#" as global namespace segment } prefix = append(prefix, POLYFILL_SEGMENT); return append(prefix, tClassifier.getName()); }
Example #23
Source File: ExportFragment.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** {@inheritDoc} */ @Override public Set<Binding> getGuiceBindingsRt(final Grammar grammar) { final BindFactory bindFactory = new BindFactory(); final String namingPrefix = GrammarUtil.getNamespace(grammar) + ".naming." + GrammarUtil.getSimpleName(grammar); //$NON-NLS-1$ final String resourcePrefix = GrammarUtil.getNamespace(grammar) + ".resource." + GrammarUtil.getSimpleName(grammar); //$NON-NLS-1$ ExportModel m = getModel(grammar); if (m != null) { bindFactory.addTypeToType(IQualifiedNameProvider.class.getName(), namingPrefix + "ExportedNamesProvider"); //$NON-NLS-1$ if (!m.getInterfaces().isEmpty()) { bindFactory.addTypeToType(IFingerprintComputer.class.getName(), resourcePrefix + "FingerprintComputer"); //$NON-NLS-1$ } if (!m.getExports().isEmpty()) { bindFactory.addTypeToType(IDefaultResourceDescriptionStrategy.class.getName(), resourcePrefix + "ResourceDescriptionStrategy"); //$NON-NLS-1$ } if (Iterables.any(m.getExports(), new Predicate<Export>() { @Override public boolean apply(final Export input) { return input.isFingerprint() && input.getFragmentAttribute() != null; } })) { bindFactory.addTypeToType(IFragmentProvider.class.getName(), resourcePrefix + "FragmentProvider"); //$NON-NLS-1$ } } bindFactory.addTypeToType(IResourceDescription.Manager.class.getName(), resourcePrefix + "ResourceDescriptionManager"); //$NON-NLS-1$ return bindFactory.getBindings(); }
Example #24
Source File: TypeCompareLogic.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** WARNING: fqnProvider may be <code>null</code>, but then the lower/greater info will be unreliable! */ /* package */ static int compare(IQualifiedNameProvider fqnProvider, Type t1, Type t2) { if (t1 == t2) { return 0; } if (t1 == null) { return -1; } if (t2 == null) { return 1; } // before comparing FQNs, compare versions if (t1.getVersion() != t2.getVersion()) { return 1; } if (fqnProvider != null) { // standard behavior relying on a fqnProvider final QualifiedName name1 = fqnProvider.getFullyQualifiedName(t1); final QualifiedName name2 = fqnProvider.getFullyQualifiedName(t2); if (name1 == null && name2 == null) { // since we know t1!=null && t2!=null, this means t1 and t2 are types without a FQN (i.e. for which // fqnProvider returns null), e.g. type variables, and since we know t1!=t2 (from above) we must // report a difference here! return 1; } if (name1 == null) { return -1; } if (name2 == null) { return 1; } return name1.compareTo(name2); } else { // fall-back behavior if fqnProvider not available return 1; // note: we already know t1!=t2 } }
Example #25
Source File: DefaultResourceDescription2Test.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected IResourceDescription createResourceDescription(Resource testResource) { DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy(); strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() { @Override public QualifiedName getFullyQualifiedName(EObject obj) { String name = SimpleAttributeResolver.NAME_RESOLVER.apply(obj); return (name != null) ? QualifiedName.create(name) : null; } }); IResourceDescription resourceDescription = new DefaultResourceDescription(testResource, strategy); return resourceDescription; }
Example #26
Source File: CatalogFromExtensionPointScope.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override protected Iterable<IEObjectDescription> getAllLocalElements() { loadDefinitions(); if (loadedModel == null) { return ImmutableList.of(); } XtextResource resource = (XtextResource) loadedModel.eResource(); IQualifiedNameProvider nameProvider = resource.getResourceServiceProvider().get(IQualifiedNameProvider.class); return Scopes.scopedElementsFor(ImmutableList.of(loadedModel), nameProvider); }
Example #27
Source File: SharedCommonTypesModule.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void configure(Binder binder) { binder.bind(IEObjectHoverProvider.class).to(JdtHoverProvider.class); binder.bind(IEObjectHoverDocumentationProvider.class).to(JdtHoverDocumentationProvider.class); binder.bind(IResourceServiceProvider.class).to(SharedCommonTypesResourceServiceProvider.class); binder.bind(IResourceSetProvider.class).to(XtextResourceSetProvider.class); binder.bindConstant().annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).to("java"); binder.bind(IQualifiedNameProvider.class).to(JvmIdentifiableQualifiedNameProvider.class); binder.bind(ICopyQualifiedNameService.class).to(DefaultCopyQualifiedNameService.class); binder.bind(IJvmTypeProvider.Factory.class).to(JdtTypeProviderFactory.class); binder.bind(IRenameRefactoringProvider.class).to(DefaultRenameRefactoringProvider.class); binder.bind(AbstractRenameProcessor.class).to(JvmMemberRenameProcessor.class); binder.bind(IRenameStrategy.Provider.class).to(JvmMemberRenameStrategy.Provider.class); binder.bind(RefactoringResourceSetProvider.class).to(JvmRefactoringResourceSetProvider.class); binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("Java"); binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.LIVE_SCOPE)) .to(LiveShadowedResourceDescriptions.class); binder.bind(IResourceDescriptions.class) .annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)) .to(CurrentDescriptions.ResourceSetAware.class); binder.bind(IResourceDescriptions.class) .annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)) .to(IBuilderState.class); binder.bind(IWorkspaceRoot.class).toInstance(ResourcesPlugin.getWorkspace().getRoot()); binder.bind(ITraceForStorageProvider.class).to(TraceForStorageProvider.class); binder.bind(IReferenceUpdater.class).to(NullReferenceUpdater.class); }
Example #28
Source File: ModelSequencerTest.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Before public void setup() { Module m = new Module() { @Override public void configure(Binder binder) { binder.bind(INamingService.class).to(DefaultNamingService.class); binder.bind(IQualifiedNameProvider.class).to(SGraphNameProvider.class); binder.bind(ITypeSystem.class).toInstance(GenericTypeSystem.getInstance()); binder.bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class); binder.bind(String.class).annotatedWith(Names.named("Separator")).toInstance("_"); } }; Injector injector = Guice.createInjector(m); injector.injectMembers(this); }
Example #29
Source File: TestLanguageRenameService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected EObject getElementWithIdentifierAt(XtextResource xtextResource, int offset) { if (offset >= 0) { if (xtextResource != null) { IParseResult parseResult = xtextResource.getParseResult(); if (parseResult != null) { ICompositeNode rootNode = parseResult.getRootNode(); if (rootNode != null) { ILeafNode leaf = NodeModelUtils.findLeafNodeAtOffset(rootNode, offset); if (leaf != null && isIdentifier(leaf)) { EObject element = eObjectAtOffsetHelper.resolveElementAt(xtextResource, offset); if (element != null) { IQualifiedNameProvider nameProvider = xtextResource.getResourceServiceProvider() .get(IQualifiedNameProvider.class); QualifiedName fqn = nameProvider.getFullyQualifiedName(element); if (fqn != null) { String leafText = NodeModelUtils.getTokenText(leaf); if (fqn.getSegmentCount() == 1 && Objects.equal(fqn.toString(), leafText) || Objects.equal(fqn.getLastSegment(), leafText)) { return element; } } } } } } } } return null; }
Example #30
Source File: AbstractRefactoringTestLanguage1RuntimeModule.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() { return DefaultDeclarativeQualifiedNameProvider.class; }