org.eclipse.xtext.xbase.imports.TypeUsages Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.imports.TypeUsages.
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: XbaseReferenceUpdater.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public boolean isUsed(JvmDeclaredType type, boolean isStatic, boolean isExtension, String memberName) { if (!isStatic) { return false; } Iterator<JvmFeature> allFeatures = staticallyImportedMemberProvider.getAllFeatures(resource, type, isStatic, isExtension, memberName).iterator(); if (!allFeatures.hasNext()) { return false; } TypeUsages typeUsages = getTypeUsages(); while (allFeatures.hasNext()) { JvmFeature feature = allFeatures.next(); if (typeUsages.getStaticImports().contains(feature) || typeUsages.getExtensionImports().contains(feature)) { return true; } } return false; }
Example #2
Source File: InteractiveUnresolvedTypeResolver.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void resolve(TypeUsages typeUsages, XtextResource resource) { if(typeUsages.getUnresolvedTypeUsages().isEmpty() || resource == null) return; Multimap<String, TypeUsage> name2usage = LinkedHashMultimap.create(); for (TypeUsage unresolved : typeUsages.getUnresolvedTypeUsages()) { String text = unresolved.getUsedTypeName(); text = nameValueConverter.toValue(text, null); name2usage.put(text, unresolved); } for (String name : name2usage.keySet()) { Iterable<TypeUsage> usages = name2usage.get(name); JvmDeclaredType resolvedType = resolve(name, usages, resource); if (resolvedType != null) { for (TypeUsage usage : usages) typeUsages.addTypeUsage( resolvedType, usage.getSuffix(), usage.getTextRegion(), usage.getContext()); } } }
Example #3
Source File: XbaseReferenceUpdater.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public boolean isConflicted(JvmDeclaredType type, boolean isStatic, boolean isExtension, String memberName) { if (!isStatic || memberName == null) { return false; } if (importSection.hasStaticImport(memberName, isExtension)) { return true; } TypeUsages typeUsages = getTypeUsages(); if (isExtension) { if (!contains(type, memberName, typeUsages.getStaticImports())) { return false; } } return isConflicted(type, memberName, typeUsages.getStaticImports()); }
Example #4
Source File: TypeUsageCollectorTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private void hasUnresolvedType(final Resource resource, final String... typeNames) { final TypeUsages typeUsages = this.typeUsageCollector.collectTypeUsages(((XtextResource) resource)); final Function1<TypeUsage, String> _function = (TypeUsage it) -> { return it.getUsedTypeName(); }; final Set<String> usedNames = IterableExtensions.<String>toSet(ListExtensions.<TypeUsage, String>map(typeUsages.getUnresolvedTypeUsages(), _function)); Assert.assertEquals(IterableExtensions.<String>toSet(((Iterable<String>)Conversions.doWrapArray(typeNames))), usedNames); }
Example #5
Source File: TypeUsageCollectorTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private void hasUnresolvedTypeSuffix(final CharSequence xtendFile, final String... suffix) { try { final Resource resource = this.file(xtendFile.toString()).eResource(); final TypeUsages typeUsages = this.typeUsageCollector.collectTypeUsages(((XtextResource) resource)); final Function1<TypeUsage, String> _function = (TypeUsage it) -> { return it.getSuffix(); }; final Set<String> foundSuffix = IterableExtensions.<String>toSet(ListExtensions.<TypeUsage, String>map(typeUsages.getUnresolvedTypeUsages(), _function)); Assert.assertEquals(IterableExtensions.<String>toSet(((Iterable<String>)Conversions.doWrapArray(suffix))), foundSuffix); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #6
Source File: XbaseReferenceUpdater.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public TypeUsages getTypeUsages() { if (typeUsages == null) { typeUsages = importedTypesCollector.collectTypeUsages(resource); } return typeUsages; }