-
Notifications
You must be signed in to change notification settings - Fork 297
Version 0.60.0 Changes
The extent of the changes and optimizations made it impossible to use the slow @Deprecated
annotation with eventual removal in all cases.
- Major reorganization and code cleanup of implementation for next version 0.60.0
-
Formatter implementation is now part of core implementation in
flexmarkmodule -
Formatterimproved with more options including wrapping text to margins.- added ability to track and map source offset(s) to their index in formatted sequence. This feature allows editor caret position preservation across formatting operation.
- Offset tracking unified using
TrackedOffset. Used byMarkdownParagraphfor text wrapping andMarkdownTablefor table formatting and able to handle caret position during typing and backspace editing operations which are immediately followed by formatting or the edited source.
-
Tests cleaned up to eliminate duplication and hacks
-
flexmark-test-utilmade reusable for other projects. Having markdown as the source code for tests is too convenient to have it only used forflexmark-javatests. -
Optimized
SegmentedSequenceimplementation using binary trees for searching segments and byte efficient segment packing. Parser performance is either slightly improved or not affected but allows usingSegmentedSequencesfor collectingFormatterandHtmlRendereroutput to track source location of all text with minimal overhead and double the performance of old implementation. -
new implementation of
LineAppendableused for text generation in rendering:-
can use
SequenceBuilderto generateBasedSequenceresult with original source offsets for those character segments which come from the source. This allows round trip source tracking from Source -> AST -> Formatted Source -> Source throughout the library.As an added bonus using the appendable makes formatting to it 40% faster than previous implementation and 160 times (yes times) more efficient in memory use. For the test below, old implementation allocated 6GB worth of segmented sequences, new implementation 37MB. The % overhead is four times greater but that is after a 43 fold reduction in total overhead bytes. Old implementation allocated 342MB of overhead, new implementation only 8MB.
As a result of increased efficiency, two additional files of about 600kB each can be included in the test run and only add 0.6 sec to the total formatter execution time and only 7.5MB of additional memory.
Tests run on 1141 markdown files from GitHub projects and some other user samples. Largest was 256k bytes. The two new files of 600KB were not included in the results to allow comparing them to previous implementation.
Description Old SegmentedSequence New Segmented Sequence New LineAppendable Total wall clock time 13.896 sec 9.672 sec 8.805 sec Parse time 2.402 sec 2.335 sec 2.352 sec Formatter appendable 0.603 sec 0.602 sec 0.798 sec Formatter sequence builder 7.264 sec 3.109 sec 1.948 sec The overhead difference is significant. The totals are for all segmented sequences created during the test run of 1141 files. Parser statistics show requirements during parsing and formatter ones are only for formatting of them while accumulating the text as a segmented sequence.
Description Old Formatter New Formatter New LineAppendable Old Parser New Parser Bytes for characters of all segmented sequences 6,029,774,526 6,029,774,526 37,253,492 917,016 917,016 Bytes for overhead of all segmented sequences 12,060,276,408 342,351,155 8,021,677 1,845,048 93,628 Overhead % 200.0% 5.7% 21.5% 201.2% 10.2% -
-
- Doc:
BasedSequence,SegmentedSequenceandBasedSequenceBuilderchanges. - Doc:
LineAppendableand usingSequenceBuilderas an appendable target for it to accumulate rendered text with source information.
-
Break: split out generic AST utilities from
flexmark-utilmodule into separate smaller modules. IntelliJ IDEA migration to help with migration from 0.50.40 will be provided where needed if the package or class is changed.com.vladsch.flexmark.utilwill no longer contain any files but will contain the separate utilities modules withflexmark-utilsmodule being an aggregation of all utilities modules, similar toflexmark-all-
ast/classes toflexmark-util-ast, any other classes which depend onNodewill most likely be moved here. -
builder/classes toflexmark-util-builder -
collection/classes toflexmark-util-collection -
data/classes toflexmark-util-data -
dependency/classes toflexmark-util-dependency -
format/classes toflexmark-util-format, with dependency onNodechanged to type parameter. -
html/classes toflexmark-util-html -
mappers/classes toflexmark-util-mappers, classes with dependency onNodewill move toflexmark-util-node -
mappers/classes toflexmark-util-mappers -
options/classes toflexmark-util-options -
sequence/classes toflexmark-util-sequence -
visitor/classes toflexmark-util-visitor - Generic helper classes from module root:
-
DelimitedBuilder.javatoflexmark-util-misc -
FileUtil.javatoflexmark-util-misc -
ImageUtils.javatoflexmark-util-misc -
Immutable.javatoflexmark-util-misc -
Mutable.javatoflexmark-util-misc -
Pair.javatoflexmark-util-misc -
Paired.javatoflexmark-util-misc -
Ref.javatoflexmark-util-misc -
TemplateUtil.javatoflexmark-util-misc -
Utils.javatoflexmark-util-misc
-
-
-
Break: delete deprecated properties, methods and classes
-
Add:
org.jetbrains:annotations:15.0dependency to have@Nullable/@NotNullannotations added for all parameters. I use IntelliJ IDEA for development and it helps to have these annotations for analysis of potential problems and use with Kotlin. -
Break: refactor and cleanup tests to eliminate duplicated code and allow easier reuse of test cases with spec example data.
-
Break: move formatter tests to
flexmark-core-testmodule to allow sharing of formatter base classes in extensions without causing dependency cycles in formatter module. -
Break: move formatter module into
flexmarkcore. this module is almost always included anyway because most extension have a dependency on formatter for their custom formatting implementations. Having it as part of the core allows relying on its functionality in all modules. -
Break: move
com.vladsch.flexmark.specandcom.vladsch.flexmark.utilinflexmark-test-utiltocom.vladsch.flexmark.test.specandcom.vladsch.flexmark.test.utilrespectively to respect the naming convention between modules and their packages. -
Break:
NodeVisitorimplementation details have changed. If you were overridingNodeVisitor.visit(Node)in the previous version it is nowfinalto ensure compile time error is generated. You will need to change your implementation. See comment in the class for instructions.ℹ️
com.vladsch.flexmark.util.ast.Visitoris only needed for implementation ofNodeVisitorandVisitHandler. Converting all anonymous implementations ofVisitHandlerto lambdas results in removal of all imports forVisitor.- Fix: remove old visitor like adapters and implement ones based on generic classes not linked to flexmark AST node.
- Deprecate old base classes:
-
com.vladsch.flexmark.util.ast.NodeAdaptedVisitorsee javadoc for class com.vladsch.flexmark.util.ast.NodeAdaptingVisitHandlercom.vladsch.flexmark.util.ast.NodeAdaptingVisitor
-