Skip to content

Instantly share code, notes, and snippets.

@brianduff
Last active September 23, 2020 03:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianduff/deaf30d1f51dc5eaee77c62921dc2334 to your computer and use it in GitHub Desktop.
Save brianduff/deaf30d1f51dc5eaee77c62921dc2334 to your computer and use it in GitHub Desktop.
type RecordIndex = i32;
type ContentIndex = i32;
type Bytes = Vec<u8>;
/// IJ has the notion of "enumerations" which are basically fast bimaps between a value of
/// arbitrary type and an integer, and support automatically adding new values which
/// get an auto-incremented integer value.
type Enumeration<A> = BiMap<A, i32>;
struct Cache {
records: Vec<Record>,
content_hashes: ContentHashes,
content: Content
}
/// A key for a content hash -> contentId mapping.
/// For a given byteArray, this is sha1(byteArray.length.toString() + "\u0000" + byteArray)
type Hash = Vec<u8>;
/// Allows a contentId to be quickly looked up given the hash of the file content.
/// This is used to avoid storing the same content multiple times in the content cache.
struct ContentHashes {
hash_to_content_index: Enumeration<Hash>,
}
/// Cached file contents.
/// Storage: content.dat.storageRecordIndex is a sequence of pointers to offsets in content.dat, and
/// a reference count for each item.
// Each record in content.dat contains content compressed with deflate
// content.dat is reference counted,
struct Content {
content_blobs: Vec<Bytes>
}
/// Represents a single VFS file or directory.
/// Stored in records.dat.
struct Record {
parent_record_index: RecordIndex,
timestamp: u64,
length: u64,
mod_count: u64,
flags: Flags,
attribs: Attribs,
// This is a reference to a content record, or 0, or -1
content_index: ContentIndex
}
/// Boolean flags for a file or directory.
/// Stored in records.dat inline with each record.
struct Flags {
children_cached: bool,
is_directory: bool,
is_read_only: bool,
must_reload_content: bool,
is_symlink: bool,
is_special: bool,
is_hidden: bool,
is_dirty: bool,
extra: bool
}
/// Custom attributes for a file or directory.
/// Storage: attrib.dat.storageRecordIndex is a sequence of pointers to offsets in attrib.dat.
/// Each record in attrib.data contains a sequence of attrib values for a single file or directory.
struct Attribs {
attrib_values: Vec<AttribValue>
}
/// A specific attribute value.
/// The set of available attribute enums types is dynamic (plugins can define custom FileAttributes), and is stored in vfs_enum_attrib.dat.
/// The attribute data for a file is stored in attrib.dat (see Attribs above).
enum AttribValue {
/// The child files or directories of the directory of this attribute.
FsRecordsDirectoryChildren {
children_record_indices: Vec<RecordIndex>
},
LanguageLevelPersistence {
language_level: u32
},
TemplateLanguage {
language: Language
},
IndexStamps,
AutoDetectionCacheAttribute,
FileIncludesIndexVersion,
IdIndexIndexVersion,
StubsIndexVersion,
StubIndexStamp,
StubIndexCumulativeBinaryBuilder,
/// The framework of a build file (I'm not sure what "forced" means here)
ForcedBuildFileFrameworkAttribute {
/// The only predefined framework in IJ is "ant"
framework_id: String
},
/// Older way of marking ant build files
ForcedAntAttribute {
is_ant: bool
},
TodoIndexIndexVersion,
FsRecordsSymlinkValue2 {
target: String
}
}
/// A dynamic list of languages supported by the IDE. I haven't seen this being actually
/// used; it seems to only be used as part of templates support.
enum Language {
Java,
Kotlin,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment