public RewritableImportSection parse(XtextResource resource) { RewritableImportSection rewritableImportSection = new RewritableImportSection( resource, importsConfiguration, importsConfiguration.getImportSection(resource), whitespaceInformationProvider .getLineSeparatorInformation(resource.getURI()) .getLineSeparator(), regionUtil, nameValueConverter); return rewritableImportSection; }
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); }