org.eclipse.xtext.naming.IQualifiedNameConverter Java Examples

The following examples show how to use org.eclipse.xtext.naming.IQualifiedNameConverter. 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: CommonTypesContribution.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public void configure(Binder binder) {
	binder.bind(IQualifiedNameConverter.class);
	
	binder.bind(BuilderDeltaConverter.class);
	binder.bind(DeltaConverter.class);
	binder.bind(TypeURIHelper.class);
	
	binder.bind(TypeResourceUnloader.class);
	binder.bind(JavaChangeQueueFiller.class);
	
	binder.bind(IEagerContribution.class).to(ListenerRegistrar.class);

	binder.bind(TraceRegionSerializer.class);
	binder.bind(ITraceForTypeRootProvider.class).to(TraceForTypeRootProvider.class);
	binder.bind(FolderAwareTrace.class);
	binder.bind(ZipFileAwareTrace.class);
	binder.bind(OppositeFileOpenerContributor.class).to(ClassFileBasedOpenerContributor.class);
}
 
Example #2
Source File: JdtBasedSimpleTypeScopeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
	projectProvider = new MockJavaProjectProvider();
	factory = new JdtTypeProviderFactory(projectProvider);
	IQualifiedNameConverter qualifiedNameConverter = new IQualifiedNameConverter.DefaultImpl();
	scopeProvider = new JdtBasedSimpleTypeScopeProvider(factory, qualifiedNameConverter);
	resourceSet = new ResourceSetImpl();
	resource = new ResourceImpl();
	resource.setURI(URI.createURI("http://does/not/exist.file"));
	emptyResource = new ResourceImpl();
	emptyResource.setURI(URI.createURI("http://does/not/exist.file2"));
	resourceSet.getResources().add(emptyResource);
	resourceSet.getResources().add(resource);
	field = TypesFactory.eINSTANCE.createJvmField();
	resource.getContents().add(field);
}
 
Example #3
Source File: AbstractConstructorScopeTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testGetElementByInstance_01() {
	JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor();
	JvmGenericType type = TypesFactory.eINSTANCE.createJvmGenericType();
	type.setPackageName("java.lang");
	type.setSimpleName("Object");
	constructor.setSimpleName("Object");
	type.getMembers().add(constructor);
	IEObjectDescription element = getConstructorScope().getSingleElement(constructor);
	assertNotNull(element);
	assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getName());
	assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getQualifiedName());
}
 
Example #4
Source File: DeltaConverter.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.5
 */
@Inject
public DeltaConverter(IQualifiedNameConverter nameConverter, TypeURIHelper uriHelper, IResourceDescriptions resourceDescriptions) {
	this.nameConverter = nameConverter;
	this.uriHelper = uriHelper;
	this.resourceDescriptions = resourceDescriptions;
}
 
Example #5
Source File: XtendImportingTypesProposalProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ConfigurableCompletionProposal.IReplacementTextApplier createTextApplier(final ContentAssistContext context, final IScope typeScope, final IQualifiedNameConverter qualifiedNameConverter, final IValueConverter<String> valueConverter) {
  final Predicate<IEObjectDescription> _function = (IEObjectDescription it) -> {
    QualifiedName _name = it.getName();
    return (!Objects.equal(_name, XtendImportedNamespaceScopeProvider.OLD_DATA_ANNOTATION));
  };
  final FilteringScope scope = new FilteringScope(typeScope, _function);
  return super.createTextApplier(context, scope, qualifiedNameConverter, valueConverter);
}
 
Example #6
Source File: ImportedNamespaceAwareLocalScopeProvider.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public ImportedNamespaceAwareLocalScopeProvider(IGlobalScopeProvider globalScopeProvider,
		IQualifiedNameProvider qualifiedNameProvider, IQualifiedNameConverter qualifiedNameConverter,
		ICaseInsensitivityHelper caseInsensitivityHelper) {
	super(globalScopeProvider, caseInsensitivityHelper);
	this.qualifiedNameProvider = qualifiedNameProvider;
	this.qualifiedNameConverter = qualifiedNameConverter;
}
 
Example #7
Source File: ImportingTypesProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public FQNImporter(Resource context, ITextViewer viewer, IScope scope,
		IQualifiedNameConverter qualifiedNameConverter, IValueConverter<String> valueConverter, 
		RewritableImportSection.Factory importSectionFactory,
		ReplaceConverter replaceConverter) {
	super(context, scope, qualifiedNameConverter, valueConverter);
	this.viewer = viewer;
	this.importSectionFactory = importSectionFactory;
	this.replaceConverter = replaceConverter;
}
 
Example #8
Source File: ImportingTypesProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected IReplacementTextApplier createTextApplier(ContentAssistContext context, IScope typeScope,
		IQualifiedNameConverter qualifiedNameConverter, IValueConverter<String> valueConverter) {
	if (EcoreUtil2.getContainerOfType(context.getCurrentModel(), XImportSection.class) != null)
		return null;
	return new FQNImporter(context.getResource(), context.getViewer(), typeScope, qualifiedNameConverter,
			valueConverter, importSectionFactory, replaceConverter);
}
 
Example #9
Source File: ImportedNamespaceAwareLocalScopeProviderTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	with(new IndexTestLanguageStandaloneSetup());

	globalScopeProvider = new ResourceSetGlobalScopeProvider();
	nameProvider = new DefaultDeclarativeQualifiedNameProvider();
	nameConverter = new IQualifiedNameConverter.DefaultImpl();
	final DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy();
	strategy.setQualifiedNameProvider(nameProvider);
	final DefaultResourceDescriptionManager resourceDescMnr = new DefaultResourceDescriptionManager() {
		@Override
		public IResourceDescription getResourceDescription(Resource resource) {
			DefaultResourceDescription resourceDescription = new DefaultResourceDescription(resource,
					strategy);
			return resourceDescription;
		}
		
	};
	final DefaultResourceServiceProvider provider = new DefaultResourceServiceProvider() {
		@Override
		public Manager getResourceDescriptionManager() {
			return resourceDescMnr;
		}
	};
	globalScopeProvider.setGlobalResourceDecriptionProvider(new GlobalResourceDescriptionProvider(new ResourceServiceProviderRegistryImpl() {
		@Override
		public IResourceServiceProvider getResourceServiceProvider(URI uri, String contentType) {
			return provider;
		}
	}));
	CaseInsensitivityHelper caseInsensitivityHelper = new CaseInsensitivityHelper();
	globalScopeProvider.setCaseInsensitivityHelper(caseInsensitivityHelper);
	scopeProvider = new ImportedNamespaceAwareLocalScopeProvider(globalScopeProvider, nameProvider, nameConverter, caseInsensitivityHelper);
}
 
Example #10
Source File: FQNPrefixMatcher.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public String getDelimiter() {
	if (qualifiedNameConverter instanceof IQualifiedNameConverter.DefaultImpl) {
		return ((IQualifiedNameConverter.DefaultImpl) qualifiedNameConverter).getDelimiter();
	} else {
		return ".";
	}
}
 
Example #11
Source File: AbstractJavaBasedContentProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.1
 */
public DefaultProposalCreator(ContentAssistContext contentAssistContext, String ruleName,
		IQualifiedNameConverter qualifiedNameConverter) {
	this.contentAssistContext = contentAssistContext;
	this.ruleName = ruleName;
	this.qualifiedNameConverter = qualifiedNameConverter;
	if (this.ruleName != null && getValueConverter() instanceof IValueConverterService.Introspectable) {
		this.valueConverter = ((IValueConverterService.Introspectable)getValueConverter()).getConverter(ruleName);
	} else {
		this.valueConverter = null;
	}
}
 
Example #12
Source File: JdtBasedConstructorScopeTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	projectProvider = new MockJavaProjectProvider();
	factory = new JdtTypeProviderFactory(projectProvider);
	resourceSet = new ResourceSetImpl();
	typeScope = new JdtBasedSimpleTypeScope(factory.createTypeProvider(resourceSet), new IQualifiedNameConverter.DefaultImpl(),Predicates.<IEObjectDescription>alwaysTrue());
	constructorScope = new JdtBasedConstructorScope(typeScope);
}
 
Example #13
Source File: JdtBasedSimpleTypeScopeTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	projectProvider = new MockJavaProjectProvider();
	factory = new JdtTypeProviderFactory(projectProvider);
	resourceSet = new ResourceSetImpl();
	typeScope = new JdtBasedSimpleTypeScope(factory.createTypeProvider(resourceSet), new IQualifiedNameConverter.DefaultImpl(),Predicates.<IEObjectDescription>alwaysTrue());
}
 
Example #14
Source File: IsInScopeWithOptionalPositionPredicate.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
public IsInScopeWithOptionalPositionPredicate(IQualifiedNameConverter converter, URI currentURI,
		boolean withLineNumber, IScope scope) {
	super();
	this.converter = converter;
	this.scope = scope;
	this.currentURI = currentURI;
	this.withLineNumber = withLineNumber;
}
 
Example #15
Source File: AbstractTypeScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected AbstractTypeScope(IJvmTypeProvider typeProvider, IQualifiedNameConverter qualifiedNameConverter,
		Predicate<IEObjectDescription> filter) {
	super(IScope.NULLSCOPE, false);
	this.typeProvider = typeProvider;
	this.qualifiedNameConverter = qualifiedNameConverter;
	this.filter = filter;
}
 
Example #16
Source File: GamlRuntimeModule.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void configure(final Binder binder) {
	super.configure(binder);
	staticInitialize();
	// binder.bind(ExpressionDescriptionBuilder.class);
	// binder.bind(IDocManager.class).to(GamlResourceDocumenter.class);
	// binder.bind(GamlSyntacticConverter.class);
	binder.bind(IDefaultResourceDescriptionStrategy.class).to(GamlResourceDescriptionStrategy.class);
	binder.bind(IQualifiedNameConverter.class).to(GamlNameConverter.class);
	binder.bind(IResourceDescription.Manager.class).to(GamlResourceDescriptionManager.class);
	// binder.bind(IOutputConfigurationProvider.class).to(GamlOutputConfigurationProvider.class);
	binder.bind(IResourceValidator.class).to(GamlResourceValidator.class);
	binder.bind(ErrorToDiagnoticTranslator.class);

}
 
Example #17
Source File: AbstractConstructorScopeTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testGetElementByInstance_01() {
	JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor();
	JvmGenericType type = TypesFactory.eINSTANCE.createJvmGenericType();
	type.setPackageName("java.lang");
	type.setSimpleName("Object");
	constructor.setSimpleName("Object");
	type.getMembers().add(constructor);
	IEObjectDescription element = getConstructorScope().getSingleElement(constructor);
	assertNotNull(element);
	assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getName());
	assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getQualifiedName());
}
 
Example #18
Source File: ClasspathBasedConstructorScopeTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	factory = new ClasspathTypeProviderFactory(getClass().getClassLoader(), null);
	resourceSet = new ResourceSetImpl();
	typeScope = new ClasspathBasedTypeScope(factory.createTypeProvider(resourceSet), new IQualifiedNameConverter.DefaultImpl(), Predicates.<IEObjectDescription>alwaysTrue());
	constructorScope = new ClasspathBasedConstructorScope(typeScope);
}
 
Example #19
Source File: SARLQuickfixProvider.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
public IQualifiedNameConverter getQualifiedNameConverter() {
	return super.getQualifiedNameConverter();
}
 
Example #20
Source File: AbstractExtraLanguageGenerator.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Change the converter of qualified name.
 *
 * @param converter the converter.
 */
@Inject
public void setQualifiedNameConverter(IQualifiedNameConverter converter) {
	this.qualifiedNameConverter = converter;
}
 
Example #21
Source File: RecordingTypeScope.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public RecordingTypeScope(AbstractTypeScope typeScope, Set<QualifiedName> importedNames, IQualifiedNameConverter qnc) {
	super(null, qnc, null);
	this.typeScope = typeScope;
	this.importedNames = importedNames;
}
 
Example #22
Source File: LocalResourceFilteringTypeScope.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IQualifiedNameConverter getQualifiedNameConverter() {
	return delegate.getQualifiedNameConverter();
}
 
Example #23
Source File: XtendResourceDescription.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public XtendResourceDescription(final Resource resource, final IDefaultResourceDescriptionStrategy strategy, final IResourceScopeCache cache, final IBatchTypeResolver typeResolver, final IQualifiedNameConverter nameConverter) {
  super(resource, strategy, cache);
  this.typeResolver = typeResolver;
  this.nameConverter = nameConverter;
}
 
Example #24
Source File: CompilationUnitImpl.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Pure
public IQualifiedNameConverter getQualifiedNameConverter() {
  return this.qualifiedNameConverter;
}
 
Example #25
Source File: AbstractSARLRuntimeModule.java    From sarl with Apache License 2.0 4 votes vote down vote up
public Class<? extends IQualifiedNameConverter> bindIQualifiedNameConverter() {
	return SARLQualifiedNameConverter.class;
}
 
Example #26
Source File: ImportedNamespaceAwareLocalScopeProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.10
 */
public IQualifiedNameConverter getQualifiedNameConverter() {
	return qualifiedNameConverter;
}
 
Example #27
Source File: IdeContentProposalProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected IQualifiedNameConverter getQualifiedNameConverter() {
	return qualifiedNameConverter;
}
 
Example #28
Source File: XtxtUMLReferenceProposalTypeScope.java    From txtUML with Eclipse Public License 1.0 4 votes vote down vote up
public XtxtUMLReferenceProposalTypeScope(IJdtTypeProvider typeProvider,
		IQualifiedNameConverter qualifiedNameConverter, Predicate<IEObjectDescription> filter) {
	super(typeProvider, qualifiedNameConverter, filter);
}
 
Example #29
Source File: PartialLinkingTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	with(ReferenceGrammarTestLanguageStandaloneSetup.class);
	IQualifiedNameConverter nameConverter = new IQualifiedNameConverter.DefaultImpl();
	IQualifiedNameProvider nameProvider = new DefaultDeclarativeQualifiedNameProvider();
	ImportUriGlobalScopeProvider globalScopeProvider = new ImportUriGlobalScopeProvider();
	globalScopeProvider.setImportResolver(new ImportUriResolver());
	globalScopeProvider.setCache(IResourceScopeCache.NullImpl.INSTANCE);
	final ResourceDescriptionsProvider provider = new ResourceDescriptionsProvider();
	provider.setResourceDescriptions(new Provider<IResourceDescriptions>() {
		@Override
		public IResourceDescriptions get() {
			return new IResourceDescriptions.NullImpl();
		}
	});
	globalScopeProvider.setResourceDescriptionsProvider(provider);
	globalScopeProvider.setLoadOnDemandDescriptions(new Provider<LoadOnDemandResourceDescriptions>() {
		@Override
		public LoadOnDemandResourceDescriptions get() {
			return PartialLinkingTest.this.get(LoadOnDemandResourceDescriptions.class);
		}
	});
	CaseInsensitivityHelper caseInsensitivityHelper = new CaseInsensitivityHelper();
	globalScopeProvider.setCaseInsensitivityHelper(caseInsensitivityHelper);
	scopeProvider = new ImportedNamespaceAwareLocalScopeProvider(globalScopeProvider, nameProvider, nameConverter, caseInsensitivityHelper);
	modelAsText =
		"spielplatz 1 {\n" +
		"  kind( Bommel1 1)\n" +
		"  kind( Bommel2 2)\n" +
		"  kind( Bommel3 3)\n" +
		"  erwachsener( Bob 4)\n" +
		"  erwachsener( Joe 5)\n" +
		"  familie( Familienname Bob Joe Bommel2 )\n" +
		"}";
	resource = getResourceFromString(modelAsText);
	assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
	model = resource.getParseResult().getRootASTElement();
	final Iterator<EObject> iter = model.eAllContents();
	while (iter.hasNext() && context == null) {
		final EObject candidate = iter.next();
		final String className = candidate.eClass().getName();
		if (className.endsWith("Familie"))
			context = candidate;
	}
	reference = (EReference) context.eClass().getEStructuralFeature("kinder");
}
 
Example #30
Source File: IdeCrossrefProposalProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected IQualifiedNameConverter getQualifiedNameConverter() {
	return qualifiedNameConverter;
}