public ActualTypeArgumentCollector(Collection<JvmTypeParameter> parametersToBeMapped, BoundTypeArgumentSource defaultSource, ITypeReferenceOwner owner) { super(owner); this.parametersToBeMapped = parametersToBeMapped; this.defaultSource = defaultSource; typeParameterMapping = Maps2.newLinkedHashMapWithExpectedSize(parametersToBeMapped.size()); }
/** * Creates a {@code LinkedHashMap} instance, with a high enough "initial capacity" that it <i>should</i> hold * {@code expectedSize} elements without growth. This behavior cannot be broadly guaranteed, but it is observed to * be true for OpenJDK 1.6. It also can't be guaranteed that the method isn't inadvertently <i>oversizing</i> the * returned map. * * @param expectedSize * the number of elements you expect to add to the returned map * @return a new, empty {@code LinkedHashMap} with enough capacity to hold {@code expectedSize} elements without resizing * @throws IllegalArgumentException * if {@code expectedSize} is negative */ public static <K, V> LinkedHashMap<K, V> newLinkedHashMapWithExpectedSize(int expectedSize) { return new LinkedHashMap<K, V>(capacity(expectedSize)) { private static final long serialVersionUID = 1L; @Override public void clear() { if (isEmpty()) return; super.clear(); } }; }
protected void acceptType(XExpression expression, TypeData typeData) { Maps2.putIntoListMap(expression, typeData, ensureExpressionTypesMapExists()); }
public RewritableImportSection(XtextResource resource, IImportsConfiguration importsConfiguration, XImportSection originalImportSection, String lineSeparator, ImportSectionRegionUtil regionUtil, IValueConverter<String> nameConverter) { this.importsConfiguration = importsConfiguration; this.resource = resource; this.lineSeparator = lineSeparator; this.regionUtil = regionUtil; this.nameValueConverter = nameConverter; this.implicitlyImportedPackages = importsConfiguration.getImplicitlyImportedPackages(resource); this.importRegion = regionUtil.computeRegion(resource); if (originalImportSection != null) { for (XImportDeclaration originalImportDeclaration : originalImportSection.getImportDeclarations()) { this.originalImportDeclarations.add(originalImportDeclaration); JvmDeclaredType importedType = originalImportDeclaration.getImportedType(); if (originalImportDeclaration.isStatic()) { String memberName = originalImportDeclaration.getMemberName(); if (originalImportDeclaration.isExtension()) { Maps2.putIntoSetMap(importedType, memberName, staticExtensionImports); } else { Maps2.putIntoSetMap(importedType, memberName, staticImports); } } else if (importedType != null) { Maps2.putIntoListMap(importedType.getSimpleName(), importedType, plainImports); } } } }
LightweightTypeReference resolvedConstraint = lightweightReference.accept( substitutor, substitutor.createVisiting(pendingParameter)); Maps2.putIntoListMap(pendingParameter, boundByConstraint(resolvedConstraint, pendingParameter), result); } else { LightweightTypeReference lightweightReference = getOwner().newReferenceToObject(); Maps2.putIntoListMap(pendingParameter, boundByConstraint(lightweightReference, pendingParameter), result); Maps2.putAllIntoListMap(pendingParameter, result.get(constraintType), result);
@Override public void importStaticExtension(JvmDeclaredType type, String memberName, boolean strict) { Maps2.putIntoSetMap(type, memberName, namedStaticExtensionImports); if (!strict) { Maps2.putIntoSetMap(type, memberName, bogusNamedStaticExtensionImports); } }
@Override public void importStatic(JvmDeclaredType type, String memberName) { Maps2.putIntoSetMap(type, memberName, namedStaticImports); }
@Override public void addExtensionsToCurrentScope(List<? extends JvmIdentifiableElement> extensionProviders) { if (extensionProviders.isEmpty()) return; if (extensionProviders.size() == 1) { addExtensionToCurrentScope(extensionProviders.get(0)); return; } Map<XExpression, LightweightTypeReference> prototypeToType = Maps2.newLinkedHashMapWithExpectedSize(extensionProviders.size()); for(JvmIdentifiableElement extensionProvider: extensionProviders) { LightweightTypeReference knownType = getResolvedTypes().getActualType(extensionProvider); if (knownType != null && !knownType.isAny() && !knownType.isUnknown()) { XFeatureCall prototype = getResolver().getXbaseFactory().createXFeatureCall(); prototype.setFeature(extensionProvider); prototypeToType.put(prototype, knownType); } } if (!prototypeToType.isEmpty()) featureScopeSession = featureScopeSession.addToExtensionScope(prototypeToType); }
@Override protected void processTypeParameter(JvmTypeParameter typeParameter, LightweightTypeReference reference) { Maps2.putIntoListMap(typeParameter, boundByDefaultSource(reference), typeParameterMapping); }
public boolean addStaticImport(JvmDeclaredType type, String memberName) { if (hasStaticImport(staticImports, type, memberName)) { return false; } Maps2.putIntoSetMap(type, memberName, staticImports); XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration(); importDeclaration.setImportedType(type); importDeclaration.setStatic(true); if (memberName == null) { importDeclaration.setWildcard(true); } else { importDeclaration.setMemberName(memberName); } addedImportDeclarations.add(importDeclaration); return true; }
if (featureScopeSession.isVisible(field) && seenNames.add(field.getSimpleName()) && isExtensionProvider(field)) { if (extensionProviders == null) { extensionProviders = Maps2.newLinkedHashMapWithExpectedSize(3);
public boolean addImport(JvmDeclaredType type) { if (plainImports.containsKey(type.getSimpleName()) || !needsImport(type)) return false; Maps2.putIntoListMap(type.getSimpleName(), type, plainImports); XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration(); importDeclaration.setImportedType(type); addedImportDeclarations.add(importDeclaration); return true; }
public boolean addStaticExtensionImport(JvmDeclaredType type, String memberName) { if (hasStaticImport(staticExtensionImports, type, memberName)) { return false; } Maps2.putIntoSetMap(type, memberName, staticExtensionImports); XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration(); importDeclaration.setImportedType(type); importDeclaration.setStatic(true); importDeclaration.setExtension(true); if (memberName == null) { importDeclaration.setWildcard(true); } else { importDeclaration.setMemberName(memberName); } addedImportDeclarations.add(importDeclaration); return true; }
List<LightweightTypeReference> explicitTypeArguments = getSyntacticTypeArguments(); int size = Math.min(declaredTypeParameters.size(), explicitTypeArguments.size()); typeParameterMapping = Maps2.newLinkedHashMapWithExpectedSize(size); for(int i = 0; i < size; i++) { JvmTypeParameter declaredTypeParameter = declaredTypeParameters.get(i);
Maps2.putIntoListMap(getExtensionSignature(desc), desc, extensionSignatures); } else { if (desc.getImplicitReceiver() != null) { Maps2.putIntoListMap(valid.getName(), valid, allElementsByName);
if (featureScopeSession.isVisible(field) && seenNames.add(field.getSimpleName()) && isExtensionProvider(field)) { if (extensionProviders == null) { extensionProviders = Maps2.newLinkedHashMapWithExpectedSize(3);
Maps2.putIntoListMap(otherHandle, copyBoundTypeArgument(currentUnbound, boundTypeArgument), ensureTypeParameterHintsMapExists()); Maps2.putIntoListMap(handle, boundTypeArgument, ensureTypeParameterHintsMapExists()); } else { throw new IllegalStateException("Cannot add hints if the reference was already resolved");