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; }
private boolean hasStaticImport(String typeName, String memberName, boolean extension) { for (String string : implicitlyImportedPackages) { if (typeName.startsWith(string)) { return typeName.substring(string.length()).lastIndexOf('.') == 0; } } Map<JvmDeclaredType, Set<String>> imports = staticImports; if (extension) { imports = staticExtensionImports; } for (JvmDeclaredType type : imports.keySet()) { if (typeName.equals(type.getIdentifier())) { Set<String> members = imports.get(type); return members != null && ((members.contains(memberName) || members.contains(null))); } } for (XImportDeclaration importDeclr : addedImportDeclarations) { String identifier = importDeclr.getImportedTypeName(); if (importDeclr.isStatic() && typeName.equals(identifier)) { if (Objects.equal(importDeclr.getMemberName(), memberName) || importDeclr.isWildcard() || "*".equals(importDeclr.getMemberName())) { return true; } } } return false; }
@Override public boolean apply(XImportDeclaration input) { return input.isStatic() && !input.isExtension(); } }), needNewline);
protected boolean needsImport(final String fqn) { for (String string : implicitlyImportedPackages) { if (fqn.startsWith(string)) { return fqn.substring(string.length() + 1).lastIndexOf('.') > 0; } } for (XImportDeclaration importDeclr : originalImportDeclarations) { if (!importDeclr.isStatic() && fqn.equals(importDeclr.getImportedTypeName())) { return false; } } for (XImportDeclaration importDeclr : addedImportDeclarations) { String identifier = importDeclr.getImportedTypeName(); if (!importDeclr.isStatic() && fqn.equals(identifier)) { return false; } } return true; }
final Map<String, JvmType> importedNames) { for (XImportDeclaration imp : importSection.getImportDeclarations()) { if (imp.getImportedNamespace() != null) { addIssue("The use of wildcard imports is deprecated.", imp, IMPORT_WILDCARD_DEPRECATED); continue; JvmType importedType = imp.getImportedType(); if (importedType == null || importedType.eIsProxy()) { continue; Map<String, List<XImportDeclaration>> map = imp.isStatic() ? (imp.isExtension() ? extensionImports : staticImports) : imports; List<XImportDeclaration> list = map.get(importedType.getIdentifier()); if (list != null) { map.put(importedType.getIdentifier(), list); if (!imp.isStatic()) { JvmType currentType = importedType; String currentSuffix = currentType.getSimpleName(); + collidingImport2.getIdentifier() + "'.", imp, null, IssueCodes.IMPORT_COLLISION); } else if (!imp.isWildcard()) { Iterable<JvmFeature> allFeatures = staticallyImportedMemberProvider.getAllFeatures(imp); if (!allFeatures.iterator().hasNext()) { addIssue("The import " + imp.getImportedName() + " cannot be resolved.", imp, IMPORT_UNRESOLVED); continue;
boolean hasLegacyImport = false; for(XImportDeclaration importDeclaration: importDeclarations) { if (!importDeclaration.isStatic()) { if (importDeclaration.isWildcard()) { if (wildcardImports == null) { wildcardImports = Lists.newArrayListWithCapacity(4); String importedNamespace = importDeclaration.getImportedNamespace(); importedNamespace = importedNamespace.substring(0, importedNamespace.length() - 2); QualifiedName qualifiedImportedNamespace = qualifiedNameConverter.toQualifiedName(importedNamespace); wildcardImports.add(AbstractNestedTypeAwareImportNormalizer.createNestedTypeAwareImportNormalizer(qualifiedImportedNamespace, true, false)); } else { JvmDeclaredType importedType = importDeclaration.getImportedType(); if (importedType != null && !importedType.eIsProxy()) { if (concreteImports == null || importedNames == null /* to make JDT happy */) {
/** Check that import mapping are known. * * @param importDeclaration the declaration. */ @Check public void checkImportsMapping(XImportDeclaration importDeclaration) { final JvmDeclaredType type = importDeclaration.getImportedType(); doTypeMappingCheck(importDeclaration, type, this.typeErrorHandler1); }
if (importSection != null) { for (XImportDeclaration decl : importSection.getImportDeclarations()) { concreteImports.addImportFor(decl.getImportedType()); if (concreteImports.addImportFor(type) && type instanceof JvmDeclaredType) { XImportDeclaration declaration = XtypeFactory.eINSTANCE.createXImportDeclaration(); declaration.setImportedType((JvmDeclaredType) type); if (importSection == null) { importSection = XtypeFactory.eINSTANCE.createXImportSection();
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; }
boolean _matched_1 = false; if (sourceCandidate instanceof XImportDeclaration) { if ((((XImportDeclaration)sourceCandidate).isStatic() && (!((XImportDeclaration)sourceCandidate).isWildcard()))) { _matched_1=true; this.addReferenceToFeatureFromStaticImport(((XImportDeclaration)sourceCandidate), targetURIs, acceptor);
@Override public boolean apply(XImportDeclaration input) { return !input.isStatic(); } }), false);
for (int i = 0; i < list.size(); i++) { XImportDeclaration staticImportDeclaration = list.get(i); if (staticImportDeclaration.isWildcard()) { if (indexToRemove == -1) { indexToRemove = i; if (Objects.equal(member.getSimpleName(), staticImportDeclaration.getMemberName())) { indexToRemove = i; break;
@Override public boolean apply(XImportDeclaration in) { return !isEmpty(in.getImportedTypeName()); } }));
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; }
protected boolean isImportDeclarationRequired(final ITypeDescriptor typeDesc, final String qualifiedName, final ContentAssistContext context, final XImportSection importSection) { return ((!(typeDesc.getName().startsWith("java.lang") && (typeDesc.getName().lastIndexOf(".") == 9))) && ((importSection == null) || (!IterableExtensions.<XImportDeclaration>exists(importSection.getImportDeclarations(), ((Function1<XImportDeclaration, Boolean>) (XImportDeclaration it) -> { JvmDeclaredType _importedType = it.getImportedType(); String _qualifiedName = null; if (_importedType!=null) { _qualifiedName=_importedType.getQualifiedName(); } return Boolean.valueOf(Objects.equal(_qualifiedName, qualifiedName)); }))))); }
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; }
EList<XImportDeclaration> _importDeclarations = section.getImportDeclarations(); for (final XImportDeclaration imp : _importDeclarations) { boolean _isStatic = imp.isStatic(); if (_isStatic) { final String importedTypeName = imp.getImportedTypeName(); if ((importedTypeName != null)) { final JvmType type = this.findTypeByName(imp, importedTypeName);
@Override public boolean apply(XImportDeclaration input) { return input.isStatic() && input.isExtension(); } }), needNewline);
public IScope getLocatorStrategyScope(final EObject eObject) { final Iterable<XImportDeclaration> enumImports = this.getEnumImports(eObject); final Function1<XImportDeclaration, Boolean> _function = (XImportDeclaration it) -> { boolean _isStatic = it.isStatic(); return Boolean.valueOf((!_isStatic)); }; final Iterable<JvmEnumerationLiteral> nonStaticImportedLiterals = this.getEnumLiterals(IterableExtensions.<XImportDeclaration>filter(enumImports, _function)); final Function<JvmEnumerationLiteral, QualifiedName> _function_1 = (JvmEnumerationLiteral it) -> { StringConcatenation _builder = new StringConcatenation(); String _simpleName = it.getDeclaringType().getSimpleName(); _builder.append(_simpleName); _builder.append("."); String _simpleName_1 = it.getSimpleName(); _builder.append(_simpleName_1); return this._iQualifiedNameConverter.toQualifiedName(_builder.toString()); }; final IScope nonStaticScope = Scopes.<JvmEnumerationLiteral>scopeFor(nonStaticImportedLiterals, _function_1, IScope.NULLSCOPE); final Function1<XImportDeclaration, Boolean> _function_2 = (XImportDeclaration it) -> { return Boolean.valueOf(it.isStatic()); }; final Iterable<JvmEnumerationLiteral> staticImportedLiterals = this.getEnumLiterals(IterableExtensions.<XImportDeclaration>filter(enumImports, _function_2)); final Function<JvmEnumerationLiteral, QualifiedName> _function_3 = (JvmEnumerationLiteral it) -> { return this._iQualifiedNameConverter.toQualifiedName(it.getSimpleName()); }; return Scopes.<JvmEnumerationLiteral>scopeFor(staticImportedLiterals, _function_3, nonStaticScope); }