public void update() { XImportSection importSection = importsConfiguration.getImportSection(resource); if (importSection == null && importsConfiguration instanceof IMutableImportsConfiguration) { importSection = XtypeFactory.eINSTANCE.createXImportSection(); IMutableImportsConfiguration mutableImportsConfiguration = (IMutableImportsConfiguration) importsConfiguration; mutableImportsConfiguration.setImportSection(resource, importSection); } if (importSection == null) { return; } removeObsoleteStaticImports(); List<XImportDeclaration> allImportDeclarations = newArrayList(); allImportDeclarations.addAll(originalImportDeclarations); allImportDeclarations.addAll(addedImportDeclarations); allImportDeclarations.removeAll(removedImportDeclarations); List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations(); importDeclarations.clear(); importDeclarations.addAll(allImportDeclarations); }
protected void checkConflicts(XImportSection importSection, final Map<String, List<XImportDeclaration>> imports, final Map<String, JvmType> importedNames) { for (JvmDeclaredType declaredType : importsConfiguration.getLocallyDefinedTypes((XtextResource)importSection.eResource())) { if(importedNames.containsKey(declaredType.getSimpleName())){ JvmType importedType = importedNames.get(declaredType.getSimpleName()); if (importedType != declaredType && importedType.eResource() != importSection.eResource()) { List<XImportDeclaration> list = imports.get(importedType.getIdentifier()); if (list != null) { for (XImportDeclaration importDeclaration: list ) { error("The import '" + importedType.getIdentifier() + "' conflicts with a type defined in the same file", importDeclaration, null, IssueCodes.IMPORT_CONFLICT); } } } } } }
@Check public void checkImports(XImportSection importSection) { if (importSection.getImportDeclarations().isEmpty()) { return; checkConflicts(importSection, imports, importedNames); if (!isIgnored(IMPORT_UNUSED)) { XtextResource xtextResource = (XtextResource) importSection.eResource();
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 ITextRegion computeRegion(XtextResource resource) { XImportSection xImportSection = config.getImportSection(resource); // try to obtain the region from the text if it is not a synthetic region. if (xImportSection != null && xImportSection.eResource() != null) { INode node = NodeModelUtils.findActualNodeFor(xImportSection); if(node == null) LOG.error("Cannot detect node for original import section"); else return node.getTextRegion(); } return new TextRegion(config.getImportSectionOffset(resource), 0); }
protected void _format(final XImportSection section, @Extension final IFormattableDocument format) { EList<XImportDeclaration> _importDeclarations = section.getImportDeclarations(); for (final XImportDeclaration imp : _importDeclarations) { { format.<XImportDeclaration>format(imp); XImportDeclaration _last = IterableExtensions.<XImportDeclaration>last(section.getImportDeclarations()); boolean _notEquals = (!Objects.equal(imp, _last)); if (_notEquals) { format.<XImportDeclaration>append(imp, XbaseFormatterPreferenceKeys.blankLinesBetweenImports); } else { format.<XImportDeclaration>append(imp, XbaseFormatterPreferenceKeys.blankLinesAfterImports); } } } }
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 Iterable<XImportDeclaration> getEnumImports(final EObject eObject) { EObject _rootContainer = EcoreUtil2.getRootContainer(eObject); final AmlModel rootElement = ((AmlModel) _rootContainer); final XImportSection importSection = rootElement.getImportSection(); if ((importSection != null)) { final Function1<XImportDeclaration, Boolean> _function = (XImportDeclaration it) -> { JvmDeclaredType _importedType = it.getImportedType(); return Boolean.valueOf((_importedType instanceof JvmEnumerationType)); }; return IterableExtensions.<XImportDeclaration>filter(rootElement.getImportSection().getImportDeclarations(), _function); } else { return Collections.<XImportDeclaration>unmodifiableList(CollectionLiterals.<XImportDeclaration>newArrayList()); } }
private AbstractScope getImportScope(XImportSection importSection, AbstractScope parent, RecordingTypeScope typeScope) { if (importSection == null) return parent; List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations(); if (importDeclarations.isEmpty()) { return parent;
protected void populateMaps(XImportSection importSection, final Map<String, List<XImportDeclaration>> imports, final Map<String, List<XImportDeclaration>> staticImports, final Map<String, List<XImportDeclaration>> extensionImports, 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);
XImportSection importSection = getScript().getImportSection(); if (importSection != null) { for (XImportDeclaration decl : importSection.getImportDeclarations()) { concreteImports.addImportFor(decl.getImportedType()); getScript().setImportSection(importSection); importSection.getImportDeclarations().add(declaration);
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); } } } }
XImportSection importSection = importsConfiguration.getImportSection((XtextResource) resource); if (importSection != null) { List<XImportDeclaration> importDeclarations = importSection.getImportDeclarations(); List<IEObjectDescription> descriptions = Lists.newArrayList(); for(XImportDeclaration importDeclaration: importDeclarations) {
@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()); } } } } }
final XImportSection section = this.importSectionLocator.getImportSection(((XtextResource) _eResource_1)); if ((section != null)) { EList<XImportDeclaration> _importDeclarations = section.getImportDeclarations(); for (final XImportDeclaration imp : _importDeclarations) { boolean _isStatic = imp.isStatic();