protected XImportDeclaration createImport(String importedNamespace, final String member) { XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration(); importDeclaration.setImportedNamespace(importedNamespace); if (member != null) { importDeclaration.setMemberName(member); } return importDeclaration; }
public static boolean isInferred(JvmTypeReference typeReference) { if (typeReference instanceof XComputedTypeReference) { IJvmTypeReferenceProvider typeProvider = ((XComputedTypeReference) typeReference).getTypeProvider(); if (typeProvider instanceof InferredTypeIndicator && !((InferredTypeIndicator)typeProvider).resolved) { return true; } } return false; }
@Override public boolean apply(XImportDeclaration input) { return !input.isStatic(); } }), false);
@Override public void doAddImports(ITypeImporter importer) { List<XImportDeclaration> imports = importSection.getImportDeclarations(); for(XImportDeclaration _import: imports) { if (_import.isStatic()) { if (_import.isWildcard()) { if (_import.isExtension()) { importer.importStaticExtension(_import.getImportedType(), false); } else { importer.importStatic(_import.getImportedType()); } } else { if (_import.isExtension()) { importer.importStaticExtension(_import.getImportedType(), _import.getMemberName(), false); } else { importer.importStatic(_import.getImportedType(), _import.getMemberName()); } } } } }
public Iterable<JvmFeature> getAllFeatures(final XImportDeclaration it) { return this.getAllFeatures(it.eResource(), it.getImportedType(), it.isStatic(), it.isExtension(), it.getMemberName()); }
protected List<ImportNormalizer> getImportedNamespaceResolvers(XImportSection importSection, boolean ignoreCase) { List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations(); List<ImportNormalizer> result = Lists.newArrayListWithExpectedSize(importDeclarations.size()); for (XImportDeclaration imp: importDeclarations) { if (!imp.isStatic()) { String value = imp.getImportedNamespace(); if(value == null) value = imp.getImportedTypeName(); ImportNormalizer resolver = createImportedNamespaceResolver(value, ignoreCase); if (resolver != null) result.add(resolver); } } return result; }
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; }
/** * Produces an inferred type which will be resolved on demand. It should not be attempted to resolve * this type during the model inference. * * @return an inferred type. */ public JvmTypeReference inferredType() { XComputedTypeReference result = xtypesFactory.createXComputedTypeReference(); result.setTypeProvider(new InferredTypeIndicator(null)); return result; }
@Check public void checkDeprecated(XImportDeclaration decl) { if (!isIgnored(DEPRECATED_MEMBER_REFERENCE)) { JvmType jvmType = decl.getImportedType(); checkDeprecated( jvmType, decl, XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE); } }
@Override public boolean apply(XImportDeclaration input) { return input.isStatic() && !input.isExtension(); } }), needNewline);
protected AbstractDemandTypeReferenceProvider getComputedTypeReference(JvmTypeReference knownType) { if (InferredTypeIndicator.isInferred(knownType)) { XComputedTypeReference casted = (XComputedTypeReference) knownType; JvmTypeReference equivalent = casted.getEquivalent(); if (equivalent instanceof XComputedTypeReference) { IJvmTypeReferenceProvider typeProvider = ((XComputedTypeReference) equivalent).getTypeProvider(); if (typeProvider instanceof AbstractDemandTypeReferenceProvider) { return (AbstractDemandTypeReferenceProvider) typeProvider; } } } return null; }
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; }
@Override public void accept(JvmTypeReference capturingTypeReference) { casted.setEquivalent(capturingTypeReference); inferAnonymousClassConstructor(anonymousClass, localClass); } });
@Override public boolean apply(XImportDeclaration in) { return !isEmpty(in.getImportedTypeName()); } }));
@Override public int compare(XImportDeclaration o1, XImportDeclaration o2) { return o1.getImportedName().compareTo(o2.getImportedName()); } });
@Override protected Object beforeSaveEObject(final InternalEObject object, final BinaryResourceImpl.EObjectOutputStream writable) throws IOException { JvmType _xblockexpression = null; { super.beforeSaveEObject(object, writable); JvmType _xifexpression = null; if ((object instanceof XComputedTypeReference)) { _xifexpression = ((XComputedTypeReference)object).getType(); } _xblockexpression = _xifexpression; } return _xblockexpression; }
/** * Produces an inferred type which will be resolved on demand. It should not be attempted to resolve * this type during the model inference. * * @param expression the expression that will be used resolve the type. May not be <code>null</code>. * @return an inferred type. */ public JvmTypeReference inferredType(XExpression expression) { Preconditions.checkNotNull(expression); XComputedTypeReference result = xtypesFactory.createXComputedTypeReference(); result.setTypeProvider(new InferredTypeIndicator(expression)); return result; }
@Override public boolean apply(XImportDeclaration input) { return input.isStatic() && input.isExtension(); } }), needNewline);
protected void requestCapturedLocalVariables(JvmTypeReference toBeWrapped, JvmDeclaredType type, ResolvedTypes resolvedTypes, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext, IAcceptor<JvmTypeReference> result) { LocalVariableCapturerImpl capturer = new LocalVariableCapturerImpl(toBeWrapped, type, this, resolvedTypes, resolvedTypesByContext); XComputedTypeReference ref = getServices().getXtypeFactory().createXComputedTypeReference(); ref.setTypeProvider(capturer); result.accept(ref); capturer.awaitCapturing(); } }
@Override public JvmTypeReference toTypeReference() { if (internalGetResolvedTo() != null) { return resolvedTo.toTypeReference(); } XComputedTypeReference result = getServices().getXtypeFactory().createXComputedTypeReference(); result.setTypeProvider(new UnboundTypeReferenceResolver(this)); return result; }