InternalIdeaDependency (final IonReader reader, final ReadContext context) { if (reader.next() == null) return null; reader.stepIn(); InternalIdeaDependency dependency = context.dependenciesMap .computeIfAbsent(readInt(reader, OBJECT_ID_FIELD), new IntObjectMap.SimpleObjectFactory<InternalIdeaDependency>() { @Override public InternalIdeaDependency create() { String type = readString(reader, "_type"); if (IdeaModuleDependency.class.getSimpleName().equals(type)) { InternalIdeaModuleDependency moduleDependency = new InternalIdeaModuleDependency(); moduleDependency.setTargetModuleName(readString(reader, "targetModuleName")); moduleDependency.setScope(InternalIdeaDependencyScope.getInstance(readString(reader, "scope"))); moduleDependency.setExported(readBoolean(reader, "exported")); return moduleDependency; } else if (IdeaSingleEntryLibraryDependency.class.getSimpleName().equals(type)) { File file = assertNotNull(readFile(reader, "file")); InternalIdeaSingleEntryLibraryDependency libraryDependency = new InternalIdeaSingleEntryLibraryDependency(file); libraryDependency.setJavadoc(readFile(reader, "javadoc")); libraryDependency.setSource(readFile(reader, "source")); libraryDependency.setScope(InternalIdeaDependencyScope.getInstance(readString(reader, "scope"))); libraryDependency.setExported(readBoolean(reader, "exported")); IonType ionType = reader.next(); assertFieldName(reader, "gradleModuleVersion"); if (ionType != IonType.NULL) { reader.stepIn(); InternalGradleModuleVersion moduleVersion = new InternalGradleModuleVersion(); moduleVersion.setGroup(readString(reader, "group")); moduleVersion.setName(readString(reader, "name")); moduleVersion.setVersion(readString(reader, "version")); reader.stepOut(); libraryDependency.setModuleVersion(moduleVersion); } return libraryDependency; } else { throw new RuntimeException("Unsupported dependency '" + type + "'"); } } }); reader.stepOut(); return dependency; }