diff --git a/README.md b/README.md index 6dfe65a21..1c3e5795f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ optimization of implementation classes. Changes are detailed in * For Versions 0.62.2 or below, Java 8 or above, Java 9+ compatible. For Versions 0.64.0 or above, Java 11 or above. * The project is on Maven: `com.vladsch.flexmark` -* The core has no dependencies other than `org.jetbrains:annotations:24.0.1`. For extensions, see +* The core has no dependencies other than `org.jspecify:jspecify:1.0.0`. For extensions, see extension description below. The API is still evolving to accommodate new extensions and functionality. diff --git a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/FormatterSpecTest.java b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/FormatterSpecTest.java index d7692f123..ab9c80046 100644 --- a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/FormatterSpecTest.java +++ b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/FormatterSpecTest.java @@ -12,24 +12,23 @@ import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; import static com.vladsch.flexmark.formatter.Formatter.RESTORE_TRACKED_SPACES; public abstract class FormatterSpecTest extends FormatterTranslationSpecTestBase { - public FormatterSpecTest(@NotNull SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { + public FormatterSpecTest(SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { super(example, optionMap, defaultOptions); } @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = aggregate(myDefaultOptions, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, Parser.builder(combinedOptions).build(), Formatter.builder(combinedOptions).build(), true) { - @NotNull List trackedOffsets = Collections.emptyList(); + List trackedOffsets = Collections.emptyList(); BasedSequence trackedSequence; BasedSequence originalSequence; @@ -64,7 +63,7 @@ public void parse(CharSequence input) { } @Override - protected @NotNull String renderHtml() { + protected String renderHtml() { if (trackedOffsets.isEmpty() && !SHOW_LINE_RANGES.get(myOptions)) { return getRenderer().render(getDocument()); } else { diff --git a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/FormatterTranslationSpecTestBase.java b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/FormatterTranslationSpecTestBase.java index f3f6d1c51..a0262e0e7 100644 --- a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/FormatterTranslationSpecTestBase.java +++ b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/FormatterTranslationSpecTestBase.java @@ -13,8 +13,7 @@ import com.vladsch.flexmark.util.data.SharedDataKeys; import com.vladsch.flexmark.util.format.options.*; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; import java.util.Map; @@ -155,7 +154,7 @@ static DataHolder marginOption(@Nullable Integer params) { return new MutableDataSet().set(Formatter.RIGHT_MARGIN, value); } - public FormatterTranslationSpecTestBase(@NotNull SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { + public FormatterTranslationSpecTestBase(SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), ComboSpecTestCase.dataHolders(OPTIONS, defaultOptions)); } } diff --git a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/RendererSpecTest.java b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/RendererSpecTest.java index 1df5ce0a6..e039db309 100644 --- a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/RendererSpecTest.java +++ b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/RendererSpecTest.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; import java.util.Map; @@ -23,7 +22,7 @@ public abstract class RendererSpecTest extends ComboSpecTestCase { static { optionsMap.put("src-pos", new MutableDataSet().set(HtmlRenderer.SOURCE_POSITION_ATTRIBUTE, "md-pos")); } - public RendererSpecTest(@NotNull SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { + public RendererSpecTest(SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), ComboSpecTestCase.dataHolders(OPTIONS, defaultOptions)); } @@ -35,7 +34,7 @@ protected boolean wantExampleInfo() { } @Override - final public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + final public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = aggregate(myDefaultOptions, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, Parser.builder(combinedOptions).build(), HtmlRenderer.builder(combinedOptions).build(), wantExampleInfo()); } diff --git a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/TranslationFormatterSpecTest.java b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/TranslationFormatterSpecTest.java index 0213ce3a4..5e35e942d 100644 --- a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/TranslationFormatterSpecTest.java +++ b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/TranslationFormatterSpecTest.java @@ -15,8 +15,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.IOException; import java.util.ArrayList; @@ -42,7 +41,7 @@ public abstract class TranslationFormatterSpecTest extends FormatterTranslationS optionsMap.put("details", new MutableDataSet().set(DETAILS, true)); optionsMap.put("ast-details", new MutableDataSet().set(AST_DETAILS, true)); } - public TranslationFormatterSpecTest(@NotNull SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { + public TranslationFormatterSpecTest(SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), ComboSpecTestCase.dataHolders(OPTIONS, defaultOptions)); } @@ -55,11 +54,11 @@ private IRender getRenderer(@Nullable DataHolder OPTIONS) { } @Override - final public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + final public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = aggregate(myDefaultOptions, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, getParser(combinedOptions), getRenderer(combinedOptions), true) { @Override - protected @NotNull String renderAst() { + protected String renderAst() { TranslationFormatter translationFormatter = (TranslationFormatter) getRenderer(); if (translationFormatter.isShowIntermediateAst()) { return translationFormatter.getAst(); @@ -116,7 +115,6 @@ public boolean isShowIntermediateAst() { return myShowIntermediateAst; } - @NotNull public String getAst() { return myAst == null ? "" : myAst; } @@ -128,7 +126,7 @@ public DataHolder getOptions() { } @Override - public void render(@NotNull Node node, @NotNull Appendable output) { + public void render(Node node, Appendable output) { Document document = (Document) node; TranslationHandler handler = myFormatter.getTranslationHandler(); diff --git a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/package-info.java b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/package-info.java index e79f1d9e6..2a44dc20e 100644 --- a/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/package-info.java +++ b/flexmark-core-test/src/main/java/com/vladsch/flexmark/core/test/util/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.core.test.util; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterNoBlankLinesSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterNoBlankLinesSpecTest.java index 4093987b5..0a0549812 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterNoBlankLinesSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterNoBlankLinesSpecTest.java @@ -6,19 +6,18 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboCoreFormatterNoBlankLinesSpecTest extends ComboCoreFormatterSpecTestBase { final private static String SPEC_RESOURCE = "/core_formatter_no_blanklines_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.BLANK_LINES_IN_AST, false) .toImmutable(); - public ComboCoreFormatterNoBlankLinesSpecTest(@NotNull SpecExample example) { + public ComboCoreFormatterNoBlankLinesSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterSpecTest.java index e731c3e22..0cbc26832 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterSpecTest.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboCoreFormatterSpecTest extends ComboCoreFormatterSpecTestBase { final private static String SPEC_RESOURCE = "/core_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboCoreFormatterSpecTest(@NotNull SpecExample example) { + public ComboCoreFormatterSpecTest(SpecExample example) { super(example, null); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterSpecTestBase.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterSpecTestBase.java index e1f05d78b..a9effdc5e 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterSpecTestBase.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreFormatterSpecTestBase.java @@ -4,8 +4,7 @@ import com.vladsch.flexmark.test.util.ComboSpecTestCase; import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; import java.util.Map; @@ -16,7 +15,7 @@ public abstract class ComboCoreFormatterSpecTestBase extends FormatterSpecTest { // optionsMap.put("atx-space-as-is", new MutableDataSet().set(Formatter.SPACE_AFTER_ATX_MARKER, DiscretionaryText.AS_IS)); // } - public ComboCoreFormatterSpecTestBase(@NotNull SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { + public ComboCoreFormatterSpecTestBase(SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), defaultOptions); } } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreTranslationFormatterSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreTranslationFormatterSpecTest.java index 7140c8c37..0dc8e0986 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreTranslationFormatterSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreTranslationFormatterSpecTest.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.format.options.*; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; @@ -17,7 +16,7 @@ public class ComboCoreTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/core_translation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static Map optionsMap = placementAndSortOptions( Parser.REFERENCES_KEEP, @@ -61,7 +60,7 @@ public class ComboCoreTranslationFormatterSpecTest extends TranslationFormatterS optionsMap.put("explicit-links-at-start", new MutableDataSet().set(Formatter.KEEP_EXPLICIT_LINKS_AT_START, true)); optionsMap.put("remove-empty-items", new MutableDataSet().set(Formatter.LIST_REMOVE_EMPTY_ITEMS, true)); } - public ComboCoreTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboCoreTranslationFormatterSpecTest(SpecExample example) { super(example, optionsMap); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreWrappingSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreWrappingSpecTest.java index cabe5840a..7a49dba0e 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreWrappingSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboCoreWrappingSpecTest.java @@ -5,20 +5,19 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.data.SharedDataKeys; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboCoreWrappingSpecTest extends ComboCoreFormatterSpecTestBase { final private static String SPEC_RESOURCE = "/core_wrapping_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(SharedDataKeys.RUNNING_TESTS, false) // Set to true to get stdout printout of intermediate wrapping information .toImmutable(); - public ComboCoreWrappingSpecTest(@NotNull SpecExample example) { + public ComboCoreWrappingSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboParagraphFormatterSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboParagraphFormatterSpecTest.java index 635153323..861ca3824 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboParagraphFormatterSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/formatter/ComboParagraphFormatterSpecTest.java @@ -18,8 +18,7 @@ import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.runners.Parameterized; import java.io.IOException; @@ -32,7 +31,7 @@ public class ComboParagraphFormatterSpecTest extends ComboCoreFormatterSpecTestBase { final private static String SPEC_RESOURCE = "/core_paragraph_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final public static DataKey FIRST_WIDTH_DELTA = new DataKey<>("FIRST_WIDTH_DELTA", 0); @@ -44,7 +43,7 @@ public class ComboParagraphFormatterSpecTest extends ComboCoreFormatterSpecTestB static { optionsMap.put("first-width-delta", new MutableDataSet().set(TestUtils.CUSTOM_OPTION, (option, params) -> TestUtils.customIntOption(option, params, ComboParagraphFormatterSpecTest::firstWidthDeltaOption))); } - public ComboParagraphFormatterSpecTest(@NotNull SpecExample example) { + public ComboParagraphFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } @@ -59,11 +58,10 @@ public static List data() { } static class ParagraphTextNode extends Node { - public ParagraphTextNode(@NotNull BasedSequence chars) { + public ParagraphTextNode(BasedSequence chars) { super(chars); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; @@ -79,7 +77,7 @@ public ParagraphParser(DataHolder options) { } @Override - public @NotNull Node parse(@NotNull BasedSequence input) { + public Node parse(BasedSequence input) { return new ParagraphTextNode(input); } } @@ -97,7 +95,7 @@ public ParagraphFormatter(DataHolder options) { final static String BANNER_RESULT = TestUtils.bannerText("Result"); @Override - public void render(@NotNull Node document, @NotNull Appendable output) { + public void render(Node document, Appendable output) { BasedSequence input = document.getChars(); StringBuilder out = new StringBuilder(); Boolean inTest = SharedDataKeys.RUNNING_TESTS.get(getOptions()); @@ -186,12 +184,12 @@ public void render(@NotNull Node document, @NotNull Appendable output) { } @Override - final public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + final public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = aggregate(myDefaultOptions, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, new ParagraphParser(combinedOptions), new ParagraphFormatter(combinedOptions), true) { @Override - protected @NotNull String renderHtml() { + protected String renderHtml() { if (SharedDataKeys.RUNNING_TESTS.get(myOptions)) { System.out.printf("%s:%d%n", myExample.getSection(), myExample.getExampleNumber()); } @@ -200,7 +198,7 @@ public void render(@NotNull Node document, @NotNull Appendable output) { } @Override - protected @NotNull String renderAst() { + protected String renderAst() { return TestUtils.ast(getDocument()); } }; diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/HtmlEmbeddedAttributeTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/HtmlEmbeddedAttributeTest.java index e3fc0d4e5..61bd137fa 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/HtmlEmbeddedAttributeTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/HtmlEmbeddedAttributeTest.java @@ -15,7 +15,6 @@ import com.vladsch.flexmark.util.html.Attributes; import com.vladsch.flexmark.util.html.MutableAttributes; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import org.junit.Before; import org.junit.Test; @@ -63,9 +62,8 @@ private static class TestNodeFactory extends NodePostProcessorFactory { addNodes(Paragraph.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new TestNodePostProcessor(); } } @@ -75,7 +73,7 @@ public static NodePostProcessorFactory Factory(DataHolder options) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { BasedSequence paragraphText = BasedSequence.NULL; if (node instanceof Paragraph) { // [foo](http://example.com) MutableAttributes attributes = new MutableAttributes(); @@ -94,12 +92,12 @@ static class TestNodePostProcessorExtension implements Parser.ParserExtension, H private TestNodePostProcessorExtension() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // add any configuration settings to options you want to apply to everything, here } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.attributeProviderFactory(EmbeddedAttributeProvider.Factory); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/HtmlRendererTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/HtmlRendererTest.java index 2642936db..64dd5fcbf 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/HtmlRendererTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/HtmlRendererTest.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.sequence.LineAppendable; -import org.jetbrains.annotations.NotNull; import org.junit.Assert; import org.junit.Test; @@ -86,9 +85,8 @@ public void percentEncodeUrl() { @Test public void attributeProviderForCodeBlock() { AttributeProviderFactory factory = new IndependentAttributeProviderFactory() { - @NotNull @Override - public AttributeProvider apply(@NotNull LinkResolverContext context) { + public AttributeProvider apply(LinkResolverContext context) { return (node, part, attributes) -> { if (node instanceof FencedCodeBlock && part == CoreNodeRenderer.CODE_CONTENT) { FencedCodeBlock fencedCodeBlock = (FencedCodeBlock) node; @@ -112,9 +110,8 @@ public AttributeProvider apply(@NotNull LinkResolverContext context) { @Test public void attributeProviderForImage() { AttributeProviderFactory factory = new IndependentAttributeProviderFactory() { - @NotNull @Override - public AttributeProvider apply(@NotNull LinkResolverContext context) { + public AttributeProvider apply(LinkResolverContext context) { return (node, part, attributes) -> { if (node instanceof Image) { attributes.remove("alt"); @@ -219,9 +216,8 @@ public void overrideInheritDependentNodeRender() { }; NodeRendererFactory nodeRendererFactory2 = new DelegatingNodeRendererFactory() { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return () -> { HashSet> set = new HashSet<>(); set.add(new NodeRenderingHandler<>(Link.class, (node, context, html) -> { @@ -270,9 +266,8 @@ public void overrideInheritDependentNodeRenderReversed() { }; NodeRendererFactory nodeRendererFactory2 = new DelegatingNodeRendererFactory() { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return () -> { HashSet> set = new HashSet<>(); set.add(new NodeRenderingHandler<>(Link.class, (node, context, html) -> { @@ -336,9 +331,8 @@ public CustomLinkResolverImpl(LinkResolverBasicContext context) { docUrl = DOC_RELATIVE_URL.get(context.getOptions()); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) { + public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) { if (node instanceof Link) { Link linkNode = (Link) node; if (linkNode.getUrl().equals("/url")) { @@ -349,9 +343,8 @@ public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicCo } static class Factory extends IndependentLinkResolverFactory { - @NotNull @Override - public LinkResolver apply(@NotNull LinkResolverBasicContext context) { + public LinkResolver apply(LinkResolverBasicContext context) { return new CustomLinkResolverImpl(context); } } @@ -371,9 +364,8 @@ public CustomRefLinkResolverImpl(LinkResolverBasicContext context) { } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) { + public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) { if (node instanceof LinkRef || node instanceof ImageRef) { RefNode linkNode = (RefNode) node; if (linkNode.getReference().startsWith(":")) { @@ -384,9 +376,8 @@ public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicCo } static class Factory extends IndependentLinkResolverFactory { - @NotNull @Override - public LinkResolver apply(@NotNull LinkResolverBasicContext context) { + public LinkResolver apply(LinkResolverBasicContext context) { return new CustomLinkResolverImpl(context); } } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/PathologicalRenderingTestCase.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/PathologicalRenderingTestCase.java index 70ce4bd9e..939d61e3a 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/PathologicalRenderingTestCase.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/html/PathologicalRenderingTestCase.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataSet; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Stopwatch; @@ -30,12 +29,12 @@ public PathologicalRenderingTestCase(boolean spcInLinkUrls) { @Nullable @Override - final public DataHolder options(@NotNull String option) { + final public DataHolder options(String option) { return null; } @Override - final public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + final public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = DataSet.aggregate(OPTIONS, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, Parser.builder(combinedOptions).build(), HtmlRenderer.builder(combinedOptions).build(), true); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/DelimiterProcessorTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/DelimiterProcessorTest.java index 78ef96092..eb1feee4d 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/DelimiterProcessorTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/DelimiterProcessorTest.java @@ -23,8 +23,7 @@ import com.vladsch.flexmark.util.data.DataSet; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; import java.util.HashSet; @@ -64,12 +63,12 @@ public void asymmetricDelimiter() { } @Override - public @Nullable DataHolder options(@NotNull String option) { + public @Nullable DataHolder options(String option) { return null; } @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = DataSet.aggregate(OPTIONS, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, PARSER, RENDERER, true); } @@ -189,7 +188,6 @@ private static class UpperCaseNode extends Node implements DelimitedNode { protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; @@ -237,9 +235,8 @@ public void setClosingMarker(BasedSequence closingMarker) { private static class UpperCaseNodeRendererFactory implements NodeRendererFactory { UpperCaseNodeRendererFactory() {} - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new UpperCaseNodeRenderer(options); } } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/ParserTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/ParserTest.java index e37da066b..c1cf75b22 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/ParserTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/ParserTest.java @@ -16,8 +16,7 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInHandler; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInStartsWithCharsHandler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; import java.io.IOException; @@ -652,7 +651,6 @@ private static class DashBlock extends Block { DashBlock() { } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; @@ -701,9 +699,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/SpecialInputTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/SpecialInputTest.java index 5119cf8e2..6ec3675f7 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/SpecialInputTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/parser/SpecialInputTest.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataSet; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; final public class SpecialInputTest extends RenderingTestCase { @@ -126,12 +125,12 @@ public void manyUnderscores() { @Nullable @Override - public DataHolder options(@NotNull String option) { + public DataHolder options(String option) { return null; } @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combineOptions = DataSet.aggregate(OPTIONS, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combineOptions, Parser.builder(combineOptions).build(), HtmlRenderer.builder(combineOptions).build(), true); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCommonMarkCompatibilitySpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCommonMarkCompatibilitySpecTest.java index 949bc7c76..50f03a1a3 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCommonMarkCompatibilitySpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCommonMarkCompatibilitySpecTest.java @@ -6,21 +6,20 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; final public class ComboCommonMarkCompatibilitySpecTest extends CoreRendererSpecTest { final private static String SPEC_RESOURCE = "/core_commonmark_compatibility_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .setFrom(ParserEmulationProfile.COMMONMARK.getOptions()) .set(HtmlRenderer.INDENT_SIZE, 4) .set(HtmlRenderer.RENDER_HEADER_ID, true) .toImmutable(); - public ComboCommonMarkCompatibilitySpecTest(@NotNull SpecExample example) { + public ComboCommonMarkCompatibilitySpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCoreDirectionalSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCoreDirectionalSpecTest.java index 9452cb48e..8ae3e53bc 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCoreDirectionalSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCoreDirectionalSpecTest.java @@ -7,14 +7,13 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; final public class ComboCoreDirectionalSpecTest extends CoreRendererSpecTest { static final String SPEC_RESOURCE = "/ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.INDENT_SIZE, 0) .set(Parser.INLINE_DELIMITER_DIRECTIONAL_PUNCTUATIONS, true) @@ -23,7 +22,7 @@ final public class ComboCoreDirectionalSpecTest extends CoreRendererSpecTest { .toImmutable(); ; - public ComboCoreDirectionalSpecTest(@NotNull SpecExample example) { + public ComboCoreDirectionalSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCoreSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCoreSpecTest.java index c95605cba..15e4eee99 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCoreSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboCoreSpecTest.java @@ -7,14 +7,13 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; final public class ComboCoreSpecTest extends CoreRendererSpecTest { static final String SPEC_RESOURCE = "/ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.INDENT_SIZE, 0) @@ -23,7 +22,7 @@ final public class ComboCoreSpecTest extends CoreRendererSpecTest { .set(TestUtils.NO_FILE_EOL, false) .toImmutable(); - public ComboCoreSpecTest(@NotNull SpecExample example) { + public ComboCoreSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboExtraSpec2Test.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboExtraSpec2Test.java index 8475b54d0..50a61f7af 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboExtraSpec2Test.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboExtraSpec2Test.java @@ -5,20 +5,19 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; final public class ComboExtraSpec2Test extends CoreRendererSpecTest { final private static String SPEC_RESOURCE = "/core_extra_ast_spec2.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.PERCENT_ENCODE_URLS, true) .toImmutable(); - public ComboExtraSpec2Test(@NotNull SpecExample example) { + public ComboExtraSpec2Test(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboExtraSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboExtraSpecTest.java index cb403ce43..812b9f1d1 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboExtraSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboExtraSpecTest.java @@ -5,20 +5,19 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; final public class ComboExtraSpecTest extends CoreRendererSpecTest { final private static String SPEC_RESOURCE = "/core_extra_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.PERCENT_ENCODE_URLS, true) .toImmutable(); - public ComboExtraSpecTest(@NotNull SpecExample example) { + public ComboExtraSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboGitHubCompatibilitySpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboGitHubCompatibilitySpecTest.java index dca41882c..f329488a5 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboGitHubCompatibilitySpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboGitHubCompatibilitySpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.HashMap; @@ -16,7 +15,7 @@ final public class ComboGitHubCompatibilitySpecTest extends CoreRendererSpecTest { final private static String SPEC_RESOURCE = "/core_gfm_doc_compatibility_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .setFrom(ParserEmulationProfile.GITHUB_DOC) @@ -30,7 +29,7 @@ final public class ComboGitHubCompatibilitySpecTest extends CoreRendererSpecTest static { optionsMap.put("no-loose-non-list-children", new MutableDataSet().set(Parser.LISTS_LOOSE_WHEN_HAS_NON_LIST_CHILDREN, false).set(Parser.LISTS_LOOSE_WHEN_BLANK_LINE_FOLLOWS_ITEM_PARAGRAPH, false)); } - public ComboGitHubCompatibilitySpecTest(@NotNull SpecExample example) { + public ComboGitHubCompatibilitySpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboIssuesSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboIssuesSpecTest.java index fac285362..217c12bd6 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboIssuesSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboIssuesSpecTest.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.sequence.LineAppendable; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.ArrayList; @@ -19,7 +18,7 @@ final public class ComboIssuesSpecTest extends CoreRendererSpecTest { final private static String SPEC_RESOURCE = "/core_issues_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.INDENT_SIZE, 2) @@ -61,7 +60,7 @@ final public class ComboIssuesSpecTest extends CoreRendererSpecTest { .set(Parser.HTML_BLOCK_DEEP_PARSE_BLANK_LINE_INTERRUPTS_PARTIAL_TAG, false) ); } - public ComboIssuesSpecTest(@NotNull SpecExample example) { + public ComboIssuesSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboKramdownCompatibilitySpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboKramdownCompatibilitySpecTest.java index b32069195..a187790c6 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboKramdownCompatibilitySpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboKramdownCompatibilitySpecTest.java @@ -6,20 +6,19 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; final public class ComboKramdownCompatibilitySpecTest extends CoreRendererSpecTest { final private static String SPEC_RESOURCE = "/core_kramdown_compatibility_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .setFrom(ParserEmulationProfile.KRAMDOWN) .set(HtmlRenderer.INDENT_SIZE, 4) .toMutable(); - public ComboKramdownCompatibilitySpecTest(@NotNull SpecExample example) { + public ComboKramdownCompatibilitySpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboMarkdownCompatibilitySpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboMarkdownCompatibilitySpecTest.java index ee882ac76..05ffdf791 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboMarkdownCompatibilitySpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboMarkdownCompatibilitySpecTest.java @@ -7,20 +7,19 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; final public class ComboMarkdownCompatibilitySpecTest extends CoreRendererSpecTest { final private static String SPEC_RESOURCE = "/core_markdown_compatibility_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .setFrom(ParserEmulationProfile.MARKDOWN) .set(HtmlRenderer.INDENT_SIZE, 4) .toMutable(); - public ComboMarkdownCompatibilitySpecTest(@NotNull SpecExample example) { + public ComboMarkdownCompatibilitySpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboMultiMarkdownCompatibilitySpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboMultiMarkdownCompatibilitySpecTest.java index 88559aca2..f733e2556 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboMultiMarkdownCompatibilitySpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboMultiMarkdownCompatibilitySpecTest.java @@ -6,20 +6,19 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; final public class ComboMultiMarkdownCompatibilitySpecTest extends CoreRendererSpecTest { final private static String SPEC_RESOURCE = "/core_multi_markdown_compatibility_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .setFrom(ParserEmulationProfile.MULTI_MARKDOWN) .set(HtmlRenderer.INDENT_SIZE, 4) .toMutable(); - public ComboMultiMarkdownCompatibilitySpecTest(@NotNull SpecExample example) { + public ComboMultiMarkdownCompatibilitySpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboPegdownCompatibilitySpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboPegdownCompatibilitySpecTest.java index f34368fed..e17b73d70 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboPegdownCompatibilitySpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/ComboPegdownCompatibilitySpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.HashMap; @@ -17,7 +16,7 @@ final public class ComboPegdownCompatibilitySpecTest extends CoreRendererSpecTest { final private static String SPEC_RESOURCE = "/core_pegdown_compatibility_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet().setFrom(ParserEmulationProfile.PEGDOWN_STRICT) .set(HtmlRenderer.INDENT_SIZE, 2) @@ -41,7 +40,7 @@ final public class ComboPegdownCompatibilitySpecTest extends CoreRendererSpecTes .set(Parser.LISTS_LOOSE_WHEN_CONTAINS_BLANK_LINE, false) ); } - public ComboPegdownCompatibilitySpecTest(@NotNull SpecExample example) { + public ComboPegdownCompatibilitySpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/CoreRendererSpecTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/CoreRendererSpecTest.java index 9ad3e4586..013decaf1 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/CoreRendererSpecTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/CoreRendererSpecTest.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.ast.KeepType; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.Arrays; @@ -150,7 +149,7 @@ public abstract class CoreRendererSpecTest extends RendererSpecTest { .set(Parser.LISTS_EMPTY_ORDERED_NON_ONE_SUB_ITEM_INTERRUPTS_ITEM_PARAGRAPH, true) ); } - public CoreRendererSpecTest(@NotNull SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { + public CoreRendererSpecTest(SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), ComboSpecTestCase.dataHolders(OPTIONS, defaultOptions)); } } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec027CoreTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec027CoreTest.java index e57ab3ba0..b25f15b82 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec027CoreTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec027CoreTest.java @@ -3,11 +3,10 @@ import com.vladsch.flexmark.parser.ParserEmulationProfile; import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; final public class FullOrigSpec027CoreTest extends OrigSpecCoreTest { static final String SPEC_RESOURCE = "/spec.0.27.txt"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = ParserEmulationProfile.COMMONMARK_0_27.getProfileOptions().toImmutable(); public FullOrigSpec027CoreTest() { @@ -15,7 +14,6 @@ public FullOrigSpec027CoreTest() { } @Override - @NotNull protected ResourceLocation getSpecResourceLocation() { return RESOURCE_LOCATION; } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec028CoreTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec028CoreTest.java index 1092e0af7..0cd6e474f 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec028CoreTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec028CoreTest.java @@ -3,11 +3,10 @@ import com.vladsch.flexmark.parser.ParserEmulationProfile; import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; final public class FullOrigSpec028CoreTest extends OrigSpecCoreTest { static final String SPEC_RESOURCE = "/spec.0.28.txt"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = ParserEmulationProfile.COMMONMARK_0_28.getProfileOptions().toImmutable(); public FullOrigSpec028CoreTest() { @@ -15,7 +14,6 @@ public FullOrigSpec028CoreTest() { } @Override - @NotNull protected ResourceLocation getSpecResourceLocation() { return RESOURCE_LOCATION; } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec029CoreTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec029CoreTest.java index e34eb42d0..de34dd77d 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec029CoreTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpec029CoreTest.java @@ -3,11 +3,10 @@ import com.vladsch.flexmark.parser.ParserEmulationProfile; import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; final public class FullOrigSpec029CoreTest extends OrigSpecCoreTest { static final String SPEC_RESOURCE = "/spec.0.29.txt"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = ParserEmulationProfile.COMMONMARK_0_29.getProfileOptions().toImmutable(); public FullOrigSpec029CoreTest() { @@ -15,7 +14,6 @@ public FullOrigSpec029CoreTest() { } @Override - @NotNull protected ResourceLocation getSpecResourceLocation() { // FIX: implement 0.29 spec and enable test //return RESOURCE_LOCATION; diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpecCoreTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpecCoreTest.java index 3bf8a9839..8ed5ac4d1 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpecCoreTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/FullOrigSpecCoreTest.java @@ -1,18 +1,16 @@ package com.vladsch.flexmark.core.test.util.renderer; import com.vladsch.flexmark.test.util.spec.ResourceLocation; -import org.jetbrains.annotations.NotNull; final public class FullOrigSpecCoreTest extends OrigSpecCoreTest { static final String SPEC_RESOURCE = "/spec.txt"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); public FullOrigSpecCoreTest() { super(null); } @Override - @NotNull protected ResourceLocation getSpecResourceLocation() { return RESOURCE_LOCATION; } diff --git a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/OrigSpecCoreTest.java b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/OrigSpecCoreTest.java index 17aa92af3..ce9687f9d 100644 --- a/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/OrigSpecCoreTest.java +++ b/flexmark-core-test/src/test/java/com/vladsch/flexmark/core/test/util/renderer/OrigSpecCoreTest.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataSet; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public abstract class OrigSpecCoreTest extends FullSpecTestCase { final private static DataHolder OPTIONS = new MutableDataSet() @@ -26,12 +25,12 @@ public OrigSpecCoreTest(@Nullable DataHolder defaultOptions) { } @Override - final public @Nullable DataHolder options(@NotNull String option) { + final public @Nullable DataHolder options(String option) { return null; } @Override - final public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + final public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combineOptions = DataSet.aggregate(myDefaultOptions, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combineOptions, Parser.builder(combineOptions).build(), HtmlRenderer.builder(combineOptions).build(), false); } diff --git a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/DocxRenderer.java b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/DocxRenderer.java index 483844175..b14bd547e 100644 --- a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/DocxRenderer.java +++ b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/DocxRenderer.java @@ -37,8 +37,7 @@ import org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart; import org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart; import org.docx4j.wml.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.*; import java.nio.charset.StandardCharsets; @@ -376,8 +375,7 @@ public void render(Node node, WordprocessingMLPackage output, DocumentContentHan * @param document the root node * @return the rendered HTML */ - @NotNull - public String render(@NotNull Node document) { + public String render(Node document) { String resourcePath = DEFAULT_TEMPLATE_RESOURCE.get(getOptions()); WordprocessingMLPackage mlPackage = getDefaultTemplate(resourcePath); render(document, mlPackage); @@ -397,7 +395,7 @@ public String render(@NotNull Node document) { } @Override - public void render(@NotNull Node document, @NotNull Appendable output) { + public void render(Node document, Appendable output) { String docx = render(document); try { output.append(docx); @@ -426,7 +424,7 @@ public Builder(@Nullable DataHolder options) { } @Override - protected void removeApiPoint(@NotNull Object apiPoint) { + protected void removeApiPoint(Object apiPoint) { if (apiPoint instanceof AttributeProviderFactory) this.attributeProviderFactories.remove(apiPoint); else if (apiPoint instanceof NodeDocxRendererFactory) this.nodeDocxRendererFactories.remove(apiPoint); else if (apiPoint instanceof LinkResolverFactory) this.linkResolverFactories.remove(apiPoint); @@ -438,7 +436,7 @@ protected void removeApiPoint(@NotNull Object apiPoint) { } @Override - protected void preloadExtension(@NotNull Extension extension) { + protected void preloadExtension(Extension extension) { if (extension instanceof DocxRendererExtension) { DocxRendererExtension docxRendererExtension = (DocxRendererExtension) extension; docxRendererExtension.rendererOptions(this); @@ -449,7 +447,7 @@ protected void preloadExtension(@NotNull Extension extension) { } @Override - protected boolean loadExtension(@NotNull Extension extension) { + protected boolean loadExtension(Extension extension) { if (extension instanceof DocxRendererExtension) { DocxRendererExtension docxRendererExtension = (DocxRendererExtension) extension; docxRendererExtension.extend(this); @@ -465,7 +463,6 @@ protected boolean loadExtension(@NotNull Extension extension) { /** * @return the configured {@link DocxRenderer} */ - @NotNull public DocxRenderer build() { return new DocxRenderer(this); } @@ -492,9 +489,8 @@ public Builder nodeFormatterFactory(NodeDocxRendererFactory nodeDocxRendererFact * @param linkResolverFactory the factory for creating a node renderer * @return {@code this} */ - @NotNull @Override - public Builder linkResolverFactory(@NotNull LinkResolverFactory linkResolverFactory) { + public Builder linkResolverFactory(LinkResolverFactory linkResolverFactory) { this.linkResolverFactories.add(linkResolverFactory); addExtensionApiPoint(linkResolverFactory); return this; @@ -506,9 +502,8 @@ public Builder linkResolverFactory(@NotNull LinkResolverFactory linkResolverFact * @param contentResolverFactory the factory for creating a node renderer * @return {@code this} */ - @NotNull @Override - public Builder contentResolverFactory(@NotNull UriContentResolverFactory contentResolverFactory) { + public Builder contentResolverFactory(UriContentResolverFactory contentResolverFactory) { this.contentResolverFactories.add(contentResolverFactory); addExtensionApiPoint(contentResolverFactory); return this; @@ -520,9 +515,8 @@ public Builder contentResolverFactory(@NotNull UriContentResolverFactory content * @param attributeProviderFactory the attribute provider factory to add * @return {@code this} */ - @NotNull @Override - public Builder attributeProviderFactory(@NotNull AttributeProviderFactory attributeProviderFactory) { + public Builder attributeProviderFactory(AttributeProviderFactory attributeProviderFactory) { this.attributeProviderFactories.add(attributeProviderFactory); addExtensionApiPoint(attributeProviderFactory); return this; @@ -534,9 +528,8 @@ public Builder attributeProviderFactory(@NotNull AttributeProviderFactory attrib * @param htmlIdGeneratorFactory the factory for generating header tag id attributes * @return {@code this} */ - @NotNull @Override - public Builder htmlIdGeneratorFactory(@NotNull HeaderIdGeneratorFactory htmlIdGeneratorFactory) { + public Builder htmlIdGeneratorFactory(HeaderIdGeneratorFactory htmlIdGeneratorFactory) { //noinspection VariableNotUsedInsideIf if (this.htmlIdGeneratorFactory != null) { throw new IllegalStateException("custom header id factory is already set to " + htmlIdGeneratorFactory.getClass().getName()); @@ -759,9 +752,8 @@ public Node getNodeFromId(String nodeId) { return nodeIdMap.getFirst(nodeId); } - @NotNull @Override - public String encodeUrl(@NotNull CharSequence url) { + public String encodeUrl(CharSequence url) { if (rendererOptions.percentEncodeUrls) { return Escaping.percentEncodeUrl(url); } else { @@ -770,7 +762,7 @@ public String encodeUrl(@NotNull CharSequence url) { } @Override - public MutableAttributes extendRenderingNodeAttributes(@NotNull AttributablePart part, @Nullable Attributes attributes) { + public MutableAttributes extendRenderingNodeAttributes(AttributablePart part, @Nullable Attributes attributes) { MutableAttributes attr = attributes != null ? attributes.toMutable() : new MutableAttributes(); for (AttributeProvider attributeProvider : myAttributeProviders) { attributeProvider.setAttributes(this.renderingNode, part, attr); @@ -779,7 +771,7 @@ public MutableAttributes extendRenderingNodeAttributes(@NotNull AttributablePart } @Override - public MutableAttributes extendRenderingNodeAttributes(@NotNull Node node, @NotNull AttributablePart part, @Nullable Attributes attributes) { + public MutableAttributes extendRenderingNodeAttributes(Node node, AttributablePart part, @Nullable Attributes attributes) { MutableAttributes attr = attributes != null ? attributes.toMutable() : new MutableAttributes(); for (AttributeProvider attributeProvider : myAttributeProviders) { attributeProvider.setAttributes(node, part, attr); @@ -788,26 +780,25 @@ public MutableAttributes extendRenderingNodeAttributes(@NotNull Node node, @NotN } @Override - public @NotNull Node getCurrentNode() { + public Node getCurrentNode() { return renderingNode; } @Override - public @NotNull Node getContextFrame() { + public Node getContextFrame() { return renderingNode; } @Override - public @NotNull DataHolder getOptions() { + public DataHolder getOptions() { return options; } @Override - public @NotNull DocxRendererOptions getDocxRendererOptions() { + public DocxRendererOptions getDocxRendererOptions() { return rendererOptions; } - @NotNull @Override public Document getDocument() { return document; @@ -838,9 +829,8 @@ final public Iterable reversedNodesOfType(Collection> c return collectedNodes == null ? NULL_ITERABLE : collectedNodes.reversedItemsOfType(Node.class, classes); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Attributes attributes, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Attributes attributes, Boolean urlEncode) { HashMap resolvedLinks = resolvedLinkMap.computeIfAbsent(linkType, k -> new HashMap<>()); String urlSeq = String.valueOf(url); @@ -867,9 +857,8 @@ public ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequenc return resolvedLink; } - @NotNull @Override - public ResolvedContent resolvedContent(@NotNull ResolvedLink resolvedLink) { + public ResolvedContent resolvedContent(ResolvedLink resolvedLink) { ResolvedContent resolvedContent = resolvedContentMap.get(resolvedLink.getUrl()); if (resolvedContent == null) { @@ -889,14 +878,14 @@ public ResolvedContent resolvedContent(@NotNull ResolvedLink resolvedLink) { } @Override - public void render(@NotNull Node node) { + public void render(Node node) { if (node instanceof Document) { htmlIdGenerator.generateIds(document); // now create a map of node to id so we can validate hyperlinks new AllNodesVisitor() { @Override - protected void process(@NotNull Node node) { + protected void process(Node node) { String id = calculateNodeId(node); if (id != null && !id.isEmpty()) { nodeIdMap.add(node, id); @@ -979,7 +968,7 @@ void renderChildrenUnwrapped(Node parent) { } } - public void renderChildren(@NotNull Node parent) { + public void renderChildren(Node parent) { String id = getNodeId(parent); if (id != null && !id.isEmpty()) { if (bookmarkWrapsChildren.contains(parent.getClass())) { diff --git a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/DocxRendererContext.java b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/DocxRendererContext.java index 5f1654676..730738c88 100644 --- a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/DocxRendererContext.java +++ b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/DocxRendererContext.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.html.renderer.ResolvedContent; import com.vladsch.flexmark.html.renderer.ResolvedLink; import com.vladsch.flexmark.util.ast.Node; -import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -51,6 +50,5 @@ public interface DocxRendererContext extends DocxContext, LinkResolverCont * @param resolvedLink resolved link * @return resolved content for the link */ - @NotNull - ResolvedContent resolvedContent(@NotNull ResolvedLink resolvedLink); + ResolvedContent resolvedContent(ResolvedLink resolvedLink); } diff --git a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/CoreNodeDocxRenderer.java b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/CoreNodeDocxRenderer.java index a661121d6..cf86af6e4 100644 --- a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/CoreNodeDocxRenderer.java +++ b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/CoreNodeDocxRenderer.java @@ -66,7 +66,6 @@ import org.docx4j.toc.TocException; import org.docx4j.toc.TocGenerator; import org.docx4j.wml.*; -import org.jetbrains.annotations.NotNull; import jakarta.xml.bind.JAXBElement; import java.awt.image.BufferedImage; @@ -1396,7 +1395,7 @@ private void renderInputField(LinkRef node, DocxRendererContext docx) { docx.addFldCharCreateR(STFldCharType.END); } - @NotNull String getCurrentTime(String useFormat) { + String getCurrentTime(String useFormat) { Date date = options.runningTests ? Date.from(Instant.ofEpochSecond(1000230400L)) : new Date(); // change to fixed date so test results do not change @@ -1409,7 +1408,7 @@ private void renderInputField(LinkRef node, DocxRendererContext docx) { return currentTime; } - @NotNull String getCurrentDate(String useFormat) { + String getCurrentDate(String useFormat) { Date date = options.runningTests ? Date.from(Instant.ofEpochSecond(1000230400L)) : new Date(); String currentDate = ""; { diff --git a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/DocxLinkResolver.java b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/DocxLinkResolver.java index de6dd0e08..075e32681 100644 --- a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/DocxLinkResolver.java +++ b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/DocxLinkResolver.java @@ -13,8 +13,7 @@ import com.vladsch.flexmark.html.renderer.ResolvedLink; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.misc.Utils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -37,9 +36,8 @@ public DocxLinkResolver(LinkResolverBasicContext context) { prefixWwwLinks = DocxRenderer.PREFIX_WWW_LINKS.get(context.getOptions()); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) { + public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) { if (node instanceof Image || node instanceof Link || node instanceof Reference || node instanceof JekyllTag) { String url = link.getUrl(); @@ -152,9 +150,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public LinkResolver apply(@NotNull LinkResolverBasicContext context) { + public LinkResolver apply(LinkResolverBasicContext context) { return new DocxLinkResolver(context); } } diff --git a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/package-info.java b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/package-info.java index 27d22980b..4c8b35f6a 100644 --- a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/package-info.java +++ b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.docx.converter.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/package-info.java b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/package-info.java index 6acf40007..5ad17ed6e 100644 --- a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/package-info.java +++ b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.docx.converter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/AttributeFormat.java b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/AttributeFormat.java index 57b425c47..792e8f106 100644 --- a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/AttributeFormat.java +++ b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/AttributeFormat.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.sequence.SequenceUtils; import org.docx4j.wml.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.math.BigInteger; @@ -111,8 +110,7 @@ private Boolean getValidFontItalic(@Nullable String s) { return null; } - @NotNull - public CTShd getShd(@NotNull DocxContext docx) { + public CTShd getShd(DocxContext docx) { CTShd shd = docx.getFactory().createCTShd(); shd.setColor("auto"); shd.setFill(fillColor); @@ -120,7 +118,7 @@ public CTShd getShd(@NotNull DocxContext docx) { return shd; } - public void setFormatRPr(@NotNull RPrAbstract rPr, @NotNull DocxContext docx) { + public void setFormatRPr(RPrAbstract rPr, DocxContext docx) { if (textColor != null) { Color color = docx.getFactory().createColor(); rPr.setColor(color); diff --git a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/ColorNameMapper.java b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/ColorNameMapper.java index ad2e9079d..1bf447630 100644 --- a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/ColorNameMapper.java +++ b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/ColorNameMapper.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.docx.converter.util; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.awt.Color; import java.util.HashMap; @@ -38,7 +37,7 @@ public class ColorNameMapper { * @param c2 color 2 * @return distance between two colors */ - public static double colorDistance(@NotNull Color c1, @NotNull Color c2) { + public static double colorDistance(Color c1, Color c2) { int red1 = c1.getRed(); int red2 = c2.getRed(); int rmean = (red1 + red2) >> 1; @@ -48,7 +47,7 @@ public static double colorDistance(@NotNull Color c1, @NotNull Color c2) { return Math.sqrt((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8)); } - public static String colorToString(@NotNull Color color) { + public static String colorToString(Color color) { int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); @@ -56,38 +55,36 @@ public static String colorToString(@NotNull Color color) { return String.format("%02x%02x%02x", r, g, b); } - @NotNull - public static Color colorFromString(@NotNull String color) { + public static Color colorFromString(String color) { return new Color( Integer.valueOf(color.substring(0, 2), 16), Integer.valueOf(color.substring(2, 4), 16), Integer.valueOf(color.substring(4, 6), 16)); } - public static boolean isHexColor(@NotNull String color) { + public static boolean isHexColor(String color) { return color.matches(hexPattern); } - public static boolean isNamedColor(@NotNull String color) { + public static boolean isNamedColor(String color) { return colors.containsKey(color); } @Nullable - public static String getValidNamedOrHexColor(@NotNull String s) { + public static String getValidNamedOrHexColor(String s) { if (ColorNameMapper.isNamedColor(s) || ColorNameMapper.isHexColor(s)) { return s; } return null; } - @NotNull - public static String getValidHexColorOrDefault(@NotNull String s, @NotNull String defaultValue) { + public static String getValidHexColorOrDefault(String s, String defaultValue) { String hexColor = getValidHexColor(s); return hexColor != null ? hexColor : defaultValue; } @Nullable - public static String getValidHexColor(@NotNull String s) { + public static String getValidHexColor(String s) { if (ColorNameMapper.isNamedColor(s)) { return colorToString(colors.get(s)); } else if (ColorNameMapper.isHexColor(s)) { @@ -96,8 +93,7 @@ public static String getValidHexColor(@NotNull String s) { return null; } - @NotNull - public static String findClosestNamedColor(@NotNull Color color) { + public static String findClosestNamedColor(Color color) { String colorName = "black"; double minDistance = Double.MAX_VALUE; @@ -111,8 +107,7 @@ public static String findClosestNamedColor(@NotNull Color color) { return colorName; } - @NotNull - public static String findClosestNamedColor(@NotNull String color) { + public static String findClosestNamedColor(String color) { return findClosestNamedColor(colorFromString(color)); } } diff --git a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/package-info.java b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/package-info.java index bc3bc12af..30ef99ffb 100644 --- a/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/package-info.java +++ b/flexmark-docx-converter/src/main/java/com/vladsch/flexmark/docx/converter/util/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.docx.converter.util; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDeDocxConverterSpec2Test.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDeDocxConverterSpec2Test.java index 87dc0512d..9fa9ffec0 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDeDocxConverterSpec2Test.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDeDocxConverterSpec2Test.java @@ -4,21 +4,20 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboDeDocxConverterSpec2Test extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_de_ast_spec2.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static String TEMPLATE_XML = "/DE-Template.xml"; final private static DataHolder OPTIONS = new MutableDataSet() .set(DocxRenderer.DEFAULT_TEMPLATE_RESOURCE, TEMPLATE_XML) .toImmutable(); - public ComboDeDocxConverterSpec2Test(@NotNull SpecExample example) { + public ComboDeDocxConverterSpec2Test(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION, OPTIONS)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDeDocxConverterSpecTest.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDeDocxConverterSpecTest.java index 17d60b8e7..20b356362 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDeDocxConverterSpecTest.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDeDocxConverterSpecTest.java @@ -4,21 +4,20 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboDeDocxConverterSpecTest extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_de_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static String TEMPLATE_XML = "/DE-Template.xml"; final private static DataHolder OPTIONS = new MutableDataSet() .set(DocxRenderer.DEFAULT_TEMPLATE_RESOURCE, TEMPLATE_XML) .toImmutable(); - public ComboDeDocxConverterSpecTest(@NotNull SpecExample example) { + public ComboDeDocxConverterSpecTest(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION, OPTIONS)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterAltStylesSpecTest.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterAltStylesSpecTest.java index 95319c3e9..c7e1f4d56 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterAltStylesSpecTest.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterAltStylesSpecTest.java @@ -4,21 +4,20 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboDocxConverterAltStylesSpecTest extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_ast_alt_styles_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final public static String TEMPLATE_XML = "/empty-numbered-headings.xml"; final private static DataHolder OPTIONS = new MutableDataSet() .set(DocxRenderer.DEFAULT_TEMPLATE_RESOURCE, TEMPLATE_XML) .toImmutable(); - public ComboDocxConverterAltStylesSpecTest(@NotNull SpecExample example) { + public ComboDocxConverterAltStylesSpecTest(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION, OPTIONS)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterAttributeSpecTest.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterAttributeSpecTest.java index 5da0d8de4..b25f7824e 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterAttributeSpecTest.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterAttributeSpecTest.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboDocxConverterAttributeSpecTest extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_attribute_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboDocxConverterAttributeSpecTest(@NotNull SpecExample example) { + public ComboDocxConverterAttributeSpecTest(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterFormSpecTest.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterFormSpecTest.java index 8f01d7bfd..30fc15204 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterFormSpecTest.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterFormSpecTest.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboDocxConverterFormSpecTest extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_form_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboDocxConverterFormSpecTest(@NotNull SpecExample example) { + public ComboDocxConverterFormSpecTest(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterIssuesSpecTest.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterIssuesSpecTest.java index 0d934075b..454a76a79 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterIssuesSpecTest.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterIssuesSpecTest.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboDocxConverterIssuesSpecTest extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_issues_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboDocxConverterIssuesSpecTest(@NotNull SpecExample example) { + public ComboDocxConverterIssuesSpecTest(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpec2Test.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpec2Test.java index 985318d4a..6a26ce95f 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpec2Test.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpec2Test.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboDocxConverterSpec2Test extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_ast_spec2.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboDocxConverterSpec2Test(@NotNull SpecExample example) { + public ComboDocxConverterSpec2Test(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpec3Test.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpec3Test.java index da59958de..4d4c19505 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpec3Test.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpec3Test.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboDocxConverterSpec3Test extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_ast_spec3.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboDocxConverterSpec3Test(@NotNull SpecExample example) { + public ComboDocxConverterSpec3Test(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpecTest.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpecTest.java index 97d045399..7f280c3df 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpecTest.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpecTest.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboDocxConverterSpecTest extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboDocxConverterSpecTest(@NotNull SpecExample example) { + public ComboDocxConverterSpecTest(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpecTestBase.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpecTestBase.java index 0cc3f5965..d8a299d84 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpecTestBase.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboDocxConverterSpecTestBase.java @@ -39,8 +39,7 @@ import org.docx4j.Docx4J; import org.docx4j.openpackaging.exceptions.Docx4JException; import org.docx4j.openpackaging.packages.WordprocessingMLPackage; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.ByteArrayOutputStream; import java.io.File; @@ -137,23 +136,23 @@ protected static DataHolder getDefaultOptions(ResourceLocation resourceLocation, return new MutableDataSet(options).set(DocxRenderer.DOC_RELATIVE_URL, filePath); } - public ComboDocxConverterSpecTestBase(@NotNull SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { + public ComboDocxConverterSpecTestBase(SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { super(example, optionsMaps(optionsMap, optionMap), dataHolders(OPTIONS, defaultOptions)); } @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combineOptions = aggregate(myDefaultOptions, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combineOptions, Parser.builder(combineOptions).build(), DocxRenderer.builder(combineOptions).build(), true); } - final public @NotNull String getFileTestCaseDumpLocation() { + final public String getFileTestCaseDumpLocation() { String specResource = removeSuffix(removePrefix(getSpecResourceLocation().getResourcePath(), '/'), '/'); String testDir = suffixWith(removeSuffix(specResource, ".md"), '/'); return TEST_ROOT_DIRECTORY + testDir; } - final public @NotNull String getFileAllTestsDumpName() { + final public String getFileAllTestsDumpName() { return getFileTestCaseDumpLocation() + "AllTests"; } @@ -199,7 +198,7 @@ final public void addSpecExample(SpecExampleRenderer exampleRenderer, SpecExampl } @Override - final public void addFullSpecExample(@NotNull SpecExampleRenderer exampleRenderer, @NotNull SpecExampleParse exampleParse, DataHolder exampleOptions, boolean ignoredTestCase, @NotNull String html, @Nullable String ast) { + final public void addFullSpecExample(SpecExampleRenderer exampleRenderer, SpecExampleParse exampleParse, DataHolder exampleOptions, boolean ignoredTestCase, String html, @Nullable String ast) { if (!DUMP_ALL_TESTS_FILES) return; SpecExample example = exampleRenderer.getExample(); diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboEnDocxConverterSpec2Test.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboEnDocxConverterSpec2Test.java index 40762ee6d..f0bc14f4e 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboEnDocxConverterSpec2Test.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboEnDocxConverterSpec2Test.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboEnDocxConverterSpec2Test extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_ast_spec2.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboEnDocxConverterSpec2Test(@NotNull SpecExample example) { + public ComboEnDocxConverterSpec2Test(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION)); } diff --git a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboEnDocxConverterSpecTest.java b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboEnDocxConverterSpecTest.java index 07f45e3f8..8d25a5d74 100644 --- a/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboEnDocxConverterSpecTest.java +++ b/flexmark-docx-converter/src/test/java/com/vladsch/flexmark/docx/converter/ComboEnDocxConverterSpecTest.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboEnDocxConverterSpecTest extends ComboDocxConverterSpecTestBase { final private static String SPEC_RESOURCE = "/docx_converter_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboEnDocxConverterSpecTest(@NotNull SpecExample example) { + public ComboEnDocxConverterSpecTest(SpecExample example) { super(example, null, getDefaultOptions(RESOURCE_LOCATION)); } diff --git a/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/Abbreviation.java b/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/Abbreviation.java index dac8563fe..8ffbbf070 100644 --- a/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/Abbreviation.java +++ b/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/Abbreviation.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.ext.abbreviation.internal.AbbreviationRepository; import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A node containing the abbreviated text that will be rendered as an abbr tag or a link with title attribute @@ -20,18 +19,16 @@ public BasedSequence getAbbreviation() { return abbreviation; } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } - @NotNull @Override protected String toStringAttributes() { return "text=" + getChars(); @@ -42,7 +39,6 @@ public boolean isDefined() { return true; } - @NotNull @Override public BasedSequence getReference() { return abbreviation; diff --git a/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/AbbreviationBlock.java b/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/AbbreviationBlock.java index 768317eeb..2c4852dcd 100644 --- a/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/AbbreviationBlock.java +++ b/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/AbbreviationBlock.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.util.ast.ReferenceNode; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A block node that contains the abbreviation definition @@ -20,7 +19,7 @@ public class AbbreviationBlock extends Block implements ReferenceNode getDataKey() { return AbbreviationExtension.ABBREVIATIONS; } - @NotNull @Override public DataKey getKeepDataKey() { return AbbreviationExtension.ABBREVIATIONS_KEEP; } - @NotNull @Override public Set getReferencedElements(Node parent) { HashSet references = new HashSet<>(); diff --git a/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/internal/package-info.java b/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/internal/package-info.java index 80f207748..e89ecd604 100644 --- a/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/internal/package-info.java +++ b/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.abbreviation.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/package-info.java b/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/package-info.java index 00350f4b3..803ca783e 100644 --- a/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/package-info.java +++ b/flexmark-ext-abbreviation/src/main/java/com/vladsch/flexmark/ext/abbreviation/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.abbreviation; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationFormatterSpecTest.java b/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationFormatterSpecTest.java index 72183da53..35b81536f 100644 --- a/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationFormatterSpecTest.java +++ b/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -15,7 +14,7 @@ public class ComboAbbreviationFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_abbreviation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AbbreviationExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -27,7 +26,7 @@ public class ComboAbbreviationFormatterSpecTest extends FormatterSpecTest { AbbreviationExtension.ABBREVIATIONS_SORT ); - public ComboAbbreviationFormatterSpecTest(@NotNull SpecExample example) { + public ComboAbbreviationFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationSpecTest.java b/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationSpecTest.java index a2f545b02..2d54790d9 100644 --- a/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationSpecTest.java +++ b/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationSpecTest.java @@ -11,7 +11,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -21,7 +20,7 @@ public class ComboAbbreviationSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_abbreviation_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList( EscapedCharacterExtension.create(), @@ -42,7 +41,7 @@ public class ComboAbbreviationSpecTest extends RendererSpecTest { optionsMap.put("links", new MutableDataSet().set(AbbreviationExtension.USE_LINKS, true)); optionsMap.put("no-abbr", new MutableDataSet().set(UNLOAD_EXTENSIONS, Collections.singletonList(AbbreviationExtension.class))); } - public ComboAbbreviationSpecTest(@NotNull SpecExample example) { + public ComboAbbreviationSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationTranslationFormatterSpecTest.java b/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationTranslationFormatterSpecTest.java index 6a2394784..a02852dab 100644 --- a/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationTranslationFormatterSpecTest.java +++ b/flexmark-ext-abbreviation/src/test/java/com/vladsch/flexmark/ext/abbreviation/ComboAbbreviationTranslationFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -15,7 +14,7 @@ public class ComboAbbreviationTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_abbreviation_translation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AbbreviationExtension.create())) .set(Parser.UNDERSCORE_DELIMITER_PROCESSOR, false); @@ -26,7 +25,7 @@ public class ComboAbbreviationTranslationFormatterSpecTest extends TranslationFo AbbreviationExtension.ABBREVIATIONS_SORT ); - public ComboAbbreviationTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboAbbreviationTranslationFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/AdmonitionBlock.java b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/AdmonitionBlock.java index 854149bf6..d65bb8d90 100644 --- a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/AdmonitionBlock.java +++ b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/AdmonitionBlock.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.ast.ParagraphContainer; import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -18,7 +17,6 @@ public class AdmonitionBlock extends Block implements ParagraphContainer { protected BasedSequence title = BasedSequence.NULL; protected BasedSequence titleClosingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { @@ -30,7 +28,6 @@ public BasedSequence[] getSegments() { }; } - @NotNull @Override public BasedSequence[] getSegmentsForChars() { return new BasedSequence[] { @@ -43,7 +40,7 @@ public BasedSequence[] getSegmentsForChars() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, openingMarker, "open"); segmentSpanChars(out, info, "info"); delimitedSegmentSpanChars(out, titleOpeningMarker, title, titleClosingMarker, "title"); diff --git a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/AdmonitionExtension.java b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/AdmonitionExtension.java index 829e3c5b3..ba600c950 100644 --- a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/AdmonitionExtension.java +++ b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/AdmonitionExtension.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; import java.io.*; import java.util.HashMap; @@ -189,7 +188,7 @@ public void extend(Formatter.Builder formatterBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -204,7 +203,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new AdmonitionNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionBlockParser.java b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionBlockParser.java index 6a1ccb8d4..f2ecd8062 100644 --- a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionBlockParser.java +++ b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionBlockParser.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInHandler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.function.Consumer; @@ -85,7 +84,7 @@ public Set> getBeforeDependents() { } @Override - public @Nullable SpecialLeadInHandler getLeadInHandler(@NotNull DataHolder options) { + public @Nullable SpecialLeadInHandler getLeadInHandler(DataHolder options) { return AdmonitionLeadInHandler.HANDLER; } @@ -94,9 +93,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } @@ -105,7 +103,7 @@ static class AdmonitionLeadInHandler implements SpecialLeadInHandler { final static SpecialLeadInHandler HANDLER = new AdmonitionLeadInHandler(); @Override - public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer) { + public boolean escape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer) { if ((sequence.length() == 3 || sequence.length() == 4 && sequence.charAt(3) == '+') && (sequence.startsWith("???") || sequence.startsWith("!!!"))) { consumer.accept("\\"); consumer.accept(sequence); @@ -115,7 +113,7 @@ public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder opti } @Override - public boolean unEscape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer) { + public boolean unEscape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer) { if ((sequence.length() == 4 || sequence.length() == 5 && sequence.charAt(4) == '+') && (sequence.startsWith("\\???") || sequence.startsWith("\\!!!"))) { consumer.accept(sequence.subSequence(1)); return true; diff --git a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionNodeFormatter.java b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionNodeFormatter.java index faad33656..6d106c902 100644 --- a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionNodeFormatter.java +++ b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionNodeFormatter.java @@ -4,8 +4,7 @@ import com.vladsch.flexmark.formatter.*; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.RepeatedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.HashSet; @@ -47,9 +46,8 @@ private void render(AdmonitionBlock node, NodeFormatterContext context, Markdown } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new AdmonitionNodeFormatter(options); } } diff --git a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionNodeRenderer.java b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionNodeRenderer.java index 2b83b26e1..7d2662ec7 100644 --- a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionNodeRenderer.java +++ b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/AdmonitionNodeRenderer.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.html.Attribute; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.LinkedHashSet; @@ -42,7 +41,7 @@ public Set getRenderingPhases() { } @Override - public void renderDocument(@NotNull NodeRendererContext context, @NotNull HtmlWriter html, @NotNull Document document, @NotNull RenderingPhase phase) { + public void renderDocument(NodeRendererContext context, HtmlWriter html, Document document, RenderingPhase phase) { if (phase == BODY_TOP) { // dump out the SVG used by the rest of the nodes @@ -126,9 +125,8 @@ private void render(AdmonitionBlock node, NodeRendererContext context, HtmlWrite } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new AdmonitionNodeRenderer(options); } } diff --git a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/package-info.java b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/package-info.java index 9a3c7eb77..8bb5e03bc 100644 --- a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/package-info.java +++ b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.admonition.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/package-info.java b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/package-info.java index 416096a2f..4c444b4f6 100644 --- a/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/package-info.java +++ b/flexmark-ext-admonition/src/main/java/com/vladsch/flexmark/ext/admonition/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.admonition; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionFormatterSpecTest.java b/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionFormatterSpecTest.java index 4ab1e4d60..fe9043cd5 100644 --- a/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionFormatterSpecTest.java +++ b/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -14,13 +13,13 @@ public class ComboAdmonitionFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_admonition_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AdmonitionExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) .toImmutable(); - public ComboAdmonitionFormatterSpecTest(@NotNull SpecExample example) { + public ComboAdmonitionFormatterSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionSpecTest.java b/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionSpecTest.java index 5a11dfcd7..67f9dda01 100644 --- a/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionSpecTest.java +++ b/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -18,7 +17,7 @@ public class ComboAdmonitionSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_admonition_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(AdmonitionExtension.create(), TablesExtension.create())) .toImmutable(); @@ -30,7 +29,7 @@ public class ComboAdmonitionSpecTest extends RendererSpecTest { optionsMap.put("no-lead-space", new MutableDataSet().set(AdmonitionExtension.ALLOW_LEADING_SPACE, false)); optionsMap.put("intellij", new MutableDataSet().set(Parser.INTELLIJ_DUMMY_IDENTIFIER, true)); } - public ComboAdmonitionSpecTest(@NotNull SpecExample example) { + public ComboAdmonitionSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionTranslationFormatterSpecTest.java b/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionTranslationFormatterSpecTest.java index dcb7cb46e..fbc17834e 100644 --- a/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionTranslationFormatterSpecTest.java +++ b/flexmark-ext-admonition/src/test/java/com/vladsch/flexmark/ext/admonition/ComboAdmonitionTranslationFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -14,12 +13,12 @@ public class ComboAdmonitionTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_admonition_translation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AdmonitionExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false); - public ComboAdmonitionTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboAdmonitionTranslationFormatterSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/AnchorLink.java b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/AnchorLink.java index 6583371d7..d3579c4be 100644 --- a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/AnchorLink.java +++ b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/AnchorLink.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Anchor link node @@ -11,13 +10,12 @@ public class AnchorLink extends Node { public AnchorLink() { } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { } } diff --git a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/AnchorLinkExtension.java b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/AnchorLinkExtension.java index c0ebad061..dd6749578 100644 --- a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/AnchorLinkExtension.java +++ b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/AnchorLinkExtension.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for anchor links @@ -37,7 +36,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -47,7 +46,7 @@ public void parserOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new AnchorLinkNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/AnchorLinkNodePostProcessor.java b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/AnchorLinkNodePostProcessor.java index 7b3166616..ba981dbe0 100644 --- a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/AnchorLinkNodePostProcessor.java +++ b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/AnchorLinkNodePostProcessor.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NodeTracker; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension.ANCHORLINKS_NO_BLOCK_QUOTE; @@ -21,7 +20,7 @@ public AnchorLinkNodePostProcessor(DataHolder options) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { if (node instanceof Heading) { Heading heading = (Heading) node; if (heading.getText().isNotNull()) { @@ -57,9 +56,8 @@ public Factory(DataHolder options) { } } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new AnchorLinkNodePostProcessor(document); } } diff --git a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/AnchorLinkNodeRenderer.java b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/AnchorLinkNodeRenderer.java index 56b3520e2..1fab6c857 100644 --- a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/AnchorLinkNodeRenderer.java +++ b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/AnchorLinkNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -60,9 +59,8 @@ private void render(AnchorLink node, NodeRendererContext context, HtmlWriter htm } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new AnchorLinkNodeRenderer(options); } } diff --git a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/package-info.java b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/package-info.java index 64c000afc..f426f8481 100644 --- a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/package-info.java +++ b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.anchorlink.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/package-info.java b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/package-info.java index 1d48f93f9..d5b24a5c1 100644 --- a/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/package-info.java +++ b/flexmark-ext-anchorlink/src/main/java/com/vladsch/flexmark/ext/anchorlink/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.anchorlink; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-anchorlink/src/test/java/com/vladsch/flexmark/ext/anchorlink/ComboAnchorLinkSpecTest.java b/flexmark-ext-anchorlink/src/test/java/com/vladsch/flexmark/ext/anchorlink/ComboAnchorLinkSpecTest.java index 7b2a8f3da..4b94960c8 100644 --- a/flexmark-ext-anchorlink/src/test/java/com/vladsch/flexmark/ext/anchorlink/ComboAnchorLinkSpecTest.java +++ b/flexmark-ext-anchorlink/src/test/java/com/vladsch/flexmark/ext/anchorlink/ComboAnchorLinkSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -17,7 +16,7 @@ public class ComboAnchorLinkSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_anchorlink_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AnchorLinkExtension.create())) .set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "anchor") @@ -37,7 +36,7 @@ public class ComboAnchorLinkSpecTest extends RendererSpecTest { .set(AnchorLinkExtension.ANCHORLINKS_TEXT_SUFFIX, "") ); } - public ComboAnchorLinkSpecTest(@NotNull SpecExample example) { + public ComboAnchorLinkSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/AsideBlock.java b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/AsideBlock.java index d21ed64b9..1de8905c1 100644 --- a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/AsideBlock.java +++ b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/AsideBlock.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.ast.BlockQuoteLike; import com.vladsch.flexmark.util.ast.KeepTrailingBlankLineContainer; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -16,11 +15,10 @@ public class AsideBlock extends Block implements BlockQuoteLike, KeepTrailingBla private BasedSequence openingMarker = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, openingMarker, "marker"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker }; diff --git a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/AsideExtension.java b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/AsideExtension.java index d8730892b..b115d6fc5 100644 --- a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/AsideExtension.java +++ b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/AsideExtension.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for ext_asides @@ -33,7 +32,7 @@ public static AsideExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -53,7 +52,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new AsideNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideBlockParser.java b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideBlockParser.java index 027305b52..0925f60d4 100644 --- a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideBlockParser.java +++ b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideBlockParser.java @@ -13,8 +13,7 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInHandler; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInStartsWithCharsHandler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -150,7 +149,7 @@ public Set> getBeforeDependents() { } @Override - public @Nullable SpecialLeadInHandler getLeadInHandler(@NotNull DataHolder options) { + public @Nullable SpecialLeadInHandler getLeadInHandler(DataHolder options) { return AsideLeadInHandler.HANDLER; } @@ -159,9 +158,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideNodeFormatter.java b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideNodeFormatter.java index 4554923b0..6f855007c 100644 --- a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideNodeFormatter.java +++ b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideNodeFormatter.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.ext.aside.AsideBlock; import com.vladsch.flexmark.formatter.*; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.Set; @@ -40,9 +39,8 @@ private void render(AsideBlock node, NodeFormatterContext context, MarkdownWrite } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new AsideNodeFormatter(options); } } diff --git a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideNodeRenderer.java b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideNodeRenderer.java index 091c34b17..84a4966e0 100644 --- a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideNodeRenderer.java +++ b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/AsideNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -29,9 +28,8 @@ private void render(AsideBlock node, NodeRendererContext context, HtmlWriter htm } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new AsideNodeRenderer(options); } } diff --git a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/package-info.java b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/package-info.java index 2c5125d49..5a9539709 100644 --- a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/package-info.java +++ b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.aside.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/package-info.java b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/package-info.java index 4ec19e2b1..581a6b151 100644 --- a/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/package-info.java +++ b/flexmark-ext-aside/src/main/java/com/vladsch/flexmark/ext/aside/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.aside; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-aside/src/test/java/com/vladsch/flexmark/ext/aside/ComboAsideFormatterSpecTest.java b/flexmark-ext-aside/src/test/java/com/vladsch/flexmark/ext/aside/ComboAsideFormatterSpecTest.java index 2c356906d..95ce10bf6 100644 --- a/flexmark-ext-aside/src/test/java/com/vladsch/flexmark/ext/aside/ComboAsideFormatterSpecTest.java +++ b/flexmark-ext-aside/src/test/java/com/vladsch/flexmark/ext/aside/ComboAsideFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboAsideFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_aside_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AsideExtension.create())) .toImmutable(); @@ -25,7 +24,7 @@ public class ComboAsideFormatterSpecTest extends FormatterSpecTest { static { // optionsMap.put("use-github", new MutableDataSet().set(EmojiExtension.USE_SHORTCUT_TYPE, EmojiShortcutType.GITHUB)); } - public ComboAsideFormatterSpecTest(@NotNull SpecExample example) { + public ComboAsideFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-aside/src/test/java/com/vladsch/flexmark/ext/aside/ComboAsideSpecTest.java b/flexmark-ext-aside/src/test/java/com/vladsch/flexmark/ext/aside/ComboAsideSpecTest.java index 27d07ed18..133c5cc68 100644 --- a/flexmark-ext-aside/src/test/java/com/vladsch/flexmark/ext/aside/ComboAsideSpecTest.java +++ b/flexmark-ext-aside/src/test/java/com/vladsch/flexmark/ext/aside/ComboAsideSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -17,7 +16,7 @@ public class ComboAsideSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_aside_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AsideExtension.create())) .toImmutable(); @@ -28,7 +27,7 @@ public class ComboAsideSpecTest extends RendererSpecTest { optionsMap.put("ignore-blank-line", new MutableDataSet().set(AsideExtension.IGNORE_BLANK_LINE, true).set(Parser.BLOCK_QUOTE_IGNORE_BLANK_LINE, true)); optionsMap.put("blank-lines", new MutableDataSet().set(Parser.BLANK_LINES_IN_AST, true).set(TestUtils.NO_FILE_EOL, false)); } - public ComboAsideSpecTest(@NotNull SpecExample example) { + public ComboAsideSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributeNode.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributeNode.java index e0e1da23f..f270e6b47 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributeNode.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributeNode.java @@ -4,8 +4,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.html.Attribute; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * An Attribute node representing a single attribute name and value in attributes node @@ -17,7 +16,6 @@ public class AttributeNode extends Node implements DoNotDecorate { protected BasedSequence value = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -25,7 +23,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, name, "name"); segmentSpanChars(out, attributeSeparator, "sep"); delimitedSegmentSpanChars(out, openingMarker, value, closingMarker, "value"); diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributeValueQuotes.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributeValueQuotes.java index 3b5755618..a34b51610 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributeValueQuotes.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributeValueQuotes.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.ext.attributes; import com.vladsch.flexmark.util.misc.CharPredicate; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.util.sequence.SequenceUtils.containsAny; @@ -19,8 +18,7 @@ public enum AttributeValueQuotes { final static CharPredicate P_SINGLE_QUOTES = CharPredicate.anyOf("'"); final static CharPredicate P_DOUBLE_QUOTES = CharPredicate.anyOf("\""); - @NotNull - public String quotesFor(@NotNull CharSequence text, @NotNull CharSequence defaultQuotes) { + public String quotesFor(CharSequence text, CharSequence defaultQuotes) { switch (this) { case NO_QUOTES_SINGLE_PREFERRED: if (!containsAny(text, P_SPACES_OR_QUOTES)) { diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributesExtension.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributesExtension.java index 651a5fd84..4f509a5bc 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributesExtension.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributesExtension.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.format.options.DiscretionaryText; -import org.jetbrains.annotations.NotNull; /** * Extension for attributes @@ -68,12 +67,12 @@ public void extend(Formatter.Builder formatterBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (ASSIGN_TEXT_ATTRIBUTES.get(htmlRendererBuilder)) { htmlRendererBuilder.nodeRendererFactory(new AttributesNodeRenderer.Factory()); } @@ -81,7 +80,7 @@ public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull S } @Override - public void extend(@NotNull RendererBuilder rendererBuilder, @NotNull String rendererType) { + public void extend(RendererBuilder rendererBuilder, String rendererType) { //rendererBuilder.nodeRendererFactory(new AttributesNodeRenderer.Factory()); rendererBuilder.attributeProviderFactory(new AttributesAttributeProvider.Factory()); } diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributesNode.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributesNode.java index edc7eea5f..32be0a082 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributesNode.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/AttributesNode.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NonRenderingInline; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A AttributesNode node @@ -15,7 +14,6 @@ public class AttributesNode extends Node implements DelimitedNode, DoNotDecorate protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -23,7 +21,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesAttributeProvider.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesAttributeProvider.java index 6e593aff1..88a5a7002 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesAttributeProvider.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesAttributeProvider.java @@ -14,7 +14,6 @@ import com.vladsch.flexmark.util.html.Attribute; import com.vladsch.flexmark.util.html.MutableAttributes; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -31,7 +30,7 @@ public AttributesAttributeProvider(LinkResolverContext context) { } @Override - public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @NotNull MutableAttributes attributes) { + public void setAttributes(Node node, AttributablePart part, MutableAttributes attributes) { // regression bug, issue #372, add option, default to both as before if (part == CoreNodeRenderer.CODE_CONTENT ? attributeOptions.fencedCodeAddAttributes.addToCode : attributeOptions.fencedCodeAddAttributes.addToPre) { ArrayList nodeAttributesList = nodeAttributeRepository.get(node); @@ -90,9 +89,8 @@ public static class Factory extends IndependentAttributeProviderFactory { // return false; //} - @NotNull @Override - public AttributeProvider apply(@NotNull LinkResolverContext context) { + public AttributeProvider apply(LinkResolverContext context) { return new AttributesAttributeProvider(context); } } diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesFormatOptions.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesFormatOptions.java index dcb1071fd..e31e6106a 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesFormatOptions.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesFormatOptions.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSetter; import com.vladsch.flexmark.util.format.options.DiscretionaryText; -import org.jetbrains.annotations.NotNull; class AttributesFormatOptions implements MutableDataSetter { final public boolean attributesCombineConsecutive; @@ -28,9 +27,8 @@ public AttributesFormatOptions(DataHolder options) { attributeClassFormat = AttributesExtension.FORMAT_ATTRIBUTE_CLASS.get(options); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(AttributesExtension.FORMAT_ATTRIBUTES_COMBINE_CONSECUTIVE, attributesCombineConsecutive); dataHolder.set(AttributesExtension.FORMAT_ATTRIBUTES_SORT, attributesSort); dataHolder.set(AttributesExtension.FORMAT_ATTRIBUTES_SPACES, attributesSpaces); diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesInlineParserExtension.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesInlineParserExtension.java index e23efd984..0bd216f3c 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesInlineParserExtension.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesInlineParserExtension.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.parser.InlineParserExtensionFactory; import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Matcher; @@ -22,16 +21,16 @@ public AttributesInlineParserExtension(LightInlineParser inlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { if (inlineParser.peek(1) != '{') { int index = inlineParser.getIndex(); BasedSequence input = inlineParser.getInput(); @@ -93,7 +92,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return "{"; @@ -105,9 +103,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser inlineParser) { + public InlineParserExtension apply(LightInlineParser inlineParser) { return new AttributesInlineParserExtension(inlineParser); } diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodeFormatter.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodeFormatter.java index 2b8a1628a..d8107b3af 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodeFormatter.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodeFormatter.java @@ -15,8 +15,7 @@ import com.vladsch.flexmark.util.html.MutableAttributes; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.PrefixedSubSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -59,7 +58,7 @@ public Set getFormattingPhases() { } @Override - public void addExplicitId(@NotNull Node node, @Nullable String id, @NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown) { + public void addExplicitId(Node node, @Nullable String id, NodeFormatterContext context, MarkdownWriter markdown) { if (id != null && node instanceof Heading) { // if our id != generated id we add explicit attributes if none are found already if (context.getRenderPurpose() == TRANSLATED) { @@ -96,7 +95,7 @@ boolean hasNoIdAttribute(Node node) { } @Override - public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase) { + public void renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase) { // reset storage for attribute keys and attributes map if (context.isTransformingText()) { context.getTranslationStore().set(ATTRIBUTE_TRANSLATION_ID, 0); @@ -666,9 +665,8 @@ static AttributeNode combineAttributes(LinkedHashMap attr } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new AttributesNodeFormatter(options); } } diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodePostProcessor.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodePostProcessor.java index 67309a67e..f908ce94a 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodePostProcessor.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodePostProcessor.java @@ -12,7 +12,6 @@ import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -227,7 +226,7 @@ static void textBaseWrap(NodeTracker state, Node lastNonAttributesNode, Node las } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { if (node instanceof AttributesNode) { AttributesNode attributesNode = (AttributesNode) node; @@ -356,9 +355,8 @@ public Factory() { addNodes(AttributesNode.class, FencedCodeBlock.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new AttributesNodePostProcessor(document); } } diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodeRenderer.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodeRenderer.java index 680bd55a3..a5cc47add 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodeRenderer.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesNodeRenderer.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.html.Attributes; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -45,9 +44,8 @@ public Set> getNodeRenderingHandlers() { } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new AttributesNodeRenderer(options); } } diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesOptions.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesOptions.java index 25ef823c7..99cdac844 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesOptions.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/AttributesOptions.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSetter; -import org.jetbrains.annotations.NotNull; class AttributesOptions implements MutableDataSetter { final public boolean assignTextAttributes; @@ -22,9 +21,8 @@ public AttributesOptions(DataHolder options) { fencedCodeAddAttributes = AttributesExtension.FENCED_CODE_ADD_ATTRIBUTES.get(options); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(AttributesExtension.ASSIGN_TEXT_ATTRIBUTES, assignTextAttributes); dataHolder.set(AttributesExtension.WRAP_NON_ATTRIBUTE_TEXT, wrapNonAttributeText); dataHolder.set(AttributesExtension.USE_EMPTY_IMPLICIT_AS_SPAN_DELIMITER, useEmptyImplicitAsSpanDelimiter); diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/NodeAttributeRepository.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/NodeAttributeRepository.java index 330f86f1c..4d242ccee 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/NodeAttributeRepository.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/NodeAttributeRepository.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; -import org.jetbrains.annotations.NotNull; import java.util.*; @@ -71,7 +70,7 @@ public ArrayList remove(Object key) { } @Override - public void putAll(@NotNull Map> m) { + public void putAll(Map> m) { nodeAttributesHashMap.putAll(m); } @@ -80,19 +79,16 @@ public void clear() { nodeAttributesHashMap.clear(); } - @NotNull @Override public Set keySet() { return nodeAttributesHashMap.keySet(); } - @NotNull @Override public Collection> values() { return nodeAttributesHashMap.values(); } - @NotNull @Override public Set>> entrySet() { return nodeAttributesHashMap.entrySet(); diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/package-info.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/package-info.java index 094d7c677..d80ac0809 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/package-info.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.attributes.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/package-info.java b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/package-info.java index 650e06630..fac9bf8ce 100644 --- a/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/package-info.java +++ b/flexmark-ext-attributes/src/main/java/com/vladsch/flexmark/ext/attributes/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.attributes; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboAttributesFormatterSpecTest.java b/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboAttributesFormatterSpecTest.java index 07383bf04..786c2f1dc 100644 --- a/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboAttributesFormatterSpecTest.java +++ b/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboAttributesFormatterSpecTest.java @@ -11,14 +11,13 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.format.options.DiscretionaryText; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.*; public class ComboAttributesFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_attributes_format_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AttributesExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -56,7 +55,7 @@ public class ComboAttributesFormatterSpecTest extends FormatterSpecTest { optionsMap.put("class-implicit", new MutableDataSet().set(AttributesExtension.FORMAT_ATTRIBUTE_CLASS, AttributeImplicitName.IMPLICIT_PREFERRED)); optionsMap.put("class-explicit", new MutableDataSet().set(AttributesExtension.FORMAT_ATTRIBUTE_CLASS, AttributeImplicitName.EXPLICIT_PREFERRED)); } - public ComboAttributesFormatterSpecTest(@NotNull SpecExample example) { + public ComboAttributesFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboAttributesTranslationFormatterSpecTest.java b/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboAttributesTranslationFormatterSpecTest.java index 9731049ec..9ebe55b5b 100644 --- a/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboAttributesTranslationFormatterSpecTest.java +++ b/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboAttributesTranslationFormatterSpecTest.java @@ -10,14 +10,13 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.*; public class ComboAttributesTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_attributes_translation_format_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AttributesExtension.create())) .toImmutable(); @@ -33,7 +32,7 @@ public class ComboAttributesTranslationFormatterSpecTest extends TranslationForm optionsMap.put("no-text-attributes", new MutableDataSet().set(AttributesExtension.ASSIGN_TEXT_ATTRIBUTES, false)); } // - public ComboAttributesTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboAttributesTranslationFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboExtAttributesSpecTest.java b/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboExtAttributesSpecTest.java index 656393e05..8238dfd9a 100644 --- a/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboExtAttributesSpecTest.java +++ b/flexmark-ext-attributes/src/test/java/com/vladsch/flexmark/ext/attributes/ComboExtAttributesSpecTest.java @@ -15,7 +15,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -25,7 +24,7 @@ public class ComboExtAttributesSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_attributes_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.RENDER_HEADER_ID, true) .set(AttributesExtension.ASSIGN_TEXT_ATTRIBUTES, true) @@ -58,7 +57,7 @@ public class ComboExtAttributesSpecTest extends RendererSpecTest { optionsMap.put("fenced-code-to-code", new MutableDataSet().set(AttributesExtension.FENCED_CODE_ADD_ATTRIBUTES, FencedCodeAddType.ADD_TO_CODE)); optionsMap.put("custom", new MutableDataSet().set(CUSTOM_OPTION, (option, text) -> null)); } - public ComboExtAttributesSpecTest(@NotNull SpecExample example) { + public ComboExtAttributesSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/internal/AutolinkNodePostProcessor.java b/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/internal/AutolinkNodePostProcessor.java index bd44cd4fd..9252822b8 100644 --- a/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/internal/AutolinkNodePostProcessor.java +++ b/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/internal/AutolinkNodePostProcessor.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.sequence.*; -import org.jetbrains.annotations.NotNull; import org.nibor.autolink.LinkExtractor; import org.nibor.autolink.LinkSpan; import org.nibor.autolink.LinkType; @@ -70,7 +69,7 @@ public int getEndIndex() { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { // TODO: figure our why optimization does not work after AutoLink inserted by inline parser if (node.getAncestorOfType(DoNotDecorate.class, DoNotLinkDecorate.class) != null) return; @@ -268,9 +267,8 @@ public Factory() { addNodes(Text.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new AutolinkNodePostProcessor(document); } } diff --git a/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/internal/package-info.java b/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/internal/package-info.java index d13c6d8f9..5968fc7a0 100644 --- a/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/internal/package-info.java +++ b/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.autolink.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/package-info.java b/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/package-info.java index 5ba0df4c6..8eb6760fb 100644 --- a/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/package-info.java +++ b/flexmark-ext-autolink/src/main/java/com/vladsch/flexmark/ext/autolink/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.autolink; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-autolink/src/test/java/com/vladsch/flexmark/ext/autolink/AutolinkTest.java b/flexmark-ext-autolink/src/test/java/com/vladsch/flexmark/ext/autolink/AutolinkTest.java index 3b66696a5..fcad145ad 100644 --- a/flexmark-ext-autolink/src/test/java/com/vladsch/flexmark/ext/autolink/AutolinkTest.java +++ b/flexmark-ext-autolink/src/test/java/com/vladsch/flexmark/ext/autolink/AutolinkTest.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataSet; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; import java.util.Collections; @@ -22,17 +21,17 @@ public class AutolinkTest extends RenderingTestCase { .set(Parser.EXTENSIONS, Collections.singleton(AutolinkExtension.create())) .toImmutable(); - final private static @NotNull Parser PARSER = Parser.builder(OPTIONS).build(); - final private static @NotNull HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build(); + final private static Parser PARSER = Parser.builder(OPTIONS).build(); + final private static HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build(); @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = DataSet.aggregate(OPTIONS, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, PARSER, RENDERER, true); } @Override - public @Nullable DataHolder options(@NotNull String option) { + public @Nullable DataHolder options(String option) { return null; } diff --git a/flexmark-ext-autolink/src/test/java/com/vladsch/flexmark/ext/autolink/ComboAutolinkSpecTest.java b/flexmark-ext-autolink/src/test/java/com/vladsch/flexmark/ext/autolink/ComboAutolinkSpecTest.java index a937149d1..75ed5ab32 100644 --- a/flexmark-ext-autolink/src/test/java/com/vladsch/flexmark/ext/autolink/ComboAutolinkSpecTest.java +++ b/flexmark-ext-autolink/src/test/java/com/vladsch/flexmark/ext/autolink/ComboAutolinkSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -17,7 +16,7 @@ @RunWith(Parameterized.class) public class ComboAutolinkSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_autolink_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(AutolinkExtension.create())) .toImmutable(); @@ -30,7 +29,7 @@ public class ComboAutolinkSpecTest extends RendererSpecTest { optionsMap.put("intellij-dummy", new MutableDataSet().set(Parser.INTELLIJ_DUMMY_IDENTIFIER, true)); optionsMap.put("typographic-ext", new MutableDataSet().set(Parser.EXTENSIONS, Arrays.asList(AutolinkExtension.create(), TypographicExtension.create()))); } - public ComboAutolinkSpecTest(@NotNull SpecExample example) { + public ComboAutolinkSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionExtension.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionExtension.java index 9dbbc6681..d3cd86b29 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionExtension.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionExtension.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.format.options.DefinitionMarker; -import org.jetbrains.annotations.NotNull; /** * Extension for definitions @@ -38,7 +37,7 @@ public void extend(Formatter.Builder formatterBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -55,7 +54,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new DefinitionNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionList.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionList.java index d60873f3d..fe41dc8a9 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionList.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionList.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.ast.ListBlock; import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -26,7 +25,6 @@ public DefinitionList(BlockContent blockContent) { super(blockContent); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionTerm.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionTerm.java index 21842b13d..9b7fbbce8 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionTerm.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/DefinitionTerm.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A Definition block node @@ -14,10 +13,9 @@ public class DefinitionTerm extends ListItem { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { } - @NotNull @Override public BasedSequence[] getSegments() { return Node.EMPTY_SEGMENTS; diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionItemBlockParser.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionItemBlockParser.java index c0a39bedd..2665f5092 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionItemBlockParser.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionItemBlockParser.java @@ -18,8 +18,7 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInCharsHandler; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInHandler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -232,7 +231,7 @@ public Set> getBeforeDependents() { } @Override - public @Nullable SpecialLeadInHandler getLeadInHandler(@NotNull DataHolder options) { + public @Nullable SpecialLeadInHandler getLeadInHandler(DataHolder options) { boolean colon = DefinitionExtension.COLON_MARKER.get(options); boolean tilde = DefinitionExtension.TILDE_MARKER.get(options); return colon && tilde ? DefinitionLeadInHandler.HANDLER_COLON_TILDE : colon ? DefinitionLeadInHandler.HANDLER_COLON : tilde ? DefinitionLeadInHandler.HANDLER_TILDE : null; @@ -243,9 +242,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionListBlockPreProcessor.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionListBlockPreProcessor.java index 838a9d23c..3c33c63e7 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionListBlockPreProcessor.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionListBlockPreProcessor.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.Set; @@ -56,7 +55,6 @@ public void preProcess(ParserState state, Block block) { } public static class Factory implements BlockPreProcessorFactory { - @NotNull @Override public Set> getBlockTypes() { HashSet> set = new HashSet<>(); @@ -83,9 +81,8 @@ public boolean affectsGlobalScope() { return true; } - @NotNull @Override - public BlockPreProcessor apply(@NotNull ParserState state) { + public BlockPreProcessor apply(ParserState state) { return new DefinitionListBlockPreProcessor(state.getProperties()); } } diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionListItemBlockPreProcessor.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionListItemBlockPreProcessor.java index 89ddaea23..71f3abce8 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionListItemBlockPreProcessor.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionListItemBlockPreProcessor.java @@ -15,8 +15,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.List; @@ -145,7 +144,6 @@ public void preProcess(ParserState state, Block block) { } public static class Factory implements BlockPreProcessorFactory { - @NotNull @Override public Set> getBlockTypes() { HashSet> set = new HashSet<>(); @@ -170,9 +168,8 @@ public boolean affectsGlobalScope() { return true; } - @NotNull @Override - public BlockPreProcessor apply(@NotNull ParserState state) { + public BlockPreProcessor apply(ParserState state) { return new DefinitionListItemBlockPreProcessor(state.getProperties()); } } diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionNodeFormatter.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionNodeFormatter.java index fd07ec664..897742bdd 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionNodeFormatter.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionNodeFormatter.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.RepeatedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -90,9 +89,8 @@ private void render(DefinitionItem node, NodeFormatterContext context, MarkdownW } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new DefinitionNodeFormatter(options); } } diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionNodeRenderer.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionNodeRenderer.java index 0dd348696..e41793a68 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionNodeRenderer.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/DefinitionNodeRenderer.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.parser.ListOptions; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -61,9 +60,8 @@ private void render(DefinitionItem node, NodeRendererContext context, HtmlWriter } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new DefinitionNodeRenderer(options); } } diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/package-info.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/package-info.java index a5efd5172..96e908c10 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/package-info.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.definition.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/package-info.java b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/package-info.java index 19b96e609..3ae1f2b19 100644 --- a/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/package-info.java +++ b/flexmark-ext-definition/src/main/java/com/vladsch/flexmark/ext/definition/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.definition; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-definition/src/test/java/com/vladsch/flexmark/ext/definition/ComboDefinitionFormatterSpecTest.java b/flexmark-ext-definition/src/test/java/com/vladsch/flexmark/ext/definition/ComboDefinitionFormatterSpecTest.java index dd50b0db3..74cf36482 100644 --- a/flexmark-ext-definition/src/test/java/com/vladsch/flexmark/ext/definition/ComboDefinitionFormatterSpecTest.java +++ b/flexmark-ext-definition/src/test/java/com/vladsch/flexmark/ext/definition/ComboDefinitionFormatterSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.format.options.DefinitionMarker; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -17,7 +16,7 @@ public class ComboDefinitionFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_definition_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(DefinitionExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -33,7 +32,7 @@ public class ComboDefinitionFormatterSpecTest extends FormatterSpecTest { optionsMap.put("marker-type-tilde", new MutableDataSet().set(DefinitionExtension.FORMAT_MARKER_TYPE, DefinitionMarker.TILDE)); optionsMap.put("no-blank-lines", new MutableDataSet().set(Parser.BLANK_LINES_IN_AST, false)); } - public ComboDefinitionFormatterSpecTest(@NotNull SpecExample example) { + public ComboDefinitionFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-definition/src/test/java/com/vladsch/flexmark/ext/definition/ComboDefinitionSpecTest.java b/flexmark-ext-definition/src/test/java/com/vladsch/flexmark/ext/definition/ComboDefinitionSpecTest.java index fac36e212..95ae6cee4 100644 --- a/flexmark-ext-definition/src/test/java/com/vladsch/flexmark/ext/definition/ComboDefinitionSpecTest.java +++ b/flexmark-ext-definition/src/test/java/com/vladsch/flexmark/ext/definition/ComboDefinitionSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -17,7 +16,7 @@ public class ComboDefinitionSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_definition_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(DefinitionExtension.create())) .toImmutable(); @@ -29,7 +28,7 @@ public class ComboDefinitionSpecTest extends RendererSpecTest { optionsMap.put("break-list", new MutableDataSet().set(DefinitionExtension.DOUBLE_BLANK_LINE_BREAKS_LIST, true)); optionsMap.put("suppress-format-eol", new MutableDataSet().set(HtmlRenderer.HTML_BLOCK_OPEN_TAG_EOL, false).set(HtmlRenderer.HTML_BLOCK_CLOSE_TAG_EOL, false).set(HtmlRenderer.INDENT_SIZE, 0)); } - public ComboDefinitionSpecTest(@NotNull SpecExample example) { + public ComboDefinitionSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/Emoji.java b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/Emoji.java index 06a9e10ee..8286005ce 100644 --- a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/Emoji.java +++ b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/Emoji.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.misc.BitFieldSet; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; /** * An emoji node containing emoji shortcut text @@ -18,14 +17,13 @@ public class Emoji extends Node implements DelimitedNode, TextContainer { protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/EmojiExtension.java b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/EmojiExtension.java index 0c1305ca0..36e81a122 100644 --- a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/EmojiExtension.java +++ b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/EmojiExtension.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for emoji shortcuts using Emoji-Cheat-Sheet.com. @@ -35,7 +34,7 @@ public static EmojiExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -55,7 +54,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new EmojiNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiJiraRenderer.java b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiJiraRenderer.java index ea16f883c..7fb45c7f3 100644 --- a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiJiraRenderer.java +++ b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiJiraRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.HashSet; @@ -59,9 +58,8 @@ private void render(Emoji node, NodeRendererContext context, HtmlWriter html) { } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new EmojiJiraRenderer(options); } } diff --git a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiNodeFormatter.java b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiNodeFormatter.java index 0d4de8930..716f62331 100644 --- a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiNodeFormatter.java +++ b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiNodeFormatter.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.ext.emoji.Emoji; import com.vladsch.flexmark.formatter.*; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.Set; @@ -37,9 +36,8 @@ void render(Emoji node, NodeFormatterContext context, MarkdownWriter markdown) { } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new EmojiNodeFormatter(options); } } diff --git a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiNodeRenderer.java b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiNodeRenderer.java index cdb305e29..ec874bd3e 100644 --- a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiNodeRenderer.java +++ b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/EmojiNodeRenderer.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.html.HtmlWriter; import com.vladsch.flexmark.html.renderer.*; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -49,9 +48,8 @@ private void render(Emoji node, NodeRendererContext context, HtmlWriter html) { } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new EmojiNodeRenderer(options); } } diff --git a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/package-info.java b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/package-info.java index 4776d4703..57d26fccd 100644 --- a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/package-info.java +++ b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.emoji.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/package-info.java b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/package-info.java index 3328dede7..a1940479e 100644 --- a/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/package-info.java +++ b/flexmark-ext-emoji/src/main/java/com/vladsch/flexmark/ext/emoji/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.emoji; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiCrashSpecTest.java b/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiCrashSpecTest.java index ec2079d42..e51a445c7 100644 --- a/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiCrashSpecTest.java +++ b/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiCrashSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboEmojiCrashSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_emoji_crash_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(EmojiExtension.create())) .set(EmojiExtension.ROOT_IMAGE_PATH, "/img/") @@ -34,7 +33,7 @@ public class ComboEmojiCrashSpecTest extends RendererSpecTest { optionsMap.put("no-size", new MutableDataSet().set(EmojiExtension.ATTR_IMAGE_SIZE, "")); optionsMap.put("no-align", new MutableDataSet().set(EmojiExtension.ATTR_ALIGN, "")); } - public ComboEmojiCrashSpecTest(@NotNull SpecExample example) { + public ComboEmojiCrashSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiJiraTest.java b/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiJiraTest.java index 66497ba48..1541187f1 100644 --- a/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiJiraTest.java +++ b/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiJiraTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -16,14 +15,14 @@ public class ComboEmojiJiraTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_emoji_jira_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.RENDER_HEADER_ID, false) .set(HtmlRenderer.GENERATE_HEADER_ID, true) .set(Parser.EXTENSIONS, Arrays.asList(JiraConverterExtension.create(), EmojiExtension.create())) .toImmutable(); - public ComboEmojiJiraTest(@NotNull SpecExample example) { + public ComboEmojiJiraTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiSpecTest.java b/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiSpecTest.java index 45af8339f..5dcc6bf2b 100644 --- a/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiSpecTest.java +++ b/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboEmojiSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_emoji_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(EmojiExtension.create())) .set(EmojiExtension.ROOT_IMAGE_PATH, "/img/") @@ -35,7 +34,7 @@ public class ComboEmojiSpecTest extends RendererSpecTest { optionsMap.put("no-size", new MutableDataSet().set(EmojiExtension.ATTR_IMAGE_SIZE, "")); optionsMap.put("no-align", new MutableDataSet().set(EmojiExtension.ATTR_ALIGN, "")); } - public ComboEmojiSpecTest(@NotNull SpecExample example) { + public ComboEmojiSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiTranslationFormatterSpecTest.java b/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiTranslationFormatterSpecTest.java index d31dd1683..5a5ef7f09 100644 --- a/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiTranslationFormatterSpecTest.java +++ b/flexmark-ext-emoji/src/test/java/com/vladsch/flexmark/ext/emoji/ComboEmojiTranslationFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboEmojiTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_emoji_translation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(EmojiExtension.create())) .toImmutable(); @@ -33,7 +32,7 @@ public class ComboEmojiTranslationFormatterSpecTest extends TranslationFormatter optionsMap.put("no-size", new MutableDataSet().set(EmojiExtension.ATTR_IMAGE_SIZE, "")); optionsMap.put("no-align", new MutableDataSet().set(EmojiExtension.ATTR_ALIGN, "")); } - public ComboEmojiTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboEmojiTranslationFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceBase.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceBase.java index 522b3f7fa..c22e17fec 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceBase.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceBase.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A EnumeratedReference node @@ -13,7 +12,6 @@ public class EnumeratedReferenceBase extends Node implements DelimitedNode, DoNo protected BasedSequence closingMarker = BasedSequence.NULL; protected EnumeratedReferenceBlock enumeratedReferenceBlock; - @NotNull @Override public BasedSequence getReference() { return text; @@ -47,14 +45,13 @@ public void setEnumeratedReferenceBlock(EnumeratedReferenceBlock enumeratedRefer this.enumeratedReferenceBlock = enumeratedReferenceBlock; } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceBlock.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceBlock.java index e5f611f23..e666f0e1a 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceBlock.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceBlock.java @@ -9,8 +9,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A EnumeratedReference block node @@ -28,19 +27,18 @@ public int compareTo(EnumeratedReferenceBlock other) { @Nullable @Override - public EnumeratedReferenceText getReferencingNode(@NotNull Node node) { + public EnumeratedReferenceText getReferencingNode(Node node) { return node instanceof EnumeratedReferenceText ? (EnumeratedReferenceText) node : null; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpan(out, openingMarker, "open"); segmentSpan(out, text, "text"); segmentSpan(out, closingMarker, "close"); segmentSpan(out, enumeratedReference, "enumeratedReference"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker, enumeratedReference }; diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceExtension.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceExtension.java index 440f4c56f..cde11bd0e 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceExtension.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceExtension.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.format.options.ElementPlacement; import com.vladsch.flexmark.util.format.options.ElementPlacementSort; -import org.jetbrains.annotations.NotNull; /** * Extension for enumerated_references @@ -42,7 +41,7 @@ public static EnumeratedReferenceExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -73,7 +72,7 @@ public void extend(Formatter.Builder formatterBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new EnumeratedReferenceNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceRepository.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceRepository.java index 21e6b7c1f..725fcef56 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceRepository.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/EnumeratedReferenceRepository.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.ast.NodeRepository; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.HashSet; @@ -35,19 +34,16 @@ public EnumeratedReferenceRepository(DataHolder options) { super(EnumeratedReferenceExtension.ENUMERATED_REFERENCES_KEEP.get(options)); } - @NotNull @Override public DataKey getDataKey() { return EnumeratedReferenceExtension.ENUMERATED_REFERENCES; } - @NotNull @Override public DataKey getKeepDataKey() { return EnumeratedReferenceExtension.ENUMERATED_REFERENCES_KEEP; } - @NotNull @Override public Set getReferencedElements(Node parent) { HashSet references = new HashSet<>(); diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceBlockParser.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceBlockParser.java index 2fa6a579e..175acaffa 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceBlockParser.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceBlockParser.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Matcher; @@ -97,9 +96,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceLinkRefProcessor.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceLinkRefProcessor.java index 88cc9d2c1..1c0363553 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceLinkRefProcessor.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceLinkRefProcessor.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class EnumeratedReferenceLinkRefProcessor implements LinkRefProcessor { static final boolean WANT_EXCLAMATION_PREFIX = false; @@ -30,13 +29,12 @@ public int getBracketNestingLevel() { } @Override - public boolean isMatch(@NotNull BasedSequence nodeChars) { + public boolean isMatch(BasedSequence nodeChars) { return nodeChars.length() >= 3 && nodeChars.charAt(0) == '[' && (nodeChars.charAt(1) == '@' || nodeChars.charAt(1) == '#') && nodeChars.endCharAt(1) == ']' && (nodeChars.length() == 3 || !Character.isDigit(nodeChars.charAt(2))); } - @NotNull @Override - public Node createNode(@NotNull BasedSequence nodeChars) { + public Node createNode(BasedSequence nodeChars) { BasedSequence enumeratedReferenceId = nodeChars.midSequence(2, -1).trim(); EnumeratedReferenceBlock enumeratedReferenceBlock = enumeratedReferenceId.length() > 0 ? enumeratedReferenceRepository.get(enumeratedReferenceId.toString()) : null; @@ -53,37 +51,35 @@ public Node createNode(@NotNull BasedSequence nodeChars) { } } - @NotNull @Override - public BasedSequence adjustInlineText(@NotNull Document document, @NotNull Node node) { + public BasedSequence adjustInlineText(Document document, Node node) { assert node instanceof EnumeratedReferenceBase; return ((EnumeratedReferenceBase) node).getText(); } @Override - public boolean allowDelimiters(@NotNull BasedSequence chars, @NotNull Document document, @NotNull Node node) { + public boolean allowDelimiters(BasedSequence chars, Document document, Node node) { return true; } @Override - public void updateNodeElements(@NotNull Document document, @NotNull Node node) { + public void updateNodeElements(Document document, Node node) { } public static class Factory implements LinkRefProcessorFactory { - @NotNull @Override - public LinkRefProcessor apply(@NotNull Document document) { + public LinkRefProcessor apply(Document document) { return new EnumeratedReferenceLinkRefProcessor(document); } @Override - public boolean getWantExclamationPrefix(@NotNull DataHolder options) { + public boolean getWantExclamationPrefix(DataHolder options) { return WANT_EXCLAMATION_PREFIX; } @Override - public int getBracketNestingLevel(@NotNull DataHolder options) { + public int getBracketNestingLevel(DataHolder options) { return BRACKET_NESTING_LEVEL; } } diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodeFormatter.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodeFormatter.java index d8f08f009..7f525d8c4 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodeFormatter.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodeFormatter.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.util.format.options.ElementPlacement; import com.vladsch.flexmark.util.format.options.ElementPlacementSort; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -110,9 +109,8 @@ private void render(EnumeratedReferenceLink node, NodeFormatterContext context, } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new EnumeratedReferenceNodeFormatter(options); } diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodePostProcessor.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodePostProcessor.java index 6096a8aa0..b8f839e0b 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodePostProcessor.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodePostProcessor.java @@ -15,7 +15,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NodeTracker; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class EnumeratedReferenceNodePostProcessor extends NodePostProcessor { final private EnumeratedReferences enumeratedReferences; @@ -28,7 +27,7 @@ public EnumeratedReferenceNodePostProcessor(Document document) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { if (node instanceof AttributesNode) { AttributesNode attributesNode = (AttributesNode) node; @@ -62,9 +61,8 @@ public Factory() { addNodes(AttributesNode.class, Heading.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new EnumeratedReferenceNodePostProcessor(document); } } diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodeRenderer.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodeRenderer.java index 93a831c50..0bb6399df 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodeRenderer.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.LinkedHashSet; @@ -36,7 +35,7 @@ public Set getRenderingPhases() { } @Override - public void renderDocument(@NotNull NodeRendererContext context, @NotNull HtmlWriter html, @NotNull Document document, @NotNull RenderingPhase phase) { + public void renderDocument(NodeRendererContext context, HtmlWriter html, Document document, RenderingPhase phase) { if (phase == RenderingPhase.HEAD_TOP) { headerIdGenerator.generateIds(document); } else if (phase == RenderingPhase.BODY_TOP) { @@ -155,9 +154,8 @@ private void render(EnumeratedReferenceBlock node, NodeRendererContext context, } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new EnumeratedReferenceNodeRenderer(options); } } diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceParagraphPreProcessor.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceParagraphPreProcessor.java index 582474d69..da8861a91 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceParagraphPreProcessor.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/EnumeratedReferenceParagraphPreProcessor.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.parser.core.ReferencePreProcessorFactory; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.Set; @@ -83,7 +82,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public Set> getBeforeDependents() { HashSet> set = new HashSet<>(); diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/package-info.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/package-info.java index fbaa9e51b..95b739a79 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/package-info.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.enumerated.reference.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/package-info.java b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/package-info.java index fe17d5c05..5cf49219a 100644 --- a/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/package-info.java +++ b/flexmark-ext-enumerated-reference/src/main/java/com/vladsch/flexmark/ext/enumerated/reference/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.enumerated.reference; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboEnumeratedReferenceFormatterSpecTest.java b/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboEnumeratedReferenceFormatterSpecTest.java index 51d2bb2b4..16ec9f90e 100644 --- a/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboEnumeratedReferenceFormatterSpecTest.java +++ b/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboEnumeratedReferenceFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -15,7 +14,7 @@ public class ComboEnumeratedReferenceFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_enumerated_reference_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(EnumeratedReferenceExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -27,7 +26,7 @@ public class ComboEnumeratedReferenceFormatterSpecTest extends FormatterSpecTest EnumeratedReferenceExtension.ENUMERATED_REFERENCE_SORT ); - public ComboEnumeratedReferenceFormatterSpecTest(@NotNull SpecExample example) { + public ComboEnumeratedReferenceFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboEnumeratedReferenceTranslationFormatterSpecTest.java b/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboEnumeratedReferenceTranslationFormatterSpecTest.java index 3c7520898..e1f83eee0 100644 --- a/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboEnumeratedReferenceTranslationFormatterSpecTest.java +++ b/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboEnumeratedReferenceTranslationFormatterSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -16,7 +15,7 @@ public class ComboEnumeratedReferenceTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_enumerated_reference_translation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(EnumeratedReferenceExtension.create(), AttributesExtension.create())) .toImmutable(); @@ -27,7 +26,7 @@ public class ComboEnumeratedReferenceTranslationFormatterSpecTest extends Transl EnumeratedReferenceExtension.ENUMERATED_REFERENCE_SORT ); - public ComboEnumeratedReferenceTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboEnumeratedReferenceTranslationFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboExtEnumeratedReferenceSpecTest.java b/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboExtEnumeratedReferenceSpecTest.java index fa5cb847a..da82523e0 100644 --- a/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboExtEnumeratedReferenceSpecTest.java +++ b/flexmark-ext-enumerated-reference/src/test/java/com/vladsch/flexmark/ext/enumerated/reference/ComboExtEnumeratedReferenceSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -16,13 +15,13 @@ public class ComboExtEnumeratedReferenceSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_enumerated_reference_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(TablesExtension.WITH_CAPTION, true) .set(Parser.EXTENSIONS, Arrays.asList(EnumeratedReferenceExtension.create(), AttributesExtension.create(), TablesExtension.create())) .toImmutable(); - public ComboExtEnumeratedReferenceSpecTest(@NotNull SpecExample example) { + public ComboExtEnumeratedReferenceSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/EscapedCharacter.java b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/EscapedCharacter.java index 251db21cd..d4d5f0ef3 100644 --- a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/EscapedCharacter.java +++ b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/EscapedCharacter.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A EscapedCharacter node @@ -12,7 +11,6 @@ public class EscapedCharacter extends Node implements DoNotDecorate { protected BasedSequence openingMarker = BasedSequence.NULL; protected BasedSequence text = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -20,7 +18,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, BasedSequence.NULL, "text"); } diff --git a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/EscapedCharacterExtension.java b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/EscapedCharacterExtension.java index a02f913ed..f6bdec9b9 100644 --- a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/EscapedCharacterExtension.java +++ b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/EscapedCharacterExtension.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for escaped_characters @@ -23,7 +22,7 @@ public static EscapedCharacterExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -38,7 +37,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new EscapedCharacterNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/EscapedCharacterNodePostProcessor.java b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/EscapedCharacterNodePostProcessor.java index c97745807..19ee7643c 100644 --- a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/EscapedCharacterNodePostProcessor.java +++ b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/EscapedCharacterNodePostProcessor.java @@ -13,7 +13,6 @@ import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.ReplacedTextMapper; import com.vladsch.flexmark.util.sequence.ReplacedTextRegion; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -22,7 +21,7 @@ public EscapedCharacterNodePostProcessor(Document document) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { BasedSequence original = node.getChars(); ReplacedTextMapper textMapper = new ReplacedTextMapper(original); // NOTE: needed for its side-effects @@ -84,9 +83,8 @@ public Factory() { addNodeWithExclusions(Text.class, DoNotDecorate.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new EscapedCharacterNodePostProcessor(document); } } diff --git a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/EscapedCharacterNodeRenderer.java b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/EscapedCharacterNodeRenderer.java index 89a554f61..0d6b6c039 100644 --- a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/EscapedCharacterNodeRenderer.java +++ b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/EscapedCharacterNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -32,9 +31,8 @@ private void render(EscapedCharacter node, NodeRendererContext context, HtmlWrit } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new EscapedCharacterNodeRenderer(options); } } diff --git a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/package-info.java b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/package-info.java index 6213939a8..45d7b252b 100644 --- a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/package-info.java +++ b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.escaped.character.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/package-info.java b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/package-info.java index 3c5bb75f6..0e6568e9b 100644 --- a/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/package-info.java +++ b/flexmark-ext-escaped-character/src/main/java/com/vladsch/flexmark/ext/escaped/character/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.escaped.character; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-escaped-character/src/test/java/com/vladsch/flexmark/ext/escaped/character/ComboEscapedCharacterSpecTest.java b/flexmark-ext-escaped-character/src/test/java/com/vladsch/flexmark/ext/escaped/character/ComboEscapedCharacterSpecTest.java index 19769fae0..74d1e57e4 100644 --- a/flexmark-ext-escaped-character/src/test/java/com/vladsch/flexmark/ext/escaped/character/ComboEscapedCharacterSpecTest.java +++ b/flexmark-ext-escaped-character/src/test/java/com/vladsch/flexmark/ext/escaped/character/ComboEscapedCharacterSpecTest.java @@ -21,7 +21,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -29,12 +28,12 @@ public class ComboEscapedCharacterSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_escaped_character_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(EscapedCharacterExtension.create())) .toImmutable(); - public ComboEscapedCharacterSpecTest(@NotNull SpecExample example) { + public ComboEscapedCharacterSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/Footnote.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/Footnote.java index e9159ae1d..88a068c9d 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/Footnote.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/Footnote.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.ext.footnotes.internal.FootnoteRepository; import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A Footnote referencing node @@ -25,7 +24,6 @@ public void setReferenceOrdinal(int referenceOrdinal) { protected int referenceOrdinal; - @NotNull @Override public BasedSequence getReference() { return text; @@ -69,14 +67,13 @@ public void setFootnoteBlock(FootnoteBlock footnoteBlock) { this.footnoteBlock = footnoteBlock; } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { out.append(" ordinal: ").append(footnoteBlock != null ? footnoteBlock.getFootnoteOrdinal() : 0).append(" "); delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/FootnoteBlock.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/FootnoteBlock.java index ac8fed8a3..bb2bca9cf 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/FootnoteBlock.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/FootnoteBlock.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A Footnote definition node containing text and other inline nodes nodes as children. @@ -40,7 +39,7 @@ public void setFootnoteReferences(int footnoteReferences) { @Nullable @Override - public Footnote getReferencingNode(@NotNull Node node) { + public Footnote getReferencingNode(Node node) { return node instanceof Footnote ? (Footnote) node : null; } @@ -69,7 +68,7 @@ public void setFootnoteOrdinal(int footnoteOrdinal) { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { out.append(" ordinal: ").append(footnoteOrdinal).append(" "); segmentSpan(out, openingMarker, "open"); segmentSpan(out, text, "text"); @@ -77,7 +76,6 @@ public void getAstExtra(@NotNull StringBuilder out) { segmentSpan(out, footnote, "footnote"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker, footnote }; diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/FootnoteExtension.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/FootnoteExtension.java index 814052b31..327a81b27 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/FootnoteExtension.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/FootnoteExtension.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.format.options.ElementPlacement; import com.vladsch.flexmark.util.format.options.ElementPlacementSort; -import org.jetbrains.annotations.NotNull; /** * Extension for footnotes @@ -47,7 +46,7 @@ public void extend(Formatter.Builder formatterBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -71,7 +70,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new FootnoteNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteBlockParser.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteBlockParser.java index 5b467d8a3..cb3e03414 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteBlockParser.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteBlockParser.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Matcher; @@ -102,9 +101,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteLinkRefProcessor.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteLinkRefProcessor.java index e9988caa4..9164d9e39 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteLinkRefProcessor.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteLinkRefProcessor.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class FootnoteLinkRefProcessor implements LinkRefProcessor { static final boolean WANT_EXCLAMATION_PREFIX = false; @@ -32,13 +31,12 @@ public int getBracketNestingLevel() { } @Override - public boolean isMatch(@NotNull BasedSequence nodeChars) { + public boolean isMatch(BasedSequence nodeChars) { return nodeChars.length() >= 3 && nodeChars.charAt(0) == '[' && nodeChars.charAt(1) == '^' && nodeChars.endCharAt(1) == ']'; } - @NotNull @Override - public Node createNode(@NotNull BasedSequence nodeChars) { + public Node createNode(BasedSequence nodeChars) { BasedSequence footnoteId = nodeChars.midSequence(2, -1).trim(); FootnoteBlock footnoteBlock = footnoteId.length() > 0 ? footnoteRepository.get(footnoteId.toString()) : null; @@ -51,37 +49,35 @@ public Node createNode(@NotNull BasedSequence nodeChars) { return footnote; } - @NotNull @Override - public BasedSequence adjustInlineText(@NotNull Document document, @NotNull Node node) { + public BasedSequence adjustInlineText(Document document, Node node) { assert node instanceof Footnote; return ((Footnote) node).getText(); } @Override - public boolean allowDelimiters(@NotNull BasedSequence chars, @NotNull Document document, @NotNull Node node) { + public boolean allowDelimiters(BasedSequence chars, Document document, Node node) { return true; } @Override - public void updateNodeElements(@NotNull Document document, @NotNull Node node) { + public void updateNodeElements(Document document, Node node) { } public static class Factory implements LinkRefProcessorFactory { - @NotNull @Override - public LinkRefProcessor apply(@NotNull Document document) { + public LinkRefProcessor apply(Document document) { return new FootnoteLinkRefProcessor(document); } @Override - public boolean getWantExclamationPrefix(@NotNull DataHolder options) { + public boolean getWantExclamationPrefix(DataHolder options) { return WANT_EXCLAMATION_PREFIX; } @Override - public int getBracketNestingLevel(@NotNull DataHolder options) { + public int getBracketNestingLevel(DataHolder options) { return BRACKET_NESTING_LEVEL; } } diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteNodeFormatter.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteNodeFormatter.java index f365bf6e4..9bc12be79 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteNodeFormatter.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteNodeFormatter.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.format.options.ElementPlacement; import com.vladsch.flexmark.util.format.options.ElementPlacementSort; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -84,9 +83,8 @@ private void render(Footnote node, NodeFormatterContext context, MarkdownWriter } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new FootnoteNodeFormatter(options); } } diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteNodeRenderer.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteNodeRenderer.java index f33944b15..2875ff54f 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteNodeRenderer.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteNodeRenderer.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.ast.NodeVisitor; import com.vladsch.flexmark.util.ast.VisitHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -47,7 +46,7 @@ public Set getRenderingPhases() { } @Override - public void renderDocument(@NotNull NodeRendererContext context, @NotNull HtmlWriter html, @NotNull Document document, @NotNull RenderingPhase phase) { + public void renderDocument(NodeRendererContext context, HtmlWriter html, Document document, RenderingPhase phase) { if (phase == RenderingPhase.BODY_TOP) { if (recheckUndefinedReferences) { // need to see if have undefined footnotes that were defined after parsing @@ -127,9 +126,8 @@ private void render(Footnote node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new FootnoteNodeRenderer(options); } } diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteRepository.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteRepository.java index b8cc62d2d..a6d0e99ac 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteRepository.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/FootnoteRepository.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; -import org.jetbrains.annotations.NotNull; import java.util.*; @@ -68,19 +67,16 @@ public FootnoteRepository(DataHolder options) { super(FootnoteExtension.FOOTNOTES_KEEP.get(options)); } - @NotNull @Override public DataKey getDataKey() { return FootnoteExtension.FOOTNOTES; } - @NotNull @Override public DataKey getKeepDataKey() { return FootnoteExtension.FOOTNOTES_KEEP; } - @NotNull @Override public Set getReferencedElements(Node parent) { HashSet references = new HashSet<>(); diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/package-info.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/package-info.java index 4e0b81459..283bb7827 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/package-info.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.footnotes.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/package-info.java b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/package-info.java index b85c02622..d2c8aba2e 100644 --- a/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/package-info.java +++ b/flexmark-ext-footnotes/src/main/java/com/vladsch/flexmark/ext/footnotes/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.footnotes; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesFormatterSpecTest.java b/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesFormatterSpecTest.java index 563675105..0c66049ed 100644 --- a/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesFormatterSpecTest.java +++ b/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -15,7 +14,7 @@ public class ComboFootnotesFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_footnotes_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(FootnoteExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -27,7 +26,7 @@ public class ComboFootnotesFormatterSpecTest extends FormatterSpecTest { FootnoteExtension.FOOTNOTE_SORT ); - public ComboFootnotesFormatterSpecTest(@NotNull SpecExample example) { + public ComboFootnotesFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesSpecTest.java b/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesSpecTest.java index 26ab92741..10de54bc2 100644 --- a/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesSpecTest.java +++ b/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesSpecTest.java @@ -7,14 +7,13 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.*; public class ComboFootnotesSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_footnotes_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(FootnoteExtension.create(), TablesExtension.create())) .toImmutable(); @@ -33,7 +32,7 @@ public class ComboFootnotesSpecTest extends RendererSpecTest { optionsMap.put("item-indent-8", new MutableDataSet().set(Parser.LISTS_ITEM_INDENT, 8)); optionsMap.put("link-text-priority", new MutableDataSet().set(Parser.LINK_TEXT_PRIORITY_OVER_LINK_REF, true)); } - public ComboFootnotesSpecTest(@NotNull SpecExample example) { + public ComboFootnotesSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesTranslationFormatterSpecTest.java b/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesTranslationFormatterSpecTest.java index 10a4fe29a..3442356ea 100644 --- a/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesTranslationFormatterSpecTest.java +++ b/flexmark-ext-footnotes/src/test/java/com/vladsch/flexmark/ext/footnotes/ComboFootnotesTranslationFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -15,7 +14,7 @@ public class ComboFootnotesTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_footnotes_translation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(FootnoteExtension.create())) .toImmutable(); @@ -26,7 +25,7 @@ public class ComboFootnotesTranslationFormatterSpecTest extends TranslationForma FootnoteExtension.FOOTNOTE_SORT ); - public ComboFootnotesTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboFootnotesTranslationFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/GfmIssue.java b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/GfmIssue.java index 83c7e3e8b..ab6a46416 100644 --- a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/GfmIssue.java +++ b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/GfmIssue.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A GfmIssue node @@ -12,7 +11,6 @@ public class GfmIssue extends Node implements DoNotDecorate { protected BasedSequence openingMarker = BasedSequence.NULL; protected BasedSequence text = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -20,7 +18,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, BasedSequence.NULL, "text"); } diff --git a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/GfmIssuesExtension.java b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/GfmIssuesExtension.java index 433d1f094..a5817a406 100644 --- a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/GfmIssuesExtension.java +++ b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/GfmIssuesExtension.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for GitHub Issues @@ -33,7 +32,7 @@ public static GfmIssuesExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -48,7 +47,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new GfmIssuesNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesInlineParserExtension.java b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesInlineParserExtension.java index b9920f5e8..a053c45ed 100644 --- a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesInlineParserExtension.java +++ b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesInlineParserExtension.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.parser.InlineParserExtensionFactory; import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Pattern; @@ -20,17 +19,17 @@ public GfmIssuesInlineParserExtension(LightInlineParser inlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { BasedSequence[] matches = inlineParser.matchWithGroups(GITHUB_ISSUE); if (matches != null) { inlineParser.flushTextNode(); @@ -52,7 +51,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return "#"; @@ -64,9 +62,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser inlineParser) { + public InlineParserExtension apply(LightInlineParser inlineParser) { return new GfmIssuesInlineParserExtension(inlineParser); } diff --git a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesJiraRenderer.java b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesJiraRenderer.java index 6aef62b0b..36b821c82 100644 --- a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesJiraRenderer.java +++ b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesJiraRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.HashSet; @@ -42,9 +41,8 @@ private void render(GfmIssue node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new GfmIssuesJiraRenderer(options); } } diff --git a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesNodeRenderer.java b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesNodeRenderer.java index 76779d128..8e1151a28 100644 --- a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesNodeRenderer.java +++ b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -47,9 +46,8 @@ private void render(GfmIssue node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new GfmIssuesNodeRenderer(options); } } diff --git a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesOptions.java b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesOptions.java index 7a444ea6a..2b14d2343 100644 --- a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesOptions.java +++ b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/GfmIssuesOptions.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSetter; -import org.jetbrains.annotations.NotNull; class GfmIssuesOptions implements MutableDataSetter { final public String gitHubIssuesUrlRoot; @@ -21,9 +20,8 @@ public GfmIssuesOptions(DataHolder options) { gitHubIssueTextSuffix = GfmIssuesExtension.GIT_HUB_ISSUE_HTML_SUFFIX.get(options); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(GfmIssuesExtension.GIT_HUB_ISSUES_URL_ROOT, gitHubIssuesUrlRoot); dataHolder.set(GfmIssuesExtension.GIT_HUB_ISSUE_URL_PREFIX, gitHubIssueUrlPrefix); dataHolder.set(GfmIssuesExtension.GIT_HUB_ISSUE_URL_SUFFIX, gitHubIssueUrlSuffix); diff --git a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/package-info.java b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/package-info.java index 7f0d24dd1..e8b5f627c 100644 --- a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/package-info.java +++ b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gfm.issues.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/package-info.java b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/package-info.java index b59512339..0ea1a29c1 100644 --- a/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/package-info.java +++ b/flexmark-ext-gfm-issues/src/main/java/com/vladsch/flexmark/ext/gfm/issues/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gfm.issues; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gfm-issues/src/test/java/com/vladsch/flexmark/ext/gfm/issues/ComboGfmIssuesSpecTest.java b/flexmark-ext-gfm-issues/src/test/java/com/vladsch/flexmark/ext/gfm/issues/ComboGfmIssuesSpecTest.java index db466da06..7511e29b0 100644 --- a/flexmark-ext-gfm-issues/src/test/java/com/vladsch/flexmark/ext/gfm/issues/ComboGfmIssuesSpecTest.java +++ b/flexmark-ext-gfm-issues/src/test/java/com/vladsch/flexmark/ext/gfm/issues/ComboGfmIssuesSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboGfmIssuesSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/gfm_issues_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(GfmIssuesExtension.create())) .toImmutable(); @@ -28,7 +27,7 @@ public class ComboGfmIssuesSpecTest extends RendererSpecTest { optionsMap.put("suffix", new MutableDataSet().set(GfmIssuesExtension.GIT_HUB_ISSUE_URL_SUFFIX, "&")); optionsMap.put("bold", new MutableDataSet().set(GfmIssuesExtension.GIT_HUB_ISSUE_HTML_PREFIX, "").set(GfmIssuesExtension.GIT_HUB_ISSUE_HTML_SUFFIX, "")); } - public ComboGfmIssuesSpecTest(@NotNull SpecExample example) { + public ComboGfmIssuesSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/Strikethrough.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/Strikethrough.java index 6f59cd0b8..306347455 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/Strikethrough.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/Strikethrough.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DelimitedNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A strikethrough node containing text and other inline nodes nodes as children. @@ -13,14 +12,13 @@ public class Strikethrough extends Node implements DelimitedNode { protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpan(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughExtension.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughExtension.java index 341e8c466..d19978676 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughExtension.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughExtension.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; /** * Extension for GFM strikethrough using ~~ (GitHub Flavored Markdown). @@ -29,7 +28,7 @@ public static StrikethroughExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -44,7 +43,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new StrikethroughNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("YOUTRACK")) { diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughSubscriptExtension.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughSubscriptExtension.java index 4291b38da..91a9b212d 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughSubscriptExtension.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughSubscriptExtension.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; /** * Extension for GFM strikethrough using ~~ (GitHub Flavored Markdown). @@ -31,7 +30,7 @@ public static StrikethroughSubscriptExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -46,7 +45,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new StrikethroughNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("YOUTRACK")) { diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/Subscript.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/Subscript.java index cba29792a..43cf4f410 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/Subscript.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/Subscript.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DelimitedNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A Subscript node containing text and other inline nodes nodes as children. @@ -13,14 +12,13 @@ public class Subscript extends Node implements DelimitedNode { protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpan(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/SubscriptExtension.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/SubscriptExtension.java index 4f94f0c69..9d9edc773 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/SubscriptExtension.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/SubscriptExtension.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; /** * Extension for GFM strikethrough using ~~ (GitHub Flavored Markdown). @@ -31,7 +30,7 @@ public static SubscriptExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -46,7 +45,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new StrikethroughNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("YOUTRACK")) { diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughJiraRenderer.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughJiraRenderer.java index cb85e2868..822ece305 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughJiraRenderer.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughJiraRenderer.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -39,9 +38,8 @@ private void render(Subscript node, NodeRendererContext context, HtmlWriter html } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new StrikethroughJiraRenderer(options); } } diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughNodeRenderer.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughNodeRenderer.java index f2d7caa96..1a3fbb654 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughNodeRenderer.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughNodeRenderer.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -69,9 +68,8 @@ private void render(Subscript node, NodeRendererContext context, HtmlWriter html } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new StrikethroughNodeRenderer(options); } } diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughYouTrackRenderer.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughYouTrackRenderer.java index 9370c8ee9..4f44d116f 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughYouTrackRenderer.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/StrikethroughYouTrackRenderer.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -39,9 +38,8 @@ private void render(Subscript node, NodeRendererContext context, HtmlWriter html } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new StrikethroughYouTrackRenderer(options); } } diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/package-info.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/package-info.java index d8e8227ec..aefa0184c 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/package-info.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gfm.strikethrough.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/package-info.java b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/package-info.java index fc0e6c015..df59d56d8 100644 --- a/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/package-info.java +++ b/flexmark-ext-gfm-strikethrough/src/main/java/com/vladsch/flexmark/ext/gfm/strikethrough/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gfm.strikethrough; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboStrikethroughSpecTest.java b/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboStrikethroughSpecTest.java index f43eaa480..5c5c1ae6a 100644 --- a/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboStrikethroughSpecTest.java +++ b/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboStrikethroughSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -17,7 +16,7 @@ public class ComboStrikethroughSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_gfm_strikethrough_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.INDENT_SIZE, 0) .set(Parser.EXTENSIONS, Collections.singleton(StrikethroughExtension.create())) @@ -27,7 +26,7 @@ public class ComboStrikethroughSpecTest extends RendererSpecTest { static { optionsMap.put("style-strikethrough", new MutableDataSet().set(StrikethroughExtension.STRIKETHROUGH_STYLE_HTML_OPEN, "").set(StrikethroughExtension.STRIKETHROUGH_STYLE_HTML_CLOSE, "")); } - public ComboStrikethroughSpecTest(@NotNull SpecExample example) { + public ComboStrikethroughSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboStrikethroughSubscriptSpecTest.java b/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboStrikethroughSubscriptSpecTest.java index 3da1b93b7..1993457a6 100644 --- a/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboStrikethroughSubscriptSpecTest.java +++ b/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboStrikethroughSubscriptSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -17,7 +16,7 @@ public class ComboStrikethroughSubscriptSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_strikethrough_subscript_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.INDENT_SIZE, 0) .set(Parser.EXTENSIONS, Collections.singleton(StrikethroughSubscriptExtension.create())) @@ -28,7 +27,7 @@ public class ComboStrikethroughSubscriptSpecTest extends RendererSpecTest { optionsMap.put("style-strikethrough", new MutableDataSet().set(StrikethroughSubscriptExtension.STRIKETHROUGH_STYLE_HTML_OPEN, "").set(StrikethroughSubscriptExtension.STRIKETHROUGH_STYLE_HTML_CLOSE, "")); optionsMap.put("style-subscript", new MutableDataSet().set(StrikethroughSubscriptExtension.SUBSCRIPT_STYLE_HTML_OPEN, "").set(StrikethroughSubscriptExtension.SUBSCRIPT_STYLE_HTML_CLOSE, "")); } - public ComboStrikethroughSubscriptSpecTest(@NotNull SpecExample example) { + public ComboStrikethroughSubscriptSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboSubscriptSpecTest.java b/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboSubscriptSpecTest.java index 63e2d2332..2b54e7092 100644 --- a/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboSubscriptSpecTest.java +++ b/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/ComboSubscriptSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -17,7 +16,7 @@ public class ComboSubscriptSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_subscript_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.INDENT_SIZE, 0) .set(Parser.EXTENSIONS, Collections.singleton(SubscriptExtension.create())) @@ -27,7 +26,7 @@ public class ComboSubscriptSpecTest extends RendererSpecTest { static { optionsMap.put("style-subscript", new MutableDataSet().set(SubscriptExtension.SUBSCRIPT_STYLE_HTML_OPEN, "").set(SubscriptExtension.SUBSCRIPT_STYLE_HTML_CLOSE, "")); } - public ComboSubscriptSpecTest(@NotNull SpecExample example) { + public ComboSubscriptSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughTest.java b/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughTest.java index 3c6bc030d..81ad17c45 100644 --- a/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughTest.java +++ b/flexmark-ext-gfm-strikethrough/src/test/java/com/vladsch/flexmark/ext/gfm/strikethrough/StrikethroughTest.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataSet; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; import java.util.Collections; @@ -24,17 +23,17 @@ public class StrikethroughTest extends RenderingTestCase { .set(TestUtils.NO_FILE_EOL, false) .set(Parser.EXTENSIONS, Collections.singleton(StrikethroughExtension.create())) .toImmutable(); - final private static @NotNull Parser PARSER = Parser.builder(OPTIONS).build(); - final private static @NotNull HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build(); + final private static Parser PARSER = Parser.builder(OPTIONS).build(); + final private static HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build(); @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = DataSet.aggregate(OPTIONS, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, PARSER, RENDERER, true); } @Override - public @Nullable DataHolder options(@NotNull String option) { + public @Nullable DataHolder options(String option) { return null; } diff --git a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/TaskListExtension.java b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/TaskListExtension.java index 064aa89a2..a5a841da3 100644 --- a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/TaskListExtension.java +++ b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/TaskListExtension.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; @@ -63,7 +62,7 @@ public void extend(Formatter.Builder formatterBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -78,7 +77,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new TaskListNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/TaskListItem.java b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/TaskListItem.java index 7e2e4e3e7..61dc519ba 100644 --- a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/TaskListItem.java +++ b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/TaskListItem.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -20,7 +19,7 @@ public class TaskListItem extends ListItem { protected boolean canChangeMarker = true; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { super.getAstExtra(out); if (isOrderedItem) out.append(" isOrderedItem"); out.append(isItemDoneMarker() ? " isDone" : " isNotDone"); diff --git a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListFormatOptions.java b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListFormatOptions.java index cc8b067eb..f97395ec6 100644 --- a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListFormatOptions.java +++ b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListFormatOptions.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSetter; -import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -32,9 +31,8 @@ public TaskListFormatOptions(DataHolder options) { formatPrioritizedTaskItems = TaskListExtension.FORMAT_PRIORITIZED_TASK_ITEMS.get(options); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(TaskListExtension.FORMAT_LIST_ITEM_CASE, taskListItemCase); dataHolder.set(TaskListExtension.FORMAT_LIST_ITEM_PLACEMENT, taskListItemPlacement); dataHolder.set(TaskListExtension.FORMAT_ORDERED_TASK_ITEM_PRIORITY, formatOrderedTaskItemPriority); diff --git a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListItemBlockPreProcessor.java b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListItemBlockPreProcessor.java index 00b9c9bbe..9c9eddd08 100644 --- a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListItemBlockPreProcessor.java +++ b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListItemBlockPreProcessor.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.Set; @@ -42,7 +41,6 @@ public void preProcess(ParserState state, Block block) { } public static class Factory implements BlockPreProcessorFactory { - @NotNull @Override public Set> getBlockTypes() { HashSet> set = new HashSet<>(); @@ -68,9 +66,8 @@ public boolean affectsGlobalScope() { return true; } - @NotNull @Override - public BlockPreProcessor apply(@NotNull ParserState state) { + public BlockPreProcessor apply(ParserState state) { return new TaskListItemBlockPreProcessor(state.getProperties()); } } diff --git a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListNodeFormatter.java b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListNodeFormatter.java index 5ccc817b4..be0400d89 100644 --- a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListNodeFormatter.java +++ b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListNodeFormatter.java @@ -10,7 +10,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.Arrays; diff --git a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListNodeRenderer.java b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListNodeRenderer.java index 8e676f6b9..698420fac 100644 --- a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListNodeRenderer.java +++ b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/TaskListNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.parser.ListOptions; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -66,9 +65,8 @@ void render(TaskListItem node, NodeRendererContext context, HtmlWriter html) { } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new TaskListNodeRenderer(options); } } diff --git a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/package-info.java b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/package-info.java index 120ea5874..b692a9eff 100644 --- a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/package-info.java +++ b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gfm.tasklist.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/package-info.java b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/package-info.java index e3c31acaa..ac41be4ed 100644 --- a/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/package-info.java +++ b/flexmark-ext-gfm-tasklist/src/main/java/com/vladsch/flexmark/ext/gfm/tasklist/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gfm.tasklist; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gfm-tasklist/src/test/java/com/vladsch/flexmark/ext/gfm/tasklist/ComboGfmTaskListFormatterSpecTest.java b/flexmark-ext-gfm-tasklist/src/test/java/com/vladsch/flexmark/ext/gfm/tasklist/ComboGfmTaskListFormatterSpecTest.java index 0f5e06090..5931fe1ca 100644 --- a/flexmark-ext-gfm-tasklist/src/test/java/com/vladsch/flexmark/ext/gfm/tasklist/ComboGfmTaskListFormatterSpecTest.java +++ b/flexmark-ext-gfm-tasklist/src/test/java/com/vladsch/flexmark/ext/gfm/tasklist/ComboGfmTaskListFormatterSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.format.options.ListBulletMarker; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -18,7 +17,7 @@ public class ComboGfmTaskListFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_gfm_tasklist_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(TaskListExtension.create())) .set(Parser.BLANK_LINES_IN_AST, true) @@ -49,7 +48,7 @@ public class ComboGfmTaskListFormatterSpecTest extends FormatterSpecTest { optionsMap.put("list-bullet-asterisk", new MutableDataSet().set(Formatter.LIST_BULLET_MARKER, ListBulletMarker.ASTERISK)); optionsMap.put("list-bullet-plus", new MutableDataSet().set(Formatter.LIST_BULLET_MARKER, ListBulletMarker.PLUS)); } - public ComboGfmTaskListFormatterSpecTest(@NotNull SpecExample example) { + public ComboGfmTaskListFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-gfm-tasklist/src/test/java/com/vladsch/flexmark/ext/gfm/tasklist/ComboGfmTaskListSpecTest.java b/flexmark-ext-gfm-tasklist/src/test/java/com/vladsch/flexmark/ext/gfm/tasklist/ComboGfmTaskListSpecTest.java index b859dc65b..c5e3ea5fd 100644 --- a/flexmark-ext-gfm-tasklist/src/test/java/com/vladsch/flexmark/ext/gfm/tasklist/ComboGfmTaskListSpecTest.java +++ b/flexmark-ext-gfm-tasklist/src/test/java/com/vladsch/flexmark/ext/gfm/tasklist/ComboGfmTaskListSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -18,7 +17,7 @@ public class ComboGfmTaskListSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_gfm_tasklist_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(TaskListExtension.create())) .toImmutable(); @@ -45,7 +44,7 @@ public class ComboGfmTaskListSpecTest extends RendererSpecTest { .set(Parser.EXTENSIONS, Collections.singleton(TaskListExtension.create())) ); } - public ComboGfmTaskListSpecTest(@NotNull SpecExample example) { + public ComboGfmTaskListSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/GfmUser.java b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/GfmUser.java index 4a504f977..2c1739e03 100644 --- a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/GfmUser.java +++ b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/GfmUser.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A GfmUser node @@ -12,7 +11,6 @@ public class GfmUser extends Node implements DoNotDecorate { protected BasedSequence openingMarker = BasedSequence.NULL; protected BasedSequence text = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -20,7 +18,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, BasedSequence.NULL, "text"); } diff --git a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/GfmUsersExtension.java b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/GfmUsersExtension.java index c35b95108..7dc8f02f5 100644 --- a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/GfmUsersExtension.java +++ b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/GfmUsersExtension.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for GitHub Users @@ -33,7 +32,7 @@ public static GfmUsersExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -48,7 +47,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new GfmUsersNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersInlineParserExtension.java b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersInlineParserExtension.java index c4575edf0..60e40081c 100644 --- a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersInlineParserExtension.java +++ b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersInlineParserExtension.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.parser.InlineParserExtensionFactory; import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Pattern; @@ -20,17 +19,17 @@ public GfmUsersInlineParserExtension(LightInlineParser inlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { int index = inlineParser.getIndex(); boolean isPossible = index == 0; if (!isPossible) { @@ -62,7 +61,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return "@"; @@ -74,9 +72,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { + public InlineParserExtension apply(LightInlineParser lightInlineParser) { return new GfmUsersInlineParserExtension(lightInlineParser); } diff --git a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersJiraRenderer.java b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersJiraRenderer.java index d5daaa57e..4f3e253ab 100644 --- a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersJiraRenderer.java +++ b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersJiraRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.HashSet; @@ -42,9 +41,8 @@ private void render(GfmUser node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new GfmUsersJiraRenderer(options); } } diff --git a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersNodeRenderer.java b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersNodeRenderer.java index 1a09704b6..f78fb9759 100644 --- a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersNodeRenderer.java +++ b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -47,9 +46,8 @@ private void render(GfmUser node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new GfmUsersNodeRenderer(options); } } diff --git a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersOptions.java b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersOptions.java index f471e5547..234022f4a 100644 --- a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersOptions.java +++ b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/GfmUsersOptions.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSetter; -import org.jetbrains.annotations.NotNull; class GfmUsersOptions implements MutableDataSetter { final public String gitHubIssuesUrlRoot; @@ -21,9 +20,8 @@ public GfmUsersOptions(DataHolder options) { gitHubUserTextSuffix = GfmUsersExtension.GIT_HUB_USER_HTML_SUFFIX.get(options); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(GfmUsersExtension.GIT_HUB_USERS_URL_ROOT, gitHubIssuesUrlRoot); dataHolder.set(GfmUsersExtension.GIT_HUB_USER_URL_PREFIX, gitHubIssueUrlPrefix); dataHolder.set(GfmUsersExtension.GIT_HUB_USER_URL_SUFFIX, gitHubIssueUrlSuffix); diff --git a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/package-info.java b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/package-info.java index f2785f8f0..03fe92ea4 100644 --- a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/package-info.java +++ b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gfm.users.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/package-info.java b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/package-info.java index 65d392a27..e6ab8ffee 100644 --- a/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/package-info.java +++ b/flexmark-ext-gfm-users/src/main/java/com/vladsch/flexmark/ext/gfm/users/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gfm.users; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gfm-users/src/test/java/com/vladsch/flexmark/ext/gfm/users/ComboGfmUsersSpecTest.java b/flexmark-ext-gfm-users/src/test/java/com/vladsch/flexmark/ext/gfm/users/ComboGfmUsersSpecTest.java index 05fbf47da..75b2871d3 100644 --- a/flexmark-ext-gfm-users/src/test/java/com/vladsch/flexmark/ext/gfm/users/ComboGfmUsersSpecTest.java +++ b/flexmark-ext-gfm-users/src/test/java/com/vladsch/flexmark/ext/gfm/users/ComboGfmUsersSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboGfmUsersSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/gfm_users_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(GfmUsersExtension.create())) .toImmutable(); @@ -28,7 +27,7 @@ public class ComboGfmUsersSpecTest extends RendererSpecTest { optionsMap.put("suffix", new MutableDataSet().set(GfmUsersExtension.GIT_HUB_USER_URL_SUFFIX, "&")); optionsMap.put("plain", new MutableDataSet().set(GfmUsersExtension.GIT_HUB_USER_HTML_PREFIX, "").set(GfmUsersExtension.GIT_HUB_USER_HTML_SUFFIX, "")); } - public ComboGfmUsersSpecTest(@NotNull SpecExample example) { + public ComboGfmUsersSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabBlockQuote.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabBlockQuote.java index 044cf9310..2ef452014 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabBlockQuote.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabBlockQuote.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -19,14 +18,13 @@ public class GitLabBlockQuote extends Block implements ParagraphContainer { private BasedSequence closingTrailing = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, openingMarker, "open"); segmentSpanChars(out, openingTrailing, "openTrail"); segmentSpanChars(out, closingMarker, "close"); segmentSpanChars(out, closingTrailing, "closeTrail"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, openingTrailing, closingMarker, closingTrailing }; diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabExtension.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabExtension.java index 965c4001a..6ce67ff9d 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabExtension.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabExtension.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for git_labs @@ -58,7 +57,7 @@ public static GitLabExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -89,7 +88,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new GitLabNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabInline.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabInline.java index 717f628fe..40fe51217 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabInline.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabInline.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DelimitedNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A Ins node @@ -13,7 +12,6 @@ public class GitLabInline extends Node implements DelimitedNode { protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -21,7 +19,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabInlineMath.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabInlineMath.java index 23af9d600..f9e42f88a 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabInlineMath.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/GitLabInlineMath.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DelimitedNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A Ins node @@ -13,7 +12,6 @@ public class GitLabInlineMath extends Node implements DelimitedNode { protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -21,7 +19,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabBlockQuoteParser.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabBlockQuoteParser.java index 391c976aa..586f9c598 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabBlockQuoteParser.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabBlockQuoteParser.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.List; import java.util.Set; @@ -125,9 +124,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabInlineMathParser.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabInlineMathParser.java index a9b350a99..45092f5f4 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabInlineMathParser.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabInlineMathParser.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.parser.InlineParserExtensionFactory; import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Matcher; @@ -20,17 +19,17 @@ public GitLabInlineMathParser(LightInlineParser inlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { if (inlineParser.peek(1) == '`') { BasedSequence input = inlineParser.getInput(); Matcher matcher = inlineParser.matcher(MATH_PATTERN); @@ -54,7 +53,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return "$"; @@ -66,9 +64,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { + public InlineParserExtension apply(LightInlineParser lightInlineParser) { return new GitLabInlineMathParser(lightInlineParser); } diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabInlineParser.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabInlineParser.java index d85c3ac67..7f0fe9e91 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabInlineParser.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabInlineParser.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -27,12 +26,12 @@ public GitLabInlineParser(LightInlineParser inlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { // convert any unclosed ones to text for (int j = openInlines.size(); j-- > 0; ) { GitLabInline gitLabInline = openInlines.get(j); @@ -45,7 +44,7 @@ public void finalizeBlock(@NotNull InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { char firstChar = inlineParser.peek(); char secondChar = inlineParser.peek(1); if ((firstChar == '{' || firstChar == '[') && (options.insParser && secondChar == '+' || options.delParser && secondChar == '-')) { @@ -103,7 +102,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return "{[-+"; @@ -115,9 +113,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { + public InlineParserExtension apply(LightInlineParser lightInlineParser) { return new GitLabInlineParser(lightInlineParser); } diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabNodeFormatter.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabNodeFormatter.java index 441b6d021..6770ffbb2 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabNodeFormatter.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabNodeFormatter.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.ext.gitlab.GitLabBlockQuote; import com.vladsch.flexmark.formatter.*; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.HashSet; @@ -39,9 +38,8 @@ private void render(GitLabBlockQuote node, NodeFormatterContext context, Markdow } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new GitLabNodeFormatter(options); } } diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabNodeRenderer.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabNodeRenderer.java index cb03dfe07..2f8903249 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabNodeRenderer.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabNodeRenderer.java @@ -20,7 +20,6 @@ import com.vladsch.flexmark.util.html.Attribute; import com.vladsch.flexmark.util.html.Attributes; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -224,9 +223,8 @@ private void render(ImageRef node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new GitLabNodeRenderer(options); } } diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabOptions.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabOptions.java index 0ec7668ad..23dff17f2 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabOptions.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/GitLabOptions.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSetter; import com.vladsch.flexmark.util.misc.CharPredicate; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; @@ -72,9 +71,8 @@ public GitLabOptions(DataHolder options) { } } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(GitLabExtension.INS_PARSER, insParser); dataHolder.set(GitLabExtension.DEL_PARSER, delParser); dataHolder.set(GitLabExtension.INLINE_MATH_PARSER, inlineMathParser); diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/package-info.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/package-info.java index aeb2b4256..0a4e8f756 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/package-info.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gitlab.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/package-info.java b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/package-info.java index 0141996b0..a6db2a574 100644 --- a/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/package-info.java +++ b/flexmark-ext-gitlab/src/main/java/com/vladsch/flexmark/ext/gitlab/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.gitlab; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-gitlab/src/test/java/com/vladsch/flexmark/ext/gitlab/ComboGitLabFormatterSpecTest.java b/flexmark-ext-gitlab/src/test/java/com/vladsch/flexmark/ext/gitlab/ComboGitLabFormatterSpecTest.java index 8ef3ddb75..0d2e052ce 100644 --- a/flexmark-ext-gitlab/src/test/java/com/vladsch/flexmark/ext/gitlab/ComboGitLabFormatterSpecTest.java +++ b/flexmark-ext-gitlab/src/test/java/com/vladsch/flexmark/ext/gitlab/ComboGitLabFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -14,13 +13,13 @@ public class ComboGitLabFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_gitlab_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(GitLabExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) .toImmutable(); - public ComboGitLabFormatterSpecTest(@NotNull SpecExample example) { + public ComboGitLabFormatterSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-gitlab/src/test/java/com/vladsch/flexmark/ext/gitlab/ComboGitLabSpecTest.java b/flexmark-ext-gitlab/src/test/java/com/vladsch/flexmark/ext/gitlab/ComboGitLabSpecTest.java index da8efd52a..0f843fcf5 100644 --- a/flexmark-ext-gitlab/src/test/java/com/vladsch/flexmark/ext/gitlab/ComboGitLabSpecTest.java +++ b/flexmark-ext-gitlab/src/test/java/com/vladsch/flexmark/ext/gitlab/ComboGitLabSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -17,7 +16,7 @@ public class ComboGitLabSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_gitlab_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.RENDER_HEADER_ID, true) .set(Parser.EXTENSIONS, Collections.singletonList(GitLabExtension.create())) @@ -43,7 +42,7 @@ public class ComboGitLabSpecTest extends RendererSpecTest { optionsMap.put("video-link-format", new MutableDataSet().set(GitLabExtension.VIDEO_IMAGE_LINK_TEXT_FORMAT, "Get Video '%s'")); optionsMap.put("video-class", new MutableDataSet().set(GitLabExtension.VIDEO_IMAGE_CLASS, "video-class")); } - public ComboGitLabSpecTest(@NotNull SpecExample example) { + public ComboGitLabSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/Ins.java b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/Ins.java index e774bde6c..cfb8ce4c5 100644 --- a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/Ins.java +++ b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/Ins.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DelimitedNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A Ins node @@ -14,7 +13,6 @@ public class Ins extends Node implements DelimitedNode { protected BasedSequence closingMarker = BasedSequence.NULL; protected String insBlockText; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -22,7 +20,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/InsExtension.java b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/InsExtension.java index bd2e3d98d..d9c2e2300 100644 --- a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/InsExtension.java +++ b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/InsExtension.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; /** * Extension for ins @@ -28,7 +27,7 @@ public static InsExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -43,7 +42,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new InsNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/InsJiraRenderer.java b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/InsJiraRenderer.java index ed482f00d..1b6789f1d 100644 --- a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/InsJiraRenderer.java +++ b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/InsJiraRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -31,9 +30,8 @@ private void render(Ins node, NodeRendererContext context, HtmlWriter html) { } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new InsJiraRenderer(options); } } diff --git a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/InsNodeRenderer.java b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/InsNodeRenderer.java index d103df2da..3c69770b9 100644 --- a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/InsNodeRenderer.java +++ b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/InsNodeRenderer.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -46,9 +45,8 @@ private void render(Ins node, NodeRendererContext context, HtmlWriter html) { } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new InsNodeRenderer(options); } } diff --git a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/package-info.java b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/package-info.java index b2c28b3e8..e688054c0 100644 --- a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/package-info.java +++ b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.ins.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/package-info.java b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/package-info.java index 1ee53bdbd..01629586e 100644 --- a/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/package-info.java +++ b/flexmark-ext-ins/src/main/java/com/vladsch/flexmark/ext/ins/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.ins; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-ins/src/test/java/com/vladsch/flexmark/ext/ins/ComboInsSpecTest.java b/flexmark-ext-ins/src/test/java/com/vladsch/flexmark/ext/ins/ComboInsSpecTest.java index 181abf369..6f875f08f 100644 --- a/flexmark-ext-ins/src/test/java/com/vladsch/flexmark/ext/ins/ComboInsSpecTest.java +++ b/flexmark-ext-ins/src/test/java/com/vladsch/flexmark/ext/ins/ComboInsSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboInsSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ins_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(InsExtension.create())) .toImmutable(); @@ -25,7 +24,7 @@ public class ComboInsSpecTest extends RendererSpecTest { static { optionsMap.put("style-ins", new MutableDataSet().set(InsExtension.INS_STYLE_HTML_OPEN, "").set(InsExtension.INS_STYLE_HTML_CLOSE, "")); } - public ComboInsSpecTest(@NotNull SpecExample example) { + public ComboInsSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/JekyllFrontMatterBlock.java b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/JekyllFrontMatterBlock.java index 15b3e5da1..72332a39a 100644 --- a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/JekyllFrontMatterBlock.java +++ b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/JekyllFrontMatterBlock.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A JekyllFrontMatter block node @@ -13,13 +12,12 @@ public class JekyllFrontMatterBlock extends Block { protected BasedSequence closingMarker = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpan(out, openingMarker, "open"); segmentSpan(out, getContent(), "content"); segmentSpan(out, closingMarker, "close"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, closingMarker }; diff --git a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/JekyllFrontMatterExtension.java b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/JekyllFrontMatterExtension.java index ae89715ad..ee978496c 100644 --- a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/JekyllFrontMatterExtension.java +++ b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/JekyllFrontMatterExtension.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for jekyll_front_matters @@ -30,7 +29,7 @@ public void extend(Formatter.Builder formatterBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -45,7 +44,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new JekyllFrontMatterNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterBlockParser.java b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterBlockParser.java index 86aa928f6..3da08b4de 100644 --- a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterBlockParser.java +++ b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterBlockParser.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Matcher; @@ -84,9 +83,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterNodeFormatter.java b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterNodeFormatter.java index 9f9239fe0..56ca4001e 100644 --- a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterNodeFormatter.java +++ b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterNodeFormatter.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.HashSet; @@ -29,7 +28,7 @@ public Set> getNodeClasses() { } @Override - public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase) { + public void renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase) { if (phase == FormattingPhase.DOCUMENT_FIRST) { Node node = document.getFirstChild(); if (node instanceof JekyllFrontMatterBlock) { @@ -53,9 +52,8 @@ private void render(JekyllFrontMatterBlock node, NodeFormatterContext context, M } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new JekyllFrontMatterNodeFormatter(options); } } diff --git a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterNodeRenderer.java b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterNodeRenderer.java index 1fb585ec3..d97c45b4f 100644 --- a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterNodeRenderer.java +++ b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/JekyllFrontMatterNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -30,9 +29,8 @@ private void render(JekyllFrontMatterBlock node, NodeRendererContext context, Ht } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new JekyllFrontMatterNodeRenderer(options); } } diff --git a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/package-info.java b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/package-info.java index 0d3f3aea0..1a51419d1 100644 --- a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/package-info.java +++ b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.jekyll.front.matter.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/package-info.java b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/package-info.java index ba0f50ce4..8279adde4 100644 --- a/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/package-info.java +++ b/flexmark-ext-jekyll-front-matter/src/main/java/com/vladsch/flexmark/ext/jekyll/front/matter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.jekyll.front.matter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-jekyll-front-matter/src/test/java/com/vladsch/flexmark/ext/jekyll/front/matter/ComboJekyllFrontMatterFormatterSpecTest.java b/flexmark-ext-jekyll-front-matter/src/test/java/com/vladsch/flexmark/ext/jekyll/front/matter/ComboJekyllFrontMatterFormatterSpecTest.java index e2697c019..a4f2a1f4e 100644 --- a/flexmark-ext-jekyll-front-matter/src/test/java/com/vladsch/flexmark/ext/jekyll/front/matter/ComboJekyllFrontMatterFormatterSpecTest.java +++ b/flexmark-ext-jekyll-front-matter/src/test/java/com/vladsch/flexmark/ext/jekyll/front/matter/ComboJekyllFrontMatterFormatterSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboJekyllFrontMatterFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_jekyll_front_matter_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(JekyllFrontMatterExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -28,7 +27,7 @@ public class ComboJekyllFrontMatterFormatterSpecTest extends FormatterSpecTest { Formatter.REFERENCE_SORT ); - public ComboJekyllFrontMatterFormatterSpecTest(@NotNull SpecExample example) { + public ComboJekyllFrontMatterFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-jekyll-front-matter/src/test/java/com/vladsch/flexmark/ext/jekyll/front/matter/ComboJekyllFrontMatterSpecTest.java b/flexmark-ext-jekyll-front-matter/src/test/java/com/vladsch/flexmark/ext/jekyll/front/matter/ComboJekyllFrontMatterSpecTest.java index eee546d23..b97490155 100644 --- a/flexmark-ext-jekyll-front-matter/src/test/java/com/vladsch/flexmark/ext/jekyll/front/matter/ComboJekyllFrontMatterSpecTest.java +++ b/flexmark-ext-jekyll-front-matter/src/test/java/com/vladsch/flexmark/ext/jekyll/front/matter/ComboJekyllFrontMatterSpecTest.java @@ -21,7 +21,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -29,12 +28,12 @@ public class ComboJekyllFrontMatterSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_jekyll_front_matter_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(JekyllFrontMatterExtension.create())) .toImmutable(); - public ComboJekyllFrontMatterSpecTest(@NotNull SpecExample example) { + public ComboJekyllFrontMatterSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTag.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTag.java index cc3d1795f..5ff40f366 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTag.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTag.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A JekyllTag node @@ -14,7 +13,6 @@ public class JekyllTag extends Block { protected BasedSequence parameters = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -22,7 +20,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, openingMarker, "open"); segmentSpanChars(out, tag, "tag"); segmentSpanChars(out, parameters, "parameters"); diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTagBlock.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTagBlock.java index 14bd7d67e..12e8a2d64 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTagBlock.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTagBlock.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -14,10 +13,9 @@ public class JekyllTagBlock extends Block { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { } - @NotNull @Override public BasedSequence[] getSegments() { return Node.EMPTY_SEGMENTS; diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTagExtension.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTagExtension.java index 41ddf3137..cddf6b91d 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTagExtension.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/JekyllTagExtension.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; import java.util.*; @@ -50,7 +49,7 @@ public void extend(Formatter.Builder formatterBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -71,7 +70,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if ("HTML".equals(rendererType)) { htmlRendererBuilder.nodeRendererFactory(new JekyllTagNodeRenderer.Factory()); } diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/IncludeNodePostProcessor.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/IncludeNodePostProcessor.java index d442eed9d..75b9a1a6d 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/IncludeNodePostProcessor.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/IncludeNodePostProcessor.java @@ -16,8 +16,7 @@ import com.vladsch.flexmark.util.dependency.DependencyResolver; import com.vladsch.flexmark.util.dependency.FirstDependent; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.UnsupportedEncodingException; import java.util.*; @@ -34,17 +33,17 @@ public class IncludeNodePostProcessor extends NodePostProcessor { final private boolean embedIncludedContent; final private Map includedHtml; - public IncludeNodePostProcessor(@NotNull Document document) { + public IncludeNodePostProcessor(Document document) { this.document = document; parser = Parser.builder(document).build(); context = new LinkResolverBasicContext() { @Override - public @NotNull DataHolder getOptions() { + public DataHolder getOptions() { return document; } @Override - public @NotNull Document getDocument() { + public Document getDocument() { return document; } }; @@ -69,7 +68,7 @@ public IncludeNodePostProcessor(@NotNull Document document) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { if (node instanceof JekyllTag && !includedDocuments.containsKey(node)) { JekyllTag jekyllTag = (JekyllTag) node; //noinspection EqualsBetweenInconvertibleTypes @@ -157,9 +156,8 @@ public Factory() { return Collections.singleton(FirstDependent.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new IncludeNodePostProcessor(document); } } diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagBlockParser.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagBlockParser.java index f7b3a086f..7d94bfb1e 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagBlockParser.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagBlockParser.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.List; import java.util.Set; @@ -89,9 +88,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagInlineParserExtension.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagInlineParserExtension.java index ada116d19..f758a34ca 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagInlineParserExtension.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagInlineParserExtension.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.parser.InlineParserExtensionFactory; import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.List; import java.util.Set; @@ -24,16 +23,16 @@ public JekyllTagInlineParserExtension(LightInlineParser lightInlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { if (inlineParser.peek(1) == '%' && (inlineParser.peek(2) == ' ' || inlineParser.peek(2) == '\t')) { BasedSequence input = inlineParser.getInput(); Matcher matcher = inlineParser.matcher(parsing.MACRO_TAG); @@ -65,7 +64,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return "{"; @@ -77,9 +75,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { + public InlineParserExtension apply(LightInlineParser lightInlineParser) { return new JekyllTagInlineParserExtension(lightInlineParser); } diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagNodeFormatter.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagNodeFormatter.java index c5ac859d1..7294a52be 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagNodeFormatter.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagNodeFormatter.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.Collections; @@ -28,7 +27,7 @@ public JekyllTagNodeFormatter(DataHolder options) { } @Override - public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase) { + public void renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase) { this.embedIncludedContent = JekyllTagExtension.EMBED_INCLUDED_CONTENT.get(document); } @@ -98,9 +97,8 @@ private void render(JekyllTag node, NodeFormatterContext context, MarkdownWriter } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new JekyllTagNodeFormatter(options); } } diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagNodeRenderer.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagNodeRenderer.java index 40ed9cd00..fe6ff4d34 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagNodeRenderer.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/JekyllTagNodeRenderer.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Map; @@ -67,9 +66,8 @@ private void render(JekyllTagBlock node, NodeRendererContext context, HtmlWriter } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new JekyllTagNodeRenderer(options); } } diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/package-info.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/package-info.java index 0aaeccfd2..cbe0ec558 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/package-info.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.jekyll.tag.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/package-info.java b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/package-info.java index 3d125ef15..595ef45f7 100644 --- a/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/package-info.java +++ b/flexmark-ext-jekyll-tag/src/main/java/com/vladsch/flexmark/ext/jekyll/tag/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.jekyll.tag; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-jekyll-tag/src/test/java/com/vladsch/flexmark/ext/jekyll/tag/ComboJekyllTagFormatterSpecTest.java b/flexmark-ext-jekyll-tag/src/test/java/com/vladsch/flexmark/ext/jekyll/tag/ComboJekyllTagFormatterSpecTest.java index 090900629..53e985431 100644 --- a/flexmark-ext-jekyll-tag/src/test/java/com/vladsch/flexmark/ext/jekyll/tag/ComboJekyllTagFormatterSpecTest.java +++ b/flexmark-ext-jekyll-tag/src/test/java/com/vladsch/flexmark/ext/jekyll/tag/ComboJekyllTagFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboJekyllTagFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_jekyll_tag_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(JekyllTagExtension.create())) .set(JekyllTagExtension.EMBED_INCLUDED_CONTENT, false) @@ -39,7 +38,7 @@ public class ComboJekyllTagFormatterSpecTest extends FormatterSpecTest { content.put("links.html", ""); optionsMap.put("includes", new MutableDataSet().set(JekyllTagExtension.INCLUDED_HTML, content)); } - public ComboJekyllTagFormatterSpecTest(@NotNull SpecExample example) { + public ComboJekyllTagFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-jekyll-tag/src/test/java/com/vladsch/flexmark/ext/jekyll/tag/ComboJekyllTagSpecTest.java b/flexmark-ext-jekyll-tag/src/test/java/com/vladsch/flexmark/ext/jekyll/tag/ComboJekyllTagSpecTest.java index 0c092f892..a43fc08a4 100644 --- a/flexmark-ext-jekyll-tag/src/test/java/com/vladsch/flexmark/ext/jekyll/tag/ComboJekyllTagSpecTest.java +++ b/flexmark-ext-jekyll-tag/src/test/java/com/vladsch/flexmark/ext/jekyll/tag/ComboJekyllTagSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboJekyllTagSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/jekyll_tag_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(JekyllTagExtension.create())) .toImmutable(); @@ -37,7 +36,7 @@ public class ComboJekyllTagSpecTest extends RendererSpecTest { optionsMap.put("includes", new MutableDataSet().set(JekyllTagExtension.INCLUDED_HTML, content)); optionsMap.put("embed-includes", new MutableDataSet().set(JekyllTagExtension.EMBED_INCLUDED_CONTENT, true)); } - public ComboJekyllTagSpecTest(@NotNull SpecExample example) { + public ComboJekyllTagSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacroDefinitionBlock.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacroDefinitionBlock.java index 38e2bcee1..c9841225f 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacroDefinitionBlock.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacroDefinitionBlock.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.util.ast.ReferenceNode; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.List; @@ -67,7 +66,7 @@ public void setInExpansion(boolean inExpansion) { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, openingMarker, "open"); segmentSpanChars(out, name, "name"); segmentSpanChars(out, openingTrailing, "openTrail"); @@ -75,7 +74,6 @@ public void getAstExtra(@NotNull StringBuilder out) { segmentSpanChars(out, closingTrailing, "closeTrail"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, name, openingTrailing, closingMarker, closingTrailing }; @@ -83,7 +81,7 @@ public BasedSequence[] getSegments() { @Nullable @Override - public MacroReference getReferencingNode(@NotNull Node node) { + public MacroReference getReferencingNode(Node node) { return node instanceof MacroReference ? (MacroReference) node : null; } diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacroReference.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacroReference.java index 8f4dc0806..9e9ce9c03 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacroReference.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacroReference.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.ext.macros.internal.MacroDefinitionRepository; import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A MacroReference node @@ -19,7 +18,6 @@ public boolean isDefined() { return myMacroDefinitionBlock != null; } - @NotNull @Override public BasedSequence getReference() { return text; @@ -51,7 +49,6 @@ public void setMacroDefinitionBlock(MacroDefinitionBlock macroDefinitionBlock) { this.myMacroDefinitionBlock = macroDefinitionBlock; } - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -59,7 +56,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacrosExtension.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacrosExtension.java index 5ea85112a..1a3661bfd 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacrosExtension.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/MacrosExtension.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.format.options.ElementPlacement; import com.vladsch.flexmark.util.format.options.ElementPlacementSort; -import org.jetbrains.annotations.NotNull; /** * Extension for macros @@ -40,7 +39,7 @@ public static MacrosExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -70,7 +69,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new MacrosNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacroDefinitionBlockParser.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacroDefinitionBlockParser.java index 5e0d308b7..07a9b0d0b 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacroDefinitionBlockParser.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacroDefinitionBlockParser.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.HashSet; @@ -123,9 +122,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacroDefinitionRepository.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacroDefinitionRepository.java index 13c497f55..af7d9b13f 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacroDefinitionRepository.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacroDefinitionRepository.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.ast.NodeRepository; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; -import org.jetbrains.annotations.NotNull; import java.util.*; @@ -41,19 +40,16 @@ public MacroDefinitionRepository(DataHolder options) { super(MacrosExtension.MACRO_DEFINITIONS_KEEP.get(options)); } - @NotNull @Override public DataKey getDataKey() { return MacrosExtension.MACRO_DEFINITIONS; } - @NotNull @Override public DataKey getKeepDataKey() { return MacrosExtension.MACRO_DEFINITIONS_KEEP; } - @NotNull @Override public Set getReferencedElements(Node parent) { HashSet references = new HashSet<>(); diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosInlineParserExtension.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosInlineParserExtension.java index 0f0409b85..511263fd8 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosInlineParserExtension.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosInlineParserExtension.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.parser.InlineParserExtensionFactory; import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Pattern; @@ -21,17 +20,17 @@ public MacrosInlineParserExtension(LightInlineParser inlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { BasedSequence match = inlineParser.match(inlineParser.getParsing().intellijDummyIdentifier ? MACRO_REFERENCE_INTELLIJ : MACRO_REFERENCE); if (match != null) { @@ -51,7 +50,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return "<"; @@ -63,9 +61,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { + public InlineParserExtension apply(LightInlineParser lightInlineParser) { return new MacrosInlineParserExtension(lightInlineParser); } diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosNodeFormatter.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosNodeFormatter.java index b2a1986d4..3510fac74 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosNodeFormatter.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosNodeFormatter.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.format.options.ElementPlacement; import com.vladsch.flexmark.util.format.options.ElementPlacementSort; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -88,9 +87,8 @@ private void render(MacroReference node, NodeFormatterContext context, MarkdownW } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new MacrosNodeFormatter(options); } } diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosNodeRenderer.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosNodeRenderer.java index 428b67dd5..c4de954fc 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosNodeRenderer.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosNodeRenderer.java @@ -12,7 +12,6 @@ import com.vladsch.flexmark.util.ast.NodeVisitor; import com.vladsch.flexmark.util.ast.VisitHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -47,7 +46,7 @@ public Set getRenderingPhases() { } @Override - public void renderDocument(@NotNull NodeRendererContext context, @NotNull HtmlWriter html, @NotNull Document document, @NotNull RenderingPhase phase) { + public void renderDocument(NodeRendererContext context, HtmlWriter html, Document document, RenderingPhase phase) { if (phase == RenderingPhase.BODY_TOP) { if (recheckUndefinedReferences) { // need to see if have undefined footnotes that were defined after parsing @@ -114,9 +113,8 @@ private void render(MacroDefinitionBlock node, NodeRendererContext context, Html } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new MacrosNodeRenderer(options); } } diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosOptions.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosOptions.java index 0c4946dcc..06f63859f 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosOptions.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/MacrosOptions.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSetter; -import org.jetbrains.annotations.NotNull; class MacrosOptions implements MutableDataSetter { final public boolean sourceWrapMacroReferences; @@ -13,9 +12,8 @@ public MacrosOptions(DataHolder options) { sourceWrapMacroReferences = MacrosExtension.SOURCE_WRAP_MACRO_REFERENCES.get(options); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(MacrosExtension.SOURCE_WRAP_MACRO_REFERENCES, sourceWrapMacroReferences); return dataHolder; } diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/package-info.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/package-info.java index e287abe10..063950046 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/package-info.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.macros.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/package-info.java b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/package-info.java index f5f0339f7..ea240623e 100644 --- a/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/package-info.java +++ b/flexmark-ext-macros/src/main/java/com/vladsch/flexmark/ext/macros/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.macros; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosFormatterSpecTest.java b/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosFormatterSpecTest.java index efa310ee3..84389051a 100644 --- a/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosFormatterSpecTest.java +++ b/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosFormatterSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -17,7 +16,7 @@ public class ComboMacrosFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_macros_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(MacrosExtension.create(), GitLabExtension.create(), TablesExtension.create())) .set(GitLabExtension.RENDER_BLOCK_MATH, false) @@ -34,7 +33,7 @@ public class ComboMacrosFormatterSpecTest extends FormatterSpecTest { MacrosExtension.MACRO_DEFINITIONS_SORT ); - public ComboMacrosFormatterSpecTest(@NotNull SpecExample example) { + public ComboMacrosFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosSpecTest.java b/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosSpecTest.java index 5f8aa3ec3..26ef74b3d 100644 --- a/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosSpecTest.java +++ b/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosSpecTest.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.ast.KeepType; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -19,7 +18,7 @@ public class ComboMacrosSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_macros_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(MacrosExtension.create(), GitLabExtension.create(), TablesExtension.create())) .set(GitLabExtension.RENDER_BLOCK_MATH, false) @@ -33,7 +32,7 @@ public class ComboMacrosSpecTest extends RendererSpecTest { optionsMap.put("references-keep-first", new MutableDataSet().set(MacrosExtension.MACRO_DEFINITIONS_KEEP, KeepType.FIRST)); optionsMap.put("references-keep-last", new MutableDataSet().set(MacrosExtension.MACRO_DEFINITIONS_KEEP, KeepType.LAST)); } - public ComboMacrosSpecTest(@NotNull SpecExample example) { + public ComboMacrosSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosTranslationFormatterSpecTest.java b/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosTranslationFormatterSpecTest.java index f3c8143a3..2dca7306a 100644 --- a/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosTranslationFormatterSpecTest.java +++ b/flexmark-ext-macros/src/test/java/com/vladsch/flexmark/ext/macros/ComboMacrosTranslationFormatterSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -17,7 +16,7 @@ public class ComboMacrosTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_macros_translation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(MacrosExtension.create(), GitLabExtension.create(), TablesExtension.create())) .set(GitLabExtension.RENDER_BLOCK_MATH, false) @@ -32,7 +31,7 @@ public class ComboMacrosTranslationFormatterSpecTest extends TranslationFormatte MacrosExtension.MACRO_DEFINITIONS_SORT ); - public ComboMacrosTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboMacrosTranslationFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/MediaTagsExtension.java b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/MediaTagsExtension.java index 39e82ef60..dba9fbe73 100644 --- a/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/MediaTagsExtension.java +++ b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/MediaTagsExtension.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; public class MediaTagsExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension { private MediaTagsExtension() { @@ -21,7 +20,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -31,7 +30,7 @@ public void parserOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new MediaTagsNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/MediaTagsNodePostProcessor.java b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/MediaTagsNodePostProcessor.java index fcb73347e..614ff861b 100644 --- a/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/MediaTagsNodePostProcessor.java +++ b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/MediaTagsNodePostProcessor.java @@ -14,14 +14,13 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class MediaTagsNodePostProcessor extends NodePostProcessor { public MediaTagsNodePostProcessor(DataHolder options) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { if (node instanceof Link) { Node previous = node.getPrevious(); @@ -68,9 +67,8 @@ public Factory(DataHolder options) { addNodes(Link.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new MediaTagsNodePostProcessor(document); } } diff --git a/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/MediaTagsNodeRenderer.java b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/MediaTagsNodeRenderer.java index 462660fa5..1fdd58480 100644 --- a/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/MediaTagsNodeRenderer.java +++ b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/MediaTagsNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.HtmlWriter; import com.vladsch.flexmark.html.renderer.*; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -112,9 +111,8 @@ private void renderVideoLink(VideoLink node, NodeRendererContext context, HtmlWr } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new MediaTagsNodeRenderer(options); } } diff --git a/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/package-info.java b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/package-info.java new file mode 100644 index 000000000..8237ec00b --- /dev/null +++ b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/internal/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package com.vladsch.flexmark.ext.media.tags.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/package-info.java b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/package-info.java index 024998f3c..22ce783a2 100644 --- a/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/package-info.java +++ b/flexmark-ext-media-tags/src/main/java/com/vladsch/flexmark/ext/media/tags/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.media.tags; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsAudioLinkSpecTest.java b/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsAudioLinkSpecTest.java index 7240cafd6..7bf35db8b 100644 --- a/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsAudioLinkSpecTest.java +++ b/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsAudioLinkSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -14,12 +13,12 @@ public class ComboMediaTagsAudioLinkSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_media_tags_audio_link_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(MediaTagsExtension.create())) .toImmutable(); - public ComboMediaTagsAudioLinkSpecTest(@NotNull SpecExample example) { + public ComboMediaTagsAudioLinkSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsEmbedLinkSpecTest.java b/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsEmbedLinkSpecTest.java index 5a4024fda..e7d0fe9ed 100644 --- a/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsEmbedLinkSpecTest.java +++ b/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsEmbedLinkSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -14,12 +13,12 @@ public class ComboMediaTagsEmbedLinkSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_media_tags_embed_link_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(MediaTagsExtension.create())) .toImmutable(); - public ComboMediaTagsEmbedLinkSpecTest(@NotNull SpecExample example) { + public ComboMediaTagsEmbedLinkSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsPictureLinkSpecTest.java b/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsPictureLinkSpecTest.java index 2c4f89e94..7ea69efe6 100644 --- a/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsPictureLinkSpecTest.java +++ b/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsPictureLinkSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -14,12 +13,12 @@ public class ComboMediaTagsPictureLinkSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_media_tags_picture_link_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(MediaTagsExtension.create())) .toImmutable(); - public ComboMediaTagsPictureLinkSpecTest(@NotNull SpecExample example) { + public ComboMediaTagsPictureLinkSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsVideoLinkSpecTest.java b/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsVideoLinkSpecTest.java index 54616eb9c..84962c04a 100644 --- a/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsVideoLinkSpecTest.java +++ b/flexmark-ext-media-tags/src/test/java/com/vladsch/flexmark/ext/media/tags/ComboMediaTagsVideoLinkSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -14,12 +13,12 @@ public class ComboMediaTagsVideoLinkSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_media_tags_video_link_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(MediaTagsExtension.create())) .toImmutable(); - public ComboMediaTagsVideoLinkSpecTest(@NotNull SpecExample example) { + public ComboMediaTagsVideoLinkSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/ResizableImage.java b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/ResizableImage.java index 9cd93898c..285dd6b57 100644 --- a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/ResizableImage.java +++ b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/ResizableImage.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class ResizableImage extends Node implements DoNotDecorate { protected BasedSequence source = BasedSequence.NULL; @@ -11,7 +10,6 @@ public class ResizableImage extends Node implements DoNotDecorate { protected BasedSequence width = BasedSequence.NULL; protected BasedSequence height = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { text, source, width, height }; diff --git a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/ResizableImageExtension.java b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/ResizableImageExtension.java index 5fda12a1b..85a4100c5 100644 --- a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/ResizableImageExtension.java +++ b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/ResizableImageExtension.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; public class ResizableImageExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension { @@ -18,7 +17,7 @@ public static ResizableImageExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -33,7 +32,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new ResizableImageNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/ResizableImageInlineParserExtension.java b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/ResizableImageInlineParserExtension.java index 53ee7c459..8e468fe2a 100644 --- a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/ResizableImageInlineParserExtension.java +++ b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/ResizableImageInlineParserExtension.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.parser.InlineParserExtensionFactory; import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Pattern; @@ -20,15 +19,15 @@ public ResizableImageInlineParserExtension(LightInlineParser inlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { int index = inlineParser.getIndex(); char c = inlineParser.getInput().safeCharAt(index + 1); if (c == '[') { @@ -56,7 +55,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return "!"; @@ -68,9 +66,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { + public InlineParserExtension apply(LightInlineParser lightInlineParser) { return new ResizableImageInlineParserExtension(lightInlineParser); } diff --git a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/ResizableImageNodeRenderer.java b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/ResizableImageNodeRenderer.java index feb310239..b69b8fa3b 100644 --- a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/ResizableImageNodeRenderer.java +++ b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/ResizableImageNodeRenderer.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.html.renderer.ResolvedLink; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -50,9 +49,8 @@ public void render(ResizableImage node, NodeRendererContext context, HtmlWriter } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new ResizableImageNodeRenderer(options); } } diff --git a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/package-info.java b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/package-info.java new file mode 100644 index 000000000..4df418279 --- /dev/null +++ b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/internal/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package com.vladsch.flexmark.ext.resizable.image.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/package-info.java b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/package-info.java new file mode 100644 index 000000000..bbc4199c1 --- /dev/null +++ b/flexmark-ext-resizable-image/src/main/java/com/vladsch/flexmark/ext/resizable/image/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package com.vladsch.flexmark.ext.resizable.image; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-resizable-image/src/test/java/com/vladsch/flexmark/ext/resizable/image/ComboResizableImageSpecTest.java b/flexmark-ext-resizable-image/src/test/java/com/vladsch/flexmark/ext/resizable/image/ComboResizableImageSpecTest.java index 47bfbd335..894c02ee2 100644 --- a/flexmark-ext-resizable-image/src/test/java/com/vladsch/flexmark/ext/resizable/image/ComboResizableImageSpecTest.java +++ b/flexmark-ext-resizable-image/src/test/java/com/vladsch/flexmark/ext/resizable/image/ComboResizableImageSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -14,12 +13,12 @@ public class ComboResizableImageSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_resizable_image_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(ResizableImageExtension.create())) .toImmutable(); - public ComboResizableImageSpecTest(@NotNull SpecExample example) { + public ComboResizableImageSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleAst.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleAst.java index ff22910dd..d9e341fe4 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleAst.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleAst.java @@ -2,18 +2,16 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A SpecExample block node */ public class SpecExampleAst extends Node { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleBlock.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleBlock.java index 5496501fa..609993d00 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleBlock.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleBlock.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -29,7 +28,7 @@ public class SpecExampleBlock extends Block { private BasedSequence closingMarker = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { //BasedSequence content = getContentChars(); //int lines = getSegments().length; //segmentSpanChars(out, openingMarker, "open"); @@ -56,7 +55,6 @@ public void getAstExtra(@NotNull StringBuilder out) { if (closingMarker.isNotNull()) segmentSpan(out, closingMarker, "closingMarker"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleExtension.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleExtension.java index 82ca4c51c..e32447028 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleExtension.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleExtension.java @@ -11,7 +11,6 @@ import com.vladsch.flexmark.test.util.spec.SpecReader; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Map; @@ -58,7 +57,7 @@ public static SpecExampleExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -78,7 +77,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new SpecExampleNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleHtml.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleHtml.java index 99194fb89..39f0c2765 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleHtml.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleHtml.java @@ -2,18 +2,16 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A SpecExample block node */ public class SpecExampleHtml extends Node { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOption.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOption.java index 2c68685fe..ba2b1ba78 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOption.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOption.java @@ -2,18 +2,16 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A SpecExample block node */ public class SpecExampleOption extends Node { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOptionSeparator.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOptionSeparator.java index 443a0f4dd..6e98fccc0 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOptionSeparator.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOptionSeparator.java @@ -2,17 +2,15 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A SpecExample block node */ public class SpecExampleOptionSeparator extends Node { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOptionsList.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOptionsList.java index 604e0c695..7569639cc 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOptionsList.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleOptionsList.java @@ -2,18 +2,16 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A SpecExample block node */ public class SpecExampleOptionsList extends Node { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleSeparator.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleSeparator.java index 5bbfd168a..1c289dd9c 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleSeparator.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleSeparator.java @@ -2,18 +2,16 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A SpecExample block node */ public class SpecExampleSeparator extends Node { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleSource.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleSource.java index ed5518969..d4b10bf54 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleSource.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/SpecExampleSource.java @@ -2,18 +2,16 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A SpecExample block node */ public class SpecExampleSource extends Node { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleBlockParser.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleBlockParser.java index c9f742e3b..66745f6f8 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleBlockParser.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleBlockParser.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -301,9 +300,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new SpecExampleBlockParser.BlockFactory(options); } } diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleNodeFormatter.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleNodeFormatter.java index d0202b170..a08cd3c81 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleNodeFormatter.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleNodeFormatter.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.LineAppendable; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.List; @@ -59,7 +58,7 @@ void render(SpecExampleBlock node, NodeFormatterContext context, MarkdownWriter markdown.blankLine(); BasedSequence optionsSet = node.getOptions(); - @NotNull List optionsList = optionsSet.splitList(",", 0, BasedSequence.SPLIT_INCLUDE_DELIM_PARTS | BasedSequence.SPLIT_TRIM_SKIP_EMPTY, CharPredicate.SPACE_TAB); + List optionsList = optionsSet.splitList(",", 0, BasedSequence.SPLIT_INCLUDE_DELIM_PARTS | BasedSequence.SPLIT_TRIM_SKIP_EMPTY, CharPredicate.SPACE_TAB); SequenceBuilder builder = node.getChars().getBuilder(); if (optionsList.isEmpty()) optionsSet = BasedSequence.NULL; else { @@ -115,9 +114,8 @@ public static class Factory implements NodeFormatterFactory { return null;//Collections.singleton(CoreNodeFormatter.Factory.class); } - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new SpecExampleNodeFormatter(options); } } diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleNodeRenderer.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleNodeRenderer.java index 22e7e3e76..7600ed8d3 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleNodeRenderer.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/SpecExampleNodeRenderer.java @@ -11,7 +11,6 @@ import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.misc.DelimitedBuilder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -185,9 +184,8 @@ private void render(BasedSequence contentChars, String language, NodeRendererCon } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new SpecExampleNodeRenderer(options); } } diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/package-info.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/package-info.java index 866597311..b3b957fad 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/package-info.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.spec.example.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/package-info.java b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/package-info.java index d336c73d0..1bfb1e38b 100644 --- a/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/package-info.java +++ b/flexmark-ext-spec-example/src/main/java/com/vladsch/flexmark/ext/spec/example/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.spec.example; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-spec-example/src/test/java/com/vladsch/flexmark/ext/spec/example/ComboSpecExampleFormatterSpecTest.java b/flexmark-ext-spec-example/src/test/java/com/vladsch/flexmark/ext/spec/example/ComboSpecExampleFormatterSpecTest.java index 51d2fbae8..29b7bf90a 100644 --- a/flexmark-ext-spec-example/src/test/java/com/vladsch/flexmark/ext/spec/example/ComboSpecExampleFormatterSpecTest.java +++ b/flexmark-ext-spec-example/src/test/java/com/vladsch/flexmark/ext/spec/example/ComboSpecExampleFormatterSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecReader; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -18,7 +17,7 @@ public class ComboSpecExampleFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_spec_example_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(JekyllFrontMatterExtension.create(), SpecExampleExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -30,7 +29,7 @@ public class ComboSpecExampleFormatterSpecTest extends FormatterSpecTest { static { // optionsMap.put("class-explicit", new MutableDataSet().set(AttributesExtension.FORMAT_ATTRIBUTE_CLASS, AttributeImplicitName.EXPLICIT_PREFERRED)); } - public ComboSpecExampleFormatterSpecTest(@NotNull SpecExample example) { + public ComboSpecExampleFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-spec-example/src/test/java/com/vladsch/flexmark/ext/spec/example/ComboSpecExampleSpecTest.java b/flexmark-ext-spec-example/src/test/java/com/vladsch/flexmark/ext/spec/example/ComboSpecExampleSpecTest.java index 650842c05..3def43e7d 100644 --- a/flexmark-ext-spec-example/src/test/java/com/vladsch/flexmark/ext/spec/example/ComboSpecExampleSpecTest.java +++ b/flexmark-ext-spec-example/src/test/java/com/vladsch/flexmark/ext/spec/example/ComboSpecExampleSpecTest.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.test.util.spec.SpecReader; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -19,7 +18,7 @@ public class ComboSpecExampleSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_spec_example_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(SpecExampleExtension.SPEC_EXAMPLE_BREAK, SpecReader.EXAMPLE_TEST_BREAK) .set(SpecExampleExtension.SPEC_SECTION_BREAK, SpecReader.SECTION_TEST_BREAK) @@ -34,7 +33,7 @@ public class ComboSpecExampleSpecTest extends RendererSpecTest { optionsMap.put("as-def-list", new MutableDataSet().set(SpecExampleExtension.SPEC_EXAMPLE_RENDER_AS, RenderAs.DEFINITION_LIST)); optionsMap.put("as-fenced-code", new MutableDataSet().set(SpecExampleExtension.SPEC_EXAMPLE_RENDER_AS, RenderAs.FENCED_CODE)); } - public ComboSpecExampleSpecTest(@NotNull SpecExample example) { + public ComboSpecExampleSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/Superscript.java b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/Superscript.java index e4c03563f..eea1831c3 100644 --- a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/Superscript.java +++ b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/Superscript.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DelimitedNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A Superscript node @@ -14,7 +13,6 @@ public class Superscript extends Node implements DelimitedNode { protected BasedSequence closingMarker = BasedSequence.NULL; protected String superscriptBlockText; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -22,7 +20,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/SuperscriptExtension.java b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/SuperscriptExtension.java index f059acdce..7f7986d58 100644 --- a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/SuperscriptExtension.java +++ b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/SuperscriptExtension.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; /** * Extension for superscripts @@ -28,7 +27,7 @@ public static SuperscriptExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -43,7 +42,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new SuperscriptNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/SuperscriptJiraRenderer.java b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/SuperscriptJiraRenderer.java index 34c79bfd1..28b6a9278 100644 --- a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/SuperscriptJiraRenderer.java +++ b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/SuperscriptJiraRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -31,9 +30,8 @@ private void render(Superscript node, NodeRendererContext context, HtmlWriter ht } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new SuperscriptJiraRenderer(options); } } diff --git a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/SuperscriptNodeRenderer.java b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/SuperscriptNodeRenderer.java index eaec9818d..0cf4bcf47 100644 --- a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/SuperscriptNodeRenderer.java +++ b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/SuperscriptNodeRenderer.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -46,9 +45,8 @@ private void render(Superscript node, NodeRendererContext context, HtmlWriter ht } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new SuperscriptNodeRenderer(options); } } diff --git a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/package-info.java b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/package-info.java index cc88d8dc5..6b62ab2e3 100644 --- a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/package-info.java +++ b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.superscript.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/package-info.java b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/package-info.java index f000b6551..7b7342de7 100644 --- a/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/package-info.java +++ b/flexmark-ext-superscript/src/main/java/com/vladsch/flexmark/ext/superscript/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.superscript; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-superscript/src/test/java/com/vladsch/flexmark/ext/superscript/ComboSuperscriptSpecTest.java b/flexmark-ext-superscript/src/test/java/com/vladsch/flexmark/ext/superscript/ComboSuperscriptSpecTest.java index d8d390a2b..be031dd40 100644 --- a/flexmark-ext-superscript/src/test/java/com/vladsch/flexmark/ext/superscript/ComboSuperscriptSpecTest.java +++ b/flexmark-ext-superscript/src/test/java/com/vladsch/flexmark/ext/superscript/ComboSuperscriptSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboSuperscriptSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/superscript_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(SuperscriptExtension.create())) .toImmutable(); @@ -25,7 +24,7 @@ public class ComboSuperscriptSpecTest extends RendererSpecTest { static { optionsMap.put("style-superscript", new MutableDataSet().set(SuperscriptExtension.SUPERSCRIPT_STYLE_HTML_OPEN, "").set(SuperscriptExtension.SUPERSCRIPT_STYLE_HTML_CLOSE, "")); } - public ComboSuperscriptSpecTest(@NotNull SpecExample example) { + public ComboSuperscriptSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableBlock.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableBlock.java index ca9096018..9eda67bc2 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableBlock.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableBlock.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -32,7 +31,6 @@ public TableBlock(BlockContent blockContent) { super(blockContent); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[0]; diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableBody.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableBody.java index 4b6573fb2..8c6e6c2a1 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableBody.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableBody.java @@ -2,13 +2,11 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Body part of a {@link TableBlock} containing {@link TableRow TableRows}. */ public class TableBody extends Node { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableCaption.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableCaption.java index 69d851ee3..505141e84 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableCaption.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableCaption.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.ast.LineBreakNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Table caption of a {@link TableBlock} containing inline nodes. @@ -57,14 +56,13 @@ public void setClosingMarker(BasedSequence closingMarker) { this.closingMarker = closingMarker; } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } } diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableCell.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableCell.java index c3eb33d31..281e7b392 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableCell.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableCell.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.html.CellAlignment; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Table cell of a {@link TableRow} containing inline nodes. @@ -111,14 +110,13 @@ public void setSpan(int span) { this.span = span; } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { if (alignment != null) out.append(" ").append(alignment); if (header) out.append(" header"); if (span > 1) out.append(" span=" + span); diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableHead.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableHead.java index 478fdf22b..d13498218 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableHead.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableHead.java @@ -2,13 +2,11 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Head part of a {@link TableBlock} containing {@link TableRow TableRows}. */ public class TableHead extends Node { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableRow.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableRow.java index 786e78472..f93004e00 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableRow.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableRow.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.LineBreakNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Table row of a {@link TableHead} or {@link TableBody} containing {@link TableCell TableCells}. @@ -15,12 +14,11 @@ public class TableRow extends Node implements LineBreakNode { private int rowNumber; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { super.getAstExtra(out); if (rowNumber != 0) out.append(" rowNumber=").append(rowNumber); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableSeparator.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableSeparator.java index 584ec2af0..08fe3358d 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableSeparator.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TableSeparator.java @@ -4,13 +4,11 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Body part of a {@link TableBlock} containing {@link TableRow TableRows}. */ public class TableSeparator extends Node implements DoNotDecorate, DoNotCollectText { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TablesExtension.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TablesExtension.java index baf0d8bc4..d33209b63 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TablesExtension.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/TablesExtension.java @@ -15,7 +15,6 @@ import com.vladsch.flexmark.util.format.TableManipulator; import com.vladsch.flexmark.util.format.options.DiscretionaryText; import com.vladsch.flexmark.util.format.options.TableCaptionHandling; -import org.jetbrains.annotations.NotNull; /** * Extension for GFM tables using "|" pipes (GitHub Flavored Markdown). @@ -67,7 +66,7 @@ public void extend(Formatter.Builder formatterBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -82,7 +81,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new TableNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableColumnSeparator.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableColumnSeparator.java index 59b5a15cc..af42db263 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableColumnSeparator.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableColumnSeparator.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Table cell separator only used during parsing, not part of the AST, use the {@link TableCell#getOpeningMarker()} and {@link TableCell#getClosingMarker()} @@ -21,18 +20,16 @@ public TableColumnSeparator(String chars) { super(BasedSequence.of(chars)); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } - @NotNull @Override protected String toStringAttributes() { return "text=" + getChars(); diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableJiraRenderer.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableJiraRenderer.java index d5f81db30..761cf4898 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableJiraRenderer.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableJiraRenderer.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -110,9 +109,8 @@ private static String getAlignValue(TableCell.Alignment alignment) { } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new TableJiraRenderer(options); } } diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableNodeFormatter.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableNodeFormatter.java index a8ca7f8da..fe08709a1 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableNodeFormatter.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableNodeFormatter.java @@ -13,8 +13,7 @@ import com.vladsch.flexmark.util.html.CellAlignment; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.LineAppendable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -233,9 +232,8 @@ private void render(Text node, NodeFormatterContext context, MarkdownWriter mark } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new TableNodeFormatter(options); } } diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableNodeRenderer.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableNodeRenderer.java index 4919afeb7..6c583a229 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableNodeRenderer.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableNodeRenderer.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -90,9 +89,8 @@ private static String getAlignValue(TableCell.Alignment alignment) { } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new TableNodeRenderer(options); } } diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableParagraphPreProcessor.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableParagraphPreProcessor.java index b1647c3d6..a08f6897f 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableParagraphPreProcessor.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/TableParagraphPreProcessor.java @@ -17,7 +17,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.format.TableFormatOptions; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; import java.util.regex.Pattern; diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/package-info.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/package-info.java index 82912a0f9..088b8fafa 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/package-info.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.tables.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/package-info.java b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/package-info.java index f6821d2b5..b433b3d3d 100644 --- a/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/package-info.java +++ b/flexmark-ext-tables/src/main/java/com/vladsch/flexmark/ext/tables/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.tables; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableFormatterSpecTest.java b/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableFormatterSpecTest.java index 43af5bea0..b4f9f3b1e 100644 --- a/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableFormatterSpecTest.java +++ b/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableFormatterSpecTest.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.format.TableFormatOptions; import com.vladsch.flexmark.util.format.options.DiscretionaryText; import com.vladsch.flexmark.util.format.options.TableCaptionHandling; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -20,7 +19,7 @@ public class ComboTableFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_tables_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(TablesExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -82,7 +81,7 @@ public int getCharWidth(char c) { ); optionsMap.put("width-provider", new MutableDataSet().set(TablesExtension.FORMAT_CHAR_WIDTH_PROVIDER, WIDTH_PROVIDER)); } - public ComboTableFormatterSpecTest(@NotNull SpecExample example) { + public ComboTableFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableManipulationSpecTest.java b/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableManipulationSpecTest.java index 47e3680a5..0ae7615e9 100644 --- a/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableManipulationSpecTest.java +++ b/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableManipulationSpecTest.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.format.TableFormatOptions; import com.vladsch.flexmark.util.format.options.DiscretionaryText; import com.vladsch.flexmark.util.format.options.TableCaptionHandling; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -20,7 +19,7 @@ public class ComboTableManipulationSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_tables_manipulation_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(TablesExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -209,7 +208,7 @@ public int getCharWidth(char c) { // @formatter:on } - public ComboTableManipulationSpecTest(@NotNull SpecExample example) { + public ComboTableManipulationSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableSpecTest.java b/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableSpecTest.java index 330b5a2c1..e184bdcb2 100644 --- a/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableSpecTest.java +++ b/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableSpecTest.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.misc.Utils; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import org.junit.runners.Parameterized; @@ -17,7 +16,7 @@ public class ComboTableSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_tables_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(TablesExtension.create())) .toImmutable(); @@ -52,7 +51,7 @@ public class ComboTableSpecTest extends RendererSpecTest { "") ); } - public ComboTableSpecTest(@NotNull SpecExample example) { + public ComboTableSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableTranslationFormatterSpecTest.java b/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableTranslationFormatterSpecTest.java index 53da4893e..0c406a16c 100644 --- a/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableTranslationFormatterSpecTest.java +++ b/flexmark-ext-tables/src/test/java/com/vladsch/flexmark/ext/tables/ComboTableTranslationFormatterSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.format.options.DiscretionaryText; import com.vladsch.flexmark.util.format.options.TableCaptionHandling; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -18,7 +17,7 @@ public class ComboTableTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_tables_translation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(TablesExtension.create())) .toImmutable(); @@ -44,7 +43,7 @@ public class ComboTableTranslationFormatterSpecTest extends TranslationFormatter optionsMap.put("left-align-marker-add", new MutableDataSet().set(TablesExtension.FORMAT_TABLE_LEFT_ALIGN_MARKER, DiscretionaryText.ADD)); optionsMap.put("left-align-marker-remove", new MutableDataSet().set(TablesExtension.FORMAT_TABLE_LEFT_ALIGN_MARKER, DiscretionaryText.REMOVE)); } - public ComboTableTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboTableTranslationFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocBlock.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocBlock.java index b9c7c3f2b..918c8b211 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocBlock.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocBlock.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.ext.toc; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A simulated toc block node @@ -13,7 +12,7 @@ public class SimTocBlock extends TocBlockBase { protected BasedSequence closingTitleMarker = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { super.getAstExtra(out); segmentSpanChars(out, anchorMarker, "anchorMarker"); segmentSpanChars(out, openingTitleMarker, "openingTitleMarker"); @@ -21,7 +20,6 @@ public void getAstExtra(@NotNull StringBuilder out) { segmentSpanChars(out, closingTitleMarker, "closingTitleMarker"); } - @NotNull @Override public BasedSequence[] getSegments() { BasedSequence[] nodeSegments = new BasedSequence[] { openingMarker, tocKeyword, style, closingMarker, anchorMarker, openingTitleMarker, title, closingTitleMarker }; diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocContent.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocContent.java index f805cea7d..333892511 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocContent.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocContent.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -12,7 +11,6 @@ * A sim toc contents node containing all text that came after the sim toc node */ public class SimTocContent extends Block implements DoNotDecorate { - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -20,7 +18,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { } public SimTocContent() { diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocExtension.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocExtension.java index d6b12503f..65c080205 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocExtension.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocExtension.java @@ -11,7 +11,6 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; /** * Extension for tocs @@ -51,7 +50,7 @@ public static SimTocExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // set header id options if not already set if (!options.contains(HtmlRenderer.GENERATE_HEADER_ID)) { options.set(HtmlRenderer.GENERATE_HEADER_ID, true); @@ -82,7 +81,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new SimTocNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocOption.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocOption.java index 4e3b653d4..12d32bb9b 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocOption.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocOption.java @@ -3,13 +3,11 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A sim toc contents node containing all text that came after the sim toc node */ public class SimTocOption extends Node implements DoNotDecorate { - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -17,7 +15,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocOptionList.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocOptionList.java index cfc5aebbc..a80855af4 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocOptionList.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocOptionList.java @@ -3,13 +3,11 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A sim toc contents node containing all text that came after the sim toc node */ public class SimTocOptionList extends Node implements DoNotDecorate { - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlock.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlock.java index 47e3e367b..3da9409b5 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlock.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlock.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.ext.toc; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A TOC node @@ -13,14 +12,13 @@ public class TocBlock extends TocBlockBase { protected BasedSequence closingMarker = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpan(out, openingMarker, "openingMarker"); segmentSpan(out, tocKeyword, "tocKeyword"); segmentSpan(out, style, "style"); segmentSpan(out, closingMarker, "closingMarker"); } - @NotNull @Override public BasedSequence[] getSegments() { BasedSequence[] nodeSegments = new BasedSequence[] { openingMarker, tocKeyword, style, closingMarker }; diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlockBase.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlockBase.java index 97fa775ac..cd0c126fd 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlockBase.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlockBase.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A TOC node @@ -14,14 +13,13 @@ public abstract class TocBlockBase extends Block { protected BasedSequence closingMarker = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpan(out, openingMarker, "openingMarker"); segmentSpan(out, tocKeyword, "tocKeyword"); segmentSpan(out, style, "style"); segmentSpan(out, closingMarker, "closingMarker"); } - @NotNull @Override public BasedSequence[] getSegments() { BasedSequence[] nodeSegments = new BasedSequence[] { openingMarker, tocKeyword, style, closingMarker }; diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocExtension.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocExtension.java index 40a73d197..887d551e1 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocExtension.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocExtension.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; /** * Extension for tocs @@ -49,7 +48,7 @@ public static TocExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // set header id options if not already set if (!options.contains(HtmlRenderer.RENDER_HEADER_ID)) { options.set(HtmlRenderer.RENDER_HEADER_ID, true); @@ -70,7 +69,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new TocNodeRenderer.Factory()); } diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocBlockParser.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocBlockParser.java index 76f7bd682..136db46db 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocBlockParser.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocBlockParser.java @@ -16,8 +16,7 @@ import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.options.ParsedOption; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.List; import java.util.Set; @@ -169,9 +168,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeFormatter.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeFormatter.java index 8e3769c5d..11918cb2e 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeFormatter.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeFormatter.java @@ -9,8 +9,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.format.MarkdownTable; import com.vladsch.flexmark.util.misc.Paired; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -92,9 +91,8 @@ private void render(SimTocContent node, NodeFormatterContext context, MarkdownWr } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new SimTocNodeFormatter(options); } } diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeRenderer.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeRenderer.java index afe2c2358..0ec7c2529 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeRenderer.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeRenderer.java @@ -12,7 +12,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.misc.Paired; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -72,9 +71,8 @@ private void renderTocHeaders(NodeRendererContext context, HtmlWriter html, Node } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new SimTocNodeRenderer(options); } } diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocBlockParser.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocBlockParser.java index 608ef3cb6..2be4a89a2 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocBlockParser.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocBlockParser.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Matcher; @@ -82,9 +81,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocFormatOptions.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocFormatOptions.java index d5427ab0d..3e8feeefe 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocFormatOptions.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocFormatOptions.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSetter; -import org.jetbrains.annotations.NotNull; public class TocFormatOptions implements MutableDataSetter { final public SimTocGenerateOnFormat updateOnFormat; @@ -20,9 +19,8 @@ public TocFormatOptions(DataHolder options) { this.options = TocExtension.FORMAT_OPTIONS.get(options); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(TocExtension.FORMAT_UPDATE_ON_FORMAT, updateOnFormat); dataHolder.set(TocExtension.FORMAT_OPTIONS, options); return dataHolder; diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocNodeRenderer.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocNodeRenderer.java index c50d1ef8c..a367e522a 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocNodeRenderer.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocNodeRenderer.java @@ -14,7 +14,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.misc.Paired; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.List; @@ -57,9 +56,8 @@ private void renderTocHeaders(NodeRendererContext context, HtmlWriter html, Node } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new TocNodeRenderer(options); } } diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocOptions.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocOptions.java index 6ddcb99a1..7d5e96ad0 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocOptions.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocOptions.java @@ -9,8 +9,7 @@ import com.vladsch.flexmark.util.misc.Mutable; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; @SuppressWarnings("WeakerAccess") public class TocOptions implements Immutable, MutableDataSetter { @@ -59,7 +58,7 @@ public TocOptions(int levels, boolean isHtml, boolean isTextOnly, boolean isNumb this(levels, isHtml, isTextOnly, isNumbered, titleLevel, title, listType, false, true, "", "", true); } - public TocOptions(@NotNull TocOptions.AsMutable other) { + public TocOptions(TocOptions.AsMutable other) { this( other.levels , other.isHtml @@ -76,7 +75,7 @@ public TocOptions(@NotNull TocOptions.AsMutable other) { ); } - public TocOptions(@NotNull TocOptions other) { + public TocOptions(TocOptions other) { this( other.levels , other.isHtml @@ -114,9 +113,8 @@ public TocOptions(@Nullable DataHolder options, boolean isSimToc) { ); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(TocExtension.LEVELS, levels); dataHolder.set(TocExtension.IS_TEXT_ONLY, isTextOnly); dataHolder.set(TocExtension.IS_NUMBERED, isNumbered); @@ -326,9 +324,8 @@ public TocOptions.AsMutable normalizeTitle() { return this; } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { return toImmutable().setIn(dataHolder); } diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/package-info.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/package-info.java index d3594ba65..093d04885 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/package-info.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.toc.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/package-info.java b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/package-info.java index b8f906e9f..755b03b8c 100644 --- a/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/package-info.java +++ b/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.toc; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocHtmlFormatterSpecTest.java b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocHtmlFormatterSpecTest.java index 4c4417b85..a2c6ca8db 100644 --- a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocHtmlFormatterSpecTest.java +++ b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocHtmlFormatterSpecTest.java @@ -10,14 +10,13 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.*; public class ComboSimTocHtmlFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_simtoc_formatter_html_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.RENDER_HEADER_ID, true) .set(Parser.EXTENSIONS, Collections.singletonList(SimTocExtension.create())) @@ -44,7 +43,7 @@ public class ComboSimTocHtmlFormatterSpecTest extends FormatterSpecTest { optionsMap.put("on-format-remove", new MutableDataSet().set(TocExtension.FORMAT_UPDATE_ON_FORMAT, SimTocGenerateOnFormat.REMOVE)); optionsMap.put("on-format-update", new MutableDataSet().set(TocExtension.FORMAT_UPDATE_ON_FORMAT, SimTocGenerateOnFormat.UPDATE)); } - public ComboSimTocHtmlFormatterSpecTest(@NotNull SpecExample example) { + public ComboSimTocHtmlFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocMdFormatterSpecTest.java b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocMdFormatterSpecTest.java index c7f53b523..e63810d7e 100644 --- a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocMdFormatterSpecTest.java +++ b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocMdFormatterSpecTest.java @@ -10,14 +10,13 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.*; public class ComboSimTocMdFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_simtoc_formatter_markdown_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.RENDER_HEADER_ID, true) .set(Parser.EXTENSIONS, Collections.singletonList(SimTocExtension.create())) @@ -64,7 +63,7 @@ public class ComboSimTocMdFormatterSpecTest extends FormatterSpecTest { optionsMap.put("default-toc", TOC_OPTIONS); optionsMap.put("default-empty-toc", EMPTY_TOC_OPTIONS); } - public ComboSimTocMdFormatterSpecTest(@NotNull SpecExample example) { + public ComboSimTocMdFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocSpecTest.java b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocSpecTest.java index 0855e854e..afeb678ae 100644 --- a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocSpecTest.java +++ b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboSimTocSpecTest.java @@ -10,14 +10,13 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.*; public class ComboSimTocSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_simtoc_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(HtmlRenderer.RENDER_HEADER_ID, true) .set(Parser.EXTENSIONS, Collections.singletonList(SimTocExtension.create())) @@ -43,7 +42,7 @@ public class ComboSimTocSpecTest extends RendererSpecTest { optionsMap.put("on-format-remove", new MutableDataSet().set(TocExtension.FORMAT_UPDATE_ON_FORMAT, SimTocGenerateOnFormat.REMOVE)); optionsMap.put("on-format-update", new MutableDataSet().set(TocExtension.FORMAT_UPDATE_ON_FORMAT, SimTocGenerateOnFormat.UPDATE)); } - public ComboSimTocSpecTest(@NotNull SpecExample example) { + public ComboSimTocSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboTocSpecTest.java b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboTocSpecTest.java index 4064e5b42..1b7780dfd 100644 --- a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboTocSpecTest.java +++ b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/ComboTocSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -17,7 +16,7 @@ public class ComboTocSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_toc_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singletonList(TocExtension.create())) .toImmutable(); @@ -38,7 +37,7 @@ public class ComboTocSpecTest extends RendererSpecTest { optionsMap.put("list-class", new MutableDataSet().set(TocExtension.LIST_CLASS, "list-class")); optionsMap.put("not-case-sensitive", new MutableDataSet().set(TocExtension.CASE_SENSITIVE_TOC_TAG, false)); } - public ComboTocSpecTest(@NotNull SpecExample example) { + public ComboTocSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/TocOptionsParserTest.java b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/TocOptionsParserTest.java index effeb2bd7..4accec10f 100644 --- a/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/TocOptionsParserTest.java +++ b/flexmark-ext-toc/src/test/java/com/vladsch/flexmark/ext/toc/TocOptionsParserTest.java @@ -24,8 +24,7 @@ import com.vladsch.flexmark.util.options.ParsedOptionStatus; import com.vladsch.flexmark.util.options.ParserMessage; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.runners.Parameterized; import java.io.IOException; @@ -35,7 +34,7 @@ public class TocOptionsParserTest extends ComboSpecTestCase { final private static String SPEC_RESOURCE = "/toc_options_parser_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() //.set(HtmlRenderer.INDENT_SIZE, 2) //.set(HtmlRenderer.RENDER_HEADER_ID, true) @@ -109,19 +108,17 @@ public MutableDataHolder getOptions() { return options; } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { if (status != null) out.append(" status:").append(status.name()); if (message != null) out.append(" message:").append(message); } - @NotNull @Override public String getNodeName() { return nodeType; @@ -141,7 +138,7 @@ public Parser(DataHolder options) { } @Override - public @NotNull Node parse(@NotNull BasedSequence input) { + public Node parse(BasedSequence input) { // here we make the lexer parse the input sequence from start to finish and accumulate everything in custom nodes BasedSequence[] lines = input.split("\n"); ParserNode example = new ParserNode("Example", input, null, null); @@ -222,7 +219,7 @@ public void render(Node node) { } @Override - public void render(@NotNull Node document, @NotNull Appendable output) { + public void render(Node document, Appendable output) { assert document instanceof ParserNode; TocOptions tocOptions = TOC_OPTIONS.get(getOptions()); HtmlWriter html = new HtmlWriter(2, 0); @@ -236,7 +233,7 @@ public void render(@NotNull Node document, @NotNull Appendable output) { } } - public TocOptionsParserTest(@NotNull SpecExample example) { + public TocOptionsParserTest(SpecExample example) { super(example, optionsMap, OPTIONS); } @@ -246,7 +243,7 @@ public static List data() { } @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder OPTIONS = aggregate(TocOptionsParserTest.OPTIONS, exampleOptions); return new FlexmarkSpecExampleRenderer(example, OPTIONS, new Parser(OPTIONS), new Renderer(OPTIONS), true); } diff --git a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicExtension.java b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicExtension.java index 2f99f6e3a..72a8b9646 100644 --- a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicExtension.java +++ b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicExtension.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; /** * Extension for typographics @@ -40,7 +39,7 @@ public static TypographicExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -63,7 +62,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML") || htmlRendererBuilder.isRendererType("JIRA")) { htmlRendererBuilder.nodeRendererFactory(new TypographicNodeRenderer.Factory()); } diff --git a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicQuotes.java b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicQuotes.java index bbcc8923d..7837d55fe 100644 --- a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicQuotes.java +++ b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicQuotes.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.TypographicText; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A TypographicQuotes node @@ -17,7 +16,6 @@ public class TypographicQuotes extends Node implements DelimitedNode, DoNotAttri protected String typographicOpening; protected String typographicClosing; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -25,7 +23,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { if (openingMarker.isNotNull()) out.append(" typographicOpening: ").append(typographicOpening).append(" "); if (closingMarker.isNotNull()) out.append(" typographicClosing: ").append(typographicClosing).append(" "); delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); diff --git a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicSmarts.java b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicSmarts.java index 1f0e42527..691e69eca 100644 --- a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicSmarts.java +++ b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicSmarts.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.ReplacedTextMapper; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.util.misc.BitFieldSet.any; @@ -47,7 +46,7 @@ public boolean collectText(ISequenceBuilder> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return ".-"; @@ -85,9 +83,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { + public InlineParserExtension apply(LightInlineParser lightInlineParser) { return new SmartsInlineParser(lightInlineParser); } diff --git a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/TypographicNodeRenderer.java b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/TypographicNodeRenderer.java index 3b099cd53..a58148641 100644 --- a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/TypographicNodeRenderer.java +++ b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/TypographicNodeRenderer.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -37,9 +36,8 @@ private void render(TypographicSmarts node, NodeRendererContext context, HtmlWri } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new TypographicNodeRenderer(options); } } diff --git a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/package-info.java b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/package-info.java index 4cbfb8350..ee6ebdc04 100644 --- a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/package-info.java +++ b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.typographic.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/package-info.java b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/package-info.java index c61ac97a5..c8c9e88f6 100644 --- a/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/package-info.java +++ b/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.typographic; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-typographic/src/test/java/com/vladsch/flexmark/ext/typographic/ComboTypographicSpecTest.java b/flexmark-ext-typographic/src/test/java/com/vladsch/flexmark/ext/typographic/ComboTypographicSpecTest.java index 650556d05..9b4be8d63 100644 --- a/flexmark-ext-typographic/src/test/java/com/vladsch/flexmark/ext/typographic/ComboTypographicSpecTest.java +++ b/flexmark-ext-typographic/src/test/java/com/vladsch/flexmark/ext/typographic/ComboTypographicSpecTest.java @@ -21,7 +21,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -31,7 +30,7 @@ public class ComboTypographicSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_typographic_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(ComboTypographicSpecTest.class, SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(ComboTypographicSpecTest.class, SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(TypographicExtension.create())) .toImmutable(); @@ -41,7 +40,7 @@ public class ComboTypographicSpecTest extends RendererSpecTest { optionsMap.put("no-quotes", new MutableDataSet().set(TypographicExtension.ENABLE_QUOTES, false)); optionsMap.put("no-smarts", new MutableDataSet().set(TypographicExtension.ENABLE_SMARTS, false)); } - public ComboTypographicSpecTest(@NotNull SpecExample example) { + public ComboTypographicSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/WikiLinkExtension.java b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/WikiLinkExtension.java index 7d0a45607..e7178e4ca 100644 --- a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/WikiLinkExtension.java +++ b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/WikiLinkExtension.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for wikilinks @@ -77,7 +76,7 @@ public static WikiLinkExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -98,7 +97,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new WikiLinkNodeRenderer.Factory()); htmlRendererBuilder.linkResolverFactory(new WikiLinkLinkResolver.Factory()); diff --git a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/WikiNode.java b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/WikiNode.java index 03c07c5ae..6b85e5cfb 100644 --- a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/WikiNode.java +++ b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/WikiNode.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.ReplacedTextMapper; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; public class WikiNode extends Node implements DoNotDecorate, TextContainer, LinkRefDerived { final public static char SEPARATOR_CHAR = '|'; @@ -25,7 +24,6 @@ public class WikiNode extends Node implements DoNotDecorate, TextContainer, Link protected BasedSequence closingMarker = BasedSequence.NULL; protected final boolean linkIsFirst; - @NotNull @Override public BasedSequence[] getSegments() { if (linkIsFirst) { @@ -54,7 +52,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { if (linkIsFirst) { segmentSpanChars(out, openingMarker, "linkOpen"); segmentSpanChars(out, text, "text"); diff --git a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkJiraRenderer.java b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkJiraRenderer.java index 1cdc086b8..0048a2eb7 100644 --- a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkJiraRenderer.java +++ b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkJiraRenderer.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.html.HtmlWriter; import com.vladsch.flexmark.html.renderer.*; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -38,9 +37,8 @@ private void render(WikiLink node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new WikiLinkJiraRenderer(options); } } diff --git a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkRefProcessor.java b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkRefProcessor.java index dbd3271a8..5a6ecc0fb 100644 --- a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkRefProcessor.java +++ b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkRefProcessor.java @@ -12,7 +12,6 @@ import com.vladsch.flexmark.util.ast.TextContainer; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class WikiLinkLinkRefProcessor implements LinkRefProcessor { static final int BRACKET_NESTING_LEVEL = 1; @@ -34,7 +33,7 @@ public int getBracketNestingLevel() { } @Override - public boolean isMatch(@NotNull BasedSequence nodeChars) { + public boolean isMatch(BasedSequence nodeChars) { int length = nodeChars.length(); if (options.imageLinks) { if (length >= 5 && nodeChars.charAt(0) == '!') { @@ -48,9 +47,8 @@ public boolean isMatch(@NotNull BasedSequence nodeChars) { return false; } - @NotNull @Override - public BasedSequence adjustInlineText(@NotNull Document document, @NotNull Node node) { + public BasedSequence adjustInlineText(Document document, Node node) { // here we remove the page ref from child text and only leave the text part assert (node instanceof WikiNode); WikiNode wikiNode = (WikiNode) node; @@ -58,14 +56,14 @@ public BasedSequence adjustInlineText(@NotNull Document document, @NotNull Node } @Override - public boolean allowDelimiters(@NotNull BasedSequence chars, @NotNull Document document, @NotNull Node node) { + public boolean allowDelimiters(BasedSequence chars, Document document, Node node) { assert (node instanceof WikiNode); WikiNode wikiNode = (WikiNode) node; return node instanceof WikiLink && WikiLinkExtension.ALLOW_INLINES.get(document) && wikiNode.getText().ifNull(wikiNode.getLink()).containsAllOf(chars); } @Override - public void updateNodeElements(@NotNull Document document, @NotNull Node node) { + public void updateNodeElements(Document document, Node node) { assert (node instanceof WikiNode); WikiNode wikiNode = (WikiNode) node; if (node instanceof WikiLink && WikiLinkExtension.ALLOW_INLINES.get(document)) { @@ -77,27 +75,25 @@ public void updateNodeElements(@NotNull Document document, @NotNull Node node) { } } - @NotNull @Override - public Node createNode(@NotNull BasedSequence nodeChars) { + public Node createNode(BasedSequence nodeChars) { return nodeChars.firstChar() == '!' ? new WikiImage(nodeChars, options.linkFirstSyntax, options.allowPipeEscape) : new WikiLink(nodeChars, options.linkFirstSyntax, options.allowAnchors, options.allowPipeEscape, options.allowAnchorEscape); } public static class Factory implements LinkRefProcessorFactory { - @NotNull @Override - public LinkRefProcessor apply(@NotNull Document document) { + public LinkRefProcessor apply(Document document) { return new WikiLinkLinkRefProcessor(document); } @Override - public boolean getWantExclamationPrefix(@NotNull DataHolder options) { + public boolean getWantExclamationPrefix(DataHolder options) { return WikiLinkExtension.IMAGE_LINKS.get(options); } @Override - public int getBracketNestingLevel(@NotNull DataHolder options) { + public int getBracketNestingLevel(DataHolder options) { return BRACKET_NESTING_LEVEL; } } diff --git a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkResolver.java b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkResolver.java index 3bf424788..ab4c171ca 100644 --- a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkResolver.java +++ b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkResolver.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.html.renderer.LinkType; import com.vladsch.flexmark.html.renderer.ResolvedLink; import com.vladsch.flexmark.util.ast.Node; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -22,9 +21,8 @@ public WikiLinkLinkResolver(LinkResolverBasicContext context) { this.options = new WikiLinkOptions(context.getOptions()); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) { + public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) { if (link.getLinkType() == WIKI_LINK) { StringBuilder sb = new StringBuilder(); final boolean isWikiImage = node instanceof WikiImage; @@ -109,9 +107,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public LinkResolver apply(@NotNull LinkResolverBasicContext context) { + public LinkResolver apply(LinkResolverBasicContext context) { return new WikiLinkLinkResolver(context); } } diff --git a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkNodeFormatter.java b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkNodeFormatter.java index 3ef8f1c0c..5f88feaab 100644 --- a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkNodeFormatter.java +++ b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkNodeFormatter.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.mappers.SpaceMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -57,7 +56,7 @@ public Set getFormattingPhases() { } @Override - public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase) { + public void renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase) { attributeUniquificationIdMap = Formatter.ATTRIBUTE_UNIQUIFICATION_ID_MAP.get(context.getTranslationStore()); options = new WikiLinkOptions(document); } @@ -255,9 +254,8 @@ private void renderLink(WikiNode node, NodeFormatterContext context, MarkdownWri } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new WikiLinkNodeFormatter(options); } } diff --git a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkNodeRenderer.java b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkNodeRenderer.java index dd2de8eb6..31b34d4fb 100644 --- a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkNodeRenderer.java +++ b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkNodeRenderer.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.html.HtmlWriter; import com.vladsch.flexmark.html.renderer.*; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -58,9 +57,8 @@ private void render(WikiImage node, NodeRendererContext context, HtmlWriter html } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new WikiLinkNodeRenderer(options); } } diff --git a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/package-info.java b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/package-info.java index 8db9e389b..3b78cad91 100644 --- a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/package-info.java +++ b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.wikilink.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/package-info.java b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/package-info.java index f43ff7463..113c9312c 100644 --- a/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/package-info.java +++ b/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.wikilink; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkFormatterSpecTest.java b/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkFormatterSpecTest.java index 455f8faf5..df27d2765 100644 --- a/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkFormatterSpecTest.java +++ b/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboWikiLinkFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_wikilink_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(WikiLinkExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -39,7 +38,7 @@ public class ComboWikiLinkFormatterSpecTest extends FormatterSpecTest { optionsMap.put("custom-link-escape", new MutableDataSet().set(WikiLinkExtension.LINK_ESCAPE_CHARS, " +<>").set(WikiLinkExtension.LINK_REPLACE_CHARS, "____")); } - public ComboWikiLinkFormatterSpecTest(@NotNull SpecExample example) { + public ComboWikiLinkFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkSpecTest.java b/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkSpecTest.java index b8e6e53ae..838444687 100644 --- a/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkSpecTest.java +++ b/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -17,7 +16,7 @@ public class ComboWikiLinkSpecTest extends RendererSpecTest { static final String SPEC_RESOURCE = "/ext_wikilink_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(WikiLinkExtension.create(), TypographicExtension.create())) .toImmutable(); @@ -39,7 +38,7 @@ public class ComboWikiLinkSpecTest extends RendererSpecTest { optionsMap.put("custom-link-escape", new MutableDataSet().set(WikiLinkExtension.LINK_ESCAPE_CHARS, " +<>").set(WikiLinkExtension.LINK_REPLACE_CHARS, "____")); optionsMap.put("link-text-priority", new MutableDataSet().set(Parser.LINK_TEXT_PRIORITY_OVER_LINK_REF, true)); } - public ComboWikiLinkSpecTest(@NotNull SpecExample example) { + public ComboWikiLinkSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkTranslationFormatterSpecTest.java b/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkTranslationFormatterSpecTest.java index bc1073e82..526bdd206 100644 --- a/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkTranslationFormatterSpecTest.java +++ b/flexmark-ext-wikilink/src/test/java/com/vladsch/flexmark/ext/wikilink/ComboWikiLinkTranslationFormatterSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboWikiLinkTranslationFormatterSpecTest extends TranslationFormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_wikilink_translation_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(WikiLinkExtension.create())) .set(Parser.UNDERSCORE_DELIMITER_PROCESSOR, false); @@ -38,7 +37,7 @@ public class ComboWikiLinkTranslationFormatterSpecTest extends TranslationFormat optionsMap.put("custom-link-escape", new MutableDataSet().set(WikiLinkExtension.LINK_ESCAPE_CHARS, " +<>").set(WikiLinkExtension.LINK_REPLACE_CHARS, "____")); } - public ComboWikiLinkTranslationFormatterSpecTest(@NotNull SpecExample example) { + public ComboWikiLinkTranslationFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/Macro.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/Macro.java index 1c0769d17..ffc13b1a9 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/Macro.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/Macro.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.LinkedHashMap; import java.util.Map; @@ -17,7 +16,6 @@ public class Macro extends Node { protected BasedSequence attributeText = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -25,7 +23,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, openingMarker, "open"); segmentSpanChars(out, name, "name"); segmentSpanChars(out, attributeText, "attributes"); diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroAttribute.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroAttribute.java index 5879f9877..65d1bb28e 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroAttribute.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroAttribute.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A macros node @@ -15,7 +14,6 @@ public class MacroAttribute extends Node implements DoNotDecorate { protected BasedSequence value = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -23,7 +21,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, attribute, "attribute"); segmentSpanChars(out, separator, "separator"); delimitedSegmentSpanChars(out, openingMarker, value, closingMarker, "value"); diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroBlock.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroBlock.java index c6b9a7fb8..0346a8d37 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroBlock.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroBlock.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -14,12 +13,11 @@ public class MacroBlock extends Block { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { if (isClosedTag()) out.append(" isClosed"); segmentSpanChars(out, getMacroContentChars(), "macroContent"); } - @NotNull @Override public BasedSequence[] getSegments() { return Node.EMPTY_SEGMENTS; diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroClose.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroClose.java index ddf0bd4f9..346d9f4e0 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroClose.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroClose.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A macros node @@ -12,7 +11,6 @@ public class MacroClose extends Node { protected BasedSequence name = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -20,7 +18,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, name, closingMarker, "name"); } diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroExtension.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroExtension.java index 8bf9fea46..bae43fa29 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroExtension.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroExtension.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for macros @@ -27,12 +26,12 @@ private MacroExtension() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new MacroNodeRenderer.Factory()); } diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroBlockParser.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroBlockParser.java index d153a4845..9e72fbb9d 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroBlockParser.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroBlockParser.java @@ -13,8 +13,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -176,9 +175,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroInlineParser.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroInlineParser.java index 1281ccede..f1dace525 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroInlineParser.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroInlineParser.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.parser.InlineParserExtensionFactory; import com.vladsch.flexmark.parser.LightInlineParser; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -26,12 +25,12 @@ public MacroInlineParser(LightInlineParser inlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { for (int j = openMacros.size(); j-- > 0; ) { inlineParser.moveNodes(openMacros.get(j), inlineParser.getBlock().getLastChild()); } @@ -40,7 +39,7 @@ public void finalizeBlock(@NotNull InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { if (inlineParser.peek(1) == '{') { BasedSequence input = inlineParser.getInput(); int index = inlineParser.getIndex(); @@ -129,7 +128,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return "{"; @@ -141,9 +139,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { + public InlineParserExtension apply(LightInlineParser lightInlineParser) { return new MacroInlineParser(lightInlineParser); } diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroNodeRenderer.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroNodeRenderer.java index 4d023a7f5..961844aa3 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroNodeRenderer.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroNodeRenderer.java @@ -11,7 +11,6 @@ import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -53,9 +52,8 @@ private void render(MacroBlock node, NodeRendererContext context, HtmlWriter htm } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new MacroNodeRenderer(options); } } diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/package-info.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/package-info.java index 62234d4c5..827c026ee 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/package-info.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.xwiki.macros.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/package-info.java b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/package-info.java index 7a3c38676..64e55ce80 100644 --- a/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/package-info.java +++ b/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.xwiki.macros; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-xwiki-macros/src/test/java/com/vladsch/flexmark/ext/xwiki/macros/ComboMacroSpecTest.java b/flexmark-ext-xwiki-macros/src/test/java/com/vladsch/flexmark/ext/xwiki/macros/ComboMacroSpecTest.java index 85ae4270a..49fc3a7f1 100644 --- a/flexmark-ext-xwiki-macros/src/test/java/com/vladsch/flexmark/ext/xwiki/macros/ComboMacroSpecTest.java +++ b/flexmark-ext-xwiki-macros/src/test/java/com/vladsch/flexmark/ext/xwiki/macros/ComboMacroSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboMacroSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/xwiki_macro_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(MacroExtension.ENABLE_RENDERING, true) .set(Parser.EXTENSIONS, Collections.singleton(MacroExtension.create())) @@ -28,7 +27,7 @@ public class ComboMacroSpecTest extends RendererSpecTest { optionsMap.put("no-inlines", new MutableDataSet().set(MacroExtension.ENABLE_INLINE_MACROS, false)); optionsMap.put("no-blocks", new MutableDataSet().set(MacroExtension.ENABLE_BLOCK_MACROS, false)); } - public ComboMacroSpecTest(@NotNull SpecExample example) { + public ComboMacroSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterBlock.java b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterBlock.java index 5da5b766c..7fbfe7b37 100644 --- a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterBlock.java +++ b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterBlock.java @@ -2,10 +2,8 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class YamlFrontMatterBlock extends Block { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterNode.java b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterNode.java index 87c1feb34..5606bddba 100644 --- a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterNode.java +++ b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterNode.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -11,7 +10,6 @@ public class YamlFrontMatterNode extends Node { private BasedSequence key; //private List values; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { key }; diff --git a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterValue.java b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterValue.java index 126234b0f..e6ced2554 100644 --- a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterValue.java +++ b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterValue.java @@ -2,10 +2,8 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class YamlFrontMatterValue extends Node { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterBlockParser.java b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterBlockParser.java index 8b6a75d9b..013c462be 100644 --- a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterBlockParser.java +++ b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterBlockParser.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.PrefixedSubSequence; import com.vladsch.flexmark.util.sequence.SegmentedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -149,9 +148,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterNodeFormatter.java b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterNodeFormatter.java index 47e5d9a6a..d378e9143 100644 --- a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterNodeFormatter.java +++ b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterNodeFormatter.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.HashSet; @@ -29,7 +28,7 @@ public Set> getNodeClasses() { } @Override - public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase) { + public void renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase) { if (phase == FormattingPhase.DOCUMENT_FIRST) { Node node = document.getFirstChild(); if (node instanceof YamlFrontMatterBlock) { @@ -53,9 +52,8 @@ private void render(YamlFrontMatterBlock node, NodeFormatterContext context, Mar } public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new YamlFrontMatterNodeFormatter(options); } } diff --git a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/package-info.java b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/package-info.java index 3fe168ace..67fe0f468 100644 --- a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/package-info.java +++ b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.yaml.front.matter.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/package-info.java b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/package-info.java index e3360d760..601ef7bd1 100644 --- a/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/package-info.java +++ b/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.yaml.front.matter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-yaml-front-matter/src/test/java/com/vladsch/flexmark/ext/yaml/front/matter/ComboYamlFrontMatterFormatterSpecTest.java b/flexmark-ext-yaml-front-matter/src/test/java/com/vladsch/flexmark/ext/yaml/front/matter/ComboYamlFrontMatterFormatterSpecTest.java index 7bfe0370c..cea2872c2 100644 --- a/flexmark-ext-yaml-front-matter/src/test/java/com/vladsch/flexmark/ext/yaml/front/matter/ComboYamlFrontMatterFormatterSpecTest.java +++ b/flexmark-ext-yaml-front-matter/src/test/java/com/vladsch/flexmark/ext/yaml/front/matter/ComboYamlFrontMatterFormatterSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -16,7 +15,7 @@ public class ComboYamlFrontMatterFormatterSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/ext_yaml_front_matter_formatter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(YamlFrontMatterExtension.create())) .set(Parser.LISTS_AUTO_LOOSE, false) @@ -28,7 +27,7 @@ public class ComboYamlFrontMatterFormatterSpecTest extends FormatterSpecTest { Formatter.REFERENCE_SORT ); - public ComboYamlFrontMatterFormatterSpecTest(@NotNull SpecExample example) { + public ComboYamlFrontMatterFormatterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-ext-yaml-front-matter/src/test/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterTest.java b/flexmark-ext-yaml-front-matter/src/test/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterTest.java index fb37f0ab2..dde36fc4b 100644 --- a/flexmark-ext-yaml-front-matter/src/test/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterTest.java +++ b/flexmark-ext-yaml-front-matter/src/test/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterTest.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataSet; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; import java.util.Collections; @@ -27,11 +26,11 @@ public class YamlFrontMatterTest extends RenderingTestCase { .set(TestUtils.NO_FILE_EOL, false) .set(Parser.EXTENSIONS, Collections.singleton(YamlFrontMatterExtension.create())) .toImmutable(); - final private static @NotNull Parser PARSER = Parser.builder(OPTIONS).build(); - final private static @NotNull HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build(); + final private static Parser PARSER = Parser.builder(OPTIONS).build(); + final private static HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build(); @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = DataSet.aggregate(OPTIONS, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, PARSER, RENDERER, true); } @@ -233,7 +232,7 @@ public void nonMatchedStartTag() { } @Override - public @Nullable DataHolder options(@NotNull String option) { + public @Nullable DataHolder options(String option) { return null; } } diff --git a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/YouTubeLinkExtension.java b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/YouTubeLinkExtension.java index 8a1477177..bf025fbe3 100644 --- a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/YouTubeLinkExtension.java +++ b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/YouTubeLinkExtension.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; public class YouTubeLinkExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension { private YouTubeLinkExtension() { @@ -21,7 +20,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -31,7 +30,7 @@ public void parserOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new YouTubeLinkNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodePostProcessor.java b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodePostProcessor.java index 5a1533493..5b5400db5 100644 --- a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodePostProcessor.java +++ b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodePostProcessor.java @@ -11,7 +11,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class YouTubeLinkNodePostProcessor extends NodePostProcessor { @@ -19,7 +18,7 @@ public YouTubeLinkNodePostProcessor(DataHolder options) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { if (node instanceof Link) { Node previous = node.getPrevious(); @@ -50,9 +49,8 @@ public Factory(DataHolder options) { addNodes(Link.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new YouTubeLinkNodePostProcessor(document); } } diff --git a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodeRenderer.java b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodeRenderer.java index 52e42eb09..09db28054 100644 --- a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodeRenderer.java +++ b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodeRenderer.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.html.HtmlWriter; import com.vladsch.flexmark.html.renderer.*; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.net.MalformedURLException; import java.net.URL; @@ -69,9 +68,8 @@ private void render(YouTubeLink node, NodeRendererContext context, HtmlWriter ht } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new YouTubeLinkNodeRenderer(options); } } diff --git a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/package-info.java b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/package-info.java index a78169689..d0b83bc90 100644 --- a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/package-info.java +++ b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.youtube.embedded.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/package-info.java b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/package-info.java index 63b9d9687..c2fa65f9a 100644 --- a/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/package-info.java +++ b/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.youtube.embedded; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-youtube-embedded/src/test/java/com/vladsch/flexmark/ext/youtube/embedded/ComboYouTubeLinkSpecTest.java b/flexmark-ext-youtube-embedded/src/test/java/com/vladsch/flexmark/ext/youtube/embedded/ComboYouTubeLinkSpecTest.java index f32faf02b..dbfb19d05 100644 --- a/flexmark-ext-youtube-embedded/src/test/java/com/vladsch/flexmark/ext/youtube/embedded/ComboYouTubeLinkSpecTest.java +++ b/flexmark-ext-youtube-embedded/src/test/java/com/vladsch/flexmark/ext/youtube/embedded/ComboYouTubeLinkSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -14,12 +13,12 @@ public class ComboYouTubeLinkSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_youtube_link_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Collections.singleton(YouTubeLinkExtension.create())) .toImmutable(); - public ComboYouTubeLinkSpecTest(@NotNull SpecExample example) { + public ComboYouTubeLinkSpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/Zzzzzz.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/Zzzzzz.java index 702267293..658a94020 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/Zzzzzz.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/Zzzzzz.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A Zzzzzz node @@ -24,7 +23,6 @@ public void setZzzzzzBlock(ZzzzzzBlock zzzzzzBlock) { this.zzzzzzBlock = zzzzzzBlock; } - @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; @@ -32,7 +30,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { out.append(" ordinal: ").append(zzzzzzBlock != null ? zzzzzzBlock.getZzzzzzOrdinal() : 0).append(" "); delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzBlock.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzBlock.java index 67a48f298..b21e96e37 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzBlock.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzBlock.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * A Zzzzzz block node @@ -41,7 +40,7 @@ public void setZzzzzzOrdinal(int zzzzzzOrdinal) { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { out.append(" ordinal: ").append(zzzzzzOrdinal).append(" "); segmentSpan(out, openingMarker, "open"); segmentSpan(out, text, "text"); @@ -49,7 +48,6 @@ public void getAstExtra(@NotNull StringBuilder out) { segmentSpan(out, zzzzzz, "zzzzzz"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker, zzzzzz }; diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzExtension.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzExtension.java index 9c1235c81..0e6e03d60 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzExtension.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzExtension.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for zzzzzzs @@ -38,7 +37,7 @@ public static ZzzzzzExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -81,7 +80,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new ZzzzzzNodeRenderer.Factory());// zzzoptionszzz(NODE_RENDERER, PHASED_NODE_RENDERER) htmlRendererBuilder.linkResolverFactory(new ZzzzzzLinkResolver.Factory());// zzzoptionszzz(LINK_RESOLVER, NODE_RENDERER, PHASED_NODE_RENDERER) diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzAttributeProvider.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzAttributeProvider.java index 0766ae4b4..bd6ca9372 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzAttributeProvider.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzAttributeProvider.java @@ -13,7 +13,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.html.Attributes; import com.vladsch.flexmark.util.html.MutableAttributes; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.html.renderer.AttributablePart.LINK; import static com.vladsch.flexmark.util.html.Attribute.LINK_STATUS_ATTR; @@ -37,7 +36,7 @@ public ZzzzzzAttributeProvider(LinkResolverContext context) { } @Override - public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @NotNull MutableAttributes attributes) { + public void setAttributes(Node node, AttributablePart part, MutableAttributes attributes) { nodeAdapter.setAttributes(node, part, attributes); } @@ -76,9 +75,8 @@ public static class Factory extends IndependentAttributeProviderFactory { // return false; //} - @NotNull @Override - public AttributeProvider apply(@NotNull LinkResolverContext context) { + public AttributeProvider apply(LinkResolverContext context) { return new ZzzzzzAttributeProvider(context); } } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockParser.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockParser.java index 82c26c719..9281e9903 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockParser.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockParser.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.regex.Pattern; @@ -91,9 +90,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockPreProcessor.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockPreProcessor.java index bf4c951ae..104cc5b60 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockPreProcessor.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockPreProcessor.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.parser.block.ParserState; import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.Set; @@ -24,7 +23,6 @@ public void preProcess(ParserState state, Block block) { } public static class Factory implements BlockPreProcessorFactory { - @NotNull @Override public Set> getBlockTypes() { HashSet> set = new HashSet<>(); @@ -49,9 +47,8 @@ public boolean affectsGlobalScope() { return true; } - @NotNull @Override - public BlockPreProcessor apply(@NotNull ParserState state) { + public BlockPreProcessor apply(ParserState state) { return new ZzzzzzBlockPreProcessor(state.getProperties()); } } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzDocumentPostProcessor.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzDocumentPostProcessor.java index 05cf7345f..aeb5a1ea1 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzDocumentPostProcessor.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzDocumentPostProcessor.java @@ -9,7 +9,6 @@ import com.vladsch.flexmark.util.ast.NodeVisitor; import com.vladsch.flexmark.util.ast.VisitHandler; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class ZzzzzzDocumentPostProcessor extends DocumentPostProcessor { final private NodeVisitor myVisitor; @@ -20,9 +19,8 @@ public ZzzzzzDocumentPostProcessor(Document document) { ); } - @NotNull @Override - public Document processDocument(@NotNull Document document) { + public Document processDocument(Document document) { myVisitor.visit(document); return document; } @@ -47,9 +45,8 @@ private void visit(Text node) { } public static class Factory extends DocumentPostProcessorFactory { - @NotNull @Override - public DocumentPostProcessor apply(@NotNull Document document) { + public DocumentPostProcessor apply(Document document) { return new ZzzzzzDocumentPostProcessor(document); } } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzInlineParserExtension.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzInlineParserExtension.java index d93fbd4e6..be17e6d3f 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzInlineParserExtension.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzInlineParserExtension.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.parser.InlineParserExtension; import com.vladsch.flexmark.parser.InlineParserExtensionFactory; import com.vladsch.flexmark.parser.LightInlineParser; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -20,12 +19,12 @@ public ZzzzzzInlineParserExtension(LightInlineParser inlineParser) { } @Override - public void finalizeDocument(@NotNull InlineParser inlineParser) { + public void finalizeDocument(InlineParser inlineParser) { } @Override - public void finalizeBlock(@NotNull InlineParser inlineParser) { + public void finalizeBlock(InlineParser inlineParser) { for (int j = openZzzzzzs.size(); j-- > 0; ) { inlineParser.moveNodes(openZzzzzzs.get(j), inlineParser.getBlock().getLastChild()); } @@ -34,7 +33,7 @@ public void finalizeBlock(@NotNull InlineParser inlineParser) { } @Override - public boolean parse(@NotNull LightInlineParser inlineParser) { + public boolean parse(LightInlineParser inlineParser) { return false; } @@ -45,7 +44,6 @@ public Set> getAfterDependents() { return null; } - @NotNull @Override public CharSequence getCharacters() { return ""; @@ -57,9 +55,8 @@ public Set> getBeforeDependents() { return null; } - @NotNull @Override - public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { + public InlineParserExtension apply(LightInlineParser lightInlineParser) { return new ZzzzzzInlineParserExtension(lightInlineParser); } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzJiraRenderer.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzJiraRenderer.java index efe1aadb6..4bd7de970 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzJiraRenderer.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzJiraRenderer.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererFactory; import com.vladsch.flexmark.html.renderer.NodeRenderingHandler; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -38,9 +37,8 @@ private void render(ZzzzzzBlock node, NodeRendererContext context, HtmlWriter ht } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new ZzzzzzJiraRenderer(options); } } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzLinkRefProcessor.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzLinkRefProcessor.java index 7aeec6bc0..c4eb57c31 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzLinkRefProcessor.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzLinkRefProcessor.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class ZzzzzzLinkRefProcessor implements LinkRefProcessor { static final boolean WANT_EXCLAMATION_PREFIX = false; @@ -30,47 +29,44 @@ public int getBracketNestingLevel() { } @Override - public boolean isMatch(@NotNull BasedSequence nodeChars) { + public boolean isMatch(BasedSequence nodeChars) { return nodeChars.length() >= 4 && nodeChars.charAt(0) == '[' && nodeChars.charAt(1) == '[' && nodeChars.endCharAt(1) == ']' && nodeChars.endCharAt(2) == ']'; } - @NotNull @Override - public BasedSequence adjustInlineText(@NotNull Document document, @NotNull Node node) { + public BasedSequence adjustInlineText(Document document, Node node) { // nothing to do, our prefixes are stripped out of a link ref return node.getChars(); } @Override - public boolean allowDelimiters(@NotNull BasedSequence chars, @NotNull Document document, @NotNull Node node) { + public boolean allowDelimiters(BasedSequence chars, Document document, Node node) { return true; } @Override - public void updateNodeElements(@NotNull Document document, @NotNull Node node) { + public void updateNodeElements(Document document, Node node) { } - @NotNull @Override - public Node createNode(@NotNull BasedSequence nodeChars) { + public Node createNode(BasedSequence nodeChars) { return new Zzzzzz(nodeChars, options.zzzzzzOption2); } public static class Factory implements LinkRefProcessorFactory { - @NotNull @Override - public LinkRefProcessor apply(@NotNull Document document) { + public LinkRefProcessor apply(Document document) { return new ZzzzzzLinkRefProcessor(document); } @Override - public boolean getWantExclamationPrefix(@NotNull DataHolder options) { + public boolean getWantExclamationPrefix(DataHolder options) { return WANT_EXCLAMATION_PREFIX; } @Override - public int getBracketNestingLevel(@NotNull DataHolder options) { + public int getBracketNestingLevel(DataHolder options) { return BRACKET_NESTING_LEVEL; } } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzLinkResolver.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzLinkResolver.java index c7c187094..39ff3613a 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzLinkResolver.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzLinkResolver.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.html.renderer.LinkResolverBasicContext; import com.vladsch.flexmark.html.renderer.ResolvedLink; import com.vladsch.flexmark.util.ast.Node; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -28,9 +27,8 @@ public ZzzzzzLinkResolver(LinkResolverBasicContext context) { ); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) { + public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) { return nodeAdapter.resolveLink(node, context, link); } @@ -52,9 +50,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public LinkResolver apply(@NotNull LinkResolverBasicContext context) { + public LinkResolver apply(LinkResolverBasicContext context) { return new ZzzzzzLinkResolver(context); } } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodePostProcessor.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodePostProcessor.java index 786044b65..e67d066d2 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodePostProcessor.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodePostProcessor.java @@ -9,14 +9,13 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NodeTracker; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class ZzzzzzNodePostProcessor extends NodePostProcessor { public ZzzzzzNodePostProcessor(Document document) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { } @@ -44,9 +43,8 @@ public Factory() { //addNodes(HtmlBlock.class, HtmlCommentBlock.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new ZzzzzzNodePostProcessor(document); } } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodeRenderer.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodeRenderer.java index 218680fab..36ada01fc 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodeRenderer.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodeRenderer.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.html.renderer.*; import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.HashSet; @@ -40,7 +39,7 @@ public Set getRenderingPhases() {//zzzoptionszzz(REMOVE, PHASED_ }//zzzoptionszzz(REMOVE, PHASED_NODE_RENDERER) @Override//zzzoptionszzz(REMOVE, PHASED_NODE_RENDERER) - public void renderDocument(@NotNull NodeRendererContext context, @NotNull HtmlWriter html, @NotNull Document document, @NotNull RenderingPhase phase) {//zzzoptionszzz(REMOVE, PHASED_NODE_RENDERER) + public void renderDocument(NodeRendererContext context, HtmlWriter html, Document document, RenderingPhase phase) {//zzzoptionszzz(REMOVE, PHASED_NODE_RENDERER) }//zzzoptionszzz(REMOVE, PHASED_NODE_RENDERER) private void render(Zzzzzz node, NodeRendererContext context, HtmlWriter html) { @@ -60,9 +59,8 @@ private void render(ZzzzzzBlock node, NodeRendererContext context, HtmlWriter ht } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new ZzzzzzNodeRenderer(options); } } diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzOptions.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzOptions.java index 23a9f4760..a72aac6c4 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzOptions.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzOptions.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSetter; -import org.jetbrains.annotations.NotNull; class ZzzzzzOptions implements MutableDataSetter { final public boolean zzzzzzOption1; @@ -17,9 +16,8 @@ public ZzzzzzOptions(DataHolder options) { zzzzzzOption3 = ZzzzzzExtension.ZZZZZZ_OPTION3.get(options); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(ZzzzzzExtension.ZZZZZZ_OPTION1, zzzzzzOption1); dataHolder.set(ZzzzzzExtension.ZZZZZZ_OPTION2, zzzzzzOption2); dataHolder.set(ZzzzzzExtension.ZZZZZZ_OPTION3, zzzzzzOption3); diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzParagraphPreProcessor.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzParagraphPreProcessor.java index 751d01555..9e2bac229 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzParagraphPreProcessor.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzParagraphPreProcessor.java @@ -9,7 +9,7 @@ import com.vladsch.flexmark.parser.core.ReferencePreProcessorFactory; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.BitSet; import java.util.HashMap; diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzRepository.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzRepository.java index 94b7867bc..0c95b4ce3 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzRepository.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzRepository.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.ast.NodeRepository; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.HashSet; @@ -44,19 +43,16 @@ public List getReferencedZzzzzzBlocks() { return referencedZzzzzzBlocks; } - @NotNull @Override public DataKey getDataKey() { return ZzzzzzExtension.ZZZZZZS; } - @NotNull @Override public DataKey getKeepDataKey() { return ZzzzzzExtension.ZZZZZZS_KEEP; } - @NotNull @Override public Set getReferencedElements(Node parent) { HashSet references = new HashSet<>(); diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/package-info.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/package-info.java index 5f919c4a1..aedc368eb 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/package-info.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.zzzzzz.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/package-info.java b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/package-info.java index 6c1323d88..d7b080d90 100644 --- a/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/package-info.java +++ b/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ext.zzzzzz; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-ext-zzzzzz/src/test/java/com/vladsch/flexmark/ext/zzzzzz/ComboZzzzzzSpecTest.java b/flexmark-ext-zzzzzz/src/test/java/com/vladsch/flexmark/ext/zzzzzz/ComboZzzzzzSpecTest.java index 315efe971..a751b1644 100644 --- a/flexmark-ext-zzzzzz/src/test/java/com/vladsch/flexmark/ext/zzzzzz/ComboZzzzzzSpecTest.java +++ b/flexmark-ext-zzzzzz/src/test/java/com/vladsch/flexmark/ext/zzzzzz/ComboZzzzzzSpecTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -17,7 +16,7 @@ public class ComboZzzzzzSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/ext_zzzzzz_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(ZzzzzzExtension.create(), TablesExtension.create())) .toImmutable(); @@ -26,7 +25,7 @@ public class ComboZzzzzzSpecTest extends RendererSpecTest { static { optionsMap.put("option1", new MutableDataSet().set(ZzzzzzExtension.ZZZZZZ_OPTION1, true));//zzzoptionszzz(CUSTOM_PROPERTIES) } - public ComboZzzzzzSpecTest(@NotNull SpecExample example) { + public ComboZzzzzzSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-formatter-test-suite/src/test/java/com/vladsch/flexmark/formatter/test/suite/ComboFormatterIssueSpecTest.java b/flexmark-formatter-test-suite/src/test/java/com/vladsch/flexmark/formatter/test/suite/ComboFormatterIssueSpecTest.java index 5930cd79b..549e5750f 100644 --- a/flexmark-formatter-test-suite/src/test/java/com/vladsch/flexmark/formatter/test/suite/ComboFormatterIssueSpecTest.java +++ b/flexmark-formatter-test-suite/src/test/java/com/vladsch/flexmark/formatter/test/suite/ComboFormatterIssueSpecTest.java @@ -43,15 +43,14 @@ import com.vladsch.flexmark.util.format.options.ElementPlacement; import com.vladsch.flexmark.util.format.options.ElementPlacementSort; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.runners.Parameterized; import java.util.*; public class ComboFormatterIssueSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/formatter_issue_test_suite_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = ParserEmulationProfile.FIXED_INDENT.getProfileOptions() .set(Parser.BLANK_LINES_IN_AST, true) .set(Parser.EXTENSIONS, Arrays.asList( @@ -133,18 +132,18 @@ public class ComboFormatterIssueSpecTest extends FormatterSpecTest { .set(Formatter.REFERENCE_SORT, ElementPlacementSort.SORT) ); } - public ComboFormatterIssueSpecTest(@NotNull SpecExample example) { + public ComboFormatterIssueSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = aggregate(OPTIONS, exampleOptions); if (USE_BUILDER.get(combinedOptions)) { return new FlexmarkSpecExampleRenderer(example, combinedOptions, Parser.builder(combinedOptions).build(), Formatter.builder(combinedOptions).build(), true) { @Override - protected @NotNull String renderHtml() { + protected String renderHtml() { SequenceBuilder builder = SequenceBuilder.emptyBuilder(getDocument().getChars()); getRenderer().render(getDocument(), builder); return builder.toString(); diff --git a/flexmark-formatter-test-suite/src/test/java/com/vladsch/flexmark/formatter/test/suite/ComboFormatterTestSpecTest.java b/flexmark-formatter-test-suite/src/test/java/com/vladsch/flexmark/formatter/test/suite/ComboFormatterTestSpecTest.java index 8e81d9cff..4b57a36b1 100644 --- a/flexmark-formatter-test-suite/src/test/java/com/vladsch/flexmark/formatter/test/suite/ComboFormatterTestSpecTest.java +++ b/flexmark-formatter-test-suite/src/test/java/com/vladsch/flexmark/formatter/test/suite/ComboFormatterTestSpecTest.java @@ -32,7 +32,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.format.options.*; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -42,7 +41,7 @@ public class ComboFormatterTestSpecTest extends FormatterSpecTest { final private static String SPEC_RESOURCE = "/formatter_test_suite_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList( AbbreviationExtension.create(), @@ -114,7 +113,7 @@ public class ComboFormatterTestSpecTest extends FormatterSpecTest { optionsMap.put("task-placement-complete-to-non-task", new MutableDataSet().set(TaskListExtension.FORMAT_LIST_ITEM_PLACEMENT, TaskListItemPlacement.COMPLETE_TO_NON_TASK)); optionsMap.put("task-placement-complete-nested-to-non-task", new MutableDataSet().set(TaskListExtension.FORMAT_LIST_ITEM_PLACEMENT, TaskListItemPlacement.COMPLETE_NESTED_TO_NON_TASK)); } - public ComboFormatterTestSpecTest(@NotNull SpecExample example) { + public ComboFormatterTestSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/DelegatingNodeRendererFactoryWrapper.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/DelegatingNodeRendererFactoryWrapper.java index 40a37b8fc..b0079ac19 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/DelegatingNodeRendererFactoryWrapper.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/DelegatingNodeRendererFactoryWrapper.java @@ -2,7 +2,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.dependency.Dependent; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.List; diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/FlexmarkHtmlConverter.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/FlexmarkHtmlConverter.java index cf53645b9..bdeffe7e5 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/FlexmarkHtmlConverter.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/FlexmarkHtmlConverter.java @@ -25,8 +25,7 @@ import com.vladsch.flexmark.util.sequence.LineAppendableImpl; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; import com.vladsch.flexmark.util.sequence.builder.StringSequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -321,7 +320,7 @@ public static Builder builder(DataHolder options) { * @param html html to convert to markdown * @param output appendable to use for the output */ - public void convert(@NotNull String html, @NotNull Appendable output) { + public void convert(String html, Appendable output) { Document document = Jsoup.parse(html); if (DUMP_HTML_TREE.get(getOptions())) { @@ -342,7 +341,7 @@ public void convert(@NotNull String html, @NotNull Appendable output) { * @param html html to be parsed * @return resulting markdown string */ - public String convert(@NotNull String html) { + public String convert(String html) { return convert(html, 1); } @@ -353,7 +352,7 @@ public String convert(@NotNull String html) { * @param maxTrailingBlankLines max trailing blank lines, -1 will suppress trailing EOL * @return resulting markdown string */ - public String convert(@NotNull String html, int maxTrailingBlankLines) { + public String convert(String html, int maxTrailingBlankLines) { Document document = Jsoup.parse(html); if (DUMP_HTML_TREE.get(getOptions())) { @@ -429,13 +428,12 @@ public Builder(@Nullable DataHolder options) { /** * @return the configured {@link FlexmarkHtmlConverter} */ - @NotNull public FlexmarkHtmlConverter build() { return new FlexmarkHtmlConverter(this); } @Override - protected void removeApiPoint(@NotNull Object apiPoint) { + protected void removeApiPoint(Object apiPoint) { if (apiPoint instanceof HtmlNodeRendererFactory) this.nodeRendererFactories.remove(apiPoint); else if (apiPoint instanceof HtmlLinkResolverFactory) this.linkResolverFactories.remove(apiPoint); else if (apiPoint instanceof HeaderIdGeneratorFactory) this.htmlIdGeneratorFactory = null; @@ -445,7 +443,7 @@ protected void removeApiPoint(@NotNull Object apiPoint) { } @Override - protected void preloadExtension(@NotNull Extension extension) { + protected void preloadExtension(Extension extension) { if (extension instanceof HtmlConverterExtension) { HtmlConverterExtension htmlConverterExtension = (HtmlConverterExtension) extension; htmlConverterExtension.rendererOptions(this); @@ -453,7 +451,7 @@ protected void preloadExtension(@NotNull Extension extension) { } @Override - protected boolean loadExtension(@NotNull Extension extension) { + protected boolean loadExtension(Extension extension) { if (extension instanceof HtmlConverterExtension) { HtmlConverterExtension htmlConverterExtension = (HtmlConverterExtension) extension; htmlConverterExtension.extend(this); @@ -473,7 +471,7 @@ protected boolean loadExtension(@NotNull Extension extension) { * @return {@code this} */ @SuppressWarnings("UnusedReturnValue") - public Builder htmlNodeRendererFactory(@NotNull HtmlNodeRendererFactory htmlNodeRendererFactory) { + public Builder htmlNodeRendererFactory(HtmlNodeRendererFactory htmlNodeRendererFactory) { this.nodeRendererFactories.add(htmlNodeRendererFactory); return this; } @@ -489,7 +487,7 @@ public Builder htmlNodeRendererFactory(@NotNull HtmlNodeRendererFactory htmlNode * @return {@code this} */ @SuppressWarnings("UnusedReturnValue") - public Builder linkResolverFactory(@NotNull HtmlLinkResolverFactory linkResolverFactory) { + public Builder linkResolverFactory(HtmlLinkResolverFactory linkResolverFactory) { this.linkResolverFactories.add(linkResolverFactory); addExtensionApiPoint(linkResolverFactory); return this; @@ -505,9 +503,9 @@ public interface HtmlConverterExtension extends Extension { * * @param options option set that will be used for the builder */ - void rendererOptions(@NotNull MutableDataHolder options); + void rendererOptions(MutableDataHolder options); - void extend(@NotNull Builder builder); + void extend(Builder builder); } final private static Iterator NULL_ITERATOR = new Iterator() { @@ -529,35 +527,35 @@ public void remove() { final public static Iterable NULL_ITERABLE = () -> NULL_ITERATOR; private class MainHtmlConverter extends HtmlNodeConverterSubContext { - final private @NotNull Document document; - final private @NotNull com.vladsch.flexmark.util.ast.Document myForDocument; - final private @NotNull Map> renderers; + final private Document document; + final private com.vladsch.flexmark.util.ast.Document myForDocument; + final private Map> renderers; - final private @NotNull List phasedFormatters; - final private @NotNull Set renderingPhases; - final private @NotNull DataHolder myOptions; + final private List phasedFormatters; + final private Set renderingPhases; + final private DataHolder myOptions; private HtmlConverterPhase phase; - final private @NotNull HtmlConverterOptions myHtmlConverterOptions; + final private HtmlConverterOptions myHtmlConverterOptions; final private @Nullable Pattern specialCharsPattern; - final private @NotNull Stack myStateStack; - final private @NotNull Map mySpecialCharsMap; + final private Stack myStateStack; + final private Map mySpecialCharsMap; private @Nullable HtmlConverterState myState; private boolean myTrace; private boolean myInlineCode; private @Nullable Parser myParser = null; - final private @NotNull HtmlLinkResolver[] myHtmlLinkResolvers; - final private @NotNull HashMap myReferenceUrlToReferenceMap; // map of URL to reference node - final private @NotNull HashMap myReferenceIdToReferenceMap; // map of RefId to reference node - final private @NotNull HashSet myExternalReferences; // map of URL to reference node + final private HtmlLinkResolver[] myHtmlLinkResolvers; + final private HashMap myReferenceUrlToReferenceMap; // map of URL to reference node + final private HashMap myReferenceIdToReferenceMap; // map of RefId to reference node + final private HashSet myExternalReferences; // map of URL to reference node @Override public HtmlConverterState getState() { return myState; } - MainHtmlConverter(@NotNull DataHolder options, @NotNull HtmlMarkdownWriter out, @NotNull Document document, @Nullable DataHolder parentOptions) { + MainHtmlConverter(DataHolder options, HtmlMarkdownWriter out, Document document, @Nullable DataHolder parentOptions) { super(out); this.myOptions = new ScopedDataSet(parentOptions, options); this.renderers = new HashMap<>(32); @@ -630,26 +628,26 @@ private class SubHtmlNodeConverter extends HtmlNodeConverterSubContext implement final private MainHtmlConverter myMainNodeRenderer; final private DataHolder myOptions; - SubHtmlNodeConverter(@NotNull MainHtmlConverter mainNodeRenderer, @NotNull HtmlMarkdownWriter out, @Nullable DataHolder options) { + SubHtmlNodeConverter(MainHtmlConverter mainNodeRenderer, HtmlMarkdownWriter out, @Nullable DataHolder options) { super(out); myMainNodeRenderer = mainNodeRenderer; myOptions = options == null || options == myMainNodeRenderer.getOptions() ? myMainNodeRenderer.getOptions() : new ScopedDataSet(myMainNodeRenderer.getOptions(), options); } @Override - public @NotNull DataHolder getOptions() { return myOptions; } + public DataHolder getOptions() { return myOptions; } @Override - public @NotNull HtmlConverterOptions getHtmlConverterOptions() { return myMainNodeRenderer.getHtmlConverterOptions(); } + public HtmlConverterOptions getHtmlConverterOptions() { return myMainNodeRenderer.getHtmlConverterOptions(); } @Override - public @NotNull Document getDocument() { return myMainNodeRenderer.getDocument(); } + public Document getDocument() { return myMainNodeRenderer.getDocument(); } @Override public HtmlConverterPhase getFormattingPhase() { return myMainNodeRenderer.getFormattingPhase(); } @Override - public void render(@NotNull Node node) { + public void render(Node node) { myMainNodeRenderer.renderNode(node, this); } @@ -659,17 +657,17 @@ public Node getCurrentNode() { } @Override - public @NotNull HtmlNodeConverterContext getSubContext() { + public HtmlNodeConverterContext getSubContext() { return getSubContext(myOptions, StringSequenceBuilder.emptyBuilder()); } @Override - public @NotNull HtmlNodeConverterContext getSubContext(@Nullable DataHolder options) { + public HtmlNodeConverterContext getSubContext(@Nullable DataHolder options) { return getSubContext(options, StringSequenceBuilder.emptyBuilder()); } @Override - public @NotNull HtmlNodeConverterContext getSubContext(@Nullable DataHolder options, @NotNull ISequenceBuilder builder) { + public HtmlNodeConverterContext getSubContext(@Nullable DataHolder options, ISequenceBuilder builder) { HtmlMarkdownWriter writer = new HtmlMarkdownWriter(builder, this.markdown.getOptions()); writer.setContext(this); //noinspection ReturnOfInnerClass @@ -677,28 +675,27 @@ public Node getCurrentNode() { } @Override - public void renderChildren(@NotNull Node parent, boolean outputAttributes, Runnable prePopAction) { + public void renderChildren(Node parent, boolean outputAttributes, Runnable prePopAction) { FlexmarkHtmlConverter.processHtmlTree(this, parent, outputAttributes, prePopAction); } - @Nullable @Override - public com.vladsch.flexmark.util.ast.Document getForDocument() { + public com.vladsch.flexmark.util.ast.@Nullable Document getForDocument() { return myMainNodeRenderer.getForDocument(); } @Override - public @NotNull ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Boolean urlEncode) { return myMainNodeRenderer.resolveLink(linkType, url, urlEncode); } @Override - public @NotNull ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Attributes attributes, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Attributes attributes, Boolean urlEncode) { return myMainNodeRenderer.resolveLink(linkType, url, attributes, urlEncode); } @Override - public void pushState(@NotNull Node parent) { + public void pushState(Node parent) { myMainNodeRenderer.pushState(parent); } @@ -708,12 +705,12 @@ public void popState(@Nullable LineAppendable out) { } @Override - public void processAttributes(@NotNull Node node) { + public void processAttributes(Node node) { myMainNodeRenderer.processAttributes(node); } @Override - public int outputAttributes(@NotNull LineAppendable out, @NotNull String initialSep) { + public int outputAttributes(LineAppendable out, String initialSep) { return myMainNodeRenderer.outputAttributes(out, initialSep); } @@ -768,42 +765,42 @@ public void delegateRender() { } @Override - public @NotNull HashMap getReferenceUrlToReferenceMap() { + public HashMap getReferenceUrlToReferenceMap() { return myMainNodeRenderer.getReferenceUrlToReferenceMap(); } @Override - public @NotNull HashMap getReferenceIdToReferenceMap() { + public HashMap getReferenceIdToReferenceMap() { return myMainNodeRenderer.getReferenceIdToReferenceMap(); } @Override - public @NotNull HashSet getExternalReferences() { + public HashSet getExternalReferences() { return myMainNodeRenderer.getExternalReferences(); } @Override - public Reference getOrCreateReference(@NotNull String url, @NotNull String text, @Nullable String title) { + public Reference getOrCreateReference(String url, String text, @Nullable String title) { return myMainNodeRenderer.getOrCreateReference(url, text, title); } @Override - public com.vladsch.flexmark.util.ast.@NotNull Node parseMarkdown(@NotNull String markdown) { + public com.vladsch.flexmark.util.ast.Node parseMarkdown(String markdown) { return myMainNodeRenderer.parseMarkdown(markdown); } @Override - public void processUnwrapped(@NotNull Node element) { + public void processUnwrapped(Node element) { myMainNodeRenderer.processUnwrapped(this, element); } @Override - public void processWrapped(@NotNull Node node, @Nullable Boolean isBlock, boolean escapeMarkdown) { + public void processWrapped(Node node, @Nullable Boolean isBlock, boolean escapeMarkdown) { FlexmarkHtmlConverter.processWrapped(this, node, isBlock, escapeMarkdown); } @Override - public void appendOuterHtml(@NotNull Node node) { + public void appendOuterHtml(Node node) { FlexmarkHtmlConverter.appendOuterHtml(this, node); } @@ -818,27 +815,27 @@ public void setInlineCode(boolean inlineCode) { } @Override - public void inlineCode(@NotNull Runnable inlineRunnable) { + public void inlineCode(Runnable inlineRunnable) { myMainNodeRenderer.inlineCode(inlineRunnable); } @Override - public @NotNull String escapeSpecialChars(@NotNull String text) { + public String escapeSpecialChars(String text) { return myMainNodeRenderer.escapeSpecialChars(text); } @Override - public @NotNull String prepareText(@NotNull String text) { + public String prepareText(String text) { return myMainNodeRenderer.prepareText(text); } @Override - public @NotNull String prepareText(@NotNull String text, boolean inCode) { + public String prepareText(String text, boolean inCode) { return myMainNodeRenderer.prepareText(text, inCode); } @Override - public @NotNull String processTextNodes(@NotNull Node node) { + public String processTextNodes(Node node) { return myMainNodeRenderer.processTextNodes(node); } @@ -848,32 +845,32 @@ public void excludeAttributes(String... excludes) { } @Override - public void processTextNodes(@NotNull Node node, boolean stripIdAttribute) { + public void processTextNodes(Node node, boolean stripIdAttribute) { processTextNodes(node, stripIdAttribute, null, null); } @Override - public void processTextNodes(@NotNull Node node, boolean stripIdAttribute, @NotNull CharSequence wrapText) { + public void processTextNodes(Node node, boolean stripIdAttribute, CharSequence wrapText) { processTextNodes(node, stripIdAttribute, wrapText, wrapText); } @Override - public void processTextNodes(@NotNull Node node, boolean stripIdAttribute, @Nullable CharSequence textPrefix, @Nullable CharSequence textSuffix) { + public void processTextNodes(Node node, boolean stripIdAttribute, @Nullable CharSequence textPrefix, @Nullable CharSequence textSuffix) { FlexmarkHtmlConverter.processTextNodes(this, node, stripIdAttribute, textPrefix, textSuffix); } @Override - public void wrapTextNodes(@NotNull Node node, @NotNull CharSequence wrapText, boolean needSpaceAround) { + public void wrapTextNodes(Node node, CharSequence wrapText, boolean needSpaceAround) { FlexmarkHtmlConverter.wrapTextNodes(this, node, wrapText, needSpaceAround); } @Override - public void processConditional(@NotNull ExtensionConversion extensionConversion, @NotNull Node node, @NotNull Runnable processNode) { + public void processConditional(ExtensionConversion extensionConversion, Node node, Runnable processNode) { FlexmarkHtmlConverter.processConditional(this, extensionConversion, node, processNode); } @Override - public void renderDefault(@NotNull Node node) { + public void renderDefault(Node node) { FlexmarkHtmlConverter.processDefault(this, node, getHtmlConverterOptions().outputUnknownTags); } @@ -893,23 +890,23 @@ public void setTrace(boolean trace) { } @Override - public @NotNull Stack getStateStack() { + public Stack getStateStack() { return myMainNodeRenderer.getStateStack(); } } @Override - public @NotNull HashMap getReferenceUrlToReferenceMap() { + public HashMap getReferenceUrlToReferenceMap() { return myReferenceUrlToReferenceMap; } @Override - public @NotNull HashMap getReferenceIdToReferenceMap() { + public HashMap getReferenceIdToReferenceMap() { return myReferenceIdToReferenceMap; } @Override - public @NotNull HashSet getExternalReferences() { + public HashSet getExternalReferences() { return myExternalReferences; } @@ -919,7 +916,7 @@ public boolean isTrace() { } @Override - public @NotNull Stack getStateStack() { + public Stack getStateStack() { return myStateStack; } @@ -929,7 +926,7 @@ public void setTrace(boolean trace) { } @Override - public com.vladsch.flexmark.util.ast.@NotNull Node parseMarkdown(@NotNull String markdown) { + public com.vladsch.flexmark.util.ast.Node parseMarkdown(String markdown) { if (myParser == null) { myParser = Parser.builder(myOptions).build(); } @@ -937,7 +934,7 @@ public void setTrace(boolean trace) { } @Override - public Reference getOrCreateReference(@NotNull String url, @NotNull String text, @Nullable String title) { + public Reference getOrCreateReference(String url, String text, @Nullable String title) { Reference reference = myReferenceUrlToReferenceMap.get(url); if (reference != null) { if (title != null && !title.trim().isEmpty()) { @@ -982,12 +979,12 @@ public Reference getOrCreateReference(@NotNull String url, @NotNull String text, } @Override - public @NotNull ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Boolean urlEncode) { return resolveLink(linkType, url, null, urlEncode); } @Override - public @NotNull ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Attributes attributes, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Attributes attributes, Boolean urlEncode) { // Resolved links not cached to allow resolving to different targets by more than URL //HashMap resolvedLinks = resolvedLinkMap.computeIfAbsent(linkType, k -> new HashMap()); @@ -1020,23 +1017,22 @@ public Node getCurrentNode() { } @Override - public @NotNull DataHolder getOptions() { + public DataHolder getOptions() { return myOptions; } @Override - public @NotNull HtmlConverterOptions getHtmlConverterOptions() { + public HtmlConverterOptions getHtmlConverterOptions() { return htmlConverterOptions; } @Override - public @NotNull Document getDocument() { + public Document getDocument() { return document; } - @Nullable @Override - public com.vladsch.flexmark.util.ast.Document getForDocument() { + public com.vladsch.flexmark.util.ast.@Nullable Document getForDocument() { return myForDocument; } @@ -1046,7 +1042,7 @@ public HtmlConverterPhase getFormattingPhase() { } @Override - public void render(@NotNull Node node) { + public void render(Node node) { renderNode(node, this); } @@ -1076,17 +1072,17 @@ void renderByPreviousHandler(HtmlNodeConverterSubContext subContext) { } @Override - public @NotNull HtmlNodeConverterContext getSubContext() { + public HtmlNodeConverterContext getSubContext() { return getSubContext(null); } @Override - public @NotNull HtmlNodeConverterContext getSubContext(@Nullable DataHolder options) { + public HtmlNodeConverterContext getSubContext(@Nullable DataHolder options) { return getSubContext(options, markdown.getBuilder()); } @Override - public @NotNull HtmlNodeConverterContext getSubContext(@Nullable DataHolder options, @NotNull ISequenceBuilder builder) { + public HtmlNodeConverterContext getSubContext(@Nullable DataHolder options, ISequenceBuilder builder) { HtmlMarkdownWriter writer = new HtmlMarkdownWriter(builder, this.markdown.getOptions()); writer.setContext(this); //noinspection ReturnOfInnerClass @@ -1142,12 +1138,12 @@ void renderNode(Node node, HtmlNodeConverterSubContext subContext) { } @Override - public void renderChildren(@NotNull Node parent, boolean outputAttributes, Runnable prePopAction) { + public void renderChildren(Node parent, boolean outputAttributes, Runnable prePopAction) { processHtmlTree(this, parent, outputAttributes, prePopAction); } @Override - public void pushState(@NotNull Node parent) { + public void pushState(Node parent) { myStateStack.push(myState); myState = new HtmlConverterState(parent); processAttributes(parent); @@ -1162,7 +1158,7 @@ public void excludeAttributes(String... excludes) { } @Override - public void processAttributes(@NotNull Node node) { + public void processAttributes(Node node) { assert myState != null; MutableAttributes attributes = myState.myAttributes; @@ -1195,7 +1191,7 @@ public void processAttributes(@NotNull Node node) { } @Override - public int outputAttributes(@NotNull LineAppendable out, @NotNull String initialSep) { + public int outputAttributes(LineAppendable out, String initialSep) { assert myState != null; Attributes attributes = myState.myAttributes; int startOffset = out.offsetWithPending(); @@ -1391,7 +1387,7 @@ private String dumpState() { // processing related helpers @Override - public void processUnwrapped(@NotNull Node element) { + public void processUnwrapped(Node element) { processUnwrapped(this, element); } @@ -1401,32 +1397,32 @@ void processUnwrapped(HtmlNodeConverterSubContext context, Node element) { } @Override - public void processWrapped(@NotNull Node node, @Nullable Boolean isBlock, boolean escapeMarkdown) { + public void processWrapped(Node node, @Nullable Boolean isBlock, boolean escapeMarkdown) { FlexmarkHtmlConverter.processWrapped(this, node, isBlock, escapeMarkdown); } @Override - public void processTextNodes(@NotNull Node node, boolean stripIdAttribute) { + public void processTextNodes(Node node, boolean stripIdAttribute) { processTextNodes(node, stripIdAttribute, null, null); } @Override - public void processTextNodes(@NotNull Node node, boolean stripIdAttribute, @NotNull CharSequence wrapText) { + public void processTextNodes(Node node, boolean stripIdAttribute, CharSequence wrapText) { processTextNodes(node, stripIdAttribute, wrapText, wrapText); } @Override - public void processTextNodes(@NotNull Node node, boolean stripIdAttribute, @Nullable CharSequence textPrefix, @Nullable CharSequence textSuffix) { + public void processTextNodes(Node node, boolean stripIdAttribute, @Nullable CharSequence textPrefix, @Nullable CharSequence textSuffix) { FlexmarkHtmlConverter.processTextNodes(this, node, stripIdAttribute, textPrefix, textSuffix); } @Override - public void wrapTextNodes(@NotNull Node node, @NotNull CharSequence wrapText, boolean needSpaceAround) { + public void wrapTextNodes(Node node, CharSequence wrapText, boolean needSpaceAround) { FlexmarkHtmlConverter.wrapTextNodes(this, node, wrapText, needSpaceAround); } @Override - public @NotNull String processTextNodes(@NotNull Node node) { + public String processTextNodes(Node node) { pushState(node); Node child; @@ -1447,7 +1443,7 @@ public void wrapTextNodes(@NotNull Node node, @NotNull CharSequence wrapText, bo } @Override - public void appendOuterHtml(@NotNull Node node) { + public void appendOuterHtml(Node node) { FlexmarkHtmlConverter.appendOuterHtml(this, node); } @@ -1462,7 +1458,7 @@ public void setInlineCode(boolean inlineCode) { } @Override - public void inlineCode(@NotNull Runnable inlineRunnable) { + public void inlineCode(Runnable inlineRunnable) { boolean oldInlineCode = myInlineCode; myInlineCode = true; try { @@ -1473,12 +1469,12 @@ public void inlineCode(@NotNull Runnable inlineRunnable) { } @Override - public @NotNull String prepareText(@NotNull String text) { + public String prepareText(String text) { return prepareText(text, myInlineCode); } @Override - public @NotNull String prepareText(@NotNull String text, boolean inCode) { + public String prepareText(String text, boolean inCode) { if (specialCharsPattern != null) { Matcher matcher = specialCharsPattern.matcher(text); int length = text.length(); @@ -1518,7 +1514,7 @@ public void inlineCode(@NotNull Runnable inlineRunnable) { } @Override - public @NotNull String escapeSpecialChars(@NotNull String text) { + public String escapeSpecialChars(String text) { if (!myHtmlConverterOptions.skipCharEscape) { text = text.replace("\\", "\\\\"); text = text.replace("*", "\\*"); @@ -1534,17 +1530,17 @@ public void inlineCode(@NotNull Runnable inlineRunnable) { } @Override - public void processConditional(@NotNull ExtensionConversion extensionConversion, @NotNull Node node, @NotNull Runnable processNode) { + public void processConditional(ExtensionConversion extensionConversion, Node node, Runnable processNode) { FlexmarkHtmlConverter.processConditional(this, extensionConversion, node, processNode); } @Override - public void renderDefault(@NotNull Node node) { + public void renderDefault(Node node) { FlexmarkHtmlConverter.processDefault(this, node, getHtmlConverterOptions().outputUnknownTags); } } - static void processTextNodes(@NotNull HtmlNodeConverterContext context, @NotNull Node node, boolean stripIdAttribute, @Nullable CharSequence textPrefix, @Nullable CharSequence textSuffix) { + static void processTextNodes(HtmlNodeConverterContext context, Node node, boolean stripIdAttribute, @Nullable CharSequence textPrefix, @Nullable CharSequence textSuffix) { context.pushState(node); Node child; @@ -1575,7 +1571,7 @@ static void processTextNodes(@NotNull HtmlNodeConverterContext context, @NotNull context.popState(markdown); } - static void wrapTextNodes(@NotNull HtmlNodeConverterContext context, @NotNull Node node, @NotNull CharSequence wrapText, boolean needSpaceAround) { + static void wrapTextNodes(HtmlNodeConverterContext context, Node node, CharSequence wrapText, boolean needSpaceAround) { String text = context.processTextNodes(node); String prefixBefore = null; String appendAfter = null; @@ -1636,7 +1632,7 @@ static void wrapTextNodes(@NotNull HtmlNodeConverterContext context, @NotNull No } } - static void processConditional(@NotNull HtmlNodeConverterContext context, @NotNull ExtensionConversion extensionConversion, @NotNull Node node, @NotNull Runnable processNode) { + static void processConditional(HtmlNodeConverterContext context, ExtensionConversion extensionConversion, Node node, Runnable processNode) { if (extensionConversion.isParsed()) { if (!extensionConversion.isSuppressed()) { processNode.run(); @@ -1646,7 +1642,7 @@ static void processConditional(@NotNull HtmlNodeConverterContext context, @NotNu } } - static void appendOuterHtml(@NotNull HtmlNodeConverterSubContext context, @NotNull Node node) { + static void appendOuterHtml(HtmlNodeConverterSubContext context, Node node) { String text = node.outerHtml(); int head = text.indexOf(">"); int tail = text.lastIndexOf(""); @@ -1692,7 +1688,7 @@ static public void processWrapped(@NotNull HtmlNodeConverterSubContext context, } } - static void processHtmlTree(@NotNull HtmlNodeConverterSubContext context, @NotNull Node parent, boolean outputAttributes, @Nullable Runnable prePopAction) { + static void processHtmlTree(HtmlNodeConverterSubContext context, Node parent, boolean outputAttributes, @Nullable Runnable prePopAction) { context.pushState(parent); HtmlConverterState oldState = context.getState(); assert oldState != null; @@ -1715,7 +1711,7 @@ static void processHtmlTree(@NotNull HtmlNodeConverterSubContext context, @NotNu context.popState(outputAttributes ? context.markdown : null); } - static String dumpState(@NotNull HtmlNodeConverterContext context) { + static String dumpState(HtmlNodeConverterContext context) { Stack stateStack = context.getStateStack(); if (!stateStack.isEmpty()) { @@ -1731,7 +1727,7 @@ static String dumpState(@NotNull HtmlNodeConverterContext context) { return ""; } - static void processDefault(@NotNull HtmlNodeConverterSubContext subContext, @NotNull Node node, boolean outputUnknownTags) { + static void processDefault(HtmlNodeConverterSubContext subContext, Node node, boolean outputUnknownTags) { if (outputUnknownTags) { subContext.processWrapped(node, null, false); } else { diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlConverterOptions.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlConverterOptions.java index 9bcde1fd6..0623dc1e1 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlConverterOptions.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlConverterOptions.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.util.format.TableFormatOptions; import com.vladsch.flexmark.util.html.CellAlignment; import com.vladsch.flexmark.util.misc.Utils; -import org.jetbrains.annotations.NotNull; import java.util.Map; import java.util.function.BiFunction; @@ -211,9 +210,8 @@ public HtmlConverterOptions(DataHolder options) { divTableHdrClasses = FlexmarkHtmlConverter.DIV_TABLE_HDR_CLASSES.get(options); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(FlexmarkHtmlConverter.LIST_CONTENT_INDENT, listContentIndent); dataHolder.set(FlexmarkHtmlConverter.SETEXT_HEADINGS, setextHeadings); dataHolder.set(FlexmarkHtmlConverter.OUTPUT_UNKNOWN_TAGS, outputUnknownTags); diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlConverterState.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlConverterState.java index a2a91ba2d..dcdb307cc 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlConverterState.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlConverterState.java @@ -2,21 +2,20 @@ import com.vladsch.flexmark.util.html.Attributes; import com.vladsch.flexmark.util.html.MutableAttributes; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.jsoup.nodes.Node; import java.util.LinkedList; import java.util.List; public class HtmlConverterState { - final @NotNull Node myParent; + final Node myParent; final List myElements; int myIndex; - final @NotNull MutableAttributes myAttributes; + final MutableAttributes myAttributes; private @Nullable LinkedList myPrePopActions; - HtmlConverterState(@NotNull Node parent) { + HtmlConverterState(Node parent) { myParent = parent; myElements = parent.childNodes(); myIndex = 0; diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlLinkResolverFactory.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlLinkResolverFactory.java index 726b4259e..9110593e7 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlLinkResolverFactory.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlLinkResolverFactory.java @@ -1,7 +1,7 @@ package com.vladsch.flexmark.html2md.converter; import com.vladsch.flexmark.util.dependency.Dependent; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.function.Function; diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlMarkdownWriter.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlMarkdownWriter.java index d5462498c..b80bcfe50 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlMarkdownWriter.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlMarkdownWriter.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.format.MarkdownWriterBase; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; @@ -20,14 +19,13 @@ public HtmlMarkdownWriter(@Nullable Appendable builder, int formatOptions) { super(builder, formatOptions); } - @NotNull @Override public HtmlMarkdownWriter getEmptyAppendable() { return new HtmlMarkdownWriter(appendable, appendable.getOptions()); } @Override - public @NotNull BasedSequence lastBlockQuoteChildPrefix(BasedSequence prefix) { + public BasedSequence lastBlockQuoteChildPrefix(BasedSequence prefix) { Node node = context.getCurrentNode(); if (node instanceof Element) { diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlNodeConverterContext.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlNodeConverterContext.java index 3bc647344..743a246bd 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlNodeConverterContext.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlNodeConverterContext.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.html.Attributes; import com.vladsch.flexmark.util.sequence.LineAppendable; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.jsoup.nodes.Document; import org.jsoup.nodes.Node; @@ -34,7 +33,7 @@ public interface HtmlNodeConverterContext extends NodeContext builder); + HtmlNodeConverterContext getSubContext(@Nullable DataHolder options, ISequenceBuilder builder); /** * Render the specified node and its children using the configured renderers. This should be used to render child @@ -61,7 +60,7 @@ public interface HtmlNodeConverterContext extends NodeContext getReferenceUrlToReferenceMap(); + HashMap getReferenceUrlToReferenceMap(); - @NotNull HashMap getReferenceIdToReferenceMap(); + HashMap getReferenceIdToReferenceMap(); - @NotNull HashSet getExternalReferences(); + HashSet getExternalReferences(); boolean isTrace(); - @NotNull Stack getStateStack(); + Stack getStateStack(); void setTrace(boolean trace); - @NotNull com.vladsch.flexmark.util.ast.Node parseMarkdown(@NotNull String markdown); + com.vladsch.flexmark.util.ast.Node parseMarkdown(String markdown); - @Nullable Reference getOrCreateReference(@NotNull String url, @NotNull String text, @Nullable String title); + @Nullable Reference getOrCreateReference(String url, String text, @Nullable String title); - @NotNull ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, @Nullable Boolean urlEncode); + ResolvedLink resolveLink(LinkType linkType, CharSequence url, @Nullable Boolean urlEncode); - @NotNull ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, @Nullable Attributes attributes, @Nullable Boolean urlEncode); + ResolvedLink resolveLink(LinkType linkType, CharSequence url, @Nullable Attributes attributes, @Nullable Boolean urlEncode); /** * @return the current node being rendered */ @Nullable Node getCurrentNode(); - void pushState(@NotNull Node parent); + void pushState(Node parent); void popState(@Nullable LineAppendable out); void excludeAttributes(String... excludes); - void processAttributes(@NotNull Node node); + void processAttributes(Node node); - int outputAttributes(@NotNull LineAppendable out, @NotNull String initialSep); + int outputAttributes(LineAppendable out, String initialSep); void transferIdToParent(); @@ -156,44 +155,44 @@ public interface HtmlNodeConverterContext extends NodeContext renderingHandlerWrapper; @Nullable Node myRenderingNode; - public HtmlNodeConverterSubContext(@NotNull HtmlMarkdownWriter markdown) { + public HtmlNodeConverterSubContext(HtmlMarkdownWriter markdown) { this.markdown = markdown; this.myRenderingNode = null; this.markdown.setContext(this); @@ -25,15 +24,15 @@ public void setRenderingNode(@Nullable Node renderingNode) { this.myRenderingNode = renderingNode; } - public @NotNull HtmlMarkdownWriter getMarkdown() { + public HtmlMarkdownWriter getMarkdown() { return markdown; } - public void flushTo(@NotNull Appendable out, int maxTrailingBlankLines) { + public void flushTo(Appendable out, int maxTrailingBlankLines) { flushTo(out, getHtmlConverterOptions().maxBlankLines, maxTrailingBlankLines); } - public void flushTo(@NotNull Appendable out, int maxBlankLines, int maxTrailingBlankLines) { + public void flushTo(Appendable out, int maxBlankLines, int maxTrailingBlankLines) { markdown.line(); try { markdown.appendTo(out, maxBlankLines, maxTrailingBlankLines); diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/internal/HtmlConverterCoreNodeRenderer.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/internal/HtmlConverterCoreNodeRenderer.java index 9dd95eec1..7a329ea9c 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/internal/HtmlConverterCoreNodeRenderer.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/internal/HtmlConverterCoreNodeRenderer.java @@ -18,7 +18,6 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.LineAppendable; import com.vladsch.flexmark.util.sequence.RepeatedSequence; -import org.jetbrains.annotations.NotNull; import org.jsoup.nodes.*; import org.jsoup.select.Elements; @@ -491,7 +490,7 @@ private void handleDivTableCell(Element element, HtmlNodeConverterContext contex } } - private boolean hasIntersection(@NotNull Set stringSet1, String[] stringSet2) { + private boolean hasIntersection(Set stringSet1, String[] stringSet2) { for (String item : stringSet2) { if (stringSet1.contains(item)) return true; } diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/internal/package-info.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/internal/package-info.java index 11881d93a..ec4d07029 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/internal/package-info.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.html2md.converter.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/package-info.java b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/package-info.java index caf528546..ce343cc7f 100644 --- a/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/package-info.java +++ b/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.html2md.converter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboAppHtmlAttributeConverterTest.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboAppHtmlAttributeConverterTest.java index 15fee5a71..42f5f26cb 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboAppHtmlAttributeConverterTest.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboAppHtmlAttributeConverterTest.java @@ -4,19 +4,18 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboAppHtmlAttributeConverterTest extends HtmlConverterTest { final private static String SPEC_RESOURCE = "/app_html_attribute_converter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(FlexmarkHtmlConverter.OUTPUT_ATTRIBUTES_ID, true) .toImmutable(); - public ComboAppHtmlAttributeConverterTest(@NotNull SpecExample example) { + public ComboAppHtmlAttributeConverterTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboAppHtmlConverterTest.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboAppHtmlConverterTest.java index afff51512..4ff90ebe1 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboAppHtmlConverterTest.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboAppHtmlConverterTest.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboAppHtmlConverterTest extends HtmlConverterTest { final private static String SPEC_RESOURCE = "/app_html_converter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboAppHtmlConverterTest(@NotNull SpecExample example) { + public ComboAppHtmlConverterTest(SpecExample example) { super(example, null); } diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboFlexmarkHtmlAttributesConverterTest.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboFlexmarkHtmlAttributesConverterTest.java index fa5168570..2df7e7e17 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboFlexmarkHtmlAttributesConverterTest.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboFlexmarkHtmlAttributesConverterTest.java @@ -4,19 +4,18 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboFlexmarkHtmlAttributesConverterTest extends HtmlConverterTest { final private static String SPEC_RESOURCE = "/flexmark_html_attributes_converter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(FlexmarkHtmlConverter.OUTPUT_ATTRIBUTES_ID, true) .toImmutable(); - public ComboFlexmarkHtmlAttributesConverterTest(@NotNull SpecExample example) { + public ComboFlexmarkHtmlAttributesConverterTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboFlexmarkHtmlConverterTest.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboFlexmarkHtmlConverterTest.java index 52b18798e..bfb8d7811 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboFlexmarkHtmlConverterTest.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboFlexmarkHtmlConverterTest.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboFlexmarkHtmlConverterTest extends HtmlConverterTest { final private static String SPEC_RESOURCE = "/flexmark_html_converter_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboFlexmarkHtmlConverterTest(@NotNull SpecExample example) { + public ComboFlexmarkHtmlConverterTest(SpecExample example) { super(example, null); } diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboHtmlAttributeConverterIssueTest.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboHtmlAttributeConverterIssueTest.java index 6da480882..5d1d9fa6d 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboHtmlAttributeConverterIssueTest.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboHtmlAttributeConverterIssueTest.java @@ -4,19 +4,18 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboHtmlAttributeConverterIssueTest extends HtmlConverterTest { final private static String SPEC_RESOURCE = "/html_attribute_converter_issue_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(FlexmarkHtmlConverter.OUTPUT_ATTRIBUTES_ID, true) .toImmutable(); - public ComboHtmlAttributeConverterIssueTest(@NotNull SpecExample example) { + public ComboHtmlAttributeConverterIssueTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboHtmlConverterIssueTest.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboHtmlConverterIssueTest.java index 4bbda44ee..64868e54e 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboHtmlConverterIssueTest.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/ComboHtmlConverterIssueTest.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboHtmlConverterIssueTest extends HtmlConverterTest { final private static String SPEC_RESOURCE = "/html_converter_issue_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); - public ComboHtmlConverterIssueTest(@NotNull SpecExample example) { + public ComboHtmlConverterIssueTest(SpecExample example) { super(example, null); } diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverter.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverter.java index 077e7cf7a..7b6c1369f 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverter.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverter.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; class HtmlConverter extends IParseBase { final static public DataKey HTML_EXTENSIONS = new DataKey<>("HTML_EXTENSIONS", 0 @@ -53,7 +52,6 @@ public RootNode(String rootNode) { myRootNode = rootNode; } - @NotNull @Override public BasedSequence[] getSegments() { return Node.EMPTY_SEGMENTS; @@ -61,7 +59,7 @@ public BasedSequence[] getSegments() { } @Override - public @NotNull Node parse(@NotNull BasedSequence input) { + public Node parse(BasedSequence input) { // here we make the lexer parse the input sequence from start to finish and accumulate everything in custom nodes String rootNode = FlexmarkHtmlConverter.builder(getOptions()).build().convert(input.toString(), 1); return new RootNode(rootNode); diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverterTest.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverterTest.java index 45f022625..9d29f0aa8 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverterTest.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverterTest.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.format.TableFormatOptions; import com.vladsch.flexmark.util.misc.Ref; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.HashMap; @@ -120,19 +119,18 @@ private static Document linkDocument() { ""); } - public HtmlConverterTest(@NotNull SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { + public HtmlConverterTest(SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { super(example, ComboSpecTestCase.optionsMaps(optionsMap, optionMap), ComboSpecTestCase.dataHolders(OPTIONS, defaultOptions)); } @Override - @NotNull - final public SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + final public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combineOptions = aggregate(myDefaultOptions, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combineOptions, new HtmlConverter(combineOptions), new HtmlRootNodeRenderer(combineOptions), true); } @Override - public @NotNull SpecExample checkExample(@NotNull SpecExample example) { + public SpecExample checkExample(SpecExample example) { // reverse source and html return example.withHtml(example.getSource()).withSource(example.getHtml()); } diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverterTextExtension.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverterTextExtension.java index 7cbc9083c..81bc3dca3 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverterTextExtension.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlConverterTextExtension.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.html.renderer.ResolvedLink; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.jsoup.nodes.Node; import java.util.Set; @@ -14,12 +13,12 @@ public static HtmlConverterTextExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(FlexmarkHtmlConverter.@NotNull Builder builder) { + public void extend(FlexmarkHtmlConverter.Builder builder) { builder.linkResolverFactory(new CustomLinkResolver.Factory()); } diff --git a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlRootNodeRenderer.java b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlRootNodeRenderer.java index 18f0746fe..2d50fd70b 100644 --- a/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlRootNodeRenderer.java +++ b/flexmark-html2md-converter/src/test/java/com/vladsch/flexmark/html2md/converter/HtmlRootNodeRenderer.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.test.util.spec.IRenderBase; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -20,7 +19,7 @@ public HtmlRootNodeRenderer(DataHolder options) { } @Override - public void render(@NotNull Node document, @NotNull Appendable output) { + public void render(Node document, Appendable output) { assert document instanceof HtmlConverter.RootNode; String text = ((HtmlConverter.RootNode) document).myRootNode; try { diff --git a/flexmark-integration-test/src/test/java/com/vladsch/flexmark/integration/test/SpecIntegrationTest.java b/flexmark-integration-test/src/test/java/com/vladsch/flexmark/integration/test/SpecIntegrationTest.java index 362479cdf..ebe359f8a 100644 --- a/flexmark-integration-test/src/test/java/com/vladsch/flexmark/integration/test/SpecIntegrationTest.java +++ b/flexmark-integration-test/src/test/java/com/vladsch/flexmark/integration/test/SpecIntegrationTest.java @@ -13,7 +13,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -28,7 +27,7 @@ @RunWith(Parameterized.class) public class SpecIntegrationTest extends RendererSpecTest { - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(TestSpecLocator.DEFAULT_SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(TestSpecLocator.DEFAULT_SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList( AutolinkExtension.create(), @@ -43,12 +42,11 @@ public class SpecIntegrationTest extends RendererSpecTest { final private static Map OVERRIDDEN_EXAMPLES = getOverriddenExamples(); - public SpecIntegrationTest(@NotNull SpecExample example) { + public SpecIntegrationTest(SpecExample example) { super(example, null, OPTIONS); } - @NotNull - public SpecExample checkExample(@NotNull SpecExample example) { + public SpecExample checkExample(SpecExample example) { String expectedHtml = OVERRIDDEN_EXAMPLES.get(example.getSource()); if (expectedHtml != null) { return example.withHtml(expectedHtml); diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/AttributeProviderSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/AttributeProviderSample.java index 14c1cd5b1..341bdf32a 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/AttributeProviderSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/AttributeProviderSample.java @@ -14,19 +14,18 @@ import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.html.MutableAttributes; import com.vladsch.flexmark.util.misc.Extension; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; public class AttributeProviderSample { static class SampleExtension implements HtmlRenderer.HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // add any configuration settings to options you want to apply to everything, here } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.attributeProviderFactory(SampleAttributeProvider.Factory()); } @@ -37,7 +36,7 @@ static SampleExtension create() { static class SampleAttributeProvider implements AttributeProvider { @Override - public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @NotNull MutableAttributes attributes) { + public void setAttributes(Node node, AttributablePart part, MutableAttributes attributes) { if (node instanceof AutoLink && part == AttributablePart.LINK) { /* @@ -72,9 +71,8 @@ public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @N static AttributeProviderFactory Factory() { return new IndependentAttributeProviderFactory() { - @NotNull @Override - public AttributeProvider apply(@NotNull LinkResolverContext context) { + public AttributeProvider apply(LinkResolverContext context) { return new SampleAttributeProvider(); } }; diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/AttributeProviderSample2.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/AttributeProviderSample2.java index babb1aa27..ecc93528f 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/AttributeProviderSample2.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/AttributeProviderSample2.java @@ -13,19 +13,18 @@ import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.html.MutableAttributes; import com.vladsch.flexmark.util.misc.Extension; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; public class AttributeProviderSample2 { static class SampleExtension implements HtmlRenderer.HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // add any configuration settings to options you want to apply to everything, here } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.attributeProviderFactory(SampleAttributeProvider.Factory()); } @@ -36,7 +35,7 @@ static SampleExtension create() { static class SampleAttributeProvider implements AttributeProvider { @Override - public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @NotNull MutableAttributes attributes) { + public void setAttributes(Node node, AttributablePart part, MutableAttributes attributes) { if (node instanceof Link && part == AttributablePart.LINK) { Link link = (Link) node; @@ -48,9 +47,8 @@ public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @N static AttributeProviderFactory Factory() { return new IndependentAttributeProviderFactory() { - @NotNull @Override - public AttributeProvider apply(@NotNull LinkResolverContext context) { + public AttributeProvider apply(LinkResolverContext context) { return new SampleAttributeProvider(); } }; diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/CustomContextDataSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/CustomContextDataSample.java index cbc9360af..cdbe876f1 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/CustomContextDataSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/CustomContextDataSample.java @@ -16,8 +16,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.NullableDataKey; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -30,12 +29,12 @@ class XhtmlContent { static class CustomExtension implements HtmlRenderer.HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.linkResolverFactory(new CustomLinkResolver.Factory()); } @@ -52,9 +51,8 @@ public CustomLinkResolver(LinkResolverBasicContext options) { // context.getHtmlOptions(); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) { + public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) { Document document = context.getDocument(); XhtmlContent xhtmlContent = XHTML_CONTENT.get(document); @@ -94,9 +92,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public LinkResolver apply(@NotNull LinkResolverBasicContext context) { + public LinkResolver apply(LinkResolverBasicContext context) { return new CustomLinkResolver(context); } } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/CustomLinkResolverSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/CustomLinkResolverSample.java index 9ac733e15..aab81a781 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/CustomLinkResolverSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/CustomLinkResolverSample.java @@ -18,8 +18,7 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.misc.Utils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.HashSet; @@ -53,9 +52,8 @@ public DocxLinkResolver(LinkResolverBasicContext context) { prefixWwwLinks = DocxRenderer.PREFIX_WWW_LINKS.get(context.getOptions()); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) { + public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) { if (node instanceof Image || node instanceof Link || node instanceof Reference || node instanceof JekyllTagBlock) { String url = link.getUrl(); @@ -168,9 +166,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public LinkResolver apply(@NotNull LinkResolverBasicContext context) { + public LinkResolver apply(LinkResolverBasicContext context) { return new com.vladsch.flexmark.docx.converter.internal.DocxLinkResolver(context); } } @@ -178,12 +175,12 @@ public LinkResolver apply(@NotNull LinkResolverBasicContext context) { static class CustomExtension implements HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.linkResolverFactory(new DocxLinkResolver.Factory()); htmlRendererBuilder.nodeRendererFactory(new CustomLinkRenderer.Factory()); } @@ -195,9 +192,8 @@ static CustomExtension create() { static class CustomLinkRenderer implements NodeRenderer { public static class Factory implements DelegatingNodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new CustomLinkRenderer(); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/FencedCodeCustomRenderingSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/FencedCodeCustomRenderingSample.java index d7e635962..8ddd99368 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/FencedCodeCustomRenderingSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/FencedCodeCustomRenderingSample.java @@ -16,7 +16,6 @@ import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -39,9 +38,8 @@ public CustomNodeRenderer(DataHolder options) { } public static class Factory implements DelegatingNodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new CustomNodeRenderer(options); } @@ -101,12 +99,12 @@ public Set> getNodeRenderingHandlers() { static class CustomExtension implements HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new CustomNodeRenderer.Factory()); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/GfmUsersIssuesSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/GfmUsersIssuesSample.java index 6e126fea0..204940cbb 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/GfmUsersIssuesSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/GfmUsersIssuesSample.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.function.BiConsumer; @@ -21,7 +20,7 @@ public static void main(String[] args) { Document document = parser.parse("Hello, @world, and #1!"); new NodeVisitor(new VisitHandler[] { }) { @Override - public void processNode(@NotNull Node node, boolean withChildren, @NotNull BiConsumer> processor) { + public void processNode(Node node, boolean withChildren, BiConsumer> processor) { System.out.println("Node: " + node); super.processNode(node, withChildren, processor); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/HtmlToMarkdownCustomizedSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/HtmlToMarkdownCustomizedSample.java index d123e5cbb..6b809a486 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/HtmlToMarkdownCustomizedSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/HtmlToMarkdownCustomizedSample.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.jsoup.nodes.Element; import org.jsoup.nodes.Node; @@ -60,12 +59,12 @@ public static HtmlConverterTextExtension create() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(FlexmarkHtmlConverter.@NotNull Builder builder) { + public void extend(FlexmarkHtmlConverter.Builder builder) { builder.linkResolverFactory(new CustomLinkResolver.Factory()); builder.htmlNodeRendererFactory(new CustomHtmlNodeConverter.Factory()); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/InlineCodeCustomRenderingSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/InlineCodeCustomRenderingSample.java index 21dc397b6..3a395f759 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/InlineCodeCustomRenderingSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/InlineCodeCustomRenderingSample.java @@ -15,7 +15,6 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.sequence.Escaping; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -38,9 +37,8 @@ public CustomNodeRenderer(DataHolder options) { } public static class Factory implements DelegatingNodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new CustomNodeRenderer(options); } @@ -91,12 +89,12 @@ public Set> getNodeRenderingHandlers() { static class CustomExtension implements HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new CustomNodeRenderer.Factory()); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeInsertingPostProcessorSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeInsertingPostProcessorSample.java index 07e4d54bd..07fbc8912 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeInsertingPostProcessorSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeInsertingPostProcessorSample.java @@ -20,7 +20,6 @@ import com.vladsch.flexmark.util.html.MutableAttributes; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.PrefixedSubSequence; -import org.jetbrains.annotations.NotNull; import java.util.Collections; @@ -46,9 +45,8 @@ private static class NodeInsertingFactory extends NodePostProcessorFactory { addNodes(ImageRef.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new NodeInsertingPostProcessor(); } } @@ -58,7 +56,7 @@ public static NodePostProcessorFactory Factory(DataHolder options) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { BasedSequence paragraphText = BasedSequence.NULL; if (node instanceof ImageRef) { // [foo](http://example.com) ImageRef imageRef = (ImageRef) node; diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererCodeBlock.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererCodeBlock.java index 9696c1853..73f9ab0b4 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererCodeBlock.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererCodeBlock.java @@ -14,7 +14,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -23,12 +22,12 @@ public class NodeRendererCodeBlock { static class SampleExtension implements HtmlRenderer.HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // add any configuration settings to options you want to apply to everything, here } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new SampleNodeRenderer.Factory()); } @@ -57,9 +56,8 @@ private void render(Code node, NodeRendererContext context, HtmlWriter html) { } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new SampleNodeRenderer(options); } } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample.java index 2f0fe354a..6ac3884c6 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -19,12 +18,12 @@ public class NodeRendererSample { static class SampleExtension implements HtmlRenderer.HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // add any configuration settings to options you want to apply to everything, here } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new SampleNodeRenderer.Factory()); } @@ -114,9 +113,8 @@ public void renderInlineHtml(HtmlInlineBase node, NodeRendererContext context, H } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new SampleNodeRenderer(options); } } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample2.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample2.java index 7563730d3..9101cc4ac 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample2.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample2.java @@ -17,7 +17,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -26,12 +25,12 @@ public class NodeRendererSample2 { static class SampleExtension implements HtmlRenderer.HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // add any configuration settings to options you want to apply to everything, here } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new SampleNodeRenderer.Factory()); } @@ -79,9 +78,8 @@ private void render(Emphasis node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new SampleNodeRenderer(options); } } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample3.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample3.java index 087bfbad6..358b1e177 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample3.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/NodeRendererSample3.java @@ -17,7 +17,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -26,12 +25,12 @@ public class NodeRendererSample3 { static class SampleExtension implements HtmlRenderer.HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // add any configuration settings to options you want to apply to everything, here } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new SampleNodeRenderer.Factory()); } @@ -79,9 +78,8 @@ private void render(Emphasis node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new SampleNodeRenderer(options); } } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/ParagraphCustomRenderingSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/ParagraphCustomRenderingSample.java index b9cfac3bd..8277d96b3 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/ParagraphCustomRenderingSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/ParagraphCustomRenderingSample.java @@ -12,7 +12,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.HashSet; @@ -34,9 +33,8 @@ public CustomNodeRenderer(DataHolder options) { } public static class Factory implements DelegatingNodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new CustomNodeRenderer(options); } @@ -68,12 +66,12 @@ public Set> getNodeRenderingHandlers() { static class CustomExtension implements HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new CustomNodeRenderer.Factory()); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/PegdownCustomLinkResolverOptions.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/PegdownCustomLinkResolverOptions.java index ccf1a3614..fc9ad3d80 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/PegdownCustomLinkResolverOptions.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/PegdownCustomLinkResolverOptions.java @@ -13,8 +13,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashSet; import java.util.Set; @@ -27,12 +26,12 @@ public class PegdownCustomLinkResolverOptions { static class CustomExtension implements HtmlRenderer.HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.linkResolverFactory(new CustomLinkResolver.Factory()); htmlRendererBuilder.nodeRendererFactory(new CustomLinkRenderer.Factory()); } @@ -49,9 +48,8 @@ public CustomLinkResolver(LinkResolverBasicContext context) { // context.getHtmlOptions(); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) { + public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) { // you can also set/clear/modify attributes through ResolvedLink.getAttributes() and ResolvedLink.getNonNullAttributes() if (node instanceof WikiImage) { @@ -90,9 +88,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public LinkResolver apply(@NotNull LinkResolverBasicContext context) { + public LinkResolver apply(LinkResolverBasicContext context) { return new CustomLinkResolver(context); } } @@ -100,9 +97,8 @@ public LinkResolver apply(@NotNull LinkResolverBasicContext context) { static class CustomLinkRenderer implements NodeRenderer { public static class Factory implements DelegatingNodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new CustomLinkRenderer(); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/SyntheticLinkFormatterSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/SyntheticLinkFormatterSample.java index aeea2e5a5..d408fa1ed 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/SyntheticLinkFormatterSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/SyntheticLinkFormatterSample.java @@ -14,8 +14,7 @@ import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.PrefixedSubSequence; import com.vladsch.flexmark.util.sequence.ReplacedTextMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.HashSet; @@ -45,7 +44,7 @@ public Set getFormattingPhases() { } @Override - public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase) { + public void renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase) { switch (phase) { case DOCUMENT_BOTTOM: markdown.blankLine(); @@ -103,9 +102,8 @@ private void render(Text node, NodeFormatterContext context, MarkdownWriter mark } static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new SyntheticLinkNodeFormatter(options); } } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/SyntheticLinkSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/SyntheticLinkSample.java index 3c1c8b708..2ee06ea7a 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/SyntheticLinkSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/SyntheticLinkSample.java @@ -23,8 +23,7 @@ import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.PrefixedSubSequence; import com.vladsch.flexmark.util.sequence.ReplacedTextMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collections; import java.util.HashSet; @@ -38,7 +37,7 @@ public SyntheticLinkPostProcessor(DataHolder options) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { BasedSequence original = node.getChars(); ReplacedTextMapper textMapper = new ReplacedTextMapper(original); BasedSequence literal = Escaping.unescape(original, textMapper); @@ -101,9 +100,8 @@ public Factory() { addNodeWithExclusions(Text.class, DoNotLinkDecorate.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new SyntheticLinkPostProcessor(document); } } @@ -113,9 +111,8 @@ public static class AppendedMarkdownPostProcessor extends DocumentPostProcessor public AppendedMarkdownPostProcessor(DataHolder options) { } - @NotNull @Override - public Document processDocument(@NotNull Document document) { + public Document processDocument(Document document) { // here you can append some markdown text but keep it based on original input by // using PrefixedSubSequence with only prefix without any characters from input string @@ -133,9 +130,8 @@ public Document processDocument(@NotNull Document document) { } public static class Factory extends DocumentPostProcessorFactory { - @NotNull @Override - public PostProcessor apply(@NotNull Document document) { + public PostProcessor apply(Document document) { return new AppendedMarkdownPostProcessor(document); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TaskListAttributeProviderSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TaskListAttributeProviderSample.java index 554f4a10f..8b92e705d 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TaskListAttributeProviderSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TaskListAttributeProviderSample.java @@ -14,19 +14,18 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.html.MutableAttributes; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; public class TaskListAttributeProviderSample { static class SampleExtension implements HtmlRenderer.HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // add any configuration settings to options you want to apply to everything, here } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.attributeProviderFactory(TaskListAttributeProvider.Factory()); } @@ -37,7 +36,7 @@ static SampleExtension create() { static class TaskListAttributeProvider implements AttributeProvider { @Override - public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @NotNull MutableAttributes attributes) { + public void setAttributes(Node node, AttributablePart part, MutableAttributes attributes) { if (node instanceof TaskListItem && (part == CoreNodeRenderer.TIGHT_LIST_ITEM || part == CoreNodeRenderer.LOOSE_LIST_ITEM)) { if (((TaskListItem) node).isItemDoneMarker()) { attributes.addValue("class", "closed-list-item"); @@ -49,9 +48,8 @@ public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @N static AttributeProviderFactory Factory() { return new IndependentAttributeProviderFactory() { - @NotNull @Override - public AttributeProvider apply(@NotNull LinkResolverContext context) { + public AttributeProvider apply(LinkResolverContext context) { return new TaskListAttributeProvider(); } }; diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/ThreadLocalOptionsExtension.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/ThreadLocalOptionsExtension.java index eaa42d9b5..60cb87a66 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/ThreadLocalOptionsExtension.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/ThreadLocalOptionsExtension.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.DataSet; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; public class ThreadLocalOptionsExtension implements Parser.ParserExtension, @@ -52,13 +51,13 @@ public void parserOptions(MutableDataHolder options) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // copy thread local options to builder options.setAll(threadOptions.get()); } @Override - public void extend(@NotNull RendererBuilder rendererBuilder, @NotNull String rendererType) { + public void extend(RendererBuilder rendererBuilder, String rendererType) { } } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TitleExtract.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TitleExtract.java index 011fbe919..89545a733 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TitleExtract.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TitleExtract.java @@ -19,7 +19,6 @@ import com.vladsch.flexmark.util.ast.TextCollectingVisitor; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -33,12 +32,12 @@ public class TitleExtract { static class HeadingExtension implements HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { // add any configuration settings to options you want to apply to everything, here } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new HeadingNodeRenderer.Factory()); } @@ -104,9 +103,8 @@ void render(Heading node, NodeRendererContext context, HtmlWriter html) { } public static class Factory implements DelegatingNodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new HeadingNodeRenderer(options); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TocSubContextSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TocSubContextSample.java index 47565499d..b38a944df 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TocSubContextSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TocSubContextSample.java @@ -16,7 +16,6 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.sequence.LineAppendable; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -33,9 +32,8 @@ public class TocSubContextSample { static class CustomNodeRenderer implements NodeRenderer { public static class Factory implements DelegatingNodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new CustomNodeRenderer(); } @@ -75,12 +73,12 @@ public Set> getNodeRenderingHandlers() { static class CustomExtension implements HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new CustomNodeRenderer.Factory()); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TocSubContextSample2.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TocSubContextSample2.java index dfd8694c3..7df265617 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TocSubContextSample2.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TocSubContextSample2.java @@ -17,7 +17,6 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.sequence.LineAppendable; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -35,9 +34,8 @@ public class TocSubContextSample2 { static class CustomNodeRenderer implements NodeRenderer { public static class Factory implements DelegatingNodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new CustomNodeRenderer(); } @@ -73,12 +71,12 @@ public Set> getNodeRenderingHandlers() { static class CustomExtension implements HtmlRendererExtension { @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new CustomNodeRenderer.Factory()); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TokenReplacingPostProcessorSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TokenReplacingPostProcessorSample.java index f9452f384..e923d7011 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TokenReplacingPostProcessorSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/TokenReplacingPostProcessorSample.java @@ -13,7 +13,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import java.util.Collections; @@ -41,15 +40,14 @@ public Factory(DataHolder options) { addNodes(Image.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new LinkReplacingPostProcessor(); } } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { if (node instanceof Link) { // [foo](http://example.com) Link link = (Link) node; Text text = new Text(link.getText()); diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/UnderlineExtensionSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/UnderlineExtensionSample.java index 99a317004..1c5b1aed9 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/UnderlineExtensionSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/UnderlineExtensionSample.java @@ -15,7 +15,6 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.Collections; import java.util.HashSet; @@ -40,14 +39,13 @@ static class Underline extends Node implements DelimitedNode { private BasedSequence text = BasedSequence.NULL; private BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { Node.delimitedSegmentSpan(out, openingMarker, text, closingMarker, "text"); } @@ -147,9 +145,8 @@ static class UnderlineNodeRenderer implements NodeRenderer { public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new UnderlineNodeRenderer(); } } @@ -180,7 +177,7 @@ static class UnderlineExtension implements Parser.ParserExtension, HtmlRenderer. private UnderlineExtension() { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { } + public void rendererOptions(MutableDataHolder options) { } @Override public void parserOptions(MutableDataHolder options) { } @@ -191,7 +188,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { htmlRendererBuilder.nodeRendererFactory(new UnderlineNodeRenderer.Factory()); } diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/YouTubeLinkSample.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/YouTubeLinkSample.java index ceedacd0e..2cf75e268 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/YouTubeLinkSample.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/YouTubeLinkSample.java @@ -15,7 +15,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -53,7 +52,7 @@ public YouTubeLinkNodePostProcessor(DataHolder options) { } @Override - public void process(@NotNull NodeTracker state, @NotNull Node node) { + public void process(NodeTracker state, Node node) { if (node instanceof Link) { Node previous = node.getPrevious(); @@ -81,9 +80,8 @@ public Factory(DataHolder options) { addNodes(Link.class); } - @NotNull @Override - public NodePostProcessor apply(@NotNull Document document) { + public NodePostProcessor apply(Document document) { return new YouTubeLinkNodePostProcessor(document); } } @@ -119,9 +117,8 @@ private void render(YouTubeLink node, NodeRendererContext context, HtmlWriter ht } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new YouTubeLinkNodeRenderer(options); } } @@ -141,7 +138,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { } @@ -151,7 +148,7 @@ public void parserOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new YouTubeLinkNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { diff --git a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/package-info.java b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/package-info.java index fbd129b1b..eafcdf0a8 100644 --- a/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/package-info.java +++ b/flexmark-java-samples/src/com/vladsch/flexmark/java/samples/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.java.samples; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/JiraConverterExtension.java b/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/JiraConverterExtension.java index 8dbaab7c6..ef51f8e5c 100644 --- a/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/JiraConverterExtension.java +++ b/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/JiraConverterExtension.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.jira.converter.internal.JiraConverterNodeRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension for jira_converters @@ -29,7 +28,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { String rendererType = HtmlRenderer.TYPE.get(options); if (rendererType.equals("HTML")) { options.set(HtmlRenderer.TYPE, "JIRA"); @@ -44,7 +43,7 @@ public void parserOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("JIRA")) { htmlRendererBuilder.nodeRendererFactory(new JiraConverterNodeRenderer.Factory()); } else { diff --git a/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/internal/JiraConverterNodeRenderer.java b/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/internal/JiraConverterNodeRenderer.java index 735cd9fd8..6ef165d40 100644 --- a/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/internal/JiraConverterNodeRenderer.java +++ b/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/internal/JiraConverterNodeRenderer.java @@ -12,7 +12,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.Escaping; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -392,9 +391,8 @@ private void render(LinkRef node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new JiraConverterNodeRenderer(options); } } diff --git a/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/internal/package-info.java b/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/internal/package-info.java index 018920990..44e32a887 100644 --- a/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/internal/package-info.java +++ b/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.jira.converter.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/package-info.java b/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/package-info.java index 6b1576097..3a432dc81 100644 --- a/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/package-info.java +++ b/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.jira.converter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-jira-converter/src/test/java/com/vladsch/flexmark/jira/converter/ComboJiraConverterSpecTest.java b/flexmark-jira-converter/src/test/java/com/vladsch/flexmark/jira/converter/ComboJiraConverterSpecTest.java index 8d3e99da3..71b1103be 100644 --- a/flexmark-jira-converter/src/test/java/com/vladsch/flexmark/jira/converter/ComboJiraConverterSpecTest.java +++ b/flexmark-jira-converter/src/test/java/com/vladsch/flexmark/jira/converter/ComboJiraConverterSpecTest.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -20,7 +19,7 @@ public class ComboJiraConverterSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/jira_converter_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList( JiraConverterExtension.create() @@ -45,7 +44,7 @@ public class ComboJiraConverterSpecTest extends RendererSpecTest { optionsMap.put("keep-whitespace", new MutableDataSet().set(TablesExtension.TRIM_CELL_WHITESPACE, false)); } - public ComboJiraConverterSpecTest(@NotNull SpecExample example) { + public ComboJiraConverterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-pdf-converter/src/main/java/com/vladsch/flexmark/pdf/converter/package-info.java b/flexmark-pdf-converter/src/main/java/com/vladsch/flexmark/pdf/converter/package-info.java index bef4c3fcb..2a137f9a7 100644 --- a/flexmark-pdf-converter/src/main/java/com/vladsch/flexmark/pdf/converter/package-info.java +++ b/flexmark-pdf-converter/src/main/java/com/vladsch/flexmark/pdf/converter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.pdf.converter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-pdf-converter/src/test/java/com/vladsch/flexmark/pdf/converter/ComboPdfConverterSpecTest.java b/flexmark-pdf-converter/src/test/java/com/vladsch/flexmark/pdf/converter/ComboPdfConverterSpecTest.java index bec50e20c..04e04e6ea 100644 --- a/flexmark-pdf-converter/src/test/java/com/vladsch/flexmark/pdf/converter/ComboPdfConverterSpecTest.java +++ b/flexmark-pdf-converter/src/test/java/com/vladsch/flexmark/pdf/converter/ComboPdfConverterSpecTest.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.runners.Parameterized; import java.util.HashMap; @@ -20,14 +19,14 @@ public class ComboPdfConverterSpecTest extends ComboSpecTestCase { final private static String SPEC_RESOURCE = "/pdf_converter_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static Map optionsMap = new HashMap<>(); static { optionsMap.put("ltr-text", new MutableDataSet().set(PdfConverterExtension.DEFAULT_TEXT_DIRECTION, PdfRendererBuilder.TextDirection.LTR)); optionsMap.put("rtl-text", new MutableDataSet().set(PdfConverterExtension.DEFAULT_TEXT_DIRECTION, PdfRendererBuilder.TextDirection.RTL)); } - public ComboPdfConverterSpecTest(@NotNull SpecExample example) { + public ComboPdfConverterSpecTest(SpecExample example) { super(example, optionsMap); } @@ -37,11 +36,11 @@ public static List data() { } @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combinedOptions = aggregate(null, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combinedOptions, Parser.builder(combinedOptions).build(), HtmlRenderer.builder(combinedOptions).build(), true) { @Override - protected @NotNull String renderHtml() { + protected String renderHtml() { String html = super.renderHtml(); return PdfConverterExtension.embedCss(html, PdfConverterExtension.DEFAULT_CSS.get(myDefaultOptions)); } diff --git a/flexmark-profile-pegdown/src/main/java/com/vladsch/flexmark/profile/pegdown/package-info.java b/flexmark-profile-pegdown/src/main/java/com/vladsch/flexmark/profile/pegdown/package-info.java index a2ccacb43..007e67a8c 100644 --- a/flexmark-profile-pegdown/src/main/java/com/vladsch/flexmark/profile/pegdown/package-info.java +++ b/flexmark-profile-pegdown/src/main/java/com/vladsch/flexmark/profile/pegdown/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.profile.pegdown; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboIssueMn236ExceptionSpecTest.java b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboIssueMn236ExceptionSpecTest.java index 41c817c7b..7be50a8c3 100644 --- a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboIssueMn236ExceptionSpecTest.java +++ b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboIssueMn236ExceptionSpecTest.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.HashMap; @@ -16,7 +15,7 @@ public class ComboIssueMn236ExceptionSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/issue_mn_236_exception_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions((ALL & ~HARDWRAPS) | (ALL_OPTIONALS & ~(EXTANCHORLINKS | EXTANCHORLINKS_WRAP))).toMutable() .set(HtmlRenderer.FENCED_CODE_LANGUAGE_CLASS_PREFIX, "") .set(HtmlRenderer.OBFUSCATE_EMAIL_RANDOM, false) @@ -27,7 +26,7 @@ public class ComboIssueMn236ExceptionSpecTest extends RendererSpecTest { optionsMap.put("hard-breaks", PegdownOptionsAdapter.flexmarkOptions((ALL & ~HARDWRAPS) | (ALL_OPTIONALS & ~(EXTANCHORLINKS | EXTANCHORLINKS_WRAP)) | HARDWRAPS)/*.toMutable().remove(Parser.EXTENSIONS)*/); optionsMap.put("anchor-links", PegdownOptionsAdapter.flexmarkOptions((ALL & ~HARDWRAPS) | (ALL_OPTIONALS & ~(EXTANCHORLINKS | EXTANCHORLINKS_WRAP)) | ANCHORLINKS)/*.toMutable().remove(Parser.EXTENSIONS)*/); } - public ComboIssueMn236ExceptionSpecTest(@NotNull SpecExample example) { + public ComboIssueMn236ExceptionSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownCompatibilitySpecTest.java b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownCompatibilitySpecTest.java index 5b670cd87..9e8f2aef3 100644 --- a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownCompatibilitySpecTest.java +++ b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownCompatibilitySpecTest.java @@ -5,21 +5,20 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.List; public class ComboPegdownCompatibilitySpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/pegdown_profile_compatibility_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions( Extensions.FENCED_CODE_BLOCKS | Extensions.AUTOLINKS ).toMutable() .set(HtmlRenderer.OBFUSCATE_EMAIL_RANDOM, false) .toImmutable(); - public ComboPegdownCompatibilitySpecTest(@NotNull SpecExample example) { + public ComboPegdownCompatibilitySpecTest(SpecExample example) { super(example, null, OPTIONS); } diff --git a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownDoxiaCompatibilitySpecTest.java b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownDoxiaCompatibilitySpecTest.java index f7b17d243..b5e890f77 100644 --- a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownDoxiaCompatibilitySpecTest.java +++ b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownDoxiaCompatibilitySpecTest.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -22,7 +21,7 @@ public class ComboPegdownDoxiaCompatibilitySpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/pegdown_doxia_compatibility_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions(ALL & ~(HARDWRAPS | ANCHORLINKS)).toMutable() .set(HtmlRenderer.FENCED_CODE_LANGUAGE_CLASS_PREFIX, "") .set(HtmlRenderer.OBFUSCATE_EMAIL_RANDOM, false) @@ -40,7 +39,7 @@ public class ComboPegdownDoxiaCompatibilitySpecTest extends RendererSpecTest { optionsMap.put("code-soft-breaks", new MutableDataSet().set(Parser.CODE_SOFT_LINE_BREAKS, true).set(HtmlRenderer.SOFT_BREAK, "\n")); optionsMap.put("code-soft-break-spaces", new MutableDataSet().set(Parser.CODE_SOFT_LINE_BREAKS, true).set(HtmlRenderer.SOFT_BREAK, " \t")); } - public ComboPegdownDoxiaCompatibilitySpecTest(@NotNull SpecExample example) { + public ComboPegdownDoxiaCompatibilitySpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownExtensionCompatibilitySpecTest.java b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownExtensionCompatibilitySpecTest.java index 7d7044515..a3898bd2b 100644 --- a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownExtensionCompatibilitySpecTest.java +++ b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownExtensionCompatibilitySpecTest.java @@ -11,7 +11,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Collections; @@ -21,7 +20,7 @@ public class ComboPegdownExtensionCompatibilitySpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/pegdown_extension_compatibility_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions((PegdownExtensions.ALL & ~(PegdownExtensions.HARDWRAPS | PegdownExtensions.ANCHORLINKS)) | (PegdownExtensions.ALL_OPTIONALS & ~(PegdownExtensions.EXTANCHORLINKS_WRAP)) | PegdownExtensions.ABBREVIATIONS | PegdownExtensions.EXTANCHORLINKS).toMutable() .set(HtmlRenderer.FENCED_CODE_LANGUAGE_CLASS_PREFIX, "") .set(HtmlRenderer.OBFUSCATE_EMAIL_RANDOM, false) @@ -39,7 +38,7 @@ public class ComboPegdownExtensionCompatibilitySpecTest extends RendererSpecTest optionsMap.put("code-soft-break-spaces", new MutableDataSet().set(Parser.CODE_SOFT_LINE_BREAKS, true).set(HtmlRenderer.SOFT_BREAK, " \t")); optionsMap.put("no-wiki-ref-anchors", new MutableDataSet().set(WikiLinkExtension.ALLOW_ANCHORS, false)); } - public ComboPegdownExtensionCompatibilitySpecTest(@NotNull SpecExample example) { + public ComboPegdownExtensionCompatibilitySpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownSpecTest.java b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownSpecTest.java index 85ae55a20..76328f186 100644 --- a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownSpecTest.java +++ b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboPegdownSpecTest.java @@ -7,19 +7,18 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.runners.Parameterized; import java.util.List; public class ComboPegdownSpecTest extends ComboSpecTestCase { final private static String SPEC_RESOURCE = "/pegdown_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(PegdownParser.PEGDOWN_EXTENSIONS, Extensions.FENCED_CODE_BLOCKS); - public ComboPegdownSpecTest(@NotNull SpecExample example) { + public ComboPegdownSpecTest(SpecExample example) { super(example, null, OPTIONS); } @@ -29,7 +28,7 @@ public static List data() { } @Override - public @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions) { + public SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions) { DataHolder combineOptions = aggregate(OPTIONS, exampleOptions); return new FlexmarkSpecExampleRenderer(example, combineOptions, new PegdownParser(combineOptions), new PegdownRenderer(combineOptions), true); } diff --git a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboStackOverflowSpecTest.java b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboStackOverflowSpecTest.java index 78f5ed209..406e776e3 100644 --- a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboStackOverflowSpecTest.java +++ b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/ComboStackOverflowSpecTest.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.HashMap; @@ -15,7 +14,7 @@ public class ComboStackOverflowSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/stack_overflow_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions((PegdownExtensions.ALL & ~PegdownExtensions.HARDWRAPS) | (PegdownExtensions.ALL_OPTIONALS & ~(PegdownExtensions.EXTANCHORLINKS | PegdownExtensions.EXTANCHORLINKS_WRAP))).toMutable() .set(HtmlRenderer.FENCED_CODE_LANGUAGE_CLASS_PREFIX, "") .set(HtmlRenderer.OBFUSCATE_EMAIL_RANDOM, false) @@ -26,7 +25,7 @@ public class ComboStackOverflowSpecTest extends RendererSpecTest { optionsMap.put("hard-breaks", PegdownOptionsAdapter.flexmarkOptions((PegdownExtensions.ALL & ~PegdownExtensions.HARDWRAPS) | (PegdownExtensions.ALL_OPTIONALS & ~(PegdownExtensions.EXTANCHORLINKS | PegdownExtensions.EXTANCHORLINKS_WRAP)) | PegdownExtensions.HARDWRAPS)/*.toMutable().remove(Parser.EXTENSIONS)*/); optionsMap.put("anchor-links", PegdownOptionsAdapter.flexmarkOptions((PegdownExtensions.ALL & ~PegdownExtensions.HARDWRAPS) | (PegdownExtensions.ALL_OPTIONALS & ~(PegdownExtensions.EXTANCHORLINKS | PegdownExtensions.EXTANCHORLINKS_WRAP)) | PegdownExtensions.ANCHORLINKS)/*.toMutable().remove(Parser.EXTENSIONS)*/); } - public ComboStackOverflowSpecTest(@NotNull SpecExample example) { + public ComboStackOverflowSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/PegdownParser.java b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/PegdownParser.java index 815126ef9..6d1317a7e 100644 --- a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/PegdownParser.java +++ b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/PegdownParser.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import org.pegdown.PegDownProcessor; import org.pegdown.ast.RootNode; @@ -55,7 +54,6 @@ public PegdownRootNode(RootNode rootNode) { myRootNode = rootNode; } - @NotNull @Override public BasedSequence[] getSegments() { return Node.EMPTY_SEGMENTS; @@ -63,7 +61,7 @@ public BasedSequence[] getSegments() { } @Override - public @NotNull Node parse(@NotNull BasedSequence input) { + public Node parse(BasedSequence input) { // here we make the lexer parse the input sequence from start to finish and accumulate everything in custom nodes int pegdownExtensions = getPegdownExtensions(getOptions()); RootNode rootNode = new PegDownProcessor(pegdownExtensions).parseMarkdown(input.toString().toCharArray()); diff --git a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/PegdownRenderer.java b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/PegdownRenderer.java index 13827628f..52b530cdd 100644 --- a/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/PegdownRenderer.java +++ b/flexmark-profile-pegdown/src/test/java/com/vladsch/flexmark/profile/pegdown/PegdownRenderer.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.test.util.spec.IRenderBase; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import org.pegdown.LinkRenderer; import org.pegdown.ToHtmlSerializer; import org.pegdown.ast.RootNode; @@ -25,7 +24,7 @@ public PegdownRenderer(DataHolder options) { } @Override - public void render(@NotNull Node document, @NotNull Appendable output) { + public void render(Node document, Appendable output) { assert document instanceof PegdownParser.PegdownRootNode; RootNode rootNode = ((PegdownParser.PegdownRootNode) document).myRootNode; diff --git a/flexmark-test-specs/pom.xml b/flexmark-test-specs/pom.xml index 385c9329d..a2dceacfb 100644 --- a/flexmark-test-specs/pom.xml +++ b/flexmark-test-specs/pom.xml @@ -17,9 +17,9 @@ flexmark-test-util - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-test-specs/src/main/java/com/vladsch/flexmark/test/specs/TestSpecLocator.java b/flexmark-test-specs/src/main/java/com/vladsch/flexmark/test/specs/TestSpecLocator.java index 3200242b0..1cef8afd4 100644 --- a/flexmark-test-specs/src/main/java/com/vladsch/flexmark/test/specs/TestSpecLocator.java +++ b/flexmark-test-specs/src/main/java/com/vladsch/flexmark/test/specs/TestSpecLocator.java @@ -1,9 +1,8 @@ package com.vladsch.flexmark.test.specs; import com.vladsch.flexmark.test.util.spec.ResourceLocation; -import org.jetbrains.annotations.NotNull; public class TestSpecLocator { final public static String DEFAULT_SPEC_RESOURCE = "/spec.txt"; - final public static @NotNull ResourceLocation DEFAULT_RESOURCE_LOCATION = ResourceLocation.of(TestSpecLocator.class, DEFAULT_SPEC_RESOURCE); + final public static ResourceLocation DEFAULT_RESOURCE_LOCATION = ResourceLocation.of(TestSpecLocator.class, DEFAULT_SPEC_RESOURCE); } diff --git a/flexmark-test-specs/src/main/java/com/vladsch/flexmark/test/specs/package-info.java b/flexmark-test-specs/src/main/java/com/vladsch/flexmark/test/specs/package-info.java index 0b9ff4d59..917fc85a5 100644 --- a/flexmark-test-specs/src/main/java/com/vladsch/flexmark/test/specs/package-info.java +++ b/flexmark-test-specs/src/main/java/com/vladsch/flexmark/test/specs/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.test.specs; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-test-util/pom.xml b/flexmark-test-util/pom.xml index 4b6c75f1a..304af07f7 100644 --- a/flexmark-test-util/pom.xml +++ b/flexmark-test-util/pom.xml @@ -37,9 +37,9 @@ junit - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/AstCollectingVisitor.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/AstCollectingVisitor.java index 4a1c25522..5d7992e01 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/AstCollectingVisitor.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/AstCollectingVisitor.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NodeVisitorBase; -import org.jetbrains.annotations.NotNull; public class AstCollectingVisitor extends NodeVisitorBase { final public static String EOL = "\n"; @@ -46,7 +45,7 @@ public void collect(Node node) { } @Override - protected void visit(@NotNull Node node) { + protected void visit(Node node) { appendIndent(); node.astString(output, true); output.append(EOL); diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ComboSpecTestCase.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ComboSpecTestCase.java index ff6d762b0..36452e935 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ComboSpecTestCase.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ComboSpecTestCase.java @@ -9,8 +9,7 @@ import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.format.options.ElementPlacement; import com.vladsch.flexmark.util.format.options.ElementPlacementSort; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -24,21 +23,21 @@ public abstract class ComboSpecTestCase extends FullSpecTestCase { final public static DataKey> CUSTOM_OPTION = TestUtils.CUSTOM_OPTION; - protected final @NotNull SpecExample example; - protected final @NotNull Map optionsMap = new HashMap<>(); + protected final SpecExample example; + protected final Map optionsMap = new HashMap<>(); protected final @Nullable DataHolder myDefaultOptions; - public ComboSpecTestCase(@NotNull SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { + public ComboSpecTestCase(SpecExample example, @Nullable Map optionMap, @Nullable DataHolder... defaultOptions) { this.example = example; myDefaultOptions = TestUtils.combineDefaultOptions(defaultOptions); if (optionMap != null) optionsMap.putAll(optionMap); } - public static @NotNull Map placementAndSortOptions(DataKey placementDataKey, DataKey sortDataKey) { + public static Map placementAndSortOptions(DataKey placementDataKey, DataKey sortDataKey) { return placementAndSortOptions(null, placementDataKey, sortDataKey); } - public static @NotNull Map placementAndSortOptions(@Nullable DataKey keepTypeDataKey, @Nullable DataKey placementDataKey, @Nullable DataKey sortDataKey) { + public static Map placementAndSortOptions(@Nullable DataKey keepTypeDataKey, @Nullable DataKey placementDataKey, @Nullable DataKey sortDataKey) { Map optionsMap = new HashMap<>(); if (keepTypeDataKey != null) { optionsMap.put("references-keep-last", new MutableDataSet().set(keepTypeDataKey, KeepType.LAST)); @@ -74,23 +73,22 @@ protected boolean compoundSections() { } @Nullable - public static DataHolder[] dataHolders(@Nullable DataHolder other, @Nullable DataHolder[] overrides) { + public static DataHolder[] dataHolders(@Nullable DataHolder other, DataHolder @Nullable [] overrides) { return TestUtils.dataHolders(other, overrides); } - @NotNull public static DataHolder aggregate(@Nullable DataHolder other, @Nullable DataHolder overrides) { return DataSet.aggregate(other, overrides); } @Nullable @Override - public DataHolder options(@NotNull String option) { + public DataHolder options(String option) { return TestUtils.processOption(optionsMap, option); } @Override - final protected @NotNull ResourceLocation getSpecResourceLocation() { + final protected ResourceLocation getSpecResourceLocation() { return example.getResourceLocation(); } @@ -103,7 +101,7 @@ public void testSpecExample() { } } - protected static @NotNull List getTestData(@NotNull ResourceLocation location) { + protected static List getTestData(ResourceLocation location) { return TestUtils.getTestData(location); } } diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/DumpSpecReader.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/DumpSpecReader.java index fbd11a00e..25c8a9464 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/DumpSpecReader.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/DumpSpecReader.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.test.util.spec.SpecReader; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import org.junit.AssumptionViolatedException; import java.io.InputStream; @@ -15,7 +14,7 @@ public class DumpSpecReader extends SpecReader { protected final SpecExampleProcessor testCase; protected StringBuilder exampleComment; - public DumpSpecReader(@NotNull InputStream stream, @NotNull SpecExampleProcessor testCase, @NotNull ResourceLocation location, boolean compoundSections) { + public DumpSpecReader(InputStream stream, SpecExampleProcessor testCase, ResourceLocation location, boolean compoundSections) { super(stream, location, compoundSections); this.testCase = testCase; } @@ -39,7 +38,7 @@ public void addSpecLine(String line, boolean isSpecExampleOpen) { } @Override - protected void addSpecExample(@NotNull SpecExample specExample) { + protected void addSpecExample(SpecExample specExample) { // not needed but to keep it consistent with SpecReader super.addSpecExample(specExample); diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ExampleOption.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ExampleOption.java index 3e7a64dab..a9f0735a5 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ExampleOption.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ExampleOption.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.test.util; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; import java.util.HashSet; @@ -21,7 +20,7 @@ public class ExampleOption { BUILT_IN_OPTIONS_SET.add(TIMED_ITERATIONS_OPTION_NAME); BUILT_IN_OPTIONS_SET.add(TIMED_OPTION_NAME); } - private static ExampleOption build(@NotNull CharSequence option) { + private static ExampleOption build(CharSequence option) { BasedSequence optionName; BasedSequence customParams; boolean isDisabled = false; @@ -53,7 +52,7 @@ private static ExampleOption build(@NotNull CharSequence option) { ); } - public static ExampleOption of(@NotNull CharSequence optionText) { + public static ExampleOption of(CharSequence optionText) { return build(optionText); } @@ -68,20 +67,19 @@ public static ExampleOption of(@NotNull CharSequence optionText) { // BUILT_IN_OPTIONS_MAP.put(TIMED_ITERATIONS_OPTION_NAME, build(TIMED_ITERATIONS_OPTION_NAME)); BUILT_IN_OPTIONS_MAP.put(TIMED_OPTION_NAME, build(TIMED_OPTION_NAME)); } - @NotNull public static HashMap getBuiltInOptions() { return new HashMap<>(BUILT_IN_OPTIONS_MAP); } - final public @NotNull BasedSequence optionText; - final public @NotNull BasedSequence optionName; - final public @NotNull BasedSequence customParams; + final public BasedSequence optionText; + final public BasedSequence optionName; + final public BasedSequence customParams; final public boolean isBuiltIn; final public boolean isDisabled; final public boolean isCustom; final public boolean isValid; - private ExampleOption(@NotNull BasedSequence optionText, @NotNull BasedSequence optionName, @NotNull BasedSequence customParams, boolean isBuiltIn, boolean isDisabled, boolean isCustom, boolean isValid) { + private ExampleOption(BasedSequence optionText, BasedSequence optionName, BasedSequence customParams, boolean isBuiltIn, boolean isDisabled, boolean isCustom, boolean isValid) { this.optionText = optionText; this.optionName = optionName; this.customParams = customParams; @@ -91,12 +89,10 @@ private ExampleOption(@NotNull BasedSequence optionText, @NotNull BasedSequence this.isValid = isValid; } - @NotNull public String getOptionText() { return optionText.toString(); } - @NotNull public String getOptionName() { return optionName.toString(); } diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ExceptionMatcher.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ExceptionMatcher.java index 0b0d25f4b..f2771f72a 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ExceptionMatcher.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/ExceptionMatcher.java @@ -2,16 +2,15 @@ import org.hamcrest.BaseMatcher; import org.hamcrest.Description; -import org.jetbrains.annotations.NotNull; import java.util.regex.Pattern; public class ExceptionMatcher extends BaseMatcher { - final private @NotNull String prefix; - final private @NotNull Pattern pattern; - final private @NotNull String message; + final private String prefix; + final private Pattern pattern; + final private String message; - public ExceptionMatcher(@NotNull Class throwable, @NotNull Pattern pattern, @NotNull String message) { + public ExceptionMatcher(Class throwable, Pattern pattern, String message) { this.prefix = throwable.getName(); this.pattern = pattern; this.message = message; @@ -43,18 +42,15 @@ public void describeTo(Description description) { description.appendText(prefix + ": " + message); } - @NotNull - public static ExceptionMatcher match(@NotNull Class throwable, @NotNull String text) { + public static ExceptionMatcher match(Class throwable, String text) { return new ExceptionMatcher(throwable, Pattern.compile(Pattern.quote(text)), text); } - @NotNull - public static ExceptionMatcher matchPrefix(@NotNull Class throwable, @NotNull String text) { + public static ExceptionMatcher matchPrefix(Class throwable, String text) { return new ExceptionMatcher(throwable, Pattern.compile(Pattern.quote(text) + "(?s:.*)"), text); } - @NotNull - public static ExceptionMatcher matchRegEx(@NotNull Class throwable, @NotNull String regEx) { + public static ExceptionMatcher matchRegEx(Class throwable, String regEx) { return new ExceptionMatcher(throwable, Pattern.compile(regEx), regEx); } } diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FlexmarkSpecExampleRenderer.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FlexmarkSpecExampleRenderer.java index 0bd8e3c37..c30df4ae1 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FlexmarkSpecExampleRenderer.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FlexmarkSpecExampleRenderer.java @@ -7,27 +7,26 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public class FlexmarkSpecExampleRenderer extends SpecExampleRendererBase { private @Nullable Node myIncludedDocument = null; private @Nullable Node myDocument = null; - private @NotNull IParse myParser; - private @NotNull IRender myRender; + private IParse myParser; + private IRender myRender; - public FlexmarkSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder options, @NotNull IParse parser, @NotNull IRender render) { + public FlexmarkSpecExampleRenderer(SpecExample example, @Nullable DataHolder options, IParse parser, IRender render) { this(example, options, parser, render, true); } - public FlexmarkSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder options, @NotNull IParse parser, @NotNull IRender render, boolean includeExampleCoord) { + public FlexmarkSpecExampleRenderer(SpecExample example, @Nullable DataHolder options, IParse parser, IRender render, boolean includeExampleCoord) { super(example, options, includeExampleCoord); myParser = parser; myRender = render; } @Override - public void includeDocument(@NotNull String includedText) { + public void includeDocument(String includedText) { // flexmark parser specific myIncludedDocument = null; @@ -38,7 +37,6 @@ public void includeDocument(@NotNull String includedText) { } } - @NotNull protected Node getIncludedDocument() { assert myIncludedDocument != null; return myIncludedDocument; @@ -64,7 +62,7 @@ protected void adjustParserForInclusion() { } } - public @NotNull Node getDocument() { + public Node getDocument() { assert myDocument != null; return myDocument; } @@ -74,7 +72,6 @@ protected void adjustParserForInclusion() { * * @return HTML string, will be cached after document is finalized to allow for timing collection iterations, */ - @NotNull @Override protected String renderHtml() { assert myDocument != null; @@ -86,7 +83,6 @@ protected String renderHtml() { * * @return HTML string, will be cached after document is finalized to allow for timing collection iterations, */ - @NotNull @Override protected String renderAst() { assert myDocument != null; @@ -98,20 +94,18 @@ public void finalizeRender() { super.finalizeRender(); } - @NotNull final public IParse getParser() { return myParser; } - public void setParser(@NotNull IParse parser) { + public void setParser(IParse parser) { myParser = parser; } - public void setRender(@NotNull IRender render) { + public void setRender(IRender render) { myRender = render; } - @NotNull final public IRender getRenderer() { return myRender; } diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java index 67f0b36ca..323987745 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/FullSpecTestCase.java @@ -2,14 +2,12 @@ import com.vladsch.flexmark.test.util.spec.ResourceLocation; import com.vladsch.flexmark.test.util.spec.SpecReader; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import static org.junit.Assert.assertEquals; public abstract class FullSpecTestCase extends RenderingTestCase implements SpecExampleProcessor { - @NotNull - public DumpSpecReader create(@NotNull ResourceLocation location) { + public DumpSpecReader create(ResourceLocation location) { return SpecReader.create(location, (stream, fileUrl) -> new DumpSpecReader(stream, this, fileUrl, compoundSections())); } @@ -17,7 +15,7 @@ protected boolean compoundSections() { return false; } - abstract protected @NotNull ResourceLocation getSpecResourceLocation(); + abstract protected ResourceLocation getSpecResourceLocation(); protected void fullTestSpecStarting() { diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/LoadUnloadDataKeyAggregator.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/LoadUnloadDataKeyAggregator.java index 69fc615f9..6be94eb41 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/LoadUnloadDataKeyAggregator.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/LoadUnloadDataKeyAggregator.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.*; import com.vladsch.flexmark.util.misc.Extension; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -19,7 +18,7 @@ private LoadUnloadDataKeyAggregator() { } @Override - public @NotNull DataHolder aggregate(@NotNull DataHolder combined) { + public DataHolder aggregate(DataHolder combined) { if (combined.contains(LOAD_EXTENSIONS) || combined.contains(UNLOAD_EXTENSIONS)) { // have something to work with, or at least clean if (combined.contains(SharedDataKeys.EXTENSIONS) || combined.contains(LOAD_EXTENSIONS)) { @@ -44,7 +43,7 @@ private LoadUnloadDataKeyAggregator() { } @Override - public @NotNull DataHolder aggregateActions(@NotNull DataHolder combined, @NotNull DataHolder other, @NotNull DataHolder overrides) { + public DataHolder aggregateActions(DataHolder combined, DataHolder other, DataHolder overrides) { if (other.contains(LOAD_EXTENSIONS) && overrides.contains(LOAD_EXTENSIONS)) { // have to combine these ArrayList loadExtensions = new ArrayList<>(LOAD_EXTENSIONS.get(other)); @@ -62,7 +61,7 @@ private LoadUnloadDataKeyAggregator() { } @Override - public @NotNull DataHolder clean(DataHolder combined) { + public DataHolder clean(DataHolder combined) { if (combined.contains(LOAD_EXTENSIONS) || combined.contains(UNLOAD_EXTENSIONS)) { return combined.toMutable().remove(LOAD_EXTENSIONS).remove(UNLOAD_EXTENSIONS); } diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/RenderingTestCase.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/RenderingTestCase.java index f4d653471..38f2760bb 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/RenderingTestCase.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/RenderingTestCase.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.SharedDataKeys; import com.vladsch.flexmark.util.misc.Extension; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.ComparisonFailure; import org.junit.Rule; import org.junit.rules.ExpectedException; @@ -56,22 +55,22 @@ public void addSpecExample(SpecExampleRenderer exampleRenderer, SpecExampleParse * @param html html used for comparison to expected html * @param ast ast used for comparison to expected ast */ - public void addFullSpecExample(@NotNull SpecExampleRenderer exampleRenderer, @NotNull SpecExampleParse exampleParse, DataHolder exampleOptions, boolean ignoredTestCase, @NotNull String html, @Nullable String ast) { + public void addFullSpecExample(SpecExampleRenderer exampleRenderer, SpecExampleParse exampleParse, DataHolder exampleOptions, boolean ignoredTestCase, String html, @Nullable String ast) { } /* * Convenience functions for those tests that do not have an example */ - final protected void assertRendering(@NotNull String source, @NotNull String html) { + final protected void assertRendering(String source, String html) { assertRendering(SpecExample.ofCaller(1, this.getClass(), source, html, null)); } - final protected void assertRendering(@NotNull String source, @NotNull String html, @Nullable String ast) { + final protected void assertRendering(String source, String html, @Nullable String ast) { assertRendering(SpecExample.ofCaller(1, this.getClass(), source, html, ast)); } - final protected void assertRendering(@NotNull SpecExample specExample) { + final protected void assertRendering(SpecExample specExample) { SpecExample example = checkExample(specExample); String message = example.getFileUrlWithLineNumber(); String source = example.getSource(); diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SettableExtractedInstance.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SettableExtractedInstance.java index a32bb0535..39e34bc2a 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SettableExtractedInstance.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SettableExtractedInstance.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.Consumer; import java.util.function.Function; @@ -19,22 +18,21 @@ * @param type for the setting */ final public class SettableExtractedInstance { - final private @NotNull DataKey> myConsumerKey; - final private @NotNull Function myDataExtractor; + final private DataKey> myConsumerKey; + final private Function myDataExtractor; - public SettableExtractedInstance(@NotNull DataKey> consumerKey, @NotNull Function dataExtractor) { + public SettableExtractedInstance(DataKey> consumerKey, Function dataExtractor) { myConsumerKey = consumerKey; myDataExtractor = dataExtractor; } - public void aggregate(@NotNull T instance, @NotNull DataHolder dataHolder) { + public void aggregate(T instance, DataHolder dataHolder) { if (dataHolder.contains(myConsumerKey)) { myConsumerKey.get(dataHolder).accept(myDataExtractor.apply(instance)); } } - @NotNull - public DataHolder aggregateActions(@NotNull DataHolder dataHolder, @Nullable DataHolder other, @Nullable DataHolder overrides) { + public DataHolder aggregateActions(DataHolder dataHolder, @Nullable DataHolder other, @Nullable DataHolder overrides) { if (other != null && other.contains(myConsumerKey) && overrides != null && overrides.contains(myConsumerKey)) { // both, need to combine Consumer otherSetter = myConsumerKey.get(other); diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SettableInstance.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SettableInstance.java index 71321ac92..b871ce510 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SettableInstance.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SettableInstance.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.function.Consumer; @@ -19,21 +18,20 @@ * @param type for the setting */ final public class SettableInstance { - final private @NotNull DataKey> myConsumerKey; + final private DataKey> myConsumerKey; final private @Nullable Collection> myExtractedInstanceSetters; - public SettableInstance(@NotNull DataKey> consumerKey, @NotNull Collection> extractedInstanceSetters) { + public SettableInstance(DataKey> consumerKey, Collection> extractedInstanceSetters) { myConsumerKey = consumerKey; myExtractedInstanceSetters = extractedInstanceSetters.size() == 0 ? null : extractedInstanceSetters; } - public SettableInstance(@NotNull DataKey> consumerKey) { + public SettableInstance(DataKey> consumerKey) { myConsumerKey = consumerKey; myExtractedInstanceSetters = null; } - @NotNull - public T setInstanceData(@NotNull T instance, @Nullable DataHolder dataHolder) { + public T setInstanceData(T instance, @Nullable DataHolder dataHolder) { if (dataHolder != null) { if (dataHolder.contains(myConsumerKey)) { myConsumerKey.get(dataHolder).accept(instance); @@ -48,7 +46,7 @@ public T setInstanceData(@NotNull T instance, @Nullable DataHolder dataHolder) { return instance; } - public DataHolder aggregateActions(@NotNull DataHolder dataHolder, @Nullable DataHolder other, @Nullable DataHolder overrides) { + public DataHolder aggregateActions(DataHolder dataHolder, @Nullable DataHolder other, @Nullable DataHolder overrides) { DataHolder results = dataHolder; if (other != null && other.contains(myConsumerKey) && overrides != null && overrides.contains(myConsumerKey)) { diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleProcessor.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleProcessor.java index 4de11449f..c7f041b75 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleProcessor.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleProcessor.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface SpecExampleProcessor { /** @@ -12,7 +11,7 @@ public interface SpecExampleProcessor { * @param option name of the options set to use * @return options or null to use default */ - @Nullable DataHolder options(@NotNull String option); + @Nullable DataHolder options(String option); /** * Allows tests to modify example during reading (DumpSpecReader) @@ -20,7 +19,7 @@ public interface SpecExampleProcessor { * @param example example as it is in the test or spec file * @return modified example if needed */ - default @NotNull SpecExample checkExample(@NotNull SpecExample example) { + default SpecExample checkExample(SpecExample example) { return example; } @@ -31,7 +30,7 @@ public interface SpecExampleProcessor { * @param exampleOptions example custom options * @return spec renderer for given example and options */ - @NotNull SpecExampleRenderer getSpecExampleRenderer(@NotNull SpecExample example, @Nullable DataHolder exampleOptions); + SpecExampleRenderer getSpecExampleRenderer(SpecExample example, @Nullable DataHolder exampleOptions); /** * Called by DumpSpecReader for each example when processing full test spec @@ -43,5 +42,5 @@ public interface SpecExampleProcessor { * @param html html used for comparison to expected html * @param ast ast used for comparison to expected ast */ - void addFullSpecExample(@NotNull SpecExampleRenderer exampleRenderer, @NotNull SpecExampleParse exampleParse, @Nullable DataHolder exampleOptions, boolean ignoredTestCase, @NotNull String html, @Nullable String ast); + void addFullSpecExample(SpecExampleRenderer exampleRenderer, SpecExampleParse exampleParse, @Nullable DataHolder exampleOptions, boolean ignoredTestCase, String html, @Nullable String ast); } diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleRenderer.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleRenderer.java index c8e99dc2a..acfe082ac 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleRenderer.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleRenderer.java @@ -2,16 +2,15 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface SpecExampleRenderer { boolean includeExampleInfo(); @Nullable DataHolder getOptions(); - @NotNull SpecExample getExample(); + SpecExample getExample(); - void includeDocument(@NotNull String includedText); + void includeDocument(String includedText); void parse(CharSequence input); // after all parsing is complete gives a chance to handle insertion of included doc @@ -22,7 +21,7 @@ public interface SpecExampleRenderer { void finalizeRender(); // caches values and does not regenerate - @NotNull String getHtml(); + String getHtml(); @Nullable String getAst(); SpecExampleRenderer NULL = new SpecExampleRenderer() { @@ -37,7 +36,7 @@ public boolean includeExampleInfo() { } @Override - public void includeDocument(@NotNull String includedText) { + public void includeDocument(String includedText) { } @@ -47,7 +46,7 @@ public void parse(CharSequence input) { } @Override - public @NotNull SpecExample getExample() { + public SpecExample getExample() { return SpecExample.NULL; } @@ -57,7 +56,7 @@ public void finalizeDocument() { } @Override - public @NotNull String getHtml() { + public String getHtml() { return ""; } diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleRendererBase.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleRendererBase.java index ab12f1721..c287ce1db 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleRendererBase.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/SpecExampleRendererBase.java @@ -3,22 +3,21 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public abstract class SpecExampleRendererBase implements SpecExampleRenderer { - protected final @NotNull SpecExample myExample; - protected final @NotNull DataHolder myOptions; + protected final SpecExample myExample; + protected final DataHolder myOptions; protected final boolean myIncludeExampleInfo; private boolean myIsFinalized; private @Nullable String myRenderedHtml; private @Nullable String myRenderedAst; - public SpecExampleRendererBase(@NotNull SpecExample example, @Nullable DataHolder options) { + public SpecExampleRendererBase(SpecExample example, @Nullable DataHolder options) { this(example, options, true); } - public SpecExampleRendererBase(@NotNull SpecExample example, @Nullable DataHolder options, boolean includeExampleInfo) { + public SpecExampleRendererBase(SpecExample example, @Nullable DataHolder options, boolean includeExampleInfo) { myExample = example; myOptions = options == null ? new DataSet() : options.toImmutable(); myIncludeExampleInfo = includeExampleInfo; @@ -30,7 +29,7 @@ public boolean isFinalized() { } @Override - final public @NotNull String getHtml() { + final public String getHtml() { if (myRenderedHtml == null || !isFinalized()) { myRenderedHtml = renderHtml(); } @@ -38,17 +37,15 @@ public boolean isFinalized() { } @Override - final public @NotNull String getAst() { + final public String getAst() { if (myRenderedAst == null || !isFinalized()) { myRenderedAst = renderAst(); } return myRenderedAst; } - @NotNull protected abstract String renderHtml(); - @NotNull protected abstract String renderAst(); @Override @@ -61,12 +58,10 @@ public boolean includeExampleInfo() { return myIncludeExampleInfo; } - @NotNull public SpecExample getExample() { return myExample; } - @NotNull @Override public DataHolder getOptions() { return myOptions.toImmutable(); diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/TestUtils.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/TestUtils.java index 3cebb13a2..01bddd55c 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/TestUtils.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/TestUtils.java @@ -15,8 +15,7 @@ import com.vladsch.flexmark.util.sequence.SegmentedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.AssumptionViolatedException; import java.io.File; @@ -38,8 +37,8 @@ public class TestUtils { final public static String MARKUP_CARET = Character.toString(MARKUP_CARET_CHAR); final public static String MARKUP_SELECTION_START = Character.toString(MARKUP_SELECTION_START_CHAR); final public static String MARKUP_SELECTION_END = Character.toString(MARKUP_SELECTION_END_CHAR); - final public static @NotNull CharPredicate CARET_PREDICATE = CharPredicate.anyOf(MARKUP_CARET_CHAR); - final public static @NotNull CharPredicate MARKUP_PREDICATE = CharPredicate.anyOf(MARKUP_CARET_CHAR, MARKUP_SELECTION_START_CHAR, MARKUP_SELECTION_END_CHAR); + final public static CharPredicate CARET_PREDICATE = CharPredicate.anyOf(MARKUP_CARET_CHAR); + final public static CharPredicate MARKUP_PREDICATE = CharPredicate.anyOf(MARKUP_CARET_CHAR, MARKUP_SELECTION_START_CHAR, MARKUP_SELECTION_END_CHAR); final public static int[] EMPTY_OFFSETS = new int[0]; static { // CAUTION: need to register our url resolvers @@ -78,7 +77,7 @@ public class TestUtils { final public static DataKey> CUSTOM_OPTION = new DataKey<>("CUSTOM_OPTION", (option, params) -> EMPTY_OPTIONS); final public static String FILE_PROTOCOL = ResourceUrlResolver.FILE_PROTOCOL; - public static DataHolder processOption(@NotNull Map optionsMap, @NotNull String option) { + public static DataHolder processOption(Map optionsMap, String option) { DataHolder dataHolder = null; if (!option.startsWith(DISABLED_OPTION_PREFIX)) { dataHolder = optionsMap.get(option); @@ -105,8 +104,7 @@ public static DataHolder processOption(@NotNull Map HashMap buildOptionsMap(@NotNull String[] options, @NotNull BiFunction factory) { + public static HashMap buildOptionsMap(String[] options, BiFunction factory) { HashMap hashMap = new HashMap<>(); int i = 0; for (String option : options) { @@ -127,8 +125,7 @@ public static HashMap buildOptionsMap(@NotNull String[] options, * @param type of value in the map * @return constructed hash map of option name */ - @NotNull - public static HashMap buildOptionsMap(boolean ensureAllBuiltInPresent, @NotNull Object[][] options, @NotNull BiFunction factory) { + public static HashMap buildOptionsMap(boolean ensureAllBuiltInPresent, Object[][] options, BiFunction factory) { HashMap hashMap = new HashMap<>(); HashSet builtInSet = new HashSet<>(ExampleOption.getBuiltInOptions().keySet()); @@ -155,8 +152,7 @@ public static HashMap buildOptionsMap(boolean ensureAllBuiltInPre return hashMap; } - @NotNull - public static Pair addSpecSection(@NotNull String headingLine, @NotNull String headingText, String[] sectionHeadings) { + public static Pair addSpecSection(String headingLine, String headingText, String[] sectionHeadings) { assert sectionHeadings.length == 7; int lastSectionLevel = Math.max(1, Math.min(6, RichSequence.of(headingLine).countLeading(CharPredicate.HASH))); sectionHeadings[lastSectionLevel] = headingText; @@ -190,7 +186,7 @@ public static Pair addSpecSection(@NotNull String headingLine, * @param optionsProvider function to take a string option name and provide settings based on it * @return combined set from applying these options together */ - public static DataHolder getOptions(@NotNull SpecExample example, @Nullable String optionSets, @NotNull Function optionsProvider) { + public static DataHolder getOptions(SpecExample example, @Nullable String optionSets, Function optionsProvider) { if (optionSets == null) return null; String[] optionNames = optionSets.replace('\u00A0', ' ').split(","); DataHolder options = null; @@ -254,16 +250,15 @@ public static MutableDataSet addOption(DataHolder options, DataKey key, T } } - public static void throwIllegalStateException(@NotNull SpecExample example, @NotNull String option) { + public static void throwIllegalStateException(SpecExample example, String option) { throw new IllegalStateException("Option " + option + " is not implemented in the RenderingTestCase subclass\n" + example.getFileUrlWithLineNumber(-1)); } - public static void throwIgnoredOption(@NotNull SpecExample example, @NotNull String optionSets, @NotNull String option) { + public static void throwIgnoredOption(SpecExample example, String optionSets, String option) { throw new AssumptionViolatedException("Ignored: example(" + example.getSection() + ": " + example.getExampleNumber() + ") options(" + optionSets + ") is using " + option + " option\n" + example.getFileUrlWithLineNumber(-1)); } - @NotNull - public static String ast(@NotNull Node node) { + public static String ast(Node node) { return new AstCollectingVisitor().collectAndGetAstText(node); } @@ -529,26 +524,22 @@ public static String getFormattedTimingInfo(String section, int exampleNumber, i return String.format(TIMED_FORMAT_STRING, getFormattedSection(section, exampleNumber), (parse - start) / 1000000.0 / iterations, (render - parse) / 1000000.0 / iterations, (render - start) / 1000000.0 / iterations); } - @NotNull public static String getFormattedSection(String section, int exampleNumber) { return section == null ? "" : section.trim() + ": " + exampleNumber; } - @NotNull - public static String getResolvedSpecResourcePath(@NotNull String testClassName, @NotNull String resourcePath) { + public static String getResolvedSpecResourcePath(String testClassName, String resourcePath) { File specInfo = new File(resourcePath); File classInfo = new File("/" + testClassName.replace('.', '/')); return !specInfo.isAbsolute() ? new File(classInfo.getParent(), resourcePath).getAbsolutePath() : resourcePath; } - @NotNull - public static String getAbsoluteSpecResourcePath(@NotNull String testClassPath, @NotNull String resourceRootPath, @NotNull String resourcePath) { + public static String getAbsoluteSpecResourcePath(String testClassPath, String resourceRootPath, String resourcePath) { File resourceFile = resourcePath.startsWith("/") ? new File(resourceRootPath, resourcePath.substring(1)) : new File(new File(testClassPath).getParent(), resourcePath); return resourceFile.getAbsolutePath(); } - @NotNull - public static String getSpecResourceFileUrl(@NotNull Class resourceClass, @NotNull String resourcePath) { + public static String getSpecResourceFileUrl(Class resourceClass, String resourcePath) { if (resourcePath.isEmpty()) { throw new IllegalStateException("Empty resource paths not supported"); } else { @@ -559,7 +550,7 @@ public static String getSpecResourceFileUrl(@NotNull Class resourceClass, @No } } - public static ArrayList getTestData(@NotNull ResourceLocation location) { + public static ArrayList getTestData(ResourceLocation location) { SpecReader specReader = SpecReader.createAndReadExamples(location, true); List examples = specReader.getExamples(); ArrayList data = new ArrayList<>(); @@ -573,16 +564,16 @@ public static ArrayList getTestData(@NotNull ResourceLocation location return data; } - public static @NotNull String getUrlWithLineNumber(@NotNull String fileUrl, int lineNumber) { + public static String getUrlWithLineNumber(String fileUrl, int lineNumber) { return (lineNumber > 0) ? fileUrl + ":" + (lineNumber + 1) : fileUrl; } - public static String adjustedFileUrl(@NotNull URL url) { + public static String adjustedFileUrl(URL url) { return ResourceResolverManager.adjustedFileUrl(url); } @Nullable - public static DataHolder combineDefaultOptions(@Nullable DataHolder[] defaultOptions) { + public static DataHolder combineDefaultOptions(DataHolder @Nullable [] defaultOptions) { DataHolder combinedOptions = null; if (defaultOptions != null) { for (DataHolder options : defaultOptions) { @@ -606,7 +597,7 @@ public static DataHolder combineDefaultOptions(@Nullable DataHolder[] defaultOpt } @Nullable - public static DataHolder[] dataHolders(@Nullable DataHolder other, @Nullable DataHolder[] overrides) { + public static DataHolder[] dataHolders(@Nullable DataHolder other, DataHolder @Nullable [] overrides) { if (other == null) return overrides; else if (overrides == null || overrides.length == 0) return new DataHolder[] { other }; @@ -616,15 +607,13 @@ public static DataHolder[] dataHolders(@Nullable DataHolder other, @Nullable Dat return holders; } - @NotNull - public static String getTestResourceRootDirectoryForModule(@NotNull Class resourceClass, @NotNull String moduleRootPackage) { + public static String getTestResourceRootDirectoryForModule(Class resourceClass, String moduleRootPackage) { String fileUrl; fileUrl = getSpecResourceFileUrl(resourceClass, wrapWith(moduleRootPackage, "/", ".txt")); return removePrefix(removeSuffix(fileUrl, suffixWith(moduleRootPackage, ".txt")), FILE_PROTOCOL); } - @NotNull - public static String getRootDirectoryForModule(@NotNull Class resourceClass, @NotNull String moduleDirectoryName) { + public static String getRootDirectoryForModule(Class resourceClass, String moduleDirectoryName) { // get project root from our class file url path String fileUrl = SpecExample.ofCaller(0, resourceClass, "", "", "").getFileUrl(); int pos = fileUrl.indexOf(wrapWith(moduleDirectoryName, '/')); @@ -636,7 +625,7 @@ public static String getRootDirectoryForModule(@NotNull Class resourceClass, } // handle custom string options - public static DataHolder customStringOption(@NotNull String option, @Nullable String params, @NotNull Function resolver) { + public static DataHolder customStringOption(String option, @Nullable String params, Function resolver) { if (params != null) { // allow escape String text = params @@ -651,7 +640,7 @@ public static DataHolder customStringOption(@NotNull String option, @Nullable St return resolver.apply(null); } - public static DataHolder customIntOption(@NotNull String option, @Nullable String params, @NotNull Function resolver) { + public static DataHolder customIntOption(String option, @Nullable String params, Function resolver) { int value = -1; if (params != null) { if (!params.matches("\\d*")) { @@ -782,18 +771,17 @@ public static Pair extractMarkup(BasedSequence input) { final public static String BANNER_PADDING = "------------------------------------------------------------------------"; final public static int BANNER_LENGTH = BANNER_PADDING.length(); - @NotNull - public static String bannerText(@NotNull String message) { + public static String bannerText(String message) { int leftPadding = 4; //(BANNER_LENGTH - message.length() - 2) >> 4; int rightPadding = BANNER_LENGTH - message.length() - 2 - leftPadding; return BANNER_PADDING.substring(0, leftPadding) + " " + message + " " + BANNER_PADDING.substring(0, rightPadding) + "\n"; } - public static void appendBanner(@NotNull StringBuilder out, @NotNull String banner) { + public static void appendBanner(StringBuilder out, String banner) { appendBanner(out, banner, true); } - public static void appendBanner(@NotNull StringBuilder out, @NotNull String banner, boolean addBlankLine) { + public static void appendBanner(StringBuilder out, String banner, boolean addBlankLine) { if (out.length() > 0 && addBlankLine) { out.append("\n"); } @@ -801,7 +789,7 @@ public static void appendBanner(@NotNull StringBuilder out, @NotNull String bann out.append(banner); } - public static void appendBannerIfNeeded(@NotNull StringBuilder out, @NotNull String banner) { + public static void appendBannerIfNeeded(StringBuilder out, String banner) { if (out.length() > 0) { out.append("\n"); out.append(banner); diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/package-info.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/package-info.java index ae31aaa0a..85739fadf 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/package-info.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.test.util; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/IParseBase.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/IParseBase.java index bff1a3bc6..a087e863e 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/IParseBase.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/IParseBase.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.BufferedReader; import java.io.IOException; @@ -24,17 +23,17 @@ public IParseBase(DataHolder options) { } @Override - public @NotNull Node parse(@NotNull String input) { + public Node parse(String input) { return parse(BasedSequence.of(input)); } @Override - public boolean transferReferences(@NotNull Document document, @NotNull Document included, Boolean onlyIfUndefined) { + public boolean transferReferences(Document document, Document included, Boolean onlyIfUndefined) { return false; } @Override - public @NotNull Node parseReader(@NotNull Reader input) throws IOException { + public Node parseReader(Reader input) throws IOException { BufferedReader bufferedReader; if (input instanceof BufferedReader) { bufferedReader = (BufferedReader) input; diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/IRenderBase.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/IRenderBase.java index 0a4439348..82a43cc28 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/IRenderBase.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/IRenderBase.java @@ -3,22 +3,21 @@ import com.vladsch.flexmark.util.ast.IRender; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.IOException; public abstract class IRenderBase implements IRender { public static final IRender NULL_RENDERER = new IRenderBase() { @Override - public void render(@NotNull Node document, @NotNull Appendable output) { + public void render(Node document, Appendable output) { } }; public static final IRender TEXT_RENDERER = new IRenderBase() { @Override - public void render(@NotNull Node document, @NotNull Appendable output) { + public void render(Node document, Appendable output) { try { output.append(document.getChars()); } catch (IOException e) { @@ -40,9 +39,8 @@ public IRenderBase(DataHolder options) { myOptions = options; } - @NotNull @Override - public String render(@NotNull Node document) { + public String render(Node document) { StringBuilder out = new StringBuilder(); render(document, out); return out.toString(); diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceLocation.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceLocation.java index e3897daaa..ae6c9569c 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceLocation.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceLocation.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.test.util.ComboSpecTestCase; import com.vladsch.flexmark.test.util.TestUtils; -import org.jetbrains.annotations.NotNull; import java.io.*; import java.nio.charset.StandardCharsets; @@ -10,38 +9,34 @@ public class ResourceLocation { final public static ResourceLocation NULL = of(Object.class, "", ""); - final private @NotNull Class resourceClass; - final private @NotNull String resourcePath; - final private @NotNull String fileUrl; - final private @NotNull String resolvedResourcePath; + final private Class resourceClass; + final private String resourcePath; + final private String fileUrl; + final private String resolvedResourcePath; - public ResourceLocation(@NotNull Class resourceClass, @NotNull String resourcePath, @NotNull String fileUrl) { + public ResourceLocation(Class resourceClass, String resourcePath, String fileUrl) { this(resourceClass, resourcePath, fileUrl, TestUtils.getResolvedSpecResourcePath(resourceClass.getName(), resourcePath)); } - private ResourceLocation(@NotNull Class resourceClass, @NotNull String resourcePath, @NotNull String fileUrl, @NotNull String resolvedResourcePath) { + private ResourceLocation(Class resourceClass, String resourcePath, String fileUrl, String resolvedResourcePath) { this.resourceClass = resourceClass; this.resourcePath = resourcePath; this.fileUrl = fileUrl; this.resolvedResourcePath = resolvedResourcePath; } - @NotNull public Class getResourceClass() { return resourceClass; } - @NotNull public String getResourcePath() { return resourcePath; } - @NotNull public String getFileUrl() { return fileUrl; } - @NotNull public String getFileDirectoryUrl() { int pos = fileUrl.lastIndexOf(File.separatorChar); if (pos > 0) { @@ -50,12 +45,10 @@ public String getFileDirectoryUrl() { return fileUrl; } - @NotNull public String getFileUrl(int lineNumber) { return TestUtils.getUrlWithLineNumber(getFileUrl(), lineNumber); } - @NotNull public String getResolvedResourcePath() { return resolvedResourcePath; } @@ -64,12 +57,10 @@ public boolean isNull() { return this == NULL; } - @NotNull public InputStream getResourceInputStream() { return getResourceInputStream(this); } - @NotNull public String getResourceText() { return getResourceText(this); } @@ -88,10 +79,10 @@ public boolean equals(Object o) { } // @formatter:off - @NotNull public ResourceLocation withResourceClass(@NotNull Class resourceClass) { return new ResourceLocation(resourceClass, resourcePath, fileUrl, resolvedResourcePath); }; - @NotNull public ResourceLocation withResourcePath(@NotNull String resourcePath) { return new ResourceLocation(resourceClass, resourcePath, fileUrl, resolvedResourcePath); }; - @NotNull public ResourceLocation withFileUrl(@NotNull String fileUrl) { return new ResourceLocation(resourceClass, resourcePath, fileUrl, resolvedResourcePath); }; - @NotNull public ResourceLocation withResolvedResourcePath(@NotNull String resolvedResourcePath) { return new ResourceLocation(resourceClass, resourcePath, fileUrl, resolvedResourcePath); }; + public ResourceLocation withResourceClass(Class resourceClass) { return new ResourceLocation(resourceClass, resourcePath, fileUrl, resolvedResourcePath); }; + public ResourceLocation withResourcePath(String resourcePath) { return new ResourceLocation(resourceClass, resourcePath, fileUrl, resolvedResourcePath); }; + public ResourceLocation withFileUrl(String fileUrl) { return new ResourceLocation(resourceClass, resourcePath, fileUrl, resolvedResourcePath); }; + public ResourceLocation withResolvedResourcePath(String resolvedResourcePath) { return new ResourceLocation(resourceClass, resourcePath, fileUrl, resolvedResourcePath); }; // @formatter:on @Override @@ -111,26 +102,25 @@ public String toString() { '}'; } - public static @NotNull ResourceLocation of(@NotNull String resourcePath) { + public static ResourceLocation of(String resourcePath) { return new ResourceLocation(ComboSpecTestCase.class, resourcePath, TestUtils.getSpecResourceFileUrl(ComboSpecTestCase.class, resourcePath), TestUtils.getResolvedSpecResourcePath(ComboSpecTestCase.class.getName(), resourcePath) ); } - public static @NotNull ResourceLocation of(@NotNull Class resourceClass, @NotNull String resourcePath) { + public static ResourceLocation of(Class resourceClass, String resourcePath) { return new ResourceLocation(resourceClass, resourcePath, TestUtils.getSpecResourceFileUrl(resourceClass, resourcePath), TestUtils.getResolvedSpecResourcePath(resourceClass.getName(), resourcePath) ); } - public static @NotNull ResourceLocation of(@NotNull Class resourceClass, @NotNull String resourcePath, @NotNull String fileUrl) { + public static ResourceLocation of(Class resourceClass, String resourcePath, String fileUrl) { return new ResourceLocation(resourceClass, resourcePath, fileUrl); } - @NotNull - public static String getResourceText(@NotNull ResourceLocation location) { + public static String getResourceText(ResourceLocation location) { StringBuilder sb = new StringBuilder(); try { String line; @@ -150,8 +140,7 @@ public static String getResourceText(@NotNull ResourceLocation location) { } } - @NotNull - public static InputStream getResourceInputStream(@NotNull ResourceLocation location) { + public static InputStream getResourceInputStream(ResourceLocation location) { String useSpecResource = location.getResolvedResourcePath(); InputStream stream = location.getResourceClass().getResourceAsStream(useSpecResource); if (stream == null) { diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceResolverManager.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceResolverManager.java index 5d3a7dd0c..ae39b9fb3 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceResolverManager.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceResolverManager.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.test.util.spec; import com.vladsch.flexmark.test.util.TestUtils; -import org.jetbrains.annotations.NotNull; import java.io.File; import java.net.URL; @@ -17,12 +16,11 @@ public class ResourceResolverManager { */ final private static ArrayList> urlResolvers = new ArrayList<>(); - public static void registerUrlResolver(@NotNull Function resolver) { + public static void registerUrlResolver(Function resolver) { ResourceResolverManager.urlResolvers.add(resolver); } - @NotNull - public static String adjustedFileUrl(@NotNull URL url) { + public static String adjustedFileUrl(URL url) { String externalForm = url.toExternalForm(); String bestProtocolMatch = null; diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceUrlResolver.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceUrlResolver.java index b9885a044..695c5372a 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceUrlResolver.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/ResourceUrlResolver.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.test.util.spec; -import org.jetbrains.annotations.NotNull; import java.util.function.Function; @@ -13,18 +12,17 @@ public interface ResourceUrlResolver extends Function { String FILE_PROTOCOL = "file://"; - static boolean isFileProtocol(@NotNull String externalForm) { + static boolean isFileProtocol(String externalForm) { return externalForm.startsWith("file:/"); } - static boolean hasProtocol(@NotNull String externalForm) { + static boolean hasProtocol(String externalForm) { int pos = externalForm.indexOf(":"); // allow windows drive letter to not be treated as protocol return pos > 1; } - @NotNull - static String removeProtocol(@NotNull String externalForm) { + static String removeProtocol(String externalForm) { int pos = externalForm.indexOf(':'); if (pos > 0) { return externalForm.substring(pos + 1); diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecExample.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecExample.java index 40008089a..1672d1934 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecExample.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecExample.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.test.util.TestUtils; import com.vladsch.flexmark.util.misc.Utils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.File; import java.net.URL; @@ -14,22 +13,22 @@ public class SpecExample { final public static SpecExample NULL = new SpecExample(ResourceLocation.NULL, 0, null, "", 0, "", "", null, null, true); - final private @NotNull ResourceLocation resourceLocation; + final private ResourceLocation resourceLocation; final private int lineNumber; final private @Nullable String optionsSet; final private @Nullable String section; final private int exampleNumber; - final private @NotNull String source; - final private @NotNull String html; + final private String source; + final private String html; final private @Nullable String ast; final private @Nullable String comment; final private boolean isNull; - public SpecExample(@NotNull ResourceLocation resourceLocation, int lineNumber, @Nullable String optionsSet, @Nullable String section, int exampleNumber, @NotNull String source, @NotNull String html, @Nullable String ast, String comment) { + public SpecExample(ResourceLocation resourceLocation, int lineNumber, @Nullable String optionsSet, @Nullable String section, int exampleNumber, String source, String html, @Nullable String ast, String comment) { this(resourceLocation, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment, false); } - private SpecExample(@NotNull ResourceLocation resourceLocation, int lineNumber, @Nullable String optionsSet, @Nullable String section, int exampleNumber, @NotNull String source, @NotNull String html, @Nullable String ast, String comment, boolean isNull) { + private SpecExample(ResourceLocation resourceLocation, int lineNumber, @Nullable String optionsSet, @Nullable String section, int exampleNumber, String source, String html, @Nullable String ast, String comment, boolean isNull) { this.resourceLocation = resourceLocation; this.lineNumber = lineNumber; this.section = section; @@ -49,12 +48,12 @@ private SpecExample(@NotNull ResourceLocation resourceLocation, int lineNumber, } // @formatter:off - public SpecExample withResourceLocation(@NotNull ResourceLocation location) { return new SpecExample(location, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } + public SpecExample withResourceLocation(ResourceLocation location) { return new SpecExample(location, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } public SpecExample withOptionsSet(@Nullable String optionsSet) { return new SpecExample(resourceLocation, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } public SpecExample withSection(@Nullable String section) { return new SpecExample(resourceLocation, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } public SpecExample withExampleNumber(int exampleNumber) { return new SpecExample(resourceLocation, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } - public SpecExample withSource(@NotNull String source) { return new SpecExample(resourceLocation, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } - public SpecExample withHtml(@NotNull String html) { return new SpecExample(resourceLocation, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } + public SpecExample withSource(String source) { return new SpecExample(resourceLocation, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } + public SpecExample withHtml(String html) { return new SpecExample(resourceLocation, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } public SpecExample withAst(@Nullable String ast) { return new SpecExample(resourceLocation, lineNumber, optionsSet, section, exampleNumber, source, html, ast, comment , isNull); } // @formatter:on @@ -88,32 +87,26 @@ public String getOptionsSet() { return optionsSet; } - @NotNull public String getFileUrlWithLineNumber() { return getFileUrlWithLineNumber(0); } - @NotNull public String getFileUrlWithLineNumber(int lineOffset) { return resourceLocation.getFileUrl(Utils.minLimit(lineNumber + lineOffset, 0)); } - @NotNull public String getFileUrl() { return resourceLocation.getFileUrl(); } - @NotNull public ResourceLocation getResourceLocation() { return resourceLocation; } - @NotNull public String getSource() { return source; } - @NotNull public String getHtml() { return html; } @@ -154,7 +147,7 @@ public String toString() { final private static ConcurrentMap classMap = new ConcurrentHashMap<>(); - public static @NotNull SpecExample ofCaller(int callNesting, Class resourceClass, @NotNull String source, @NotNull String html, @Nullable String ast) { + public static SpecExample ofCaller(int callNesting, Class resourceClass, String source, String html, @Nullable String ast) { StackTraceElement[] trace = Thread.currentThread().getStackTrace(); StackTraceElement traceElement = trace[callNesting + 2]; String javaClassFile = classMap.get(resourceClass.getName()); diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecReader.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecReader.java index 18047998b..90fa42c0d 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecReader.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecReader.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.test.util.TestUtils; import com.vladsch.flexmark.util.misc.Pair; -import org.jetbrains.annotations.NotNull; import java.io.BufferedReader; import java.io.IOException; @@ -30,8 +29,8 @@ public class SpecReader { final public static String SECTION_TEST_BREAK = "…"; protected static final Pattern SECTION_PATTERN = Pattern.compile("#{1,6} +(.*)"); - protected final @NotNull InputStream inputStream; - protected final @NotNull ResourceLocation resourceLocation; + protected final InputStream inputStream; + protected final ResourceLocation resourceLocation; protected final boolean compoundSections; protected final List examples = new ArrayList<>(); @@ -50,28 +49,24 @@ public class SpecReader { protected int contentLineNumber = 0; protected int commentLineNumber = 0; - public SpecReader(@NotNull InputStream stream, @NotNull ResourceLocation location, boolean compoundSections) { + public SpecReader(InputStream stream, ResourceLocation location, boolean compoundSections) { this.inputStream = stream; this.resourceLocation = location; this.compoundSections = compoundSections; } - @NotNull public String getFileUrl() { return resourceLocation.getFileUrl(); } - @NotNull public ResourceLocation getResourceLocation() { return resourceLocation; } - @NotNull public List getExamples() { return examples; } - @NotNull public List getExamplesSourceAsString() { List result = new ArrayList<>(); for (SpecExample example : examples) { @@ -80,20 +75,20 @@ public List getExamplesSourceAsString() { return result; } - public static @NotNull SpecReader create(@NotNull ResourceLocation location, boolean compoundSections) { + public static SpecReader create(ResourceLocation location, boolean compoundSections) { return create(location, (stream, location1) -> new SpecReader(stream, location1, compoundSections)); } - public static @NotNull S create(@NotNull ResourceLocation location, @NotNull SpecReaderFactory readerFactory) { + public static S create(ResourceLocation location, SpecReaderFactory readerFactory) { InputStream stream = location.getResourceInputStream(); return readerFactory.create(stream, location); } - public static @NotNull SpecReader createAndReadExamples(@NotNull ResourceLocation location, boolean compoundSections) { + public static SpecReader createAndReadExamples(ResourceLocation location, boolean compoundSections) { return createAndReadExamples(location, (stream, location1) -> new SpecReader(stream, location1, compoundSections)); } - public static @NotNull S createAndReadExamples(@NotNull ResourceLocation location, @NotNull SpecReaderFactory readerFactory) { + public static S createAndReadExamples(ResourceLocation location, SpecReaderFactory readerFactory) { S reader = create(location, readerFactory); reader.readExamples(); return reader; @@ -125,7 +120,7 @@ protected void addSpecLine(String line, boolean isSpecExampleOpen) { } - protected void addSpecExample(@NotNull SpecExample example) { + protected void addSpecExample(SpecExample example) { examples.add(example); } diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecReaderFactory.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecReaderFactory.java index 5a19c10b5..86eb00855 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecReaderFactory.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/SpecReaderFactory.java @@ -1,9 +1,8 @@ package com.vladsch.flexmark.test.util.spec; -import org.jetbrains.annotations.NotNull; import java.io.InputStream; public interface SpecReaderFactory { - @NotNull S create(@NotNull InputStream inputStream, @NotNull ResourceLocation location); + S create(InputStream inputStream, ResourceLocation location); } diff --git a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/package-info.java b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/package-info.java index ae52e9cab..7af3c0ac0 100644 --- a/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/package-info.java +++ b/flexmark-test-util/src/main/java/com/vladsch/flexmark/test/util/spec/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.test.util.spec; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-tree-iteration/pom.xml b/flexmark-tree-iteration/pom.xml index a0f87c20e..bcd6941a7 100644 --- a/flexmark-tree-iteration/pom.xml +++ b/flexmark-tree-iteration/pom.xml @@ -13,9 +13,9 @@ - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 com.vladsch.flexmark diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/FixedIterationConditions.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/FixedIterationConditions.java index 9a48c2643..4596fe8f4 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/FixedIterationConditions.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/FixedIterationConditions.java @@ -1,16 +1,15 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; import java.util.function.Function; public class FixedIterationConditions implements IterationConditions { - final private @NotNull Function initializer; - final private @NotNull Function iterator; - final private @NotNull Function reverseInitializer; - final private @NotNull Function reverseIterator; + final private Function initializer; + final private Function iterator; + final private Function reverseInitializer; + final private Function reverseIterator; - public FixedIterationConditions(@NotNull Function initializer, @NotNull Function iterator, @NotNull Function reverseInitializer, @NotNull Function reverseIterator) { + public FixedIterationConditions(Function initializer, Function iterator, Function reverseInitializer, Function reverseIterator) { this.initializer = initializer; this.iterator = iterator; this.reverseInitializer = reverseInitializer; @@ -18,18 +17,15 @@ public FixedIterationConditions(@NotNull Function initializer, @No } @Override - @NotNull public Function getInitializer() { return initializer; } @Override - @NotNull public Function getIterator() { return iterator; } - @NotNull @Override public IterationConditions getReversed() { return new FixedIterationConditions<>(reverseInitializer, reverseIterator, initializer, iterator); diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IterationConditions.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IterationConditions.java index fcb6a1153..c35726e8a 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IterationConditions.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IterationConditions.java @@ -1,22 +1,17 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; import java.util.function.Function; public interface IterationConditions { - @NotNull Function getInitializer(); - @NotNull Function getIterator(); - @NotNull default IterationConditions getReversed() { throw new IllegalStateException("Method not implemented"); } - @NotNull default IterationConditions getAborted() { Function function = n -> null; return new FixedIterationConditions<>(function, function, function, function); diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IterationConsumer.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IterationConsumer.java index 41ef6f921..99f067340 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IterationConsumer.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IterationConsumer.java @@ -1,15 +1,14 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; public interface IterationConsumer { // starting a new recursion iteration - default void startRecursion(@NotNull VoidIteration iteration) { + default void startRecursion(VoidIteration iteration) { } // after recursion is done but before stack is adjusted for new level - default void endRecursion(@NotNull VoidIteration iteration) { + default void endRecursion(VoidIteration iteration) { } } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IteratorInstance.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IteratorInstance.java index b9445283b..e3fc5e83d 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IteratorInstance.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/IteratorInstance.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import java.util.Stack; @@ -16,37 +15,37 @@ final public class IteratorInstance implements ValueIteration { private Iteration myIteration; // current iteration information private @Nullable Stack> myRecursions; // recursion frames - final private @NotNull IterationConditions myIterationConditions; - final private @NotNull Predicate myRecursionPredicate; - final private @NotNull Predicate myFilterPredicate; + final private IterationConditions myIterationConditions; + final private Predicate myRecursionPredicate; + final private Predicate myFilterPredicate; private int myTotalLoopCount = 0; // total looping count across all nesting levels, including filtered out elements private int myTotalAcceptCount = 0; // total looping count across all nesting levels, only consumed elements private @Nullable N myMatch; private @Nullable MutableDataSet myDataSet; - final private @NotNull Object myDefaultValue; + final private Object myDefaultValue; // ValueResult - private @NotNull Object myResult; + private Object myResult; private boolean myBreak = false; private boolean myHadRecurse = false; // true if current iteration had performed recurse private boolean myIsDefaultResult = true; private int myMaxRecursions = 0; public IteratorInstance( - @NotNull IterationConditions iterationConditions, - @NotNull Predicate filterPredicate, - @NotNull Predicate recursionPredicate, - @NotNull N element + IterationConditions iterationConditions, + Predicate filterPredicate, + Predicate recursionPredicate, + N element ) { this(iterationConditions, filterPredicate, recursionPredicate, element, VoidIteration.NULL); } public IteratorInstance( - @NotNull IterationConditions iterationConditions, - @NotNull Predicate filterPredicate, - @NotNull Predicate recursionPredicate, - @NotNull N element, - @NotNull Object defaultValue + IterationConditions iterationConditions, + Predicate filterPredicate, + Predicate recursionPredicate, + N element, + Object defaultValue ) { myIterationConditions = iterationConditions; myRecursionPredicate = recursionPredicate; @@ -56,11 +55,11 @@ public IteratorInstance( myResult = defaultValue; } - public void iterate(@NotNull VoidIterationConsumer consumer) { + public void iterate(VoidIterationConsumer consumer) { iterate(new VoidToValueIConsumerAdapter<>(consumer)); } - public void iterate(@NotNull ValueIterationConsumer consumer) { + public void iterate(ValueIterationConsumer consumer) { consumer.beforeStart(this); if (LOG_INFO.isDebugEnabled()) LOG_INFO.debug("Starting looping " + myIteration); @@ -129,12 +128,11 @@ public boolean getHaveAcceptableNext() { } @Override - public void setResult(@NotNull Object value) { + public void setResult(Object value) { myResult = value; myIsDefaultResult = false; } - @NotNull @Override public R getResult() { //noinspection unchecked @@ -142,7 +140,7 @@ public R getResult() { } @Override - public void Return(@NotNull Object value) { + public void Return(Object value) { myResult = value; myBreak = true; myMatch = null; @@ -234,7 +232,7 @@ public boolean isIncomplete() { } @Override - public void ifIncomplete(@NotNull Runnable runnable) { + public void ifIncomplete(Runnable runnable) { if (isIncomplete()) { runnable.run(); } @@ -280,7 +278,6 @@ public boolean isDefaultResult() { return myIsDefaultResult; } - @NotNull @Override public R getDefaultValue() { //noinspection unchecked diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/MappedIterator.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/MappedIterator.java index 8b440a500..737f3a621 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/MappedIterator.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/MappedIterator.java @@ -1,16 +1,15 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; import java.util.function.Function; import java.util.function.Predicate; public class MappedIterator { - protected final @NotNull B myElement; - protected final @NotNull ValueIterationAdapter myAdapter; - protected final @NotNull TreeIterator myTreeIterator; + protected final B myElement; + protected final ValueIterationAdapter myAdapter; + protected final TreeIterator myTreeIterator; - public MappedIterator(@NotNull B element, @NotNull ValueIterationAdapter adapter, @NotNull TreeIterator treeIterator) { + public MappedIterator(B element, ValueIterationAdapter adapter, TreeIterator treeIterator) { myElement = element; myAdapter = adapter; myTreeIterator = treeIterator; @@ -22,17 +21,15 @@ public MappedIterator(@NotNull B element, @NotNull ValueIterationAdapter getTreeIterator() { return myTreeIterator; } - @NotNull - final public R doLoop(@NotNull R defaultValue, @NotNull ValueIterationConsumer consumer) { + final public R doLoop(R defaultValue, ValueIterationConsumer consumer) { return myTreeIterator.doLoop(myElement, defaultValue, myAdapter, consumer); } - final public void doLoop(@NotNull VoidIterationConsumer consumer) { + final public void doLoop(VoidIterationConsumer consumer) { myTreeIterator.doLoop(myElement, myAdapter, consumer); } @@ -42,12 +39,10 @@ final public void doLoop(@NotNull VoidIterationConsumer consumer) { // // ******************************************************* - @NotNull public MappedIterator getModifiedCopy(B element, ValueIterationAdapter adapter, TreeIterator treeIterator) { return new MappedIterator<>(element, adapter, treeIterator); } - @NotNull public MappedIterator getModifiedCopyF(B element, ValueIterationAdapter adapter, TreeIterator treeIterator) { return new MappedIterator<>(element, adapter, treeIterator); } @@ -58,94 +53,76 @@ public MappedIterator getModifiedCopyF(B element, ValueItera // // ******************************************************* - @NotNull public MappedIterator reversed() { return getModifiedCopy(myElement, myAdapter, myTreeIterator.reversed()); } - @NotNull public MappedIterator recursive() { return getModifiedCopy(myElement, myAdapter, myTreeIterator.recursive()); } - @NotNull public MappedIterator nonRecursive() { return getModifiedCopy(myElement, myAdapter, myTreeIterator.nonRecursive()); } - @NotNull public MappedIterator recursive(boolean recursive) { return recursive ? recursive() : nonRecursive(); } - @NotNull public MappedIterator nonRecursive(boolean nonRecursive) { return nonRecursive ? nonRecursive() : recursive(); } - @NotNull - public MappedIterator recurse(@NotNull Predicate predicate) { + public MappedIterator recurse(Predicate predicate) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.recurse(predicate)); } - @NotNull - public MappedIterator recurse(@NotNull Class clazz) { + public MappedIterator recurse(Class clazz) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.recurse(clazz)); } - @NotNull - public MappedIterator recurse(@NotNull Class clazz, @NotNull Predicate predicate) { + public MappedIterator recurse(Class clazz, Predicate predicate) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.recurse(clazz, predicate)); } - @NotNull - public MappedIterator noRecurse(@NotNull Predicate predicate) { + public MappedIterator noRecurse(Predicate predicate) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.noRecurse(predicate)); } - @NotNull - public MappedIterator noRecurse(@NotNull Class clazz) { + public MappedIterator noRecurse(Class clazz) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.noRecurse(clazz)); } - @NotNull - public MappedIterator noRecurse(@NotNull Class clazz, @NotNull Predicate predicate) { + public MappedIterator noRecurse(Class clazz, Predicate predicate) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.recurse(clazz, predicate)); } - @NotNull public MappedIterator filterFalse() { return aborted(); } - @NotNull public MappedIterator aborted() { return getModifiedCopy(myElement, myAdapter, myTreeIterator.aborted()); } - @NotNull - public MappedIterator filterOut(@NotNull Predicate predicate) { + public MappedIterator filterOut(Predicate predicate) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.filterOut(predicate)); } - @NotNull - public MappedIterator filterOut(@NotNull Class clazz) { + public MappedIterator filterOut(Class clazz) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.filterOut(clazz)); } - @NotNull - public MappedIterator filterOut(@NotNull Class clazz, @NotNull Predicate predicate) { + public MappedIterator filterOut(Class clazz, Predicate predicate) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.filterOut(clazz, predicate)); } - @NotNull - public MappedIterator filter(@NotNull Predicate predicate) { + public MappedIterator filter(Predicate predicate) { return getModifiedCopy(myElement, myAdapter, myTreeIterator.filter(predicate)); } - @NotNull - public MappedIterator acceptFilter(@NotNull ValueIterationFilter filter) { + public MappedIterator acceptFilter(ValueIterationFilter filter) { return getModifiedCopy(myElement, myAdapter.andThen(ValueIterationAdapterImpl.of(filter)), myTreeIterator); } @@ -155,27 +132,22 @@ public MappedIterator acceptFilter(@NotNull ValueIterationFilter MappedIterator filter(@NotNull Class clazz) { + public MappedIterator filter(Class clazz) { return getModifiedCopyF(myElement, myAdapter.andThen(ValueIterationAdapterImpl.of(clazz)), myTreeIterator); } - @NotNull - public MappedIterator filter(@NotNull Class clazz, @NotNull Predicate predicate) { + public MappedIterator filter(Class clazz, Predicate predicate) { return getModifiedCopyF(myElement, myAdapter.andThen(ValueIterationAdapterImpl.of(clazz, predicate)), myTreeIterator); } - @NotNull - public MappedIterator adapt(@NotNull Function adapter) { + public MappedIterator adapt(Function adapter) { return getModifiedCopyF(myElement, myAdapter.andThen(ValueIterationAdapterImpl.of(adapter)), myTreeIterator); } - @NotNull - public MappedIterator adapt(@NotNull ValueIterationAdapter adapter) { + public MappedIterator adapt(ValueIterationAdapter adapter) { return getModifiedCopyF(myElement, myAdapter.andThen(adapter), myTreeIterator); } - @NotNull public MappedIterator toObjectMapped(Class clazz) { Function objectToB = it -> clazz.isInstance(it) ? clazz.cast(it) : null; Function tToObject = it -> it; @@ -195,7 +167,7 @@ public MappedIterator toObjectMapped(Class clazz) { // // ******************************************************* - public static MappedIterator create(N element, @NotNull TreeIterator treeIterator) { + public static MappedIterator create(N element, TreeIterator treeIterator) { return new MappedIterator<>(element, ValueIterationAdapterImpl.of(), treeIterator); } } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/NodeIterator.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/NodeIterator.java index e5dda423b..065ad1e62 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/NodeIterator.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/NodeIterator.java @@ -1,14 +1,13 @@ package com.vladsch.flexmark.tree.iteration; import com.vladsch.flexmark.util.ast.Node; -import org.jetbrains.annotations.NotNull; import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; public class NodeIterator extends MappedIterator { - public NodeIterator(@NotNull Node element, @NotNull ValueIterationAdapter adapter, @NotNull TreeIterator treeIterator) { + public NodeIterator(Node element, ValueIterationAdapter adapter, TreeIterator treeIterator) { super(element, adapter, treeIterator); } @@ -18,12 +17,10 @@ public NodeIterator(@NotNull Node element, @NotNull ValueIterationAdapter getModifiedCopy(Node element, ValueIterationAdapter adapter, TreeIterator treeIterator) { return new NodeIterator<>(element, adapter, treeIterator); } - @NotNull public NodeIterator getModifiedCopyF(Node element, ValueIterationAdapter adapter, TreeIterator treeIterator) { return new NodeIterator<>(element, adapter, treeIterator); } @@ -34,111 +31,93 @@ public NodeIterator getModifiedCopyF(Node element, ValueIter // // ******************************************************* - @NotNull @Override public NodeIterator reversed() { return (NodeIterator) super.reversed(); } - @NotNull @Override public NodeIterator recursive() { return (NodeIterator) super.recursive(); } - @NotNull @Override public NodeIterator nonRecursive() { return (NodeIterator) super.nonRecursive(); } - @NotNull @Override public NodeIterator recursive(boolean recursive) { return (NodeIterator) super.recursive(recursive); } - @NotNull @Override public NodeIterator nonRecursive(boolean nonRecursive) { return (NodeIterator) super.nonRecursive(nonRecursive); } - @NotNull @Override - public NodeIterator recurse(@NotNull Predicate predicate) { + public NodeIterator recurse(Predicate predicate) { return (NodeIterator) super.recurse(predicate); } - @NotNull @Override - public NodeIterator recurse(@NotNull Class clazz) { + public NodeIterator recurse(Class clazz) { return (NodeIterator) super.recurse(clazz); } - @NotNull @Override - public NodeIterator recurse(@NotNull Class clazz, @NotNull Predicate predicate) { + public NodeIterator recurse(Class clazz, Predicate predicate) { return (NodeIterator) super.recurse(clazz, predicate); } - @NotNull @Override - public NodeIterator noRecurse(@NotNull Predicate predicate) { + public NodeIterator noRecurse(Predicate predicate) { return (NodeIterator) super.noRecurse(predicate); } - @NotNull @Override - public NodeIterator noRecurse(@NotNull Class clazz) { + public NodeIterator noRecurse(Class clazz) { return (NodeIterator) super.noRecurse(clazz); } - @NotNull @Override - public NodeIterator noRecurse(@NotNull Class clazz, @NotNull Predicate predicate) { + public NodeIterator noRecurse(Class clazz, Predicate predicate) { return (NodeIterator) super.noRecurse(clazz, predicate); } - @NotNull @Override public NodeIterator filterFalse() { return (NodeIterator) super.filterFalse(); } - @NotNull @Override public NodeIterator aborted() { return (NodeIterator) super.aborted(); } - @NotNull @Override - public NodeIterator filterOut(@NotNull Predicate predicate) { + public NodeIterator filterOut(Predicate predicate) { return (NodeIterator) super.filterOut(predicate); } - @NotNull @Override - public NodeIterator filterOut(@NotNull Class clazz) { + public NodeIterator filterOut(Class clazz) { return (NodeIterator) super.filterOut(clazz); } - @NotNull @Override - public NodeIterator filterOut(@NotNull Class clazz, @NotNull Predicate predicate) { + public NodeIterator filterOut(Class clazz, Predicate predicate) { return (NodeIterator) super.filterOut(clazz, predicate); } - @NotNull @Override - public NodeIterator filter(@NotNull Predicate predicate) { + public NodeIterator filter(Predicate predicate) { return (NodeIterator) super.filter(predicate); } - @NotNull @Override - public NodeIterator acceptFilter(@NotNull ValueIterationFilter filter) { + public NodeIterator acceptFilter(ValueIterationFilter filter) { return (NodeIterator) super.acceptFilter(filter); } @@ -148,27 +127,23 @@ public NodeIterator acceptFilter(@NotNull ValueIterationFilter fil // // ******************************************************* - @NotNull @Override - public NodeIterator filter(@NotNull Class clazz) { + public NodeIterator filter(Class clazz) { return (NodeIterator) super.filter(clazz); } - @NotNull @Override - public NodeIterator filter(@NotNull Class clazz, @NotNull Predicate predicate) { + public NodeIterator filter(Class clazz, Predicate predicate) { return (NodeIterator) super.filter(clazz, predicate); } - @NotNull @Override - public NodeIterator adapt(@NotNull Function adapter) { + public NodeIterator adapt(Function adapter) { return (NodeIterator) super.adapt(adapter); } - @NotNull @Override - public NodeIterator adapt(@NotNull ValueIterationAdapter adapter) { + public NodeIterator adapt(ValueIterationAdapter adapter) { return (NodeIterator) super.adapt(adapter); } @@ -178,22 +153,18 @@ public NodeIterator adapt(@NotNull ValueIterationAdapter recurse(@NotNull Set> nodeClassSet) { + public NodeIterator recurse(Set> nodeClassSet) { return getModifiedCopyF(myElement, myAdapter, myTreeIterator.recurse(it -> nodeClassSet.contains(it.getClass()))); } - @NotNull - public NodeIterator filterOut(@NotNull Set> nodeClassSet) { + public NodeIterator filterOut(Set> nodeClassSet) { return getModifiedCopyF(myElement, myAdapter, myTreeIterator.filterOut(it -> nodeClassSet.contains(it.getClass()))); } - @NotNull - public NodeIterator filter(@NotNull Set> nodeClassSet) { + public NodeIterator filter(Set> nodeClassSet) { return getModifiedCopyF(myElement, myAdapter, myTreeIterator.filter(it -> nodeClassSet.contains(it.getClass()))); } - @NotNull public MappedIterator toNodeObjectMapped() { return toObjectMapped(Node.class); } @@ -204,19 +175,19 @@ public MappedIterator toNodeObjectMapped() { // // ******************************************************* - public static NodeIterator of(@NotNull Node element, @NotNull TreeIterator treeIterator) { + public static NodeIterator of(Node element, TreeIterator treeIterator) { return new NodeIterator<>(element, ValueIterationAdapterImpl.of(), treeIterator); } - public static NodeIterator of(@NotNull Node element, @NotNull IterationConditions constraints) { + public static NodeIterator of(Node element, IterationConditions constraints) { return of(element, new TreeIterator<>(constraints)); } - public static NodeIterator of(@NotNull Node element, @NotNull IterationConditions constraints, @NotNull Predicate filter) { + public static NodeIterator of(Node element, IterationConditions constraints, Predicate filter) { return of(element, new TreeIterator<>(constraints, filter)); } - public static NodeIterator of(@NotNull Node element, @NotNull IterationConditions constraints, @NotNull Predicate filter, @NotNull Predicate recursion) { + public static NodeIterator of(Node element, IterationConditions constraints, Predicate filter, Predicate recursion) { return of(element, new TreeIterator<>(constraints, filter, recursion)); } } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/TreeIterator.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/TreeIterator.java index 181cad657..3eb060181 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/TreeIterator.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/TreeIterator.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,17 +37,14 @@ public TreeIterator( myFilter = filter; } - @NotNull - public Predicate getPredicate(@NotNull Class clazz) { + public Predicate getPredicate(Class clazz) { return clazz::isInstance; } - @NotNull - public Predicate getPredicate(@NotNull Class clazz, @NotNull Predicate predicate) { + public Predicate getPredicate(Class clazz, Predicate predicate) { return (it) -> clazz.isInstance(it) && predicate.test(clazz.cast(it)); } - @NotNull public IterationConditions getConstraints() { return myConstraints; } @@ -61,157 +57,133 @@ public Predicate getFilter() { return myFilter; } - @NotNull - public TreeIterator modifiedCopy(@NotNull IterationConditions constraints, @NotNull Predicate filter, @NotNull Predicate recursion) { + public TreeIterator modifiedCopy(IterationConditions constraints, Predicate filter, Predicate recursion) { return new TreeIterator<>(constraints, filter, recursion); } - @NotNull public TreeIterator reversed() { return modifiedCopy(myConstraints.getReversed(), myFilter, myRecursion); } - @NotNull public TreeIterator recursive() { //noinspection unchecked return modifiedCopy(myConstraints, myFilter, (Predicate) TRUE); } - @NotNull public TreeIterator nonRecursive() { //noinspection unchecked return modifiedCopy(myConstraints, myFilter, (Predicate) FALSE); } - @NotNull - public TreeIterator recurse(@NotNull Predicate predicate) { + public TreeIterator recurse(Predicate predicate) { return modifiedCopy(myConstraints, myFilter, it -> myRecursion.test(it) || predicate.test(it)); } - @NotNull - public TreeIterator recurse(@NotNull Class clazz) { + public TreeIterator recurse(Class clazz) { return recurse(getPredicate(clazz)); } - @NotNull - public TreeIterator recurse(@NotNull Class clazz, @NotNull Predicate predicate) { + public TreeIterator recurse(Class clazz, Predicate predicate) { return recurse(getPredicate(clazz, predicate)); } - @NotNull - public TreeIterator noRecurse(@NotNull Predicate predicate) { + public TreeIterator noRecurse(Predicate predicate) { return modifiedCopy(myConstraints, myFilter, it -> myRecursion.test(it) && !predicate.test(it)); } - @NotNull - public TreeIterator noRecurse(@NotNull Class clazz) { + public TreeIterator noRecurse(Class clazz) { return noRecurse(getPredicate(clazz)); } - @NotNull - public TreeIterator noRecurse(@NotNull Class clazz, @NotNull Predicate predicate) { + public TreeIterator noRecurse(Class clazz, Predicate predicate) { return noRecurse(getPredicate(clazz, predicate)); } - @NotNull public TreeIterator aborted() { return modifiedCopy(myConstraints.getAborted(), myFilter, myRecursion); } - @NotNull - public TreeIterator filterOut(@NotNull Predicate predicate) { + public TreeIterator filterOut(Predicate predicate) { return modifiedCopy(myConstraints, it -> myFilter.test(it) && !predicate.test(it), myRecursion); } - @NotNull - public TreeIterator filterOut(@NotNull Class clazz) { + public TreeIterator filterOut(Class clazz) { return filterOut(getPredicate(clazz)); } - @NotNull - public TreeIterator filterOut(@NotNull Class clazz, @NotNull Predicate predicate) { + public TreeIterator filterOut(Class clazz, Predicate predicate) { return filterOut(getPredicate(clazz, predicate)); } - @NotNull - public TreeIterator filter(@NotNull Predicate predicate) { + public TreeIterator filter(Predicate predicate) { return modifiedCopy(myConstraints, it -> myFilter.test(it) && predicate.test(it), myRecursion); } - @NotNull - public TreeIterator filter(@NotNull Class clazz) { + public TreeIterator filter(Class clazz) { return filter(getPredicate(clazz)); } - @NotNull - public TreeIterator filter(@NotNull Class clazz, @NotNull Predicate predicate) { + public TreeIterator filter(Class clazz, Predicate predicate) { return filter(getPredicate(clazz, predicate)); } - @NotNull - public static TreeIterator of(@NotNull IterationConditions constraints) { + public static TreeIterator of(IterationConditions constraints) { return new TreeIterator<>(constraints); } - @NotNull - public static TreeIterator of(@NotNull IterationConditions constraints, @NotNull Predicate filter) { + public static TreeIterator of(IterationConditions constraints, Predicate filter) { return new TreeIterator<>(constraints, filter); } - @NotNull - public static TreeIterator of(@NotNull IterationConditions constraints, @NotNull Predicate filter, @NotNull Predicate recursion) { + public static TreeIterator of(IterationConditions constraints, Predicate filter, Predicate recursion) { return new TreeIterator<>(constraints, filter, recursion); } - @NotNull public static Predicate TRUE() { return n -> true; } - @NotNull public static Predicate FALSE() { return n -> true; } - public ValueIteration iterate(@NotNull N element, @NotNull R defaultValue, @NotNull ValueIterationConsumer consumer) { + public ValueIteration iterate(N element, R defaultValue, ValueIterationConsumer consumer) { IteratorInstance instance = new IteratorInstance<>(getConstraints(), getFilter(), getRecursion(), element, defaultValue); instance.iterate(consumer); return instance; } - public ValueIteration iterate(@NotNull N element, @NotNull R defaultValue, @NotNull ValueIterationAdapter adapter, @NotNull ValueIterationConsumer consumer) { + public ValueIteration iterate(N element, R defaultValue, ValueIterationAdapter adapter, ValueIterationConsumer consumer) { IteratorInstance instance = new IteratorInstance<>(getConstraints(), getFilter(), getRecursion(), element, defaultValue); instance.iterate(adapter.getConsumerAdapter().getConsumer(consumer)); return instance; } - public VoidIteration iterate(@NotNull N element, @NotNull VoidIterationConsumer consumer) { + public VoidIteration iterate(N element, VoidIterationConsumer consumer) { IteratorInstance instance = new IteratorInstance<>(getConstraints(), getFilter(), getRecursion(), element); instance.iterate(consumer); return instance; } - public VoidIteration iterate(@NotNull N element, @NotNull ValueIterationAdapter adapter, @NotNull VoidIterationConsumer consumer) { + public VoidIteration iterate(N element, ValueIterationAdapter adapter, VoidIterationConsumer consumer) { IteratorInstance instance = new IteratorInstance<>(getConstraints(), getFilter(), getRecursion(), element); instance.iterate(adapter.getConsumerAdapter().getConsumer(consumer)); return instance; } - @NotNull - public R doLoop(@NotNull N element, @NotNull R defaultValue, @NotNull ValueIterationConsumer consumer) { + public R doLoop(N element, R defaultValue, ValueIterationConsumer consumer) { return iterate(element, defaultValue, consumer).getResult(); } - public void doLoop(@NotNull N element, @NotNull VoidIterationConsumer consumer) { + public void doLoop(N element, VoidIterationConsumer consumer) { iterate(element, consumer); } - @NotNull - public R doLoop(@NotNull N element, @NotNull R defaultValue, @NotNull ValueIterationAdapter adapter, @NotNull ValueIterationConsumer consumer) { + public R doLoop(N element, R defaultValue, ValueIterationAdapter adapter, ValueIterationConsumer consumer) { return iterate(element, defaultValue, adapter, consumer).getResult(); } - public void doLoop(@NotNull N element, @NotNull ValueIterationAdapter adapter, @NotNull VoidIterationConsumer consumer) { + public void doLoop(N element, ValueIterationAdapter adapter, VoidIterationConsumer consumer) { iterate(element, adapter, consumer); } } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIteration.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIteration.java index f8bfcc877..536598d58 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIteration.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIteration.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; public interface ValueIteration extends VoidIteration { /** @@ -8,7 +7,7 @@ public interface ValueIteration extends VoidIteration { * * @param value value to return from the loop */ - void setResult(@NotNull R value); + void setResult(R value); /** * @return true if the current loop result value was never set (ie. only set at loop instantiation with @@ -22,13 +21,11 @@ public interface ValueIteration extends VoidIteration { /** * @return defaultValue passed to loop instance */ - @NotNull R getDefaultValue(); /** * @return current result value */ - @NotNull R getResult(); /** @@ -36,5 +33,5 @@ public interface ValueIteration extends VoidIteration { * * @param value value to return for the result of the loop */ - void Return(@NotNull R value); + void Return(R value); } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationAdapter.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationAdapter.java index a1e52d53d..7e7f87447 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationAdapter.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationAdapter.java @@ -1,14 +1,11 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; public interface ValueIterationAdapter { - @NotNull ValueIterationConsumerAdapter getConsumerAdapter(); - @NotNull ValueIterationAdapter andThen(ValueIterationAdapter after); + ValueIterationAdapter andThen(ValueIterationAdapter after); - @NotNull ValueIterationAdapter compose(ValueIterationAdapter before); } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationAdapterImpl.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationAdapterImpl.java index ce66736e8..93e4a7ab2 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationAdapterImpl.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationAdapterImpl.java @@ -1,31 +1,28 @@ package com.vladsch.flexmark.tree.iteration; import com.vladsch.flexmark.util.collection.iteration.ArrayIterable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.Function; import java.util.function.Predicate; public class ValueIterationAdapterImpl implements ValueIterationAdapter { - final private @NotNull ValueIterationConsumerAdapter myConsumerAdapter; + final private ValueIterationConsumerAdapter myConsumerAdapter; static class ConsumerAdapter implements ValueIterationConsumerAdapter { - final private @NotNull Function myFunction; + final private Function myFunction; final private @Nullable ValueIterationFilter myFilter; - public ConsumerAdapter(@NotNull Function function, @Nullable ValueIterationFilter filter) { + public ConsumerAdapter(Function function, @Nullable ValueIterationFilter filter) { myFunction = function; myFilter = filter; } - @NotNull @Override public ValueIterationConsumer getConsumer(ValueIterationConsumer valueConsumer) { return new MyValueIterationConsumer<>(myFunction, myFilter, valueConsumer); } - @NotNull @Override public ValueIterationConsumer getConsumer(VoidIterationConsumer voidConsumer) { return new MyValueIterationConsumer<>(myFunction, myFilter, new VoidToValueIConsumerAdapter<>(voidConsumer)); @@ -37,14 +34,14 @@ private static class MyValueIterationConsumer implements ValueIteration final private Function myFunction; final private @Nullable ValueIterationFilter myFilter; - public MyValueIterationConsumer(@NotNull Function function, @Nullable ValueIterationFilter filter, ValueIterationConsumer consumer) { + public MyValueIterationConsumer(Function function, @Nullable ValueIterationFilter filter, ValueIterationConsumer consumer) { myFunction = function; myFilter = filter; myConsumer = consumer; } @Override - public void accept(@NotNull P it, @NotNull ValueIteration iteration) { + public void accept(P it, ValueIteration iteration) { T applied = myFunction.apply(it); if (applied == null || myFilter != null && !myFilter.filter(applied, iteration)) { //loop.Continue(); @@ -54,22 +51,22 @@ public void accept(@NotNull P it, @NotNull ValueIteration iteration) { } @Override - public void beforeStart(@NotNull ValueIteration iteration) { + public void beforeStart(ValueIteration iteration) { myConsumer.beforeStart(iteration); } @Override - public void startRecursion(@NotNull VoidIteration iteration) { + public void startRecursion(VoidIteration iteration) { myConsumer.startRecursion(iteration); } @Override - public void endRecursion(@NotNull VoidIteration iteration) { + public void endRecursion(VoidIteration iteration) { myConsumer.endRecursion(iteration); } @Override - public void afterEnd(@NotNull ValueIteration iteration) { + public void afterEnd(ValueIteration iteration) { myConsumer.afterEnd(iteration); } } @@ -83,44 +80,39 @@ public ChainedConsumerAdapter(ValueIterationConsumerAdapter before myAfterAdapter = afterAdapter; } - @NotNull @Override public ValueIterationConsumer getConsumer(ValueIterationConsumer valueConsumer) { return myBeforeAdapter.getConsumer(myAfterAdapter.getConsumer(valueConsumer)); } - @NotNull @Override public ValueIterationConsumer getConsumer(VoidIterationConsumer voidConsumer) { return myBeforeAdapter.getConsumer(myAfterAdapter.getConsumer(voidConsumer)); } } - public ValueIterationAdapterImpl(@NotNull Function function) { + public ValueIterationAdapterImpl(Function function) { this(function, null); } - public ValueIterationAdapterImpl(@NotNull Function function, @Nullable ValueIterationFilter filter) { + public ValueIterationAdapterImpl(Function function, @Nullable ValueIterationFilter filter) { this(new ConsumerAdapter<>(function, filter)); } - public ValueIterationAdapterImpl(@NotNull ValueIterationConsumerAdapter consumerAdapter) { + public ValueIterationAdapterImpl(ValueIterationConsumerAdapter consumerAdapter) { myConsumerAdapter = consumerAdapter; } - @NotNull @Override public ValueIterationConsumerAdapter getConsumerAdapter() { return myConsumerAdapter; } - @NotNull @Override public ValueIterationAdapter andThen(ValueIterationAdapter after) { return new ValueIterationAdapterImpl<>(new ChainedConsumerAdapter<>(myConsumerAdapter, after.getConsumerAdapter())); } - @NotNull @Override public ValueIterationAdapter compose(ValueIterationAdapter before) { return new ValueIterationAdapterImpl<>(new ChainedConsumerAdapter<>(before.getConsumerAdapter(), myConsumerAdapter)); diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationConsumer.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationConsumer.java index 300a91f84..f8f23787d 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationConsumer.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationConsumer.java @@ -1,17 +1,16 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; public interface ValueIterationConsumer extends IterationConsumer { - void accept(@NotNull N it, @NotNull ValueIteration iteration); + void accept(N it, ValueIteration iteration); // before start of all iterations - default void beforeStart(@NotNull ValueIteration iteration) { + default void beforeStart(ValueIteration iteration) { } // iteration is done, before returning - default void afterEnd(@NotNull ValueIteration iteration) { + default void afterEnd(ValueIteration iteration) { } } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationConsumerAdapter.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationConsumerAdapter.java index 7ceb9a2b9..7dfc5d2b8 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationConsumerAdapter.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationConsumerAdapter.java @@ -1,9 +1,8 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; public interface ValueIterationConsumerAdapter { - @NotNull ValueIterationConsumer getConsumer(ValueIterationConsumer valueConsumer); + ValueIterationConsumer getConsumer(ValueIterationConsumer valueConsumer); - @NotNull ValueIterationConsumer getConsumer(VoidIterationConsumer voidConsumer); + ValueIterationConsumer getConsumer(VoidIterationConsumer voidConsumer); } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidIteration.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidIteration.java index 43ce76691..22e76ba0b 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidIteration.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidIteration.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.tree.iteration; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; public interface VoidIteration { Object NULL = new Object(); @@ -77,7 +76,7 @@ public interface VoidIteration { * * @param runnable to run */ - void ifIncomplete(@NotNull Runnable runnable); + void ifIncomplete(Runnable runnable); /** * @return times through the loop of the current recursion level, includes skipped elements due to filtering diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidIterationConsumer.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidIterationConsumer.java index ff088d5a7..e05296710 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidIterationConsumer.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidIterationConsumer.java @@ -1,17 +1,16 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; public interface VoidIterationConsumer extends IterationConsumer { - void accept(@NotNull N it, @NotNull VoidIteration loop); + void accept(N it, VoidIteration loop); // before start of all iterations - default void beforeStart(@NotNull VoidIteration iteration) { + default void beforeStart(VoidIteration iteration) { } // iteration is done, before returning - default void afterEnd(@NotNull VoidIteration iteration) { + default void afterEnd(VoidIteration iteration) { } } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidToValueIConsumerAdapter.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidToValueIConsumerAdapter.java index 2389088ec..50084b1ff 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidToValueIConsumerAdapter.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/VoidToValueIConsumerAdapter.java @@ -1,36 +1,35 @@ package com.vladsch.flexmark.tree.iteration; -import org.jetbrains.annotations.NotNull; public class VoidToValueIConsumerAdapter implements ValueIterationConsumer { - final private @NotNull VoidIterationConsumer myConsumer; + final private VoidIterationConsumer myConsumer; - public VoidToValueIConsumerAdapter(@NotNull VoidIterationConsumer consumer) { + public VoidToValueIConsumerAdapter(VoidIterationConsumer consumer) { myConsumer = consumer; } @Override - public void accept(@NotNull N it, @NotNull ValueIteration iteration) { + public void accept(N it, ValueIteration iteration) { myConsumer.accept(it, iteration); } @Override - public void beforeStart(@NotNull ValueIteration iteration) { + public void beforeStart(ValueIteration iteration) { myConsumer.beforeStart(iteration); } @Override - public void startRecursion(@NotNull VoidIteration iteration) { + public void startRecursion(VoidIteration iteration) { myConsumer.startRecursion(iteration); } @Override - public void endRecursion(@NotNull VoidIteration iteration) { + public void endRecursion(VoidIteration iteration) { myConsumer.endRecursion(iteration); } @Override - public void afterEnd(@NotNull ValueIteration iteration) { + public void afterEnd(ValueIteration iteration) { myConsumer.afterEnd(iteration); } } diff --git a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/package-info.java b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/package-info.java index 69f5f98e3..0af9a445f 100644 --- a/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/package-info.java +++ b/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.tree.iteration; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-ast/pom.xml b/flexmark-util-ast/pom.xml index 0103aa170..161f89d61 100644 --- a/flexmark-util-ast/pom.xml +++ b/flexmark-util-ast/pom.xml @@ -43,9 +43,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/AllNodesVisitor.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/AllNodesVisitor.java index 48e3629a8..10cbe218f 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/AllNodesVisitor.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/AllNodesVisitor.java @@ -1,15 +1,14 @@ package com.vladsch.flexmark.util.ast; -import org.jetbrains.annotations.NotNull; public abstract class AllNodesVisitor { - protected abstract void process(@NotNull Node node); + protected abstract void process(Node node); - public void visit(@NotNull Node node) { + public void visit(Node node) { visitChildren(node); } - private void visitChildren(@NotNull Node parent) { + private void visitChildren(Node parent) { Node node = parent.getFirstChild(); while (node != null) { // A subclass of this visitor might modify the node, resulting in getNext returning a different node or no diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlankLine.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlankLine.java index c0c51e3dc..5b3a231af 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlankLine.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlankLine.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public class BlankLine extends Block { private Block claimedBlankLine = null; @@ -17,23 +16,22 @@ public Block getClaimedBlankLine() { } @SuppressWarnings("UnusedReturnValue") - public BlankLine setClaimedBlankLine(@NotNull Block claimedBlankLine) { + public BlankLine setClaimedBlankLine(Block claimedBlankLine) { this.claimedBlankLine = claimedBlankLine; return this; } - public BlankLine(@NotNull BasedSequence chars) { + public BlankLine(BasedSequence chars) { super(chars); setCharsFromContent(); } - public BlankLine(@NotNull BasedSequence chars, @NotNull Block claimedBlankLine) { + public BlankLine(BasedSequence chars, Block claimedBlankLine) { super(chars); setCharsFromContent(); this.claimedBlankLine = claimedBlankLine; } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Block.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Block.java index a9317e071..844471001 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Block.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Block.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.List; @@ -10,15 +9,15 @@ public abstract class Block extends ContentNode { public Block() { } - public Block(@NotNull BasedSequence chars) { + public Block(BasedSequence chars) { super(chars); } - public Block(@NotNull BasedSequence chars, @NotNull List lineSegments) { + public Block(BasedSequence chars, List lineSegments) { super(chars, lineSegments); } - public Block(@NotNull List lineSegments) { + public Block(List lineSegments) { super(lineSegments); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockContent.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockContent.java index f2fd2a694..8cb210239 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockContent.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockContent.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SegmentedSequence; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -12,19 +11,19 @@ public class BlockContent { final private ArrayList lines = new ArrayList<>(); final private ArrayList lineIndents = new ArrayList<>(); - public @NotNull BasedSequence getLine(int line) { + public BasedSequence getLine(int line) { return lines.get(line); } - public @NotNull BasedSequence getSpanningChars() { + public BasedSequence getSpanningChars() { return lines.size() > 0 ? lines.get(0).baseSubSequence(lines.get(0).getStartOffset(), lines.get(lines.size() - 1).getEndOffset()) : BasedSequence.NULL; } - public @NotNull List getLines() { + public List getLines() { return lines; } - public @NotNull List getLineIndents() { + public List getLineIndents() { return lineIndents; } @@ -35,7 +34,7 @@ public int getLineCount() { public BlockContent() { } - public BlockContent(@NotNull BlockContent other, int startLine, int lineIndent) { + public BlockContent(BlockContent other, int startLine, int lineIndent) { // copy content from other assert other.lines.size() == other.lineIndents.size() : "lines and eols should be of the same size"; @@ -61,12 +60,12 @@ public int getSourceLength() { return lines.size() > 0 ? lines.get(lines.size() - 1).getEndOffset() - lines.get(0).getStartOffset() : -1; } - public void add(@NotNull BasedSequence lineWithEOL, int lineIndent) { + public void add(BasedSequence lineWithEOL, int lineIndent) { lines.add(lineWithEOL); lineIndents.add(lineIndent); } - public void addAll(@NotNull List lines, List lineIndents) { + public void addAll(List lines, List lineIndents) { assert lines.size() == lineIndents.size() : "lines and lineIndents should be of the same size"; this.lines.addAll(lines); this.lineIndents.addAll(lineIndents); @@ -76,16 +75,16 @@ public boolean hasSingleLine() { return lines.size() == 1; } - public @NotNull BasedSequence getContents() { + public BasedSequence getContents() { if (lines.size() == 0) return BasedSequence.NULL; return getContents(0, lines.size()); } - public @NotNull BlockContent subContents(int startLine, int endLine) { + public BlockContent subContents(int startLine, int endLine) { return new BlockContent(this, startLine, endLine); } - public @NotNull BasedSequence getContents(int startLine, int endLine) { + public BasedSequence getContents(int startLine, int endLine) { if (lines.size() == 0) return BasedSequence.NULL; if (startLine < 0) { @@ -104,7 +103,7 @@ public boolean hasSingleLine() { return SegmentedSequence.create(lines.get(0), lines.subList(startLine, endLine)); } - public @NotNull String getString() { + public String getString() { if (lines.size() == 0) return ""; StringBuilder sb = new StringBuilder(); diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockNodeVisitor.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockNodeVisitor.java index 884a9ada6..979c06133 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockNodeVisitor.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockNodeVisitor.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.ast; -import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.function.BiConsumer; @@ -16,20 +15,20 @@ public class BlockNodeVisitor extends NodeVisitor { public BlockNodeVisitor() { } - public BlockNodeVisitor(@NotNull VisitHandler... handlers) { + public BlockNodeVisitor(VisitHandler... handlers) { super(handlers); } - public BlockNodeVisitor(@NotNull VisitHandler[]... handlers) { + public BlockNodeVisitor(VisitHandler[]... handlers) { super(handlers); } - public BlockNodeVisitor(@NotNull Collection handlers) { + public BlockNodeVisitor(Collection handlers) { super(handlers); } @Override - public void processNode(@NotNull Node node, boolean withChildren, @NotNull BiConsumer> processor) { + public void processNode(Node node, boolean withChildren, BiConsumer> processor) { if (node instanceof Block) { super.processNode(node, withChildren, processor); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockTracker.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockTracker.java index 9360525cd..633e07a87 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockTracker.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockTracker.java @@ -1,13 +1,12 @@ package com.vladsch.flexmark.util.ast; -import org.jetbrains.annotations.NotNull; public interface BlockTracker { - void blockAdded(@NotNull Block node); - void blockAddedWithChildren(@NotNull Block node); - void blockAddedWithDescendants(@NotNull Block node); + void blockAdded(Block node); + void blockAddedWithChildren(Block node); + void blockAddedWithDescendants(Block node); - void blockRemoved(@NotNull Block node); - void blockRemovedWithChildren(@NotNull Block node); - void blockRemovedWithDescendants(@NotNull Block node); + void blockRemoved(Block node); + void blockRemovedWithChildren(Block node); + void blockRemovedWithDescendants(Block node); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ClassifyingNodeTracker.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ClassifyingNodeTracker.java index e3e2496ea..00ca62cd8 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ClassifyingNodeTracker.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ClassifyingNodeTracker.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.util.collection.iteration.ReversibleIterable; import com.vladsch.flexmark.util.collection.iteration.ReversibleIterator; import com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.BitSet; import java.util.HashMap; @@ -15,13 +14,13 @@ import java.util.Set; public class ClassifyingNodeTracker implements NodeTracker { - protected final @NotNull ClassificationBag, Node> nodeClassifier; + protected final ClassificationBag, Node> nodeClassifier; final private @Nullable NodeTracker host; - final private @NotNull OrderedMap, Set>> exclusionMap; - final private @NotNull OrderedSet> exclusionSet; - final private @NotNull HashMap nodeAncestryMap; + final private OrderedMap, Set>> exclusionMap; + final private OrderedSet> exclusionSet; + final private HashMap nodeAncestryMap; - public ClassifyingNodeTracker(@Nullable NodeTracker host, @NotNull Map, Set>> exclusionMap) { + public ClassifyingNodeTracker(@Nullable NodeTracker host, Map, Set>> exclusionMap) { this.host = host; nodeClassifier = new ClassificationBag<>(NodeClassifier.INSTANCE); this.exclusionMap = new OrderedMap<>(exclusionMap.size()); @@ -37,22 +36,18 @@ public ClassifyingNodeTracker(@Nullable NodeTracker host, @NotNull Map(); } - @NotNull public OrderedMap, Set>> getExclusionMap() { return exclusionMap; } - @NotNull public HashMap getNodeAncestryMap() { return nodeAncestryMap; } - @NotNull public OrderedSet> getExclusionSet() { return exclusionSet; } - @NotNull public ClassificationBag, Node> getNodeClassifier() { return nodeClassifier; } @@ -64,14 +59,14 @@ private void validateLinked(Node node) { } @Override - public void nodeAdded(@NotNull Node node) { + public void nodeAdded(Node node) { validateLinked(node); nodeClassifier.add(node); if (host != null) host.nodeAdded(node); } @Override - public void nodeAddedWithChildren(@NotNull Node node) { + public void nodeAddedWithChildren(Node node) { validateLinked(node); nodeClassifier.add(node); addNodes(node.getChildren()); @@ -79,54 +74,54 @@ public void nodeAddedWithChildren(@NotNull Node node) { } @Override - public void nodeAddedWithDescendants(@NotNull Node node) { + public void nodeAddedWithDescendants(Node node) { validateLinked(node); nodeClassifier.add(node); addNodes(node.getDescendants()); if (host != null) host.nodeAddedWithDescendants(node); } - private void addNodes(@NotNull ReversiblePeekingIterable nodes) { + private void addNodes(ReversiblePeekingIterable nodes) { for (Node child : nodes) { nodeClassifier.add(child); } } - private void validateUnlinked(@NotNull Node node) { + private void validateUnlinked(Node node) { if (!(node.getNext() == null && node.getParent() == null)) { throw new IllegalStateException("Removed block " + node + " is still linked in the AST"); } } @Override - public void nodeRemoved(@NotNull Node node) { + public void nodeRemoved(Node node) { nodeRemovedWithDescendants(node); } @Override - public void nodeRemovedWithChildren(@NotNull Node node) { + public void nodeRemovedWithChildren(Node node) { nodeRemovedWithDescendants(node); } @Override - public void nodeRemovedWithDescendants(@NotNull Node node) { + public void nodeRemovedWithDescendants(Node node) { validateUnlinked(node); nodeClassifier.add(node); removeNodes(node.getDescendants()); if (host != null) host.nodeRemovedWithDescendants(node); } - private void removeNodes(@NotNull ReversiblePeekingIterable nodes) { + private void removeNodes(ReversiblePeekingIterable nodes) { for (Node child : nodes) { nodeClassifier.add(child); } } - public @NotNull OrderedSet getItems() { + public OrderedSet getItems() { return nodeClassifier.getItems(); } - public @NotNull ReversibleIterable getCategoryItems(@NotNull Class nodeClass, @NotNull Set> classes) { + public ReversibleIterable getCategoryItems(Class nodeClass, Set> classes) { return nodeClassifier.getCategoryItems(nodeClass, classes); } } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Content.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Content.java index 40a3a5715..01404a9d9 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Content.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Content.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -9,11 +8,11 @@ * A node that uses delimiters in the source form (e.g. *bold*). */ public interface Content { - @NotNull BasedSequence getSpanningChars(); + BasedSequence getSpanningChars(); int getLineCount(); - @NotNull BasedSequence getLineChars(int index); - @NotNull BasedSequence getContentChars(); - @NotNull BasedSequence getContentChars(int startLine, int endLine); - @NotNull List getContentLines(); - @NotNull List getContentLines(int startLine, int endLine); + BasedSequence getLineChars(int index); + BasedSequence getContentChars(); + BasedSequence getContentChars(int startLine, int endLine); + List getContentLines(); + List getContentLines(int startLine, int endLine); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ContentNode.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ContentNode.java index f1e601985..5a0b75639 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ContentNode.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ContentNode.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SegmentedSequence; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -14,44 +13,44 @@ public ContentNode() { } - public ContentNode(@NotNull BasedSequence chars) { + public ContentNode(BasedSequence chars) { super(chars); } - public ContentNode(@NotNull BasedSequence chars, @NotNull List lineSegments) { + public ContentNode(BasedSequence chars, List lineSegments) { super(chars); this.lineSegments = lineSegments; } - public ContentNode(@NotNull List lineSegments) { + public ContentNode(List lineSegments) { this(getSpanningChars(lineSegments), lineSegments); } - public ContentNode(@NotNull BlockContent blockContent) { + public ContentNode(BlockContent blockContent) { this(blockContent.getSpanningChars(), blockContent.getLines()); } - public void setContent(@NotNull BasedSequence chars, @NotNull List lineSegments) { + public void setContent(BasedSequence chars, List lineSegments) { setChars(chars); this.lineSegments = lineSegments; } - public void setContent(@NotNull List lineSegments) { + public void setContent(List lineSegments) { this.lineSegments = lineSegments; setChars(getSpanningChars()); } - public void setContent(@NotNull BlockContent blockContent) { + public void setContent(BlockContent blockContent) { setChars(blockContent.getSpanningChars()); this.lineSegments = blockContent.getLines(); } @Override - public @NotNull BasedSequence getSpanningChars() { + public BasedSequence getSpanningChars() { return getSpanningChars(lineSegments); } - private static @NotNull BasedSequence getSpanningChars(@NotNull List lineSegments) { + private static BasedSequence getSpanningChars(List lineSegments) { return lineSegments.isEmpty() ? BasedSequence.NULL : lineSegments.get(0).baseSubSequence(lineSegments.get(0).getStartOffset(), lineSegments.get(lineSegments.size() - 1).getEndOffset()); } @@ -60,41 +59,36 @@ public int getLineCount() { return lineSegments.size(); } - @NotNull @Override public BasedSequence getLineChars(int index) { return lineSegments.get(index); } - @NotNull @Override public List getContentLines() { return lineSegments; } - @NotNull @Override public List getContentLines(int startLine, int endLine) { return lineSegments.subList(startLine, endLine); } - @NotNull @Override public BasedSequence getContentChars() { return lineSegments.isEmpty() ? BasedSequence.NULL : SegmentedSequence.create(lineSegments.get(0), lineSegments); } - @NotNull @Override public BasedSequence getContentChars(int startLine, int endLine) { return lineSegments.isEmpty() ? BasedSequence.NULL : SegmentedSequence.create(lineSegments.get(0), getContentLines(startLine, endLine)); } - public void setContentLines(@NotNull List contentLines) { + public void setContentLines(List contentLines) { this.lineSegments = contentLines; } - public void setContentLine(int lineIndex, @NotNull BasedSequence contentLine) { + public void setContentLine(int lineIndex, BasedSequence contentLine) { ArrayList lines = new ArrayList<>(lineSegments); lines.set(lineIndex, contentLine); this.lineSegments = lines; diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/DescendantNodeIterable.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/DescendantNodeIterable.java index fc9d3f9c1..3e47ed496 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/DescendantNodeIterable.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/DescendantNodeIterable.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterable; import com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterator; -import org.jetbrains.annotations.NotNull; public class DescendantNodeIterable implements ReversiblePeekingIterable { private ReversiblePeekingIterable iterable; @@ -12,7 +11,7 @@ public class DescendantNodeIterable implements ReversiblePeekingIterable { * * @param iterable node iterable to use for iterating nodes and their descendants */ - public DescendantNodeIterable(@NotNull ReversiblePeekingIterable iterable) { + public DescendantNodeIterable(ReversiblePeekingIterable iterable) { if (iterable instanceof DescendantNodeIterable) { this.iterable = ((DescendantNodeIterable) iterable).iterable; } else { @@ -20,19 +19,16 @@ public DescendantNodeIterable(@NotNull ReversiblePeekingIterable iterable) } } - @NotNull @Override public ReversiblePeekingIterator iterator() { return new DescendantNodeIterator(iterable.iterator()); } - @NotNull @Override public ReversiblePeekingIterable reversed() { return new DescendantNodeIterable(iterable.reversed()); } - @NotNull @Override public ReversiblePeekingIterator reversedIterator() { return new DescendantNodeIterator(iterable.reversedIterator()); diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/DescendantNodeIterator.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/DescendantNodeIterator.java index a66cc9e8f..949ab9352 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/DescendantNodeIterator.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/DescendantNodeIterator.java @@ -1,15 +1,14 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterator; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Stack; import java.util.function.Consumer; public class DescendantNodeIterator implements ReversiblePeekingIterator { final private boolean isReversed; - private @NotNull ReversiblePeekingIterator iterator; + private ReversiblePeekingIterator iterator; private @Nullable Stack> iteratorStack; private Node result; @@ -18,7 +17,7 @@ public class DescendantNodeIterator implements ReversiblePeekingIterator { * * @param iterator iterator to use for iterating nodes and their descendants */ - public DescendantNodeIterator(@NotNull ReversiblePeekingIterator iterator) { + public DescendantNodeIterator(ReversiblePeekingIterator iterator) { this.isReversed = iterator.isReversed(); this.iterator = iterator instanceof DescendantNodeIterator ? ((DescendantNodeIterator) iterator).iterator : iterator; this.iteratorStack = null; @@ -36,7 +35,7 @@ public boolean hasNext() { } @Override - public @NotNull Node next() { + public Node next() { result = iterator.next(); if (result.getFirstChild() != null) { @@ -72,7 +71,7 @@ public void remove() { result = null; } - public void forEachRemaining(@NotNull Consumer consumer) { + public void forEachRemaining(Consumer consumer) { while (hasNext()) { consumer.accept(next()); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Document.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Document.java index b9d910a33..668416c02 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Document.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Document.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.data.*; import com.vladsch.flexmark.util.misc.Utils; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.Map; @@ -17,7 +16,7 @@ public class Document extends Block implements MutableDataHolder { final private MutableDataSet dataSet; @Override - public @NotNull BasedSequence[] getSegments() { + public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @@ -27,71 +26,57 @@ public Document(DataHolder options, BasedSequence chars) { } @Override - public @NotNull MutableDataHolder clear() { + public MutableDataHolder clear() { throw new UnsupportedOperationException(); } - @NotNull @Override - public MutableDataHolder set(@NotNull DataKey key, @NotNull T value) {return dataSet.set(key, value);} + public MutableDataHolder set(DataKey key, T value) {return dataSet.set(key, value);} - @NotNull @Override - public MutableDataHolder set(@NotNull NullableDataKey key, @Nullable T value) {return dataSet.set(key, value);} + public MutableDataHolder set(NullableDataKey key, @Nullable T value) {return dataSet.set(key, value);} - @NotNull @Override - public MutableDataSet setFrom(@NotNull MutableDataSetter dataSetter) {return dataSet.setFrom(dataSetter);} + public MutableDataSet setFrom(MutableDataSetter dataSetter) {return dataSet.setFrom(dataSetter);} - @NotNull @Override - public MutableDataSet setAll(@NotNull DataHolder other) {return dataSet.setAll(other);} + public MutableDataSet setAll(DataHolder other) {return dataSet.setAll(other);} public static MutableDataSet merge(DataHolder... dataHolders) {return MutableDataSet.merge(dataHolders);} - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) {return dataSet.setIn(dataHolder);} + public MutableDataHolder setIn(MutableDataHolder dataHolder) {return dataSet.setIn(dataHolder);} - @NotNull @Override - public MutableDataSet remove(@NotNull DataKeyBase key) {return dataSet.remove(key);} + public MutableDataSet remove(DataKeyBase key) {return dataSet.remove(key);} @Override @Nullable - public Object getOrCompute(@NotNull DataKeyBase key, @NotNull DataValueFactory factory) {return dataSet.getOrCompute(key, factory);} + public Object getOrCompute(DataKeyBase key, DataValueFactory factory) {return dataSet.getOrCompute(key, factory);} @Override - @NotNull public MutableDataSet toMutable() {return dataSet.toMutable();} @Override - @NotNull public DataSet toImmutable() {return dataSet.toImmutable();} @Override - @NotNull public MutableDataSet toDataSet() {return dataSet.toDataSet();} - @NotNull - public static DataHolder aggregateActions(@NotNull DataHolder other, @NotNull DataHolder overrides) {return DataSet.aggregateActions(other, overrides);} + public static DataHolder aggregateActions(DataHolder other, DataHolder overrides) {return DataSet.aggregateActions(other, overrides);} - @NotNull public DataHolder aggregate() {return dataSet.aggregate();} - @NotNull public static DataHolder aggregate(@Nullable DataHolder other, @Nullable DataHolder overrides) {return DataSet.aggregate(other, overrides);} @Override - @NotNull public Map, Object> getAll() {return dataSet.getAll();} @Override - @NotNull public Collection> getKeys() {return dataSet.getKeys();} @Override - public boolean contains(@NotNull DataKeyBase key) {return dataSet.contains(key);} + public boolean contains(DataKeyBase key) {return dataSet.contains(key);} @Override public int getLineCount() { diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/IParse.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/IParse.java index 78f039dbd..e111adbd7 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/IParse.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/IParse.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.IOException; import java.io.Reader; @@ -20,7 +19,7 @@ public interface IParse { * @param input the text to parse * @return the root node */ - @NotNull Node parse(@NotNull BasedSequence input); + Node parse(BasedSequence input); /** * Parse the specified input text into a tree of nodes. @@ -30,7 +29,7 @@ public interface IParse { * @param input the text to parse * @return the root node */ - @NotNull Node parse(@NotNull String input); + Node parse(String input); /** * Parse the specified reader into a tree of nodes. The caller is responsible for closing the reader. @@ -41,7 +40,7 @@ public interface IParse { * @return the root node * @throws IOException when reading throws an exception */ - @NotNull Node parseReader(@NotNull Reader input) throws IOException; + Node parseReader(Reader input) throws IOException; /** * Get Options for parsing @@ -60,5 +59,5 @@ public interface IParse { * null to use repository's KEEP_TYPE to make the determination (if KEEP_FIRST then only transfer if undefined, * @return true if any references were transferred */ - boolean transferReferences(@NotNull Document document, @NotNull Document included, @Nullable Boolean onlyIfUndefined); + boolean transferReferences(Document document, Document included, @Nullable Boolean onlyIfUndefined); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/IRender.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/IRender.java index 64b3c0024..ed79a3d7e 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/IRender.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/IRender.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * Render interface for rendering implementation for RenderingTestCase @@ -10,7 +9,7 @@ public interface IRender { // CAUTION: the reason this is not a Document, which it always is in practice is for tests which generate // a fake NODE and generating a fake Document (unless made into an interface and without extras) would be too difficult - void render(@NotNull Node document, @NotNull Appendable output); + void render(Node document, Appendable output); /** * Render the tree of nodes to HTML. @@ -18,8 +17,7 @@ public interface IRender { * @param document the root node * @return the rendered HTML */ - @NotNull - default String render(@NotNull Node document) { + default String render(Node document) { StringBuilder sb = new StringBuilder(); render(document, sb); return sb.toString(); diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Node.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Node.java index 167efc6ca..1e58953c1 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Node.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Node.java @@ -9,8 +9,7 @@ import com.vladsch.flexmark.util.sequence.SegmentedSequence; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; import com.vladsch.flexmark.util.visitor.AstNode; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; @@ -20,12 +19,12 @@ public abstract class Node { final public static AstNode AST_ADAPTER = new AstNode() { @Override - public @Nullable Node getFirstChild(@NotNull Node node) { + public @Nullable Node getFirstChild(Node node) { return node.firstChild; } @Override - public @Nullable Node getNext(@NotNull Node node) { + public @Nullable Node getNext(Node node) { return node.next; } }; @@ -35,12 +34,12 @@ public abstract class Node { private @Nullable Node lastChild = null; private @Nullable Node prev = null; @Nullable Node next = null; - private @NotNull BasedSequence chars = BasedSequence.NULL; + private BasedSequence chars = BasedSequence.NULL; public Node() { } - public Node(@NotNull BasedSequence chars) { + public Node(BasedSequence chars) { this.chars = chars; } @@ -67,7 +66,7 @@ public Node(@NotNull BasedSequence chars) { public Pair getLineColumnAtEnd() { return chars.baseLineColumnAtEnd(); } // @formatter:on - public @Nullable Node getAncestorOfType(@NotNull Class... classes) { + public @Nullable Node getAncestorOfType(Class... classes) { Node parent = getParent(); while (parent != null) { for (Class nodeType : classes) { @@ -78,7 +77,7 @@ public Node(@NotNull BasedSequence chars) { return null; } - public int countAncestorsOfType(@NotNull Class... classes) { + public int countAncestorsOfType(Class... classes) { Node parent = getParent(); int count = 0; while (parent != null) { @@ -93,7 +92,7 @@ public int countAncestorsOfType(@NotNull Class... classes) { return count; } - public int countDirectAncestorsOfType(@Nullable Class skip, @NotNull Class... classes) { + public int countDirectAncestorsOfType(@Nullable Class skip, Class... classes) { Node parent = getParent(); int count = 0; while (parent != null) { @@ -117,7 +116,7 @@ public int countDirectAncestorsOfType(@Nullable Class skip, @NotNull Class return count; } - public @Nullable Node getOldestAncestorOfTypeAfter(@NotNull Class ancestor, @NotNull Class after) { + public @Nullable Node getOldestAncestorOfTypeAfter(Class ancestor, Class after) { Node parent = getParent(); Node oldestAncestor = null; while (parent != null) { @@ -128,7 +127,7 @@ public int countDirectAncestorsOfType(@Nullable Class skip, @NotNull Class return oldestAncestor; } - public @Nullable Node getChildOfType(@NotNull Class... classes) { + public @Nullable Node getChildOfType(Class... classes) { Node child = getFirstChild(); while (child != null) { for (Class nodeType : classes) { @@ -139,7 +138,7 @@ public int countDirectAncestorsOfType(@Nullable Class skip, @NotNull Class return null; } - public static int getNodeOfTypeIndex(@NotNull Node node, @NotNull Class... classes) { + public static int getNodeOfTypeIndex(Node node, Class... classes) { int i = 0; for (Class nodeType : classes) { if (nodeType.isInstance(node)) return i; @@ -149,7 +148,7 @@ public static int getNodeOfTypeIndex(@NotNull Node node, @NotNull Class... cl } @SuppressWarnings("BooleanMethodIsAlwaysInverted") - public boolean isOrDescendantOfType(@NotNull Class... classes) { + public boolean isOrDescendantOfType(Class... classes) { Node node = this; while (node != null) { if (node.getNodeOfTypeIndex(classes) != -1) return true; @@ -158,7 +157,7 @@ public boolean isOrDescendantOfType(@NotNull Class... classes) { return false; } - public int getNodeOfTypeIndex(@NotNull Class... classes) { + public int getNodeOfTypeIndex(Class... classes) { return Node.getNodeOfTypeIndex(this, classes); } @@ -171,42 +170,42 @@ public int getNodeOfTypeIndex(@NotNull Class... classes) { return null; } - public @NotNull ReversiblePeekingIterable getChildren() { + public ReversiblePeekingIterable getChildren() { if (firstChild == null) { return NodeIterable.EMPTY; } return new NodeIterable(firstChild, lastChild, false); } - public @NotNull ReversiblePeekingIterable getReversedChildren() { + public ReversiblePeekingIterable getReversedChildren() { if (firstChild == null) { return NodeIterable.EMPTY; } return new NodeIterable(firstChild, lastChild, true); } - public @NotNull ReversiblePeekingIterable getDescendants() { + public ReversiblePeekingIterable getDescendants() { if (firstChild == null) { return NodeIterable.EMPTY; } return new DescendantNodeIterable(getChildren()); } - public @NotNull ReversiblePeekingIterable getReversedDescendants() { + public ReversiblePeekingIterable getReversedDescendants() { if (firstChild == null) { return NodeIterable.EMPTY; } return new DescendantNodeIterable(getReversedChildren()); } - public @NotNull ReversiblePeekingIterator getChildIterator() { + public ReversiblePeekingIterator getChildIterator() { if (firstChild == null) { return NodeIterator.EMPTY; } return new NodeIterator(firstChild, lastChild, false); } - public @NotNull ReversiblePeekingIterator getReversedChildIterator() { + public ReversiblePeekingIterator getReversedChildIterator() { if (firstChild == null) { return NodeIterator.EMPTY; } @@ -214,7 +213,7 @@ public int getNodeOfTypeIndex(@NotNull Class... classes) { } // full document char sequence - public @NotNull BasedSequence getChars() { + public BasedSequence getChars() { return chars; } @@ -242,7 +241,7 @@ public boolean hasOrMoreChildren(int childCount) { return false; } - public @NotNull Document getDocument() { + public Document getDocument() { Node node = this; while (node != null && !(node instanceof Document)) { node = node.getParent(); @@ -251,7 +250,7 @@ public boolean hasOrMoreChildren(int childCount) { return (Document) node; } - public void setChars(@NotNull BasedSequence chars) { + public void setChars(BasedSequence chars) { this.chars = chars; } @@ -260,7 +259,6 @@ public Node getNext() { return next; } - @NotNull public Node getLastInChain() { Node lastNode = this; while (this.getClass().isInstance(lastNode.getNext())) lastNode = lastNode.getNext(); @@ -271,11 +269,11 @@ public Node getLastInChain() { return prev; } - public void extractToFirstInChain(@NotNull Node node) { + public void extractToFirstInChain(Node node) { getFirstInChain().extractChainTo(node); } - public void extractChainTo(@NotNull Node node) { + public void extractChainTo(Node node) { Node lastNode = this; do { Node next = lastNode.getNext(); @@ -284,13 +282,13 @@ public void extractChainTo(@NotNull Node node) { } while (this.getClass().isInstance(lastNode)); } - public @NotNull Node getFirstInChain() { + public Node getFirstInChain() { Node lastNode = this; while (this.getClass().isInstance(lastNode.getPrevious())) lastNode = lastNode.getPrevious(); return lastNode; } - public @Nullable Node getPreviousAnyNot(@NotNull Class... classes) { + public @Nullable Node getPreviousAnyNot(Class... classes) { Node node = prev; if (classes.length > 0) { while (node != null && getNodeOfTypeIndex(node, classes) != -1) { @@ -300,7 +298,7 @@ public void extractChainTo(@NotNull Node node) { return node; } - public @Nullable Node getPreviousAny(@NotNull Class... classes) { + public @Nullable Node getPreviousAny(Class... classes) { Node node = prev; if (classes.length > 0) { while (node != null && getNodeOfTypeIndex(node, classes) == -1) { @@ -310,7 +308,7 @@ public void extractChainTo(@NotNull Node node) { return node; } - public @Nullable Node getNextAnyNot(@NotNull Class... classes) { + public @Nullable Node getNextAnyNot(Class... classes) { Node node = next; if (classes.length > 0) { while (node != null && getNodeOfTypeIndex(node, classes) != -1) { @@ -320,7 +318,7 @@ public void extractChainTo(@NotNull Node node) { return node; } - public @Nullable Node getNextAny(@NotNull Class... classes) { + public @Nullable Node getNextAny(Class... classes) { Node node = next; if (classes.length > 0) { while (node != null && getNodeOfTypeIndex(node, classes) == -1) { @@ -334,7 +332,7 @@ public void extractChainTo(@NotNull Node node) { return firstChild; } - public @Nullable Node getFirstChildAnyNot(@NotNull Class... classes) { + public @Nullable Node getFirstChildAnyNot(Class... classes) { Node node = firstChild; if (classes.length > 0) { while (node != null && getNodeOfTypeIndex(node, classes) != -1) { @@ -344,7 +342,7 @@ public void extractChainTo(@NotNull Node node) { return node; } - public @Nullable Node getFirstChildAny(@NotNull Class... classes) { + public @Nullable Node getFirstChildAny(Class... classes) { Node node = firstChild; if (classes.length > 0) { while (node != null && getNodeOfTypeIndex(node, classes) == -1) { @@ -358,7 +356,7 @@ public void extractChainTo(@NotNull Node node) { return lastChild; } - public @Nullable Node getLastChildAnyNot(@NotNull Class... classes) { + public @Nullable Node getLastChildAnyNot(Class... classes) { Node node = lastChild; if (classes.length > 0) { while (node != null && getNodeOfTypeIndex(node, classes) != -1) { @@ -368,7 +366,7 @@ public void extractChainTo(@NotNull Node node) { return node; } - public @Nullable Node getLastChildAny(@NotNull Class... classes) { + public @Nullable Node getLastChildAny(Class... classes) { Node node = lastChild; if (classes.length > 0) { while (node != null && getNodeOfTypeIndex(node, classes) == -1) { @@ -403,7 +401,7 @@ public void appendChild(Node child) { } } - public void prependChild(@NotNull Node child) { + public void prependChild(Node child) { child.unlink(); child.setParent(this); if (this.firstChild != null) { @@ -432,7 +430,7 @@ public void unlink() { this.prev = null; } - public void insertAfter(@NotNull Node sibling) { + public void insertAfter(Node sibling) { sibling.unlink(); sibling.next = this.next; @@ -469,11 +467,11 @@ public String toString() { return getClass().getName().substring(getClass().getPackage().getName().length() + 1) + "{" + toStringAttributes() + "}"; } - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { } - public void astExtraChars(@NotNull StringBuilder out) { + public void astExtraChars(StringBuilder out) { if (getChars().length() > 0) { if (getChars().length() <= 10) { segmentSpanChars(out, getChars(), "chars"); @@ -484,7 +482,7 @@ public void astExtraChars(@NotNull StringBuilder out) { } } - public static void astChars(@NotNull StringBuilder out, @NotNull CharSequence chars, @NotNull String name) { + public static void astChars(StringBuilder out, CharSequence chars, String name) { if (chars.length() > 0) { if (chars.length() <= 10) { out.append(' ').append(name).append(" \"").append(chars).append("\""); @@ -495,16 +493,13 @@ public static void astChars(@NotNull StringBuilder out, @NotNull CharSequence ch } } - @NotNull protected String toStringAttributes() { return ""; } - @NotNull public abstract BasedSequence[] getSegments(); - @NotNull - public static BasedSequence getLeadSegment(@NotNull BasedSequence[] segments) { + public static BasedSequence getLeadSegment(BasedSequence[] segments) { for (BasedSequence segment : segments) { if (segment != BasedSequence.NULL) return segment; } @@ -512,7 +507,6 @@ public static BasedSequence getLeadSegment(@NotNull BasedSequence[] segments) { return BasedSequence.NULL; } - @NotNull public static BasedSequence getTrailSegment(BasedSequence[] segments) { int iMax = segments.length; @@ -524,7 +518,6 @@ public static BasedSequence getTrailSegment(BasedSequence[] segments) { return BasedSequence.NULL; } - @NotNull public static BasedSequence spanningChars(BasedSequence... segments) { int startOffset = Integer.MAX_VALUE; int endOffset = -1; @@ -602,23 +595,23 @@ public void setCharsFromContent() { } } - public static void segmentSpan(@NotNull StringBuilder out, int startOffset, int endOffset, @Nullable String name) { + public static void segmentSpan(StringBuilder out, int startOffset, int endOffset, @Nullable String name) { if (name != null && !name.trim().isEmpty()) out.append(" ").append(name).append(":"); out.append("[").append(startOffset).append(", ").append(endOffset).append("]"); } - public static void segmentSpanChars(@NotNull StringBuilder out, int startOffset, int endOffset, @Nullable String name, @NotNull String chars) { + public static void segmentSpanChars(StringBuilder out, int startOffset, int endOffset, @Nullable String name, String chars) { segmentSpanChars(out, startOffset, endOffset, name, chars, "", ""); } public static void segmentSpanChars( - @NotNull StringBuilder out, + StringBuilder out, int startOffset, int endOffset, @Nullable String name, - @NotNull String chars1, - @NotNull String splice, - @NotNull String chars2 + String chars1, + String splice, + String chars2 ) { if (name != null && !name.trim().isEmpty()) out.append(" ").append(name).append(":"); out.append("[").append(startOffset).append(", ").append(endOffset); @@ -632,16 +625,16 @@ public static void segmentSpanChars( out.append("]"); } - public static void segmentSpan(@NotNull StringBuilder out, @NotNull BasedSequence sequence, @Nullable String name) { + public static void segmentSpan(StringBuilder out, BasedSequence sequence, @Nullable String name) { if (sequence.isNotNull()) segmentSpan(out, sequence.getStartOffset(), sequence.getEndOffset(), name); } - public static void segmentSpanChars(@NotNull StringBuilder out, @NotNull BasedSequence sequence, @NotNull String name) { + public static void segmentSpanChars(StringBuilder out, BasedSequence sequence, String name) { if (sequence.isNotNull()) segmentSpanChars(out, sequence.getStartOffset(), sequence.getEndOffset(), name, sequence.toString()); } - public static void segmentSpanCharsToVisible(@NotNull StringBuilder out, @NotNull BasedSequence sequence, @NotNull String name) { + public static void segmentSpanCharsToVisible(StringBuilder out, BasedSequence sequence, String name) { if (sequence.isNotNull()) { if (sequence.length() <= 10) { segmentSpanChars(out, sequence.getStartOffset(), sequence.getEndOffset(), name, sequence.toVisibleWhitespaceString()); @@ -653,11 +646,11 @@ public static void segmentSpanCharsToVisible(@NotNull StringBuilder out, @NotNul } public static void delimitedSegmentSpan( - @NotNull StringBuilder out, - @NotNull BasedSequence openingSequence, - @NotNull BasedSequence sequence, - @NotNull BasedSequence closingSequence, - @NotNull String name + StringBuilder out, + BasedSequence openingSequence, + BasedSequence sequence, + BasedSequence closingSequence, + String name ) { segmentSpanChars(out, openingSequence.getStartOffset(), openingSequence.getEndOffset(), name + "Open", openingSequence.toString()); if (sequence.length() <= 10) { @@ -670,11 +663,11 @@ public static void delimitedSegmentSpan( } public static void delimitedSegmentSpanChars( - @NotNull StringBuilder out, - @NotNull BasedSequence openingSequence, - @NotNull BasedSequence sequence, - @NotNull BasedSequence closingSequence, - @NotNull String name + StringBuilder out, + BasedSequence openingSequence, + BasedSequence sequence, + BasedSequence closingSequence, + String name ) { if (openingSequence.isNotNull()) segmentSpanChars(out, openingSequence.getStartOffset(), openingSequence.getEndOffset(), name + "Open", openingSequence.toString()); @@ -684,7 +677,7 @@ public static void delimitedSegmentSpanChars( segmentSpanChars(out, closingSequence.getStartOffset(), closingSequence.getEndOffset(), name + "Close", closingSequence.toString()); } - public void takeChildren(@NotNull Node node) { + public void takeChildren(Node node) { if (node.firstChild != null) { Node firstChild = node.firstChild; Node lastChild = node.lastChild; @@ -712,23 +705,23 @@ public void takeChildren(@NotNull Node node) { } } - public @NotNull String getNodeName() { + public String getNodeName() { return getClass().getName().substring(getClass().getPackage().getName().length() + 1); } - public void astString(@NotNull StringBuilder out, boolean withExtra) { + public void astString(StringBuilder out, boolean withExtra) { out.append(getNodeName()); out.append("[").append(getStartOffset()).append(", ").append(getEndOffset()).append("]"); if (withExtra) getAstExtra(out); } - public @NotNull String toAstString(boolean withExtra) { + public String toAstString(boolean withExtra) { StringBuilder sb = new StringBuilder(); astString(sb, withExtra); return sb.toString(); } - public static @NotNull String toSegmentSpan(@NotNull BasedSequence sequence, @Nullable String name) { + public static String toSegmentSpan(BasedSequence sequence, @Nullable String name) { StringBuilder out = new StringBuilder(); segmentSpan(out, sequence, name); return out.toString(); @@ -760,7 +753,7 @@ public BasedSequence getExactChildChars() { return segments.toSequence(); } - public @NotNull Node getBlankLineSibling() { + public Node getBlankLineSibling() { // need to find the first node that can contain a blank line that is not the last non-blank line of its parent assert parent != null; @@ -820,7 +813,7 @@ public int getEndLineNumber() { * * @return array of segments */ - public @NotNull BasedSequence[] getSegmentsForChars() { + public BasedSequence[] getSegmentsForChars() { return getSegments(); } @@ -831,8 +824,8 @@ public int getEndLineNumber() { * * @return concatenated string of all segments */ - public @NotNull BasedSequence getCharsFromSegments() { - @NotNull BasedSequence[] segments = getSegmentsForChars(); + public BasedSequence getCharsFromSegments() { + BasedSequence[] segments = getSegmentsForChars(); return segments.length == 0 ? BasedSequence.NULL : SegmentedSequence.create(segments[0], Arrays.asList(segments)); } @@ -850,7 +843,7 @@ public void setCharsFromSegments() { * * @param firstNode first child in chain */ - public void appendChain(@NotNull Node firstNode) { + public void appendChain(Node firstNode) { Node node = firstNode; while (node != null) { Node next = node.next; @@ -864,7 +857,7 @@ public void appendChain(@NotNull Node firstNode) { * * @param firstNode first child in chain */ - public void insertChainAfter(@NotNull Node firstNode) { + public void insertChainAfter(Node firstNode) { Node posNode = this; Node node = firstNode; while (node != null) { @@ -880,7 +873,7 @@ public void insertChainAfter(@NotNull Node firstNode) { * * @param firstNode first child in chain */ - public void insertChainBefore(@NotNull Node firstNode) { + public void insertChainBefore(Node firstNode) { Node posNode = this; Node node = firstNode; while (node != null) { diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeClassifier.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeClassifier.java index 15220abbd..159ebb936 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeClassifier.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeClassifier.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.ast; -import org.jetbrains.annotations.NotNull; import java.util.function.Function; @@ -11,7 +10,7 @@ private NodeClassifier() { } @Override - public @NotNull Class apply(@NotNull Node value) { + public Class apply(Node value) { return value.getClass(); } } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeClassifierVisitor.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeClassifierVisitor.java index bc4e540d4..06487cec6 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeClassifierVisitor.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeClassifierVisitor.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.collection.CopyOnWriteRef; import com.vladsch.flexmark.util.collection.OrderedMap; import com.vladsch.flexmark.util.collection.OrderedSet; -import org.jetbrains.annotations.NotNull; import java.util.*; @@ -26,7 +25,7 @@ public NodeClassifierVisitor(Map, Set>> exclusion exclusionSet = classifyingNodeTracker.getExclusionSet(); } - public @NotNull ClassifyingNodeTracker classify(@NotNull Node node) { + public ClassifyingNodeTracker classify(Node node) { // no double dipping assert !isClassificationDone; visit(node); @@ -35,20 +34,20 @@ public NodeClassifierVisitor(Map, Set>> exclusion } @Override - public void visit(@NotNull Node node) { + public void visit(Node node) { visitChildren(node); } // @formatter:off - @Override public void nodeRemoved(@NotNull Node node) { } - @Override public void nodeRemovedWithChildren(@NotNull Node node) { } - @Override public void nodeRemovedWithDescendants(@NotNull Node node) { } - @Override public void nodeAddedWithChildren(@NotNull Node node) { nodeAdded(node); } - @Override public void nodeAddedWithDescendants(@NotNull Node node) { nodeAdded(node); } + @Override public void nodeRemoved(Node node) { } + @Override public void nodeRemovedWithChildren(Node node) { } + @Override public void nodeRemovedWithDescendants(Node node) { } + @Override public void nodeAddedWithChildren(Node node) { nodeAdded(node); } + @Override public void nodeAddedWithDescendants(Node node) { nodeAdded(node); } // @formatter:on @Override - public void nodeAdded(@NotNull Node node) { + public void nodeAdded(Node node) { if (isClassificationDone) { if (node.getParent() == null) { throw new IllegalStateException("Node must be inserted into the document before calling node tracker nodeAdded functions"); @@ -134,7 +133,7 @@ boolean updateNodeAncestry(Node node, CopyOnWriteRef nodeAncestryBitSet) * @param parent the parent node whose children should be visited */ @Override - public void visitChildren(@NotNull Node parent) { + public void visitChildren(Node parent) { if (!isClassificationDone) { // initial collection phase if (!(parent instanceof Document)) { diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeCollectingVisitor.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeCollectingVisitor.java index a2b20634c..e053fe71d 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeCollectingVisitor.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeCollectingVisitor.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.collection.ClassificationBag; import com.vladsch.flexmark.util.collection.SubClassingBag; -import org.jetbrains.annotations.NotNull; import java.util.*; import java.util.function.Function; @@ -11,13 +10,13 @@ public class NodeCollectingVisitor { final public static Function> NODE_CLASSIFIER = Node::getClass; final private static Class[] EMPTY_CLASSES = new Class[0]; - final private @NotNull HashMap, List>> subClassMap; - final private @NotNull HashSet> included; - final private @NotNull HashSet> excluded; - final private @NotNull ClassificationBag, Node> nodes; - final private @NotNull Class[] classes; + final private HashMap, List>> subClassMap; + final private HashSet> included; + final private HashSet> excluded; + final private ClassificationBag, Node> nodes; + final private Class[] classes; - public NodeCollectingVisitor(@NotNull Set> classes) { + public NodeCollectingVisitor(Set> classes) { this.classes = classes.toArray(EMPTY_CLASSES); subClassMap = new HashMap<>(); @@ -34,7 +33,7 @@ public NodeCollectingVisitor(@NotNull Set> classes) { nodes = new ClassificationBag<>(NODE_CLASSIFIER); } - public void collect(@NotNull Node node) { + public void collect(Node node) { visit(node); } @@ -42,7 +41,7 @@ public SubClassingBag getSubClassingBag() { return new SubClassingBag<>(nodes, subClassMap); } - private void visit(@NotNull Node node) { + private void visit(Node node) { Class nodeClass = node.getClass(); if (included.contains(nodeClass)) { nodes.add(node); @@ -74,7 +73,7 @@ private void visit(@NotNull Node node) { visitChildren(node); } - private void visitChildren(@NotNull Node parent) { + private void visitChildren(Node parent) { Node node = parent.getFirstChild(); while (node != null) { // A subclass of this visitor might modify the node, resulting in getNext returning a different node or no diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterable.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterable.java index c3787da3f..cb8ff75e2 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterable.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterable.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.collection.iteration.ReversibleIterator; import com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterable; import com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterator; -import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; @@ -18,7 +17,6 @@ public NodeIterable(Node firstNode, Node lastNode, boolean reversed) { this.reversed = reversed; } - @NotNull @Override public ReversiblePeekingIterator iterator() { return new NodeIterator(firstNode, lastNode, reversed); @@ -31,7 +29,6 @@ public void forEach(Consumer consumer) { } } - @NotNull @Override public ReversiblePeekingIterable reversed() { return new NodeIterable(firstNode, lastNode, !reversed); @@ -42,20 +39,17 @@ public boolean isReversed() { return reversed; } - @NotNull @Override public ReversiblePeekingIterator reversedIterator() { return new NodeIterator(firstNode, lastNode, !reversed); } final public static ReversiblePeekingIterable EMPTY = new ReversiblePeekingIterable() { - @NotNull @Override public ReversiblePeekingIterator iterator() { return NodeIterator.EMPTY; } - @NotNull @Override public ReversiblePeekingIterable reversed() { return this; @@ -70,7 +64,6 @@ public boolean isReversed() { return false; } - @NotNull @Override public ReversiblePeekingIterator reversedIterator() { return NodeIterator.EMPTY; diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterator.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterator.java index 9e08684cd..1bd5e383e 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterator.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterator.java @@ -1,7 +1,7 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.collection.iteration.ReversiblePeekingIterator; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.NoSuchElementException; import java.util.function.Consumer; diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeRepository.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeRepository.java index 8bb080985..4e6be90f6 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeRepository.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeRepository.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.data.DataKey; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; import java.util.function.Consumer; @@ -12,14 +11,14 @@ public abstract class NodeRepository implements Map { protected final Map nodeMap = new HashMap<>(); protected final KeepType keepType; - public abstract @NotNull DataKey> getDataKey(); - public abstract @NotNull DataKey getKeepDataKey(); + public abstract DataKey> getDataKey(); + public abstract DataKey getKeepDataKey(); // function implementing extraction of referenced elements by given node or its children - public abstract @NotNull Set getReferencedElements(Node parent); + public abstract Set getReferencedElements(Node parent); @SafeVarargs - protected final void visitNodes(@NotNull Node parent, @NotNull Consumer runnable, @NotNull Class... classes) { + protected final void visitNodes(Node parent, Consumer runnable, Class... classes) { NodeVisitor visitor = new NodeVisitor(); for (Class clazz : classes) { visitor.addHandler(new VisitHandler<>(clazz, runnable::accept)); @@ -31,23 +30,23 @@ public NodeRepository(@Nullable KeepType keepType) { this.keepType = keepType == null ? KeepType.LOCKED : keepType; } - public @NotNull String normalizeKey(@NotNull CharSequence key) { + public String normalizeKey(CharSequence key) { return key.toString(); } - public @Nullable T getFromRaw(@NotNull CharSequence rawKey) { + public @Nullable T getFromRaw(CharSequence rawKey) { return nodeMap.get(normalizeKey(rawKey)); } - public @Nullable T putRawKey(@NotNull CharSequence key, @NotNull T t) { + public @Nullable T putRawKey(CharSequence key, T t) { return put(normalizeKey(key), t); } - public @NotNull Collection getValues() { + public Collection getValues() { return nodeMap.values(); } - public static boolean transferReferences(@NotNull NodeRepository destination, @NotNull NodeRepository included, boolean onlyIfUndefined, @Nullable Map referenceIdMap) { + public static boolean transferReferences(NodeRepository destination, NodeRepository included, boolean onlyIfUndefined, @Nullable Map referenceIdMap) { // copy references but only if they are not defined in the original document boolean transferred = false; for (Map.Entry entry : included.entrySet()) { @@ -65,7 +64,7 @@ public static boolean transferReferences(@NotNull NodeRepository destinat } @Override - public @Nullable T put(@NotNull String s, @NotNull T t) { + public @Nullable T put(String s, T t) { nodeList.add(t); if (keepType == KeepType.LOCKED) throw new IllegalStateException("Not allowed to modify LOCKED repository"); @@ -80,7 +79,7 @@ public static boolean transferReferences(@NotNull NodeRepository destinat } @Override - public void putAll(@NotNull Map map) { + public void putAll(Map map) { if (keepType == KeepType.LOCKED) throw new IllegalStateException("Not allowed to modify LOCKED repository"); if (keepType != KeepType.LAST) { for (String key : map.keySet()) { @@ -92,7 +91,7 @@ public void putAll(@NotNull Map map) { } @Override - public @Nullable T remove(@NotNull Object o) { + public @Nullable T remove(Object o) { if (keepType == KeepType.LOCKED) throw new IllegalStateException("Not allowed to modify LOCKED repository"); return nodeMap.remove(o); } @@ -110,23 +109,20 @@ public void clear() { public boolean isEmpty() {return nodeMap.isEmpty();} @Override - public boolean containsKey(@NotNull Object o) {return nodeMap.containsKey(o);} + public boolean containsKey(Object o) {return nodeMap.containsKey(o);} @Override public boolean containsValue(Object o) {return nodeMap.containsValue(o);} @Override - public @Nullable T get(@NotNull Object o) {return nodeMap.get(o);} + public @Nullable T get(Object o) {return nodeMap.get(o);} - @NotNull @Override public Set keySet() {return nodeMap.keySet();} - @NotNull @Override public List values() {return nodeList;} - @NotNull @Override public Set> entrySet() {return nodeMap.entrySet();} diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeTracker.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeTracker.java index 128a53db5..1c6f887e5 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeTracker.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeTracker.java @@ -1,13 +1,12 @@ package com.vladsch.flexmark.util.ast; -import org.jetbrains.annotations.NotNull; public interface NodeTracker { - void nodeAdded(@NotNull Node node); - void nodeAddedWithChildren(@NotNull Node node); - void nodeAddedWithDescendants(@NotNull Node node); + void nodeAdded(Node node); + void nodeAddedWithChildren(Node node); + void nodeAddedWithDescendants(Node node); - void nodeRemoved(@NotNull Node node); - void nodeRemovedWithChildren(@NotNull Node node); - void nodeRemovedWithDescendants(@NotNull Node node); + void nodeRemoved(Node node); + void nodeRemovedWithChildren(Node node); + void nodeRemovedWithDescendants(Node node); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitHandler.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitHandler.java index 54a2af8de..90c2842bf 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitHandler.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitHandler.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.ast; -import org.jetbrains.annotations.NotNull; /** * Interface to visit variations on specific nodes: @@ -9,6 +8,6 @@ * visitChildren() visit node's children */ public interface NodeVisitHandler extends Visitor { - void visitNodeOnly(@NotNull Node node); - void visitChildren(@NotNull Node parent); + void visitNodeOnly(Node node); + void visitChildren(Node parent); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitor.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitor.java index 286948505..5d16ddb88 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitor.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitor.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.visitor.AstActionHandler; -import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -70,63 +69,63 @@ public NodeVisitor() { super(Node.AST_ADAPTER); } - public NodeVisitor(@NotNull VisitHandler... handlers) { + public NodeVisitor(VisitHandler... handlers) { super(Node.AST_ADAPTER); super.addActionHandlers(handlers); } - public NodeVisitor(@NotNull VisitHandler[]... handlers) { + public NodeVisitor(VisitHandler[]... handlers) { super(Node.AST_ADAPTER); //noinspection unchecked super.addActionHandlers(handlers); } - public NodeVisitor(@NotNull Collection handlers) { + public NodeVisitor(Collection handlers) { super(Node.AST_ADAPTER); addHandlers(handlers); } // add handler variations - public @NotNull NodeVisitor addTypedHandlers(@NotNull Collection> handlers) { + public NodeVisitor addTypedHandlers(Collection> handlers) { return super.addActionHandlers(handlers.toArray(EMPTY_HANDLERS)); } @SuppressWarnings("UnusedReturnValue") - public @NotNull NodeVisitor addHandlers(@NotNull Collection handlers) { + public NodeVisitor addHandlers(Collection handlers) { return super.addActionHandlers(handlers.toArray(EMPTY_HANDLERS)); } - public @NotNull NodeVisitor addHandlers(@NotNull VisitHandler[] handlers) { + public NodeVisitor addHandlers(VisitHandler[] handlers) { return super.addActionHandlers(handlers); } - public @NotNull NodeVisitor addHandlers(@NotNull VisitHandler[]... handlers) { + public NodeVisitor addHandlers(VisitHandler[]... handlers) { //noinspection unchecked return super.addActionHandlers(handlers); } @SuppressWarnings("UnusedReturnValue") - public @NotNull NodeVisitor addHandler(@NotNull VisitHandler handler) { + public NodeVisitor addHandler(VisitHandler handler) { //noinspection unchecked return super.addActionHandler(handler); } @Override - final public void visit(@NotNull Node node) { + final public void visit(Node node) { processNode(node, true, this::visit); } @Override - final public void visitNodeOnly(@NotNull Node node) { + final public void visitNodeOnly(Node node) { processNode(node, false, this::visit); } @Override - final public void visitChildren(@NotNull Node parent) { + final public void visitChildren(Node parent) { processChildren(parent, this::visit); } - private void visit(@NotNull Node node, @NotNull Visitor handler) { + private void visit(Node node, Visitor handler) { handler.visit(node); } } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitorBase.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitorBase.java index 84ec7f807..913d9bfaa 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitorBase.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitorBase.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.ast; -import org.jetbrains.annotations.NotNull; /** * Abstract visitor that visits all children by default. @@ -9,9 +8,9 @@ * call {@link #visitChildren}. */ public abstract class NodeVisitorBase { - protected abstract void visit(@NotNull Node node); + protected abstract void visit(Node node); - public void visitChildren(@NotNull Node parent) { + public void visitChildren(Node parent) { Node node = parent.getFirstChild(); while (node != null) { // A subclass of this visitor might modify the node, resulting in getNext returning a different node or no diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ReferenceNode.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ReferenceNode.java index ea6b2ac9a..df086b02a 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ReferenceNode.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ReferenceNode.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.util.ast; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface ReferenceNode, B extends Node, N extends Node> extends Comparable { - @Nullable N getReferencingNode(@NotNull Node node); + @Nullable N getReferencingNode(Node node); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ReferencingNode.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ReferencingNode.java index e575ec9fb..0cd894001 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ReferencingNode.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ReferencingNode.java @@ -1,11 +1,10 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public interface ReferencingNode, B extends ReferenceNode> { boolean isDefined(); - @NotNull BasedSequence getReference(); + BasedSequence getReference(); B getReferenceNode(Document document); B getReferenceNode(R repository); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/SpaceInsertingSequenceBuilder.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/SpaceInsertingSequenceBuilder.java index 8eadf6f9e..13574ec70 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/SpaceInsertingSequenceBuilder.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/SpaceInsertingSequenceBuilder.java @@ -8,32 +8,26 @@ import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; import com.vladsch.flexmark.util.sequence.builder.SegmentOptimizer; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public class SpaceInsertingSequenceBuilder implements ISequenceBuilder { - @NotNull - public static SpaceInsertingSequenceBuilder emptyBuilder(@NotNull BasedSequence base) { + public static SpaceInsertingSequenceBuilder emptyBuilder(BasedSequence base) { return new SpaceInsertingSequenceBuilder(SequenceBuilder.emptyBuilder(base), false); } - @NotNull - public static SpaceInsertingSequenceBuilder emptyBuilder(@NotNull BasedSequence base, @NotNull SegmentOptimizer optimizer) { + public static SpaceInsertingSequenceBuilder emptyBuilder(BasedSequence base, SegmentOptimizer optimizer) { return new SpaceInsertingSequenceBuilder(SequenceBuilder.emptyBuilder(base, optimizer), false); } - @NotNull - public static SpaceInsertingSequenceBuilder emptyBuilder(@NotNull BasedSequence base, int options) { + public static SpaceInsertingSequenceBuilder emptyBuilder(BasedSequence base, int options) { return new SpaceInsertingSequenceBuilder(SequenceBuilder.emptyBuilder(base, options), BitFieldSet.any(options, TextContainer.F_ADD_SPACES_BETWEEN_NODES)); } - @NotNull - public static SpaceInsertingSequenceBuilder emptyBuilder(@NotNull BasedSequence base, int options, @NotNull SegmentOptimizer optimizer) { + public static SpaceInsertingSequenceBuilder emptyBuilder(BasedSequence base, int options, SegmentOptimizer optimizer) { return new SpaceInsertingSequenceBuilder(SequenceBuilder.emptyBuilder(base, options, optimizer), BitFieldSet.any(options, TextContainer.F_ADD_SPACES_BETWEEN_NODES)); } - @NotNull - public static SpaceInsertingSequenceBuilder emptyBuilder(@NotNull SequenceBuilder builder) { + public static SpaceInsertingSequenceBuilder emptyBuilder(SequenceBuilder builder) { return new SpaceInsertingSequenceBuilder(builder, false); } @@ -138,10 +132,8 @@ public boolean needEol() { return false; } - @NotNull public BasedSequence getBaseSequence() {return out.getBaseSequence();} - @NotNull public BasedSegmentBuilder getSegmentBuilder() {return out.getSegmentBuilder();} @Override @@ -149,11 +141,9 @@ public boolean needEol() { public BasedSequence getSingleBasedSequence() {return out.getSingleBasedSequence();} @Override - @NotNull public SpaceInsertingSequenceBuilder getBuilder() {return new SpaceInsertingSequenceBuilder(out.getBuilder(), addSpacesBetweenNodes);} @Override - @NotNull public SpaceInsertingSequenceBuilder append(@Nullable CharSequence chars, int startIndex, int endIndex) { if (addSpaces && chars != null && startIndex < endIndex && !CharPredicate.WHITESPACE.test(chars.charAt(startIndex)) && needSpace()) { out.append(' '); @@ -164,7 +154,6 @@ public SpaceInsertingSequenceBuilder append(@Nullable CharSequence chars, int st } @Override - @NotNull public SpaceInsertingSequenceBuilder append(char c) { if (addSpaces && !CharPredicate.WHITESPACE.test(c) && needSpace()) { out.append(' '); @@ -175,7 +164,6 @@ public SpaceInsertingSequenceBuilder append(char c) { } @Override - @NotNull public SpaceInsertingSequenceBuilder append(char c, int count) { if (addSpaces && !CharPredicate.WHITESPACE.test(c) && needSpace()) { out.append(' '); @@ -185,7 +173,6 @@ public SpaceInsertingSequenceBuilder append(char c, int count) { return this; } - @NotNull public SpaceInsertingSequenceBuilder append(int startOffset, int endOffset) { if (addSpaces && startOffset < endOffset && !CharPredicate.WHITESPACE.test(out.getBaseSequence().charAt(startOffset)) && needSpace()) { out.append(' '); @@ -195,26 +182,20 @@ public SpaceInsertingSequenceBuilder append(int startOffset, int endOffset) { return this; } - @NotNull - public SpaceInsertingSequenceBuilder append(@NotNull Range chars) {return append(chars.getStart(), chars.getEnd());} + public SpaceInsertingSequenceBuilder append(Range chars) {return append(chars.getStart(), chars.getEnd());} - @NotNull - public SpaceInsertingSequenceBuilder addRange(@NotNull Range range) {return append(range.getStart(), range.getEnd());} + public SpaceInsertingSequenceBuilder addRange(Range range) {return append(range.getStart(), range.getEnd());} - @NotNull public SpaceInsertingSequenceBuilder addByOffsets(int startOffset, int endOffset) {return append(startOffset, endOffset);} - @NotNull public SpaceInsertingSequenceBuilder addByLength(int startOffset, int textLength) {return append(startOffset, startOffset + textLength);} @Override - @NotNull public BasedSequence toSequence() {return out.toSequence();} @Override public int length() {return out.length();} - @NotNull public String toStringWithRanges() {return out.toStringWithRanges();} @Override @@ -223,13 +204,11 @@ public SpaceInsertingSequenceBuilder append(int startOffset, int endOffset) { public String toStringNoAddedSpaces() {return out.toStringNoAddedSpaces();} @Override - @NotNull public SpaceInsertingSequenceBuilder addAll(Iterable sequences) { return append(sequences); } @Override - @NotNull public SpaceInsertingSequenceBuilder append(Iterable sequences) { for (CharSequence sequence : sequences) { append(sequence); @@ -238,14 +217,11 @@ public SpaceInsertingSequenceBuilder append(Iterable seq } @Override - @NotNull public SpaceInsertingSequenceBuilder add(@Nullable CharSequence chars) {return append(chars);} @Override - @NotNull public SpaceInsertingSequenceBuilder append(@Nullable CharSequence chars) { return chars == null ? this : append(chars, 0, chars.length());} @Override - @NotNull public SpaceInsertingSequenceBuilder append(@Nullable CharSequence chars, int startIndex) {return chars == null ? this : append(chars, startIndex, chars.length());} } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/TextCollectingVisitor.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/TextCollectingVisitor.java index 60e9c8bfc..d682ba3fe 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/TextCollectingVisitor.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/TextCollectingVisitor.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.function.BiConsumer; @@ -13,7 +12,7 @@ public class TextCollectingVisitor { public TextCollectingVisitor() { myVisitor = new NodeVisitor() { @Override - public void processNode(@NotNull Node node, boolean withChildren, @NotNull BiConsumer> processor) { + public void processNode(Node node, boolean withChildren, BiConsumer> processor) { if (!node.isOrDescendantOfType(DoNotCollectText.class)) { out.setLastNode(node); if (node instanceof Block && out.isNotEmpty()) { diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/VisitHandler.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/VisitHandler.java index 7a8b5eeef..433397866 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/VisitHandler.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/VisitHandler.java @@ -1,17 +1,16 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.visitor.AstHandler; -import org.jetbrains.annotations.NotNull; /** * Node visit handler for specific node type */ public class VisitHandler extends AstHandler> implements Visitor { - public VisitHandler(@NotNull Class klass, @NotNull Visitor adapter) { + public VisitHandler(Class klass, Visitor adapter) { super(klass, adapter); } - public void visit(@NotNull Node node) { + public void visit(Node node) { //noinspection unchecked getAdapter().visit((N) node); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Visitor.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Visitor.java index 9375b071d..d2ce07295 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Visitor.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Visitor.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.ast; import com.vladsch.flexmark.util.visitor.AstAction; -import org.jetbrains.annotations.NotNull; /** * Node visitor interface @@ -9,5 +8,5 @@ * @param specific node type */ public interface Visitor extends AstAction { - void visit(@NotNull N node); + void visit(N node); } diff --git a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/package-info.java b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/package-info.java index 17efc7cf7..65f1320f5 100644 --- a/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/package-info.java +++ b/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.ast; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-builder/pom.xml b/flexmark-util-builder/pom.xml index bdbd92586..0788f6fde 100644 --- a/flexmark-util-builder/pom.xml +++ b/flexmark-util-builder/pom.xml @@ -27,9 +27,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-builder/src/main/java/com/vladsch/flexmark/util/builder/BuilderBase.java b/flexmark-util-builder/src/main/java/com/vladsch/flexmark/util/builder/BuilderBase.java index 74c28eac3..c1e889901 100644 --- a/flexmark-util-builder/src/main/java/com/vladsch/flexmark/util/builder/BuilderBase.java +++ b/flexmark-util-builder/src/main/java/com/vladsch/flexmark/util/builder/BuilderBase.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.*; import com.vladsch.flexmark.util.misc.Extension; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; @@ -26,14 +25,14 @@ public abstract class BuilderBase> extends MutableDataS * * @param apiPoint api point object */ - protected abstract void removeApiPoint(@NotNull Object apiPoint); + protected abstract void removeApiPoint(Object apiPoint); /** * Preload operation for extension, perform any data config and other operation needed for loading extension * * @param extension to preload */ - protected abstract void preloadExtension(@NotNull Extension extension); + protected abstract void preloadExtension(Extension extension); /** * Load extension if it is valid @@ -41,13 +40,13 @@ public abstract class BuilderBase> extends MutableDataS * @param extension to load * @return true if extension was loaded */ - protected abstract boolean loadExtension(@NotNull Extension extension); + protected abstract boolean loadExtension(Extension extension); /** * @param extensions extensions to load * @return {@code this} */ - final public @NotNull T extensions(@NotNull Collection extensions) { + final public T extensions(Collection extensions) { ArrayList addedExtensions = new ArrayList<>(EXTENSIONS.get(this).size() + extensions.size()); // first give extensions a chance to modify parser options @@ -85,7 +84,6 @@ public abstract class BuilderBase> extends MutableDataS /** * @return actual instance the builder is supposed to build */ - @NotNull public abstract Object build(); /** @@ -93,7 +91,7 @@ public abstract class BuilderBase> extends MutableDataS * * @param apiPoint point registered */ - protected void addExtensionApiPoint(@NotNull Object apiPoint) { + protected void addExtensionApiPoint(Object apiPoint) { Extension extension = currentExtension; if (extension != null) { @@ -110,16 +108,14 @@ protected void addExtensionApiPoint(@NotNull Object apiPoint) { * @param value value for the key * @return builder */ - @NotNull @Override - public MutableDataSet set(@NotNull DataKey key, @NotNull V value) { + public MutableDataSet set(DataKey key, V value) { addExtensionApiPoint(key); return super.set(key, value); } - @NotNull @Override - public MutableDataSet set(@NotNull NullableDataKey key, @Nullable V value) { + public MutableDataSet set(NullableDataKey key, @Nullable V value) { addExtensionApiPoint(key); return super.set(key, value); } @@ -134,7 +130,7 @@ public MutableDataSet set(@NotNull NullableDataKey key, @Nullable V value */ @Deprecated @Override - public V get(@NotNull DataKey key) { + public V get(DataKey key) { return key.get(this); } @@ -159,7 +155,7 @@ protected BuilderBase() { * @param excludeExtensions collection of extension classes to remove from extensions * @return modified options if removed and options were immutable or the same options if nothing to remove or options were mutable. */ - public static DataHolder removeExtensions(@NotNull DataHolder options, @NotNull Collection> excludeExtensions) { + public static DataHolder removeExtensions(DataHolder options, Collection> excludeExtensions) { if (options.contains(EXTENSIONS)) { ArrayList extensions = new ArrayList<>(EXTENSIONS.get(options)); boolean removed = extensions.removeIf(it -> excludeExtensions.contains(it.getClass())); diff --git a/flexmark-util-builder/src/main/java/com/vladsch/flexmark/util/builder/package-info.java b/flexmark-util-builder/src/main/java/com/vladsch/flexmark/util/builder/package-info.java index 9cf1c0ae6..31ac3ca66 100644 --- a/flexmark-util-builder/src/main/java/com/vladsch/flexmark/util/builder/package-info.java +++ b/flexmark-util-builder/src/main/java/com/vladsch/flexmark/util/builder/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.builder; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-collection/pom.xml b/flexmark-util-collection/pom.xml index 77c980b4f..a31eaf1a8 100644 --- a/flexmark-util-collection/pom.xml +++ b/flexmark-util-collection/pom.xml @@ -22,9 +22,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMaxAggregator.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMaxAggregator.java index c419c0e1f..ea7148e02 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMaxAggregator.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMaxAggregator.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.BiFunction; diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMinAggregator.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMinAggregator.java index d48edfd6d..51abce4d6 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMinAggregator.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMinAggregator.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.BiFunction; diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ClassificationBag.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ClassificationBag.java index a75aa2834..f0d478f56 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ClassificationBag.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ClassificationBag.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.collection.iteration.BitSetIterable; import com.vladsch.flexmark.util.collection.iteration.IndexedIterable; import com.vladsch.flexmark.util.collection.iteration.ReversibleIterable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.BitSet; import java.util.Collection; @@ -12,23 +11,23 @@ import java.util.function.Function; public class ClassificationBag { - final private @NotNull OrderedSet items; - final @NotNull IndexedItemBitSetMap bag; + final private OrderedSet items; + final IndexedItemBitSetMap bag; final @Nullable CollectionHost host; public ClassificationBag(Function mapper) { this(0, mapper); } - public ClassificationBag(@NotNull Function mapper, @Nullable CollectionHost host) { + public ClassificationBag(Function mapper, @Nullable CollectionHost host) { this(0, mapper, host); } - public ClassificationBag(int capacity, @NotNull Function mapper) { + public ClassificationBag(int capacity, Function mapper) { this(capacity, mapper, null); } - public ClassificationBag(int capacity, @NotNull Function mapper, @Nullable CollectionHost host) { + public ClassificationBag(int capacity, Function mapper, @Nullable CollectionHost host) { this.host = host; this.items = new OrderedSet<>(capacity, new CollectionHost() { @Override @@ -70,7 +69,6 @@ public int getIteratorModificationCount() { this.bag = new IndexedItemBitSetMap<>(mapper); } - @NotNull public OrderedSet getItems() { return items; } @@ -111,7 +109,7 @@ public int getCategoryCount(@Nullable K category) { return bitSet == null ? 0 : bitSet.cardinality(); } - public @NotNull Map getCategoryMap() { + public Map getCategoryMap() { return bag; } @@ -120,34 +118,34 @@ public void clear() { } @SafeVarargs - final public @NotNull ReversibleIterable getCategoryItems(@NotNull Class xClass, @NotNull K... categories) { + final public ReversibleIterable getCategoryItems(Class xClass, K... categories) { return new IndexedIterable>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(categoriesBitSet(categories), false)); } - final public @NotNull ReversibleIterable getCategoryItems(@NotNull Class xClass, @NotNull Collection categories) { + final public ReversibleIterable getCategoryItems(Class xClass, Collection categories) { return new IndexedIterable>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(categoriesBitSet(categories), false)); } - final public @NotNull ReversibleIterable getCategoryItems(@NotNull Class xClass, @NotNull BitSet bitSet) { + final public ReversibleIterable getCategoryItems(Class xClass, BitSet bitSet) { return new IndexedIterable>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(bitSet, false)); } @SafeVarargs - final public @NotNull ReversibleIterable getCategoryItemsReversed(@NotNull Class xClass, @NotNull K... categories) { + final public ReversibleIterable getCategoryItemsReversed(Class xClass, K... categories) { return new IndexedIterable>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(categoriesBitSet(categories), true)); } - final public @NotNull ReversibleIterable getCategoryItemsReversed(@NotNull Class xClass, @NotNull Collection categories) { + final public ReversibleIterable getCategoryItemsReversed(Class xClass, Collection categories) { return new IndexedIterable>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(categoriesBitSet(categories), true)); } - final public @NotNull ReversibleIterable getCategoryItemsReversed(@NotNull Class xClass, @NotNull BitSet bitSet) { + final public ReversibleIterable getCategoryItemsReversed(Class xClass, BitSet bitSet) { return new IndexedIterable>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(bitSet, true)); } @SafeVarargs @SuppressWarnings("WeakerAccess") - final public @NotNull BitSet categoriesBitSet(@NotNull K... categories) { + final public BitSet categoriesBitSet(K... categories) { BitSet bitSet = new BitSet(); for (K category : categories) { BitSet bitSet1 = bag.get(category); @@ -158,7 +156,7 @@ public void clear() { return bitSet; } - final public @NotNull BitSet categoriesBitSet(@NotNull Collection categories) { + final public BitSet categoriesBitSet(Collection categories) { BitSet bitSet = new BitSet(); for (K category : categories) { BitSet bitSet1 = bag.get(category); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/CollectionHost.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/CollectionHost.java index ec0b8fa28..6f685068c 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/CollectionHost.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/CollectionHost.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface CollectionHost { void adding(int index, @Nullable K k, @Nullable Object v); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/CopyOnWriteRef.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/CopyOnWriteRef.java index 9890926ad..849953300 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/CopyOnWriteRef.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/CopyOnWriteRef.java @@ -1,16 +1,15 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.Function; public class CopyOnWriteRef { private @Nullable T value; private int referenceCount; - final private @NotNull Function copyFunction; + final private Function copyFunction; - public CopyOnWriteRef(@Nullable T value, @NotNull Function copyFunction) { + public CopyOnWriteRef(@Nullable T value, Function copyFunction) { this.value = value; referenceCount = 0; this.copyFunction = copyFunction; diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemBitSetMap.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemBitSetMap.java index 82e766738..75163eff7 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemBitSetMap.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemBitSetMap.java @@ -1,52 +1,51 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.NotNull; import java.util.BitSet; import java.util.function.Function; public class IndexedItemBitSetMap extends IndexedItemSetMapBase { - final private @NotNull Function computable; + final private Function computable; - public IndexedItemBitSetMap(@NotNull Function computable) { + public IndexedItemBitSetMap(Function computable) { this(computable, 0); } - public IndexedItemBitSetMap(@NotNull Function computable, int capacity) { + public IndexedItemBitSetMap(Function computable, int capacity) { super(capacity); this.computable = computable; } - public @NotNull Function getComputable() { + public Function getComputable() { return computable; } @Override - public @NotNull K mapKey(@NotNull M key) { + public K mapKey(M key) { return computable.apply(key); } @Override - public @NotNull BitSet newSet() { + public BitSet newSet() { return new BitSet(); } @Override - public boolean addSetItem(@NotNull BitSet set, int item) { + public boolean addSetItem(BitSet set, int item) { boolean old = set.get(item); set.set(item); return old; } @Override - public boolean removeSetItem(@NotNull BitSet set, int item) { + public boolean removeSetItem(BitSet set, int item) { boolean old = set.get(item); set.clear(item); return old; } @Override - public boolean containsSetItem(@NotNull BitSet set, int item) { + public boolean containsSetItem(BitSet set, int item) { return set.get(item); } } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemSetMap.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemSetMap.java index b19407e93..9cf19e820 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemSetMap.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemSetMap.java @@ -1,20 +1,19 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.NotNull; import java.util.Map; public interface IndexedItemSetMap extends Map { - @NotNull M mapKey(@NotNull K key); + M mapKey(K key); - @NotNull S newSet(); - boolean addSetItem(@NotNull S s, int item); - boolean removeSetItem(@NotNull S s, int item); - boolean containsSetItem(@NotNull S s, int item); + S newSet(); + boolean addSetItem(S s, int item); + boolean removeSetItem(S s, int item); + boolean containsSetItem(S s, int item); @SuppressWarnings("UnusedReturnValue") - boolean addItem(@NotNull K key, int item); + boolean addItem(K key, int item); @SuppressWarnings("UnusedReturnValue") - boolean removeItem(@NotNull K key, int item); - boolean containsItem(@NotNull K key, int item); + boolean removeItem(K key, int item); + boolean containsItem(K key, int item); } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemSetMapBase.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemSetMapBase.java index d0cf0b669..0d9b2c46d 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemSetMapBase.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemSetMapBase.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.HashMap; @@ -20,18 +19,18 @@ public IndexedItemSetMapBase(int capacity) { } @Override - public abstract @NotNull K mapKey(@NotNull M key); + public abstract K mapKey(M key); @Override - public abstract @NotNull S newSet(); + public abstract S newSet(); @Override - public abstract boolean addSetItem(@NotNull S s, int item); + public abstract boolean addSetItem(S s, int item); @Override - public abstract boolean removeSetItem(@NotNull S s, int item); + public abstract boolean removeSetItem(S s, int item); @Override - public abstract boolean containsSetItem(@NotNull S s, int item); + public abstract boolean containsSetItem(S s, int item); @Override - public boolean addItem(@NotNull M key, int item) { + public boolean addItem(M key, int item) { K mapKey = mapKey(key); S itemSet = bag.get(mapKey); if (itemSet == null) { @@ -42,14 +41,14 @@ public boolean addItem(@NotNull M key, int item) { } @Override - public boolean removeItem(@NotNull M key, int item) { + public boolean removeItem(M key, int item) { K mapKey = mapKey(key); S itemSet = bag.get(mapKey); return itemSet != null && removeSetItem(itemSet, item); } @Override - public boolean containsItem(@NotNull M key, int item) { + public boolean containsItem(M key, int item) { K mapKey = mapKey(key); S itemSet = bag.get(mapKey); return itemSet != null && containsSetItem(itemSet, item); @@ -81,7 +80,7 @@ public boolean containsValue(@Nullable Object o) { } @Override - public @Nullable S put(@NotNull K k, @NotNull S vs) { + public @Nullable S put(K k, S vs) { return bag.put(k, vs); } @@ -91,7 +90,7 @@ public boolean containsValue(@Nullable Object o) { } @Override - public void putAll(@NotNull Map map) { + public void putAll(Map map) { bag.putAll(map); } @@ -101,17 +100,17 @@ public void clear() { } @Override - public @NotNull Set keySet() { + public Set keySet() { return bag.keySet(); } @Override - public @NotNull Collection values() { + public Collection values() { return bag.values(); } @Override - public @NotNull Set> entrySet() { + public Set> entrySet() { return bag.entrySet(); } } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ItemFactoryMap.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ItemFactoryMap.java index d515c1937..f76dfb198 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ItemFactoryMap.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ItemFactoryMap.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.HashMap; @@ -11,13 +10,13 @@ public class ItemFactoryMap implements Map, I> { protected final HashMap, I> itemMap; - protected final @NotNull P param; + protected final P param; - public ItemFactoryMap(@NotNull P param) { + public ItemFactoryMap(P param) { this(param, 0); } - public ItemFactoryMap(@NotNull P param, int capacity) { + public ItemFactoryMap(P param, int capacity) { this.itemMap = new HashMap<>(capacity); this.param = param; } @@ -50,10 +49,10 @@ public I getItem(Function factory) { public boolean containsKey(@Nullable Object o) {return itemMap.containsKey(o);} @Override - public @Nullable I put(@NotNull Function factory, @NotNull I i) {return itemMap.put(factory, i);} + public @Nullable I put(Function factory, I i) {return itemMap.put(factory, i);} @Override - public void putAll(@NotNull Map, ? extends I> map) {itemMap.putAll(map);} + public void putAll(Map, ? extends I> map) {itemMap.putAll(map);} @Override public @Nullable I remove(@Nullable Object o) {return itemMap.remove(o);} @@ -65,11 +64,11 @@ public I getItem(Function factory) { public boolean containsValue(@Nullable Object o) {return itemMap.containsValue(o);} @Override - public @NotNull Set> keySet() {return itemMap.keySet();} + public Set> keySet() {return itemMap.keySet();} @Override - public @NotNull Collection values() {return itemMap.values();} + public Collection values() {return itemMap.values();} @Override - public @NotNull Set, I>> entrySet() {return itemMap.entrySet();} + public Set, I>> entrySet() {return itemMap.entrySet();} } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MapEntry.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MapEntry.java index 45a0113f5..140fa4785 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MapEntry.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MapEntry.java @@ -1,22 +1,21 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Map; import java.util.Objects; final public class MapEntry implements Map.Entry { - final private @NotNull K key; + final private K key; final private @Nullable V value; - public MapEntry(@NotNull K key, @Nullable V value) { + public MapEntry(K key, @Nullable V value) { this.key = key; this.value = value; } @Override - public @NotNull K getKey() { + public K getKey() { return key; } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MaxAggregator.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MaxAggregator.java index 7265dc7cf..4945a662a 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MaxAggregator.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MaxAggregator.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.BiFunction; diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MinAggregator.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MinAggregator.java index d392e39f9..06e5520ac 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MinAggregator.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MinAggregator.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.BiFunction; diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedMap.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedMap.java index e4418c071..f8cc74878 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedMap.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedMap.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.util.collection; import com.vladsch.flexmark.util.collection.iteration.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; import java.util.function.Consumer; @@ -10,8 +9,8 @@ @SuppressWarnings("WeakerAccess") public class OrderedMap implements Map, Iterable> { - final @NotNull OrderedSet keySet; - final private @NotNull ArrayList valueList; + final OrderedSet keySet; + final private ArrayList valueList; final private @Nullable CollectionHost host; boolean inUpdate; private @Nullable Indexed> indexedEntryProxy; @@ -25,7 +24,7 @@ public OrderedMap(int capacity) { this(capacity, null); } - public OrderedMap(@NotNull CollectionHost host) { + public OrderedMap(CollectionHost host) { this(0, host); } @@ -68,7 +67,7 @@ public int getIteratorModificationCount() { }); } - public @NotNull Indexed> getIndexedEntryProxy() { + public Indexed> getIndexedEntryProxy() { if (indexedEntryProxy != null) return indexedEntryProxy; indexedEntryProxy = new Indexed>() { @Override @@ -100,7 +99,7 @@ public int modificationCount() { return indexedEntryProxy; } - public @NotNull Indexed getIndexedValueProxy() { + public Indexed getIndexedValueProxy() { if (indexedValueProxy != null) return indexedValueProxy; indexedValueProxy = new Indexed() { @Override @@ -132,7 +131,7 @@ public int modificationCount() { return indexedValueProxy; } - @NotNull Map.Entry getEntry(int index) { + Map.Entry getEntry(int index) { return new MapEntry<>(keySet.getValue(index), valueList.get(index)); } @@ -140,7 +139,7 @@ public int getModificationCount() { return keySet.getModificationCount(); } - void adding(int index, @NotNull K k, @NotNull Object v) { + void adding(int index, K k, Object v) { if (v == null) throw new IllegalArgumentException(); if (host != null && !host.skipHostUpdate()) { host.adding(index, k, v); @@ -156,7 +155,7 @@ void addingNull(int index) { addNulls(index); } - Object removing(int index, @NotNull K k) { + Object removing(int index, K k) { if (host != null && !host.skipHostUpdate()) { host.removing(index, k); } @@ -210,7 +209,7 @@ public void addNulls(int index) { } @Override - public @Nullable V put(@NotNull K k, @NotNull V v) { + public @Nullable V put(K k, V v) { int index = keySet.indexOf(k); if (index == -1) { keySet.add(k, v); @@ -222,7 +221,7 @@ public void addNulls(int index) { return old; } - public @NotNull V computeIfMissing(@NotNull K k, @NotNull Function runnableValue) { + public V computeIfMissing(K k, Function runnableValue) { int index = keySet.indexOf(k); if (index == -1) { V v = runnableValue.apply(k); @@ -234,19 +233,19 @@ public void addNulls(int index) { } @Override - public @NotNull V remove(@Nullable Object o) { + public V remove(@Nullable Object o) { //noinspection unchecked return (V) keySet.removeHosted(o); } @Override - public void putAll(@NotNull Map map) { + public void putAll(Map map) { for (Map.Entry entry : map.entrySet()) { put(entry.getKey(), entry.getValue()); } } - public void addAll(@NotNull Collection> entries) { + public void addAll(Collection> entries) { for (Map.Entry entry : entries) { put(entry.getKey(), entry.getValue()); } @@ -257,13 +256,11 @@ public void clear() { keySet.clear(); } - @NotNull @Override public OrderedSet keySet() { return keySet; } - @NotNull @Override public Collection values() { if (!keySet.isSparse()) { @@ -288,7 +285,6 @@ public Collection values() { return valueList.get(index); } - @NotNull @Override public OrderedSet> entrySet() { // create it with inHostUpdate already set so we can populate it without callbacks @@ -305,7 +301,7 @@ public OrderedSet> entrySet() { return values; } - public @NotNull List> entries() { + public List> entries() { // create it with inHostUpdate already set so we can populate it without callbacks List> values = new ArrayList<>(); Iterator> iterator = entryIterator(); @@ -315,64 +311,64 @@ public OrderedSet> entrySet() { return values; } - public @NotNull List keys() { + public List keys() { // create it with inHostUpdate already set so we can populate it without callbacks return keySet.values(); } - public @NotNull ReversibleIndexedIterator valueIterator() { + public ReversibleIndexedIterator valueIterator() { return new IndexedIterator<>(getIndexedValueProxy(), keySet.indexIterator()); } - public @NotNull ReversibleIndexedIterator reversedValueIterator() { + public ReversibleIndexedIterator reversedValueIterator() { return new IndexedIterator<>(getIndexedValueProxy(), keySet.reversedIndexIterator()); } - public @NotNull ReversibleIndexedIterator keyIterator() { + public ReversibleIndexedIterator keyIterator() { return keySet.iterator(); } - public @NotNull ReversibleIndexedIterator reversedKeyIterator() { + public ReversibleIndexedIterator reversedKeyIterator() { return keySet.reversedIterator(); } - public @NotNull ReversibleIndexedIterator> entryIterator() { + public ReversibleIndexedIterator> entryIterator() { return new IndexedIterator<>(getIndexedEntryProxy(), keySet.indexIterator()); } - public @NotNull ReversibleIndexedIterator> reversedEntryIterator() { + public ReversibleIndexedIterator> reversedEntryIterator() { return new IndexedIterator<>(getIndexedEntryProxy(), keySet.reversedIndexIterator()); } - public @NotNull ReversibleIndexedIterator> reversedIterator() { + public ReversibleIndexedIterator> reversedIterator() { return reversedEntryIterator(); } - public @NotNull ReversibleIterable valueIterable() { + public ReversibleIterable valueIterable() { return new IndexedIterable<>(getIndexedValueProxy(), keySet.indexIterable()); } - public @NotNull ReversibleIterable reversedValueIterable() { + public ReversibleIterable reversedValueIterable() { return new IndexedIterable<>(getIndexedValueProxy(), keySet.reversedIndexIterable()); } - public @NotNull ReversibleIterable keyIterable() { + public ReversibleIterable keyIterable() { return keySet.iterable(); } - public @NotNull ReversibleIterable reversedKeyIterable() { + public ReversibleIterable reversedKeyIterable() { return keySet.reversedIterable(); } - public @NotNull ReversibleIterable> entryIterable() { + public ReversibleIterable> entryIterable() { return new IndexedIterable<>(getIndexedEntryProxy(), keySet.indexIterable()); } - public @NotNull ReversibleIterable> reversedEntryIterable() { + public ReversibleIterable> reversedEntryIterable() { return new IndexedIterable<>(getIndexedEntryProxy(), keySet.reversedIndexIterable()); } - public @NotNull ReversibleIterable> reversedIterable() { + public ReversibleIterable> reversedIterable() { return reversedEntryIterable(); } @@ -380,7 +376,6 @@ public OrderedSet> entrySet() { * Iterable */ - @NotNull @Override public ReversibleIndexedIterator> iterator() { return entryIterator(); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedMultiMap.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedMultiMap.java index b8ee9c923..80280219e 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedMultiMap.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedMultiMap.java @@ -3,15 +3,14 @@ import com.vladsch.flexmark.util.collection.iteration.*; import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.misc.Paired; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; import java.util.function.Consumer; public class OrderedMultiMap implements Map, Iterable> { - final private @NotNull OrderedSet keySet; - final private @NotNull OrderedSet valueSet; + final private OrderedSet keySet; + final private OrderedSet valueSet; final private @Nullable CollectionHost> host; boolean isInKeyUpdate; boolean isInValueUpdate; @@ -25,7 +24,7 @@ public OrderedMultiMap(int capacity) { this(capacity, null); } - public OrderedMultiMap(@NotNull CollectionHost> host) { + public OrderedMultiMap(CollectionHost> host) { this(0, host); } @@ -264,23 +263,23 @@ public void addNullEntry(int index) { isInKeyUpdate = false; } - public boolean putEntry(@NotNull Map.Entry e) { + public boolean putEntry(Map.Entry e) { return addKeyValue(e.getKey(), e.getValue()); } - public boolean putKeyValueEntry(@NotNull Map.Entry e) { + public boolean putKeyValueEntry(Map.Entry e) { return addKeyValue(e.getKey(), e.getValue()); } - public boolean putValueKeyEntry(@NotNull Map.Entry e) { + public boolean putValueKeyEntry(Map.Entry e) { return addKeyValue(e.getValue(), e.getKey()); } - public boolean putKeyValuePair(@NotNull Paired e) { + public boolean putKeyValuePair(Paired e) { return addKeyValue(e.getFirst(), e.getSecond()); } - public boolean putValueKeyPair(@NotNull Paired e) { + public boolean putValueKeyPair(Paired e) { return addKeyValue(e.getSecond(), e.getFirst()); } @@ -357,7 +356,7 @@ private boolean addKeyValue(@Nullable K k, @Nullable V v) { return removeKey(o); } - public @Nullable Map.Entry removeEntry(@NotNull Map.Entry e) { + public Map.@Nullable Entry removeEntry(Map.Entry e) { boolean b = removeEntryIndex(-1, e.getKey(), e.getValue()); return b ? e : null; } @@ -421,7 +420,7 @@ public K removeValue(Object o) { } @Override - public void putAll(@NotNull Map map) { + public void putAll(Map map) { putAllKeyValues(map); } @@ -452,13 +451,11 @@ public void clear() { isInValueUpdate = false; } - @NotNull @Override public OrderedSet keySet() { return keySet; } - @NotNull @Override public Collection values() { if (!keySet.isSparse()) { @@ -494,7 +491,6 @@ public V getValue(int index) { return valueSet.getValue(index); } - @NotNull @Override public OrderedSet> entrySet() { return keyValueEntrySet(); @@ -570,7 +566,6 @@ private BitSet getKeyValueIntersectionSet() { * Iterable */ - @NotNull @Override public Iterator> iterator() { return entrySetIterator(); @@ -590,13 +585,13 @@ public OrderedSet> keyValueEntrySet() { OrderedSet> values = new OrderedSet<>(keySet.size(), new CollectionHost>() { @Override - public void adding(int index, @Nullable Map.Entry entry, @Nullable Object v) { + public void adding(int index, Map.@Nullable Entry entry, @Nullable Object v) { assert v == null; OrderedMultiMap.this.putKeyValue(entry.getKey(), entry.getValue()); } @Override - public Object removing(int index, @Nullable Map.Entry entry) { + public Object removing(int index, Map.@Nullable Entry entry) { boolean b = OrderedMultiMap.this.removeEntryIndex(index, entry.getKey(), entry.getValue()); return b ? entry : null; } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedSet.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedSet.java index 53583bb61..4fb6a97dd 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedSet.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/OrderedSet.java @@ -1,19 +1,18 @@ package com.vladsch.flexmark.util.collection; import com.vladsch.flexmark.util.collection.iteration.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.lang.reflect.Array; import java.util.*; public class OrderedSet implements Set, Iterable { - final private @NotNull HashMap keyMap; - @NotNull final ArrayList valueList; + final private HashMap keyMap; + final ArrayList valueList; private @Nullable final CollectionHost host; private @Nullable Indexed indexedProxy; private @Nullable Indexed allowConcurrentModsIndexedProxy; - final private @NotNull BitSet validIndices; + final private BitSet validIndices; private int modificationCount; public OrderedSet() { @@ -24,7 +23,7 @@ public OrderedSet(int capacity) { this(capacity, null); } - public OrderedSet(@NotNull CollectionHost host) { + public OrderedSet(CollectionHost host) { this(0, host); } @@ -38,7 +37,7 @@ public OrderedSet(int capacity, @Nullable CollectionHost host) { this.allowConcurrentModsIndexedProxy = null; } - public @NotNull BitSet indexBitSet(@NotNull Iterable items) { + public BitSet indexBitSet(Iterable items) { BitSet bitSet = new BitSet(); for (E element : items) { int i = indexOf(element); @@ -49,11 +48,11 @@ public OrderedSet(int capacity, @Nullable CollectionHost host) { return bitSet; } - public @NotNull BitSet differenceBitSet(@NotNull Iterable items) { + public BitSet differenceBitSet(Iterable items) { return differenceBitSet(items.iterator()); } - public @NotNull BitSet differenceBitSet(@NotNull Iterator items) { + public BitSet differenceBitSet(Iterator items) { BitSet bitSet = new BitSet(); int j = 0; while (items.hasNext()) { @@ -68,11 +67,11 @@ public OrderedSet(int capacity, @Nullable CollectionHost host) { return bitSet; } - public @NotNull BitSet keyDifferenceBitSet(@NotNull Iterable> items) { + public BitSet keyDifferenceBitSet(Iterable> items) { return keyDifferenceBitSet(items.iterator()); } - public @NotNull BitSet keyDifferenceBitSet(@NotNull Iterator> items) { + public BitSet keyDifferenceBitSet(Iterator> items) { BitSet bitSet = new BitSet(); int j = 0; while (items.hasNext()) { @@ -86,11 +85,11 @@ public OrderedSet(int capacity, @Nullable CollectionHost host) { return bitSet; } - public @NotNull BitSet valueDifferenceBitSet(@NotNull Iterable> items) { + public BitSet valueDifferenceBitSet(Iterable> items) { return valueDifferenceBitSet(items.iterator()); } - public @NotNull BitSet valueDifferenceBitSet(@NotNull Iterator> items) { + public BitSet valueDifferenceBitSet(Iterator> items) { BitSet bitSet = new BitSet(); int j = 0; while (items.hasNext()) { @@ -137,13 +136,13 @@ public int modificationCount() { } } - public @NotNull Indexed getIndexedProxy() { + public Indexed getIndexedProxy() { if (indexedProxy != null) return indexedProxy; indexedProxy = new IndexedProxy(false); return indexedProxy; } - public @NotNull Indexed getConcurrentModsIndexedProxy() { + public Indexed getConcurrentModsIndexedProxy() { if (allowConcurrentModsIndexedProxy != null) return allowConcurrentModsIndexedProxy; allowConcurrentModsIndexedProxy = new IndexedProxy(true); return allowConcurrentModsIndexedProxy; @@ -203,11 +202,11 @@ public boolean contains(@Nullable Object o) { return keyMap.containsKey(o); } - public @NotNull List getValueList() { + public List getValueList() { return valueList; } - public @NotNull List values() { + public List values() { if (!isSparse()) return valueList; List list = new ArrayList<>(); for (E item : iterable()) list.add(item); @@ -269,40 +268,39 @@ public void addNulls(int index) { while (valueList.size() <= index) valueList.add(null); } - public @NotNull ReversibleIterator indexIterator() { + public ReversibleIterator indexIterator() { return new BitSetIterator(validIndices); } - public @NotNull ReversibleIterator reversedIndexIterator() { + public ReversibleIterator reversedIndexIterator() { return new BitSetIterator(validIndices, true); } - public @NotNull ReversibleIterable indexIterable() { + public ReversibleIterable indexIterable() { return new BitSetIterable(validIndices); } - public @NotNull ReversibleIterable reversedIndexIterable() { + public ReversibleIterable reversedIndexIterable() { return new BitSetIterable(validIndices, true); } @Override - public @NotNull ReversibleIndexedIterator iterator() { + public ReversibleIndexedIterator iterator() { return new IndexedIterator<>(getIndexedProxy(), indexIterator()); } - public @NotNull ReversibleIndexedIterator reversedIterator() { + public ReversibleIndexedIterator reversedIterator() { return new IndexedIterator<>(getIndexedProxy(), reversedIndexIterator()); } - public @NotNull ReversibleIterable iterable() { + public ReversibleIterable iterable() { return new IndexedIterable<>(getIndexedProxy(), indexIterable()); } - public @NotNull ReversibleIterable reversedIterable() { + public ReversibleIterable reversedIterable() { return new IndexedIterable<>(getIndexedProxy(), reversedIndexIterable()); } - @NotNull @Override public Object[] toArray() { Object[] objects = new Object[keyMap.size()]; @@ -315,9 +313,8 @@ public Object[] toArray() { return objects; } - @NotNull @Override - public T[] toArray(@NotNull T[] array) { + public T[] toArray(T[] array) { Object[] objects = array; if (array.length < keyMap.size()) { @@ -405,7 +402,7 @@ public boolean remove(@Nullable Object o) { } @Override - public boolean containsAll(@NotNull Collection collection) { + public boolean containsAll(Collection collection) { for (Object o : collection) { if (!keyMap.containsKey(o)) { return false; @@ -415,7 +412,7 @@ public boolean containsAll(@NotNull Collection collection) { } @Override - public boolean addAll(@NotNull Collection collection) { + public boolean addAll(Collection collection) { boolean[] changed = { false }; for (E e : collection) { if (add(e)) changed[0] = true; @@ -424,7 +421,7 @@ public boolean addAll(@NotNull Collection collection) { } @Override - public boolean retainAll(@NotNull Collection collection) { + public boolean retainAll(Collection collection) { BitSet removeSet = new BitSet(valueList.size()); removeSet.set(0, valueList.size()); removeSet.and(validIndices); @@ -451,7 +448,7 @@ public boolean retainAll(@NotNull Collection collection) { } @Override - public boolean removeAll(@NotNull Collection collection) { + public boolean removeAll(Collection collection) { boolean changed = false; for (Object o : collection) { if (keyMap.containsKey(o)) { @@ -497,7 +494,6 @@ public int hashCode() { return result; } - @NotNull public BitSet getValidIndices() { return validIndices; } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/SubClassingBag.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/SubClassingBag.java index 3ef99f2c4..3dbb4c5a7 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/SubClassingBag.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/SubClassingBag.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.util.collection; import com.vladsch.flexmark.util.collection.iteration.ReversibleIterable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.BitSet; import java.util.Collection; @@ -10,10 +9,10 @@ import java.util.List; public class SubClassingBag { - final private @NotNull ClassificationBag, T> items; - final private @NotNull HashMap, BitSet> subClassMap; + final private ClassificationBag, T> items; + final private HashMap, BitSet> subClassMap; - public SubClassingBag(@NotNull ClassificationBag, T> items, HashMap, @NotNull List>> subClassMap) { + public SubClassingBag(ClassificationBag, T> items, HashMap, List>> subClassMap) { this.items = items; this.subClassMap = new HashMap<>(); @@ -26,7 +25,7 @@ public SubClassingBag(@NotNull ClassificationBag, T> items, HashMap getItems() { + public OrderedSet getItems() { return items.getItems(); } @@ -47,24 +46,24 @@ public int getTypeCount(@Nullable Class category) { return bitSet == null ? 0 : bitSet.cardinality(); } - final public @NotNull ReversibleIterable itemsOfType(@NotNull Class xClass, @NotNull Class... categories) { + final public ReversibleIterable itemsOfType(Class xClass, Class... categories) { return items.getCategoryItems(xClass, typeBitSet(xClass, categories)); } - final public @NotNull ReversibleIterable itemsOfType(@NotNull Class xClass, @NotNull Collection> categories) { + final public ReversibleIterable itemsOfType(Class xClass, Collection> categories) { return items.getCategoryItems(xClass, typeBitSet(xClass, categories)); } - final public @NotNull ReversibleIterable reversedItemsOfType(@NotNull Class xClass, @NotNull Class... categories) { + final public ReversibleIterable reversedItemsOfType(Class xClass, Class... categories) { return items.getCategoryItemsReversed(xClass, typeBitSet(xClass, categories)); } - final public @NotNull ReversibleIterable reversedItemsOfType(@NotNull Class xClass, @NotNull Collection> categories) { + final public ReversibleIterable reversedItemsOfType(Class xClass, Collection> categories) { return items.getCategoryItemsReversed(xClass, typeBitSet(xClass, categories)); } @SuppressWarnings("WeakerAccess") - final public @NotNull BitSet typeBitSet(@NotNull Class xClass, @NotNull Class... categories) { + final public BitSet typeBitSet(Class xClass, Class... categories) { BitSet bitSet = new BitSet(); for (Class category : categories) { if (xClass.isAssignableFrom(category) && subClassMap.containsKey(category)) { @@ -75,7 +74,7 @@ public int getTypeCount(@Nullable Class category) { } @SuppressWarnings("WeakerAccess") - final public @NotNull BitSet typeBitSet(@NotNull Class xClass, @NotNull Collection> categories) { + final public BitSet typeBitSet(Class xClass, Collection> categories) { BitSet bitSet = new BitSet(); for (Class category : categories) { if (xClass.isAssignableFrom(category) && subClassMap.containsKey(category)) { diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/TwoWayHashMap.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/TwoWayHashMap.java index a065423d3..fccf67cde 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/TwoWayHashMap.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/TwoWayHashMap.java @@ -1,13 +1,12 @@ package com.vladsch.flexmark.util.collection; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; public class TwoWayHashMap { - private @NotNull HashMap fToSMap = new HashMap<>(); - private @NotNull HashMap sToFMap = new HashMap<>(); + private HashMap fToSMap = new HashMap<>(); + private HashMap sToFMap = new HashMap<>(); public void add(@Nullable F f, @Nullable S s) { fToSMap.put(f, s); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ArrayIterable.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ArrayIterable.java index e9e4926d8..cb32441b4 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ArrayIterable.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ArrayIterable.java @@ -15,7 +15,6 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; public class ArrayIterable implements ReversibleIterable { public static ArrayIterable of(T[] items) { @@ -47,7 +46,7 @@ public ArrayIterable(T[] array, int startIndex, int endIndex, boolean isReversed } @Override - public @NotNull ReversibleIterable reversed() { + public ReversibleIterable reversed() { return new ArrayIterable<>(array, startIndex, endIndex, !isReversed); } @@ -57,11 +56,10 @@ public boolean isReversed() { } @Override - public @NotNull ReversibleIterator reversedIterator() { + public ReversibleIterator reversedIterator() { return new MyIterator<>(array, startIndex, endIndex, !isReversed); } - @NotNull @Override public ReversibleIterator iterator() { return new MyIterator<>(array, startIndex, endIndex, isReversed); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/BitSetIterable.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/BitSetIterable.java index ec8ad2e20..88cd2016d 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/BitSetIterable.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/BitSetIterable.java @@ -1,18 +1,17 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; import java.util.BitSet; public class BitSetIterable implements ReversibleIterable { - final private @NotNull BitSet bitSet; + final private BitSet bitSet; final private boolean reversed; - public BitSetIterable(@NotNull BitSet bitSet) { + public BitSetIterable(BitSet bitSet) { this(bitSet, false); } - public BitSetIterable(@NotNull BitSet bitSet, boolean reversed) { + public BitSetIterable(BitSet bitSet, boolean reversed) { this.bitSet = bitSet; this.reversed = reversed; } @@ -22,19 +21,16 @@ public boolean isReversed() { return reversed; } - @NotNull @Override public ReversibleIterator iterator() { return new BitSetIterator(bitSet, reversed); } - @NotNull @Override public ReversibleIterable reversed() { return new BitSetIterable(bitSet, !reversed); } - @NotNull @Override public ReversibleIterator reversedIterator() { return new BitSetIterator(bitSet, !reversed); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/BitSetIterator.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/BitSetIterator.java index dc6c92e6d..7fe85a693 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/BitSetIterator.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/BitSetIterator.java @@ -1,22 +1,21 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; import java.util.BitSet; import java.util.NoSuchElementException; import java.util.function.Consumer; public class BitSetIterator implements ReversibleIterator { - final private @NotNull BitSet bitSet; + final private BitSet bitSet; final private boolean reversed; private int next; private int last; - public BitSetIterator(@NotNull BitSet bitSet) { + public BitSetIterator(BitSet bitSet) { this(bitSet, false); } - public BitSetIterator(@NotNull BitSet bitSet, boolean reversed) { + public BitSetIterator(BitSet bitSet, boolean reversed) { this.bitSet = bitSet; this.reversed = reversed; next = reversed ? bitSet.previousSetBit(bitSet.length()) : bitSet.nextSetBit(0); @@ -51,7 +50,7 @@ public void remove() { bitSet.clear(last); } - public void forEachRemaining(@NotNull Consumer consumer) { + public void forEachRemaining(Consumer consumer) { while (hasNext()) { consumer.accept(next()); } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedItemIterable.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedItemIterable.java index fd0c60881..1c06730e1 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedItemIterable.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedItemIterable.java @@ -1,16 +1,15 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; public class IndexedItemIterable implements ReversibleIndexedIterable { - final private @NotNull Indexed items; + final private Indexed items; final private boolean reversed; - public IndexedItemIterable(@NotNull Indexed items) { + public IndexedItemIterable(Indexed items) { this(items, false); } - public IndexedItemIterable(@NotNull Indexed items, boolean reversed) { + public IndexedItemIterable(Indexed items, boolean reversed) { this.items = items; this.reversed = reversed; } @@ -20,19 +19,16 @@ public boolean isReversed() { return reversed; } - @NotNull @Override public ReversibleIndexedIterator iterator() { return new IndexedItemIterator<>(items, reversed); } - @NotNull @Override public ReversibleIndexedIterable reversed() { return new IndexedItemIterable<>(items, !reversed); } - @NotNull @Override public ReversibleIndexedIterator reversedIterator() { return new IndexedItemIterator<>(items, !reversed); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedItemIterator.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedItemIterator.java index f90eaca60..372a97ff3 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedItemIterator.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedItemIterator.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; import java.util.ConcurrentModificationException; import java.util.NoSuchElementException; @@ -13,11 +12,11 @@ public class IndexedItemIterator implements ReversibleIndexedIterator { private int last; private int modificationCount; - public IndexedItemIterator(@NotNull Indexed items) { + public IndexedItemIterator(Indexed items) { this(items, false); } - public IndexedItemIterator(@NotNull Indexed items, boolean isReversed) { + public IndexedItemIterator(Indexed items, boolean isReversed) { this.items = items; reversed = isReversed; next = reversed ? items.size() - 1 : 0; @@ -40,7 +39,7 @@ public boolean hasNext() { } @Override - public @NotNull R next() { + public R next() { if (modificationCount != items.modificationCount()) { throw new ConcurrentModificationException(); } @@ -77,7 +76,7 @@ public int getIndex() { return last; } - public void forEachRemaining(@NotNull Consumer consumer) { + public void forEachRemaining(Consumer consumer) { while (hasNext()) { consumer.accept(next()); } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedIterable.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedIterable.java index ec04ea344..babcfc0ec 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedIterable.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedIterable.java @@ -1,12 +1,11 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; public class IndexedIterable> implements ReversibleIndexedIterable { - final private @NotNull ReversibleIterable iterable; - final private @NotNull Indexed items; + final private ReversibleIterable iterable; + final private Indexed items; - public IndexedIterable(@NotNull Indexed items, @NotNull I iterable) { + public IndexedIterable(Indexed items, I iterable) { this.items = items; this.iterable = iterable; } @@ -16,19 +15,16 @@ public boolean isReversed() { return iterable.isReversed(); } - @NotNull @Override public ReversibleIndexedIterator iterator() { return new IndexedIterator<>(items, iterable.iterator()); } - @NotNull @Override public ReversibleIndexedIterable reversed() { return new IndexedIterable<>(items, iterable.reversed()); } - @NotNull @Override public ReversibleIndexedIterator reversedIterator() { return new IndexedIterator<>(items, iterable.reversedIterator()); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedIterator.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedIterator.java index 3bb63b611..fd9c37288 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedIterator.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedIterator.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; import java.util.ConcurrentModificationException; import java.util.NoSuchElementException; @@ -12,7 +11,7 @@ public class IndexedIterator> implem private int lastIndex; private int modificationCount; - public IndexedIterator(@NotNull Indexed items, @NotNull I iterator) { + public IndexedIterator(Indexed items, I iterator) { this.items = items; this.iterator = iterator; this.lastIndex = -1; @@ -30,7 +29,7 @@ public boolean hasNext() { } @Override - public @NotNull R next() { + public R next() { if (modificationCount != items.modificationCount()) { throw new ConcurrentModificationException(); } @@ -63,7 +62,7 @@ public int getIndex() { return lastIndex; } - public void forEachRemaining(@NotNull Consumer consumer) { + public void forEachRemaining(Consumer consumer) { while (hasNext()) { consumer.accept(next()); } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/Reverse.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/Reverse.java index 109543e56..9a3dd10eb 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/Reverse.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/Reverse.java @@ -1,29 +1,28 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; import java.util.List; @SuppressWarnings("WeakerAccess") public class Reverse implements ReversibleIterable { - final private @NotNull List list; + final private List list; final private boolean isReversed; - public Reverse(@NotNull List list) { + public Reverse(List list) { this(list, true); } - public Reverse(@NotNull List list, boolean isReversed) { + public Reverse(List list, boolean isReversed) { this.list = list; this.isReversed = isReversed; } static class ReversedListIterator implements ReversibleIterator { - final private @NotNull List list; + final private List list; final private boolean isReversed; private int index; - ReversedListIterator(@NotNull List list, boolean isReversed) { + ReversedListIterator(List list, boolean isReversed) { this.list = list; this.isReversed = isReversed; if (isReversed) { @@ -67,13 +66,11 @@ public T next() { } } - @NotNull @Override public ReversibleIterator iterator() { return new ReversedListIterator<>(list, isReversed); } - @NotNull @Override public ReversibleIterable reversed() { return new Reverse<>(list, !isReversed); @@ -84,7 +81,6 @@ public boolean isReversed() { return isReversed; } - @NotNull @Override public ReversibleIterator reversedIterator() { return new ReversedListIterator<>(list, !isReversed); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversibleIndexedIterable.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversibleIndexedIterable.java index 93d61fad3..76cfed021 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversibleIndexedIterable.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversibleIndexedIterable.java @@ -1,12 +1,11 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; public interface ReversibleIndexedIterable extends ReversibleIterable { @Override - @NotNull ReversibleIndexedIterator iterator(); + ReversibleIndexedIterator iterator(); @Override - @NotNull ReversibleIndexedIterable reversed(); + ReversibleIndexedIterable reversed(); @Override - @NotNull ReversibleIndexedIterator reversedIterator(); + ReversibleIndexedIterator reversedIterator(); } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversibleIterable.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversibleIterable.java index 04e34a44e..e89f190e9 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversibleIterable.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversibleIterable.java @@ -1,11 +1,10 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; public interface ReversibleIterable extends Iterable { @Override - @NotNull ReversibleIterator iterator(); - @NotNull ReversibleIterable reversed(); + ReversibleIterator iterator(); + ReversibleIterable reversed(); boolean isReversed(); - @NotNull ReversibleIterator reversedIterator(); + ReversibleIterator reversedIterator(); } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversiblePeekingIterable.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversiblePeekingIterable.java index 8e3ffa9e1..19120f82e 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversiblePeekingIterable.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversiblePeekingIterable.java @@ -1,12 +1,11 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.NotNull; public interface ReversiblePeekingIterable extends ReversibleIterable { @Override - @NotNull ReversiblePeekingIterator iterator(); + ReversiblePeekingIterator iterator(); @Override - @NotNull ReversiblePeekingIterable reversed(); + ReversiblePeekingIterable reversed(); @Override - @NotNull ReversiblePeekingIterator reversedIterator(); + ReversiblePeekingIterator reversedIterator(); } diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversiblePeekingIterator.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversiblePeekingIterator.java index aae489836..c9f90117e 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversiblePeekingIterator.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ReversiblePeekingIterator.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.util.collection.iteration; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface ReversiblePeekingIterator extends ReversibleIterator { @Nullable E peek(); diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/package-info.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/package-info.java index 82cef53fb..60f961b19 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/package-info.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.collection.iteration; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/package-info.java b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/package-info.java index 7d7013974..ae01699e2 100644 --- a/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/package-info.java +++ b/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.collection; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-data/pom.xml b/flexmark-util-data/pom.xml index ea0491bfc..c447b6349 100644 --- a/flexmark-util-data/pom.xml +++ b/flexmark-util-data/pom.xml @@ -23,9 +23,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataHolder.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataHolder.java index 8f766f202..c2c8f6455 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataHolder.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataHolder.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.Map; @@ -9,10 +8,10 @@ public interface DataHolder extends MutableDataSetter { DataHolder NULL = new DataSet(); - @NotNull Map, Object> getAll(); - @NotNull Collection> getKeys(); + Map, Object> getAll(); + Collection> getKeys(); - boolean contains(@NotNull DataKeyBase key); + boolean contains(DataKeyBase key); /** * @param key data key @@ -21,12 +20,12 @@ public interface DataHolder extends MutableDataSetter { */ @Deprecated @Nullable - default T get(@NotNull DataKey key) { + default T get(DataKey key) { return key.get(this); } @Override - default @NotNull MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + default MutableDataHolder setIn(MutableDataHolder dataHolder) { return dataHolder.setAll(this); } @@ -43,12 +42,11 @@ default T get(@NotNull DataKey key) { * @param factory factory taking this data holder and computing/providing default value * @return object value for the key */ - Object getOrCompute(@NotNull DataKeyBase key, @NotNull DataValueFactory factory); + Object getOrCompute(DataKeyBase key, DataValueFactory factory); - @NotNull MutableDataHolder toMutable(); - @NotNull DataHolder toImmutable(); + MutableDataHolder toMutable(); + DataHolder toImmutable(); - @NotNull default DataSet toDataSet() { return this instanceof DataSet ? (DataSet) this : this instanceof MutableDataHolder ? new MutableDataSet(this) : new DataSet(this); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKey.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKey.java index a5c328f99..a49d66ee2 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKey.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKey.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * NOTE: Constructors have changed in a breaking way from 0.50.x and prior implementations @@ -36,7 +35,7 @@ public class DataKey extends DataKeyBase { * @param defaultValue default to use when data holder is null * @param factory data value factory for creating a new default value for the key for a non-null data holder */ - public DataKey(@NotNull String name, @NotNull T defaultValue, @NotNull DataNotNullValueFactory factory) { + public DataKey(String name, T defaultValue, DataNotNullValueFactory factory) { super(name, defaultValue, factory); } @@ -48,7 +47,7 @@ public DataKey(@NotNull String name, @NotNull T defaultValue, @NotNull DataNotNu * @param name See {@link #getName()}. * @param supplier data value factory for creating a new default value for the key not dependent on dataHolder */ - public DataKey(@NotNull String name, @NotNull NotNullValueSupplier supplier) { + public DataKey(String name, NotNullValueSupplier supplier) { super(name, supplier.get(), (holder) -> supplier.get()); } @@ -61,36 +60,32 @@ public DataKey(@NotNull String name, @NotNull NotNullValueSupplier supplier) * @param name See {@link #getName()}. * @param defaultKey The NullableDataKey to take the default value from at time of construction. */ - public DataKey(@NotNull String name, @NotNull DataKey defaultKey) { + public DataKey(String name, DataKey defaultKey) { this(name, defaultKey.getDefaultValue(), defaultKey::get); } - public DataKey(@NotNull String name, @NotNull T defaultValue) { + public DataKey(String name, T defaultValue) { this(name, defaultValue, options -> defaultValue); } - @NotNull public DataNotNullValueFactory getFactory() { return (DataNotNullValueFactory) super.getFactory(); } - @NotNull public T getDefaultValue() { return super.getDefaultValue(); } - @NotNull - public T getDefaultValue(@NotNull DataHolder holder) { + public T getDefaultValue(DataHolder holder) { return super.getDefaultValue(holder); } - @NotNull public T get(@Nullable DataHolder holder) { return super.get(holder); } @Override - public @NotNull MutableDataHolder set(@NotNull MutableDataHolder dataHolder, @NotNull T value) { + public MutableDataHolder set(MutableDataHolder dataHolder, T value) { return dataHolder.set(this, value); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKeyAggregator.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKeyAggregator.java index 18e000c3a..357477e24 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKeyAggregator.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKeyAggregator.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -12,7 +11,7 @@ public interface DataKeyAggregator { * @param combined set of combined options (by overwriting or combined by prior aggregator) * @return combined and cleaned of aggregate action keys, return MutableDataHolder if it was modified so downstream aggregators re-use the mutable */ - @NotNull DataHolder aggregate(@NotNull DataHolder combined); + DataHolder aggregate(DataHolder combined); /** * Combine aggregate action keys from two sets but do not apply them @@ -22,7 +21,7 @@ public interface DataKeyAggregator { * @param overrides overriding set of options * @return combined aggregate actions from other and overrides overwritten in combined */ - @NotNull DataHolder aggregateActions(@NotNull DataHolder combined, @NotNull DataHolder other, @NotNull DataHolder overrides); + DataHolder aggregateActions(DataHolder combined, DataHolder other, DataHolder overrides); /** * Remove any keys which contain aggregation actions and do not represent a state @@ -30,7 +29,7 @@ public interface DataKeyAggregator { * @param combined combined data holder * @return cleaned of all aggregate action keys */ - @NotNull DataHolder clean(DataHolder combined); + DataHolder clean(DataHolder combined); /** * return a set of aggregator classes this aggregator should run after diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKeyBase.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKeyBase.java index 473d22047..949bbb35a 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKeyBase.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKeyBase.java @@ -1,11 +1,10 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public abstract class DataKeyBase implements MutableDataValueSetter { - final private @NotNull String name; - final private @NotNull DataValueFactory factory; + final private String name; + final private DataValueFactory factory; final private T defaultValue; /** @@ -17,7 +16,7 @@ public abstract class DataKeyBase implements MutableDataValueSetter { * @param defaultValue default to use when data holder is null * @param factory data value factory for creating a new default value for the key for a non-null data holder */ - public DataKeyBase(@NotNull String name, T defaultValue, @NotNull DataValueFactory factory) { + public DataKeyBase(String name, T defaultValue, DataValueFactory factory) { this.name = name; this.defaultValue = defaultValue; this.factory = factory; @@ -32,20 +31,18 @@ public DataKeyBase(@NotNull String name, T defaultValue, @NotNull DataValueFacto * @param name See {@link #getName()}. * @param defaultKey The NullableDataKey to take the default value from at time of construction. */ - public DataKeyBase(@NotNull String name, @NotNull DataKeyBase defaultKey) { + public DataKeyBase(String name, DataKeyBase defaultKey) { this(name, defaultKey.defaultValue, defaultKey::get); } - public DataKeyBase(@NotNull String name, T defaultValue) { + public DataKeyBase(String name, T defaultValue) { this(name, defaultValue, options -> defaultValue); } - @NotNull public String getName() { return name; } - @NotNull public DataValueFactory getFactory() { return factory; } @@ -54,7 +51,7 @@ public T getDefaultValue() { return defaultValue; } - public T getDefaultValue(@NotNull DataHolder holder) { + public T getDefaultValue(DataHolder holder) { return factory.apply(holder); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataNotNullValueFactory.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataNotNullValueFactory.java index f0736fc15..bd507fea9 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataNotNullValueFactory.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataNotNullValueFactory.java @@ -1,9 +1,8 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; public interface DataNotNullValueFactory extends DataValueFactory { @Override - @NotNull T apply(@NotNull DataHolder dataHolder); + T apply(DataHolder dataHolder); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataNotNullValueNullableFactory.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataNotNullValueNullableFactory.java index 49f9e12e6..e167f04c5 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataNotNullValueNullableFactory.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataNotNullValueNullableFactory.java @@ -1,10 +1,9 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface DataNotNullValueNullableFactory extends DataNotNullValueFactory { @Override - @NotNull T apply(@Nullable DataHolder dataHolder); + T apply(@Nullable DataHolder dataHolder); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataSet.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataSet.java index 60bdb3a3a..5e1e83507 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataSet.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataSet.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -24,8 +23,7 @@ public DataSet(@Nullable DataHolder other) { * @param overrides overrides on options * @return resulting options where aggregate action keys were aggregated but not applied */ - @NotNull - public static DataHolder aggregateActions(@NotNull DataHolder other, @NotNull DataHolder overrides) { + public static DataHolder aggregateActions(DataHolder other, DataHolder overrides) { DataSet combined = new DataSet(other); combined.dataSet.putAll(overrides.getAll()); @@ -40,7 +38,6 @@ public static DataHolder aggregateActions(@NotNull DataHolder other, @NotNull Da * * @return resulting data holder */ - @NotNull public DataHolder aggregate() { DataHolder combined = this; for (DataKeyAggregator combiner : ourDataKeyAggregators) { @@ -56,7 +53,6 @@ public DataHolder aggregate() { * @param overrides overrides which may contain aggregate actions * @return resulting options with aggregate actions applied and removed from set */ - @NotNull public static DataHolder aggregate(@Nullable DataHolder other, @Nullable DataHolder overrides) { if (other == null && overrides == null) { return new DataSet(); @@ -70,22 +66,22 @@ public static DataHolder aggregate(@Nullable DataHolder other, @Nullable DataHol } @Override - public @NotNull Map, Object> getAll() { + public Map, Object> getAll() { return dataSet; } @Override - public @NotNull Collection> getKeys() { + public Collection> getKeys() { return dataSet.keySet(); } @Override - public boolean contains(@NotNull DataKeyBase key) { + public boolean contains(DataKeyBase key) { return dataSet.containsKey(key); } @Override - public @Nullable Object getOrCompute(@NotNull DataKeyBase key, @NotNull DataValueFactory factory) { + public @Nullable Object getOrCompute(DataKeyBase key, DataValueFactory factory) { if (dataSet.containsKey(key)) { return dataSet.get(key); } else { @@ -93,8 +89,7 @@ public boolean contains(@NotNull DataKeyBase key) { } } - @NotNull - public static DataSet merge(@NotNull DataHolder... dataHolders) { + public static DataSet merge(DataHolder... dataHolders) { DataSet dataSet = new DataSet(); for (DataHolder dataHolder : dataHolders) { dataSet.dataSet.putAll(dataHolder.getAll()); @@ -102,26 +97,24 @@ public static DataSet merge(@NotNull DataHolder... dataHolders) { return dataSet; } - @NotNull @Override public MutableDataSet toMutable() { return new MutableDataSet(this); } - @NotNull @Override public DataSet toImmutable() { return this; } @Override - public @NotNull DataSet toDataSet() { + public DataSet toDataSet() { return this; } final private static ArrayList ourDataKeyAggregators = new ArrayList<>(); - public static void registerDataKeyAggregator(@NotNull DataKeyAggregator keyAggregator) { + public static void registerDataKeyAggregator(DataKeyAggregator keyAggregator) { if (isAggregatorRegistered(keyAggregator)) { throw new IllegalStateException("Aggregator " + keyAggregator + " is already registered"); } @@ -146,14 +139,14 @@ public static void registerDataKeyAggregator(@NotNull DataKeyAggregator keyAggre ourDataKeyAggregators.add(keyAggregator); } - static boolean isAggregatorRegistered(@NotNull DataKeyAggregator keyAggregator) { + static boolean isAggregatorRegistered(DataKeyAggregator keyAggregator) { for (DataKeyAggregator aggregator : ourDataKeyAggregators) { if (aggregator.getClass() == keyAggregator.getClass()) return true; } return false; } - static boolean invokeSetContains(@Nullable Set> invokeSet, @NotNull DataKeyAggregator aggregator) { + static boolean invokeSetContains(@Nullable Set> invokeSet, DataKeyAggregator aggregator) { if (invokeSet == null) return false; return invokeSet.contains(aggregator.getClass()); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataValueFactory.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataValueFactory.java index 3db0e2903..7c286ef29 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataValueFactory.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataValueFactory.java @@ -1,12 +1,11 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.Function; public interface DataValueFactory extends Function { @Override - @Nullable T apply(@NotNull DataHolder dataHolder); + @Nullable T apply(DataHolder dataHolder); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataValueNullableFactory.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataValueNullableFactory.java index 14c46cda4..ecfc0cdc9 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataValueNullableFactory.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataValueNullableFactory.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface DataValueNullableFactory extends DataValueFactory { @Override diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataHolder.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataHolder.java index eb08c1865..0f4a3ad9c 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataHolder.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataHolder.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface MutableDataHolder extends DataHolder, MutableDataSetter { /** @@ -13,12 +12,12 @@ public interface MutableDataHolder extends DataHolder, MutableDataSetter { * @deprecated use key.get(dataHolder) instead, which will do the same thing an carries nullable information for the data */ @Deprecated - default T get(@NotNull DataKey key) { + default T get(DataKey key) { return key.get(this); } @Override - Object getOrCompute(@NotNull DataKeyBase key, @NotNull DataValueFactory factory); + Object getOrCompute(DataKeyBase key, DataValueFactory factory); /** * Store the given value for the key @@ -28,7 +27,7 @@ default T get(@NotNull DataKey key) { * @param value value to store * @return mutable data holder for chained calls */ - @NotNull MutableDataHolder set(@NotNull DataKey key, @NotNull T value); + MutableDataHolder set(DataKey key, T value); /** * Store the given value for the key @@ -38,7 +37,7 @@ default T get(@NotNull DataKey key) { * @param value value to store * @return mutable data holder for chained calls */ - @NotNull MutableDataHolder set(@NotNull NullableDataKey key, @Nullable T value); + MutableDataHolder set(NullableDataKey key, @Nullable T value); /** * Remove the stored value for the key, used to force to default or to force recompute @@ -46,7 +45,7 @@ default T get(@NotNull DataKey key) { * @param key data key to remove * @return mutable data holder for chained calls */ - @NotNull MutableDataHolder remove(@NotNull DataKeyBase key); + MutableDataHolder remove(DataKeyBase key); /** * Store the given value for the key @@ -54,7 +53,7 @@ default T get(@NotNull DataKey key) { * @param dataSetter data setter which will set values * @return mutable data holder for chained calls */ - @NotNull MutableDataHolder setFrom(@NotNull MutableDataSetter dataSetter); + MutableDataHolder setFrom(MutableDataSetter dataSetter); /** * Copy all values from one data holder to this data holder @@ -62,7 +61,7 @@ default T get(@NotNull DataKey key) { * @param other data holder from which to copy all values * @return mutable data holder for chained calls */ - @NotNull MutableDataHolder setAll(@NotNull DataHolder other); + MutableDataHolder setAll(DataHolder other); /** * Set options in given mutable data holder @@ -70,14 +69,13 @@ default T get(@NotNull DataKey key) { * @param dataHolder data holder where to copy options from this data holder * @return dataHolder */ - @NotNull @Override - MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder); + MutableDataHolder setIn(MutableDataHolder dataHolder); /** * clear all options out of the data set * * @return mutable data holder for chained calls */ - @NotNull MutableDataHolder clear(); + MutableDataHolder clear(); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataSet.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataSet.java index 4d16a604c..49c801857 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataSet.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataSet.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public class MutableDataSet extends DataSet implements MutableDataHolder { public MutableDataSet() { @@ -12,33 +11,29 @@ public MutableDataSet(@Nullable DataHolder other) { super(other); } - @NotNull @Override - public MutableDataSet set(@NotNull DataKey key, @NotNull T value) { + public MutableDataSet set(DataKey key, T value) { return set((DataKeyBase) key, value); } - @NotNull @Override - public MutableDataSet set(@NotNull NullableDataKey key, @Nullable T value) { + public MutableDataSet set(NullableDataKey key, @Nullable T value) { return set((DataKeyBase) key, value); } - private MutableDataSet set(@NotNull DataKeyBase key, T value) { + private MutableDataSet set(DataKeyBase key, T value) { dataSet.put(key, value); return this; } - @NotNull @Override - public MutableDataSet setFrom(@NotNull MutableDataSetter dataSetter) { + public MutableDataSet setFrom(MutableDataSetter dataSetter) { dataSetter.setIn(this); return this; } - @NotNull @Override - public MutableDataSet setAll(@NotNull DataHolder other) { + public MutableDataSet setAll(DataHolder other) { dataSet.putAll(other.getAll()); return this; } @@ -53,22 +48,20 @@ public static MutableDataSet merge(DataHolder... dataHolders) { return dataSet; } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.setAll(this); return dataHolder; } - @NotNull @Override - public MutableDataSet remove(@NotNull DataKeyBase key) { + public MutableDataSet remove(DataKeyBase key) { dataSet.remove(key); return this; } @Override - public @Nullable Object getOrCompute(@NotNull DataKeyBase key, @NotNull DataValueFactory factory) { + public @Nullable Object getOrCompute(DataKeyBase key, DataValueFactory factory) { if (dataSet.containsKey(key)) { return dataSet.get(key); } else { @@ -78,24 +71,21 @@ public MutableDataSet remove(@NotNull DataKeyBase key) { } } - @NotNull @Override public MutableDataSet toMutable() { return this; } - @NotNull @Override public DataSet toImmutable() { return new DataSet(this); } @Override - public @NotNull MutableDataSet toDataSet() { + public MutableDataSet toDataSet() { return this; } - @NotNull @Override public MutableDataSet clear() { dataSet.clear(); diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataSetter.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataSetter.java index 9ce531e95..16f24255d 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataSetter.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataSetter.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; public interface MutableDataSetter { - @NotNull MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder); + MutableDataHolder setIn(MutableDataHolder dataHolder); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataValueSetter.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataValueSetter.java index f0dadf818..25d8d1143 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataValueSetter.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataValueSetter.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; public interface MutableDataValueSetter { - @NotNull MutableDataHolder set(@NotNull MutableDataHolder dataHolder, T value); + MutableDataHolder set(MutableDataHolder dataHolder, T value); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableScopedDataSet.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableScopedDataSet.java index 560d4c0a2..fd11f0a25 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableScopedDataSet.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableScopedDataSet.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; @@ -26,7 +25,7 @@ public DataHolder getParent() { } @Override - public @NotNull Map, Object> getAll() { + public Map, Object> getAll() { if (parent != null) { HashMap, Object> all = new HashMap<>(super.getAll()); for (DataKeyBase key : parent.getKeys()) { @@ -42,7 +41,7 @@ public DataHolder getParent() { } @Override - public @NotNull Collection> getKeys() { + public Collection> getKeys() { if (parent != null) { ArrayList> all = new ArrayList<>(super.getKeys()); for (DataKeyBase key : parent.getKeys()) { @@ -58,12 +57,12 @@ public DataHolder getParent() { } @Override - public boolean contains(@NotNull DataKeyBase key) { + public boolean contains(DataKeyBase key) { return super.contains(key) || (parent != null && parent.contains(key)); } @Override - public @Nullable Object getOrCompute(@NotNull DataKeyBase key, @NotNull DataValueFactory factory) { + public @Nullable Object getOrCompute(DataKeyBase key, DataValueFactory factory) { if (parent == null || super.contains(key) || !parent.contains(key)) { return super.getOrCompute(key, factory); } else { diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/NotNullValueSupplier.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/NotNullValueSupplier.java index 87993a192..61b70cbbf 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/NotNullValueSupplier.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/NotNullValueSupplier.java @@ -1,11 +1,9 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; import java.util.function.Supplier; public interface NotNullValueSupplier extends Supplier { - @NotNull @Override T get(); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/NullableDataKey.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/NullableDataKey.java index f80116225..e10f4fc6c 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/NullableDataKey.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/NullableDataKey.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.Supplier; @@ -15,7 +14,7 @@ public class NullableDataKey extends DataKeyBase { * @param defaultValue default to use when data holder is null * @param factory data value factory for creating a new default value for the key for a non-null data holder */ - public NullableDataKey(@NotNull String name, @Nullable T defaultValue, @NotNull DataValueFactory factory) { + public NullableDataKey(String name, @Nullable T defaultValue, DataValueFactory factory) { super(name, defaultValue, factory); } @@ -27,7 +26,7 @@ public NullableDataKey(@NotNull String name, @Nullable T defaultValue, @NotNull * @param name See {@link #getName()}. * @param factory data value factory for creating a new default value for the key */ - public NullableDataKey(@NotNull String name, @NotNull DataValueNullableFactory factory) { + public NullableDataKey(String name, DataValueNullableFactory factory) { super(name, factory.apply(null), factory); } @@ -39,7 +38,7 @@ public NullableDataKey(@NotNull String name, @NotNull DataValueNullableFactory supplier) { + public NullableDataKey(String name, Supplier supplier) { super(name, supplier.get(), (holder) -> supplier.get()); } @@ -52,11 +51,11 @@ public NullableDataKey(@NotNull String name, @NotNull Supplier supplier) { * @param name See {@link #getName()}. * @param defaultKey The NullableDataKey to take the default value from at time of construction. */ - public NullableDataKey(@NotNull String name, @NotNull DataKeyBase defaultKey) { + public NullableDataKey(String name, DataKeyBase defaultKey) { this(name, defaultKey.getDefaultValue(), defaultKey::get); } - public NullableDataKey(@NotNull String name, @Nullable T defaultValue) { + public NullableDataKey(String name, @Nullable T defaultValue) { this(name, defaultValue, options -> defaultValue); } @@ -65,7 +64,7 @@ public NullableDataKey(@NotNull String name, @Nullable T defaultValue) { * * @param name key name */ - public NullableDataKey(@NotNull String name) { + public NullableDataKey(String name) { this(name, null, options -> null); } @@ -75,7 +74,7 @@ public T getDefaultValue() { } @Nullable - public T getDefaultValue(@NotNull DataHolder holder) { + public T getDefaultValue(DataHolder holder) { return super.getDefaultValue(holder); } @@ -85,7 +84,7 @@ public T get(@Nullable DataHolder holder) { } @Override - public @NotNull MutableDataHolder set(@NotNull MutableDataHolder dataHolder, @Nullable T value) { + public MutableDataHolder set(MutableDataHolder dataHolder, @Nullable T value) { return dataHolder.set(this, value); } diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/ScopedDataSet.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/ScopedDataSet.java index 6e55c2621..7c62ced96 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/ScopedDataSet.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/ScopedDataSet.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.data; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -23,7 +22,7 @@ public DataHolder getParent() { } @Override - public @NotNull Map, Object> getAll() { + public Map, Object> getAll() { if (parent != null) { HashMap, Object> all = new HashMap<>(parent.getAll()); all.putAll(super.getAll()); @@ -34,7 +33,7 @@ public DataHolder getParent() { } @Override - public @NotNull Collection> getKeys() { + public Collection> getKeys() { if (parent != null) { HashSet> all = new HashSet<>(parent.getKeys()); all.addAll(super.getKeys()); @@ -45,19 +44,19 @@ public DataHolder getParent() { } @Override - public @NotNull MutableDataSet toMutable() { + public MutableDataSet toMutable() { MutableDataSet mutableDataSet = new MutableDataSet(); mutableDataSet.dataSet.putAll(super.getAll()); return parent != null ? new MutableScopedDataSet(parent, mutableDataSet) : mutableDataSet; } @Override - public boolean contains(@NotNull DataKeyBase key) { + public boolean contains(DataKeyBase key) { return super.contains(key) || (parent != null && parent.contains(key)); } @Override - public @Nullable Object getOrCompute(@NotNull DataKeyBase key, @NotNull DataValueFactory factory) { + public @Nullable Object getOrCompute(DataKeyBase key, DataValueFactory factory) { if (parent == null || super.contains(key) || !parent.contains(key)) { return super.getOrCompute(key, factory); } else { diff --git a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/package-info.java b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/package-info.java index 42e976890..5a7ccd8fe 100644 --- a/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/package-info.java +++ b/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.data; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-dependency/pom.xml b/flexmark-util-dependency/pom.xml index b20ab1272..f9fa96291 100644 --- a/flexmark-util-dependency/pom.xml +++ b/flexmark-util-dependency/pom.xml @@ -31,9 +31,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyHandler.java b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyHandler.java index 815afb54a..a05dc1264 100644 --- a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyHandler.java +++ b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyHandler.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.collection.iteration.ReversibleIndexedIterator; import com.vladsch.flexmark.util.misc.Ref; -import org.jetbrains.annotations.NotNull; import java.util.*; @@ -12,9 +11,9 @@ @SuppressWarnings("rawtypes") @Deprecated public abstract class DependencyHandler> { - protected abstract @NotNull S createStage(List dependents); - protected abstract @NotNull Class getDependentClass(D dependent); - protected abstract @NotNull R createResolvedDependencies(List stages); + protected abstract S createStage(List dependents); + protected abstract Class getDependentClass(D dependent); + protected abstract R createResolvedDependencies(List stages); public R resolveDependencies(List dependentsList) { if (dependentsList.size() == 0) { diff --git a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyResolver.java b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyResolver.java index 873c45569..e5b9fc1b8 100644 --- a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyResolver.java +++ b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyResolver.java @@ -2,14 +2,13 @@ import com.vladsch.flexmark.util.collection.iteration.ReversibleIndexedIterator; import com.vladsch.flexmark.util.misc.Ref; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; import java.util.function.Function; public class DependencyResolver { - public static @NotNull List resolveFlatDependencies(@NotNull List dependentsList, @Nullable Function, DependentItemMap> itemSorter, @Nullable Function> classExtractor) { + public static List resolveFlatDependencies(List dependentsList, @Nullable Function, DependentItemMap> itemSorter, @Nullable Function> classExtractor) { List> list = resolveDependencies(dependentsList, itemSorter, classExtractor); if (list.isEmpty()) { return Collections.emptyList(); @@ -29,7 +28,7 @@ public class DependencyResolver { } } - public static @NotNull List> resolveDependencies(@NotNull List dependentsList, @Nullable Function, DependentItemMap> itemSorter, @Nullable Function> classExtractor) { + public static List> resolveDependencies(List dependentsList, @Nullable Function, DependentItemMap> itemSorter, @Nullable Function> classExtractor) { if (dependentsList.size() == 0) { return Collections.emptyList(); } else if (dependentsList.size() == 1) { diff --git a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/Dependent.java b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/Dependent.java index 678768d11..d29c796ed 100644 --- a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/Dependent.java +++ b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/Dependent.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.util.dependency; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; diff --git a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/FlatDependencyHandler.java b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/FlatDependencyHandler.java index e883de085..d8f76a799 100644 --- a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/FlatDependencyHandler.java +++ b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/FlatDependencyHandler.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.dependency; -import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.function.Function; @@ -15,20 +14,17 @@ public List resolvedDependencies(List dependentsList) { return dependencies.dependencies; } - @NotNull @Override protected FlatDependencyStage createStage(List dependents) { return new FlatDependencyStage<>(dependents); } - @NotNull @Override protected Class getDependentClass(T dependent) { //noinspection unchecked return (Class) dependent.getClass(); } - @NotNull @Override protected FlatDependencies createResolvedDependencies(List> stages) { return new FlatDependencies<>(stages); diff --git a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/package-info.java b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/package-info.java index 9c5fe7628..df9e51b1f 100644 --- a/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/package-info.java +++ b/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.dependency; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-experimental/pom.xml b/flexmark-util-experimental/pom.xml index 9e19243c4..773e13bc0 100644 --- a/flexmark-util-experimental/pom.xml +++ b/flexmark-util-experimental/pom.xml @@ -42,6 +42,11 @@ junit test + + org.jspecify + jspecify + 1.0.0 + org.jetbrains annotations diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/BitIntegerSet.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/BitIntegerSet.java index 326c3f984..c5f5df56c 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/BitIntegerSet.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/BitIntegerSet.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.collection.iteration.BitSetIterator; import com.vladsch.flexmark.util.collection.iteration.ReversibleIterable; import com.vladsch.flexmark.util.collection.iteration.ReversibleIterator; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.lang.reflect.Array; import java.nio.ByteBuffer; @@ -18,7 +17,7 @@ public class BitIntegerSet implements Set, ReversibleIterable { final public static int[] EMPTY_INT = new int[0]; - final private @NotNull BitSet myBits; + final private BitSet myBits; final private boolean myReversed; public BitIntegerSet() { @@ -30,16 +29,16 @@ public BitIntegerSet(int i) { myReversed = false; } - public BitIntegerSet(@NotNull BitSet other) { + public BitIntegerSet(BitSet other) { myBits = (BitSet) other.clone(); myReversed = false; } - public BitIntegerSet(@NotNull BitIntegerSet other) { + public BitIntegerSet(BitIntegerSet other) { this(other, other.isReversed()); } - private BitIntegerSet(@NotNull BitIntegerSet other, boolean reversed) { + private BitIntegerSet(BitIntegerSet other, boolean reversed) { myBits = (BitSet) other.myBits.clone(); myReversed = reversed; } @@ -90,7 +89,6 @@ public boolean contains(@Nullable Object o) { return o instanceof Integer && myBits.get((Integer) o); } - @NotNull @Override public Object[] toArray() { Object[] array = new Object[cardinality()]; @@ -101,9 +99,8 @@ public Object[] toArray() { return array; } - @NotNull @Override - public T[] toArray(@NotNull T[] array) { + public T[] toArray(T[] array) { Object[] objects = array; int count = cardinality(); @@ -129,19 +126,17 @@ public T[] toArray(@NotNull T[] array) { } @Override - public boolean add(@NotNull Integer item) { + public boolean add(Integer item) { boolean old = myBits.get(item); myBits.set(item); return old; } - @NotNull - public int[] toArray(@Nullable int[] array) { + public int[] toArray(int @Nullable [] array) { return toArray(array, 0); } - @NotNull - public int[] toArray(@Nullable int[] array, int destinationIndex) { + public int[] toArray(int @Nullable [] array, int destinationIndex) { int arrayLength = array == null ? 0 : array.length; assert destinationIndex <= arrayLength; @@ -171,7 +166,7 @@ public boolean remove(@Nullable Object o) { } @Override - public boolean containsAll(@NotNull Collection collection) { + public boolean containsAll(Collection collection) { if (collection instanceof BitIntegerSet) { BitSet other = ((BitIntegerSet) collection).myBits; BitSet bitSet = (BitSet) this.myBits.clone(); @@ -190,11 +185,11 @@ public boolean addAll(int... collection) { return addAll(collection, 0, Integer.MAX_VALUE); } - public boolean addAll(@NotNull int[] collection, int startIndex) { + public boolean addAll(int[] collection, int startIndex) { return addAll(collection, startIndex, Integer.MAX_VALUE); } - public boolean addAll(@NotNull int[] collection, int startIndex, int endIndex) { + public boolean addAll(int[] collection, int startIndex, int endIndex) { assert startIndex <= endIndex; boolean changed = false; @@ -207,7 +202,7 @@ public boolean addAll(@NotNull int[] collection, int startIndex, int endIndex) { } @Override - public boolean addAll(@NotNull Collection collection) { + public boolean addAll(Collection collection) { if (collection instanceof BitIntegerSet) { BitSet other = ((BitIntegerSet) collection).myBits; BitSet bitSet = (BitSet) this.myBits.clone(); @@ -224,7 +219,7 @@ public boolean addAll(@NotNull Collection collection) { } @Override - public boolean retainAll(@NotNull Collection collection) { + public boolean retainAll(Collection collection) { BitSet other; if (!(collection instanceof BitSet)) { other = new BitSet(); @@ -244,7 +239,7 @@ public boolean retainAll(@NotNull Collection collection) { } @Override - public boolean removeAll(@NotNull Collection collection) { + public boolean removeAll(Collection collection) { if (collection instanceof BitIntegerSet) { BitSet other = ((BitIntegerSet) collection).myBits; BitSet bitSet = (BitSet) this.myBits.clone(); @@ -263,7 +258,7 @@ public boolean removeAll(@NotNull Collection collection) { return changed; } - public void forEach(@NotNull Consumer consumer) { + public void forEach(Consumer consumer) { int index = myBits.nextSetBit(0); while (index >= 0) { consumer.accept(index); @@ -271,7 +266,7 @@ public void forEach(@NotNull Consumer consumer) { } } - public void forEach(@NotNull IntConsumer consumer) { + public void forEach(IntConsumer consumer) { int index = myBits.nextSetBit(0); while (index >= 0) { consumer.accept(index); @@ -295,35 +290,35 @@ public void clear() { } // @formatter:off - public static @NotNull BitIntegerSet valueOf(@NotNull long[] longs) {return new BitIntegerSet(BitSet.valueOf(longs));} - public static @NotNull BitIntegerSet valueOf(@NotNull LongBuffer buffer) {return new BitIntegerSet(BitSet.valueOf(buffer));} - public static @NotNull BitIntegerSet valueOf(@NotNull byte[] bytes) {return new BitIntegerSet(BitSet.valueOf(bytes));} - public static @NotNull BitIntegerSet valueOf(@NotNull ByteBuffer buffer) {return new BitIntegerSet(BitSet.valueOf(buffer));} - - public @NotNull byte[] toByteArray() {return myBits.toByteArray();} - public @NotNull long[] toLongArray() {return myBits.toLongArray();} - - public @NotNull BitIntegerSet flip(int i) {myBits.flip(i); return this;} - public @NotNull BitIntegerSet flip(int i, int i1) {myBits.flip(i, i1); return this;} - public @NotNull BitIntegerSet set(int i) {myBits.set(i); return this;} - public @NotNull BitIntegerSet set(int i, boolean b) {myBits.set(i, b); return this;} - public @NotNull BitIntegerSet set(int i, int i1) {myBits.set(i, i1); return this;} - public @NotNull BitIntegerSet set(int i, int i1, boolean b) {myBits.set(i, i1, b); return this;} - public @NotNull BitIntegerSet clear(int i) {myBits.clear(i); return this;} - public @NotNull BitIntegerSet clear(int i, int i1) {myBits.clear(i, i1); return this;} - - public @NotNull BitIntegerSet and(@NotNull BitSet set) {myBits.and(set); return this;} - public @NotNull BitIntegerSet or(@NotNull BitSet set) {myBits.or(set); return this;} - public @NotNull BitIntegerSet xor(@NotNull BitSet set) {myBits.xor(set); return this;} - public @NotNull BitIntegerSet andNot(@NotNull BitSet set) {myBits.andNot(set); return this;} - public @NotNull BitIntegerSet and(@NotNull BitIntegerSet set) {myBits.and(set.myBits); return this;} - public @NotNull BitIntegerSet or(@NotNull BitIntegerSet set) {myBits.or(set.myBits); return this;} - public @NotNull BitIntegerSet xor(@NotNull BitIntegerSet set) {myBits.xor(set.myBits); return this;} - public @NotNull BitIntegerSet andNot(@NotNull BitIntegerSet set) {myBits.andNot(set.myBits); return this;} + public static BitIntegerSet valueOf(long[] longs) {return new BitIntegerSet(BitSet.valueOf(longs));} + public static BitIntegerSet valueOf(LongBuffer buffer) {return new BitIntegerSet(BitSet.valueOf(buffer));} + public static BitIntegerSet valueOf(byte[] bytes) {return new BitIntegerSet(BitSet.valueOf(bytes));} + public static BitIntegerSet valueOf(ByteBuffer buffer) {return new BitIntegerSet(BitSet.valueOf(buffer));} + + public byte[] toByteArray() {return myBits.toByteArray();} + public long[] toLongArray() {return myBits.toLongArray();} + + public BitIntegerSet flip(int i) {myBits.flip(i); return this;} + public BitIntegerSet flip(int i, int i1) {myBits.flip(i, i1); return this;} + public BitIntegerSet set(int i) {myBits.set(i); return this;} + public BitIntegerSet set(int i, boolean b) {myBits.set(i, b); return this;} + public BitIntegerSet set(int i, int i1) {myBits.set(i, i1); return this;} + public BitIntegerSet set(int i, int i1, boolean b) {myBits.set(i, i1, b); return this;} + public BitIntegerSet clear(int i) {myBits.clear(i); return this;} + public BitIntegerSet clear(int i, int i1) {myBits.clear(i, i1); return this;} + + public BitIntegerSet and(BitSet set) {myBits.and(set); return this;} + public BitIntegerSet or(BitSet set) {myBits.or(set); return this;} + public BitIntegerSet xor(BitSet set) {myBits.xor(set); return this;} + public BitIntegerSet andNot(BitSet set) {myBits.andNot(set); return this;} + public BitIntegerSet and(BitIntegerSet set) {myBits.and(set.myBits); return this;} + public BitIntegerSet or(BitIntegerSet set) {myBits.or(set.myBits); return this;} + public BitIntegerSet xor(BitIntegerSet set) {myBits.xor(set.myBits); return this;} + public BitIntegerSet andNot(BitIntegerSet set) {myBits.andNot(set.myBits); return this;} public boolean get(int i) {return myBits.get(i);} - public @NotNull BitIntegerSet get(int i, int i1) {return new BitIntegerSet(myBits.get(i, i1));} + public BitIntegerSet get(int i, int i1) {return new BitIntegerSet(myBits.get(i, i1));} public int nextSetBit(int i) {return myBits.nextSetBit(i);} public int nextClearBit(int i) {return myBits.nextClearBit(i);} @@ -331,16 +326,16 @@ public void clear() { public int previousClearBit(int i) {return myBits.previousClearBit(i);} public boolean intersects(BitSet set) {return myBits.intersects(set);} - public @NotNull BitSet bitSet() { return myBits; } + public BitSet bitSet() { return myBits; } // @formatter:on @Override - public @NotNull ReversibleIterator iterator() { + public ReversibleIterator iterator() { return new BitSetIterator(myBits, myReversed); } @Override - public @NotNull ReversibleIterable reversed() { + public ReversibleIterable reversed() { return new BitIntegerSet(this, !myReversed); } @@ -350,7 +345,7 @@ public boolean isReversed() { } @Override - public @NotNull ReversibleIterator reversedIterator() { + public ReversibleIterator reversedIterator() { return new BitSetIterator(myBits, !myReversed); } } diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/KeyedItemFactoryMap.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/KeyedItemFactoryMap.java index 7162852d8..4b2026668 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/KeyedItemFactoryMap.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/KeyedItemFactoryMap.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.experimental.util.collection; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.HashMap; @@ -10,21 +9,21 @@ import java.util.function.Function; public class KeyedItemFactoryMap implements Map> { - protected final @NotNull HashMap> factoryMap; - protected final @NotNull HashMap itemMap; - protected final @NotNull P param; + protected final HashMap> factoryMap; + protected final HashMap itemMap; + protected final P param; - public KeyedItemFactoryMap(@NotNull P param) { + public KeyedItemFactoryMap(P param) { this(param, 0); } - public KeyedItemFactoryMap(@NotNull P param, int capacity) { + public KeyedItemFactoryMap(P param, int capacity) { this.factoryMap = new HashMap<>(capacity); this.itemMap = new HashMap<>(); this.param = param; } - public @Nullable I getItem(@NotNull K key) { + public @Nullable I getItem(K key) { I item = itemMap.get(key); if (item == null) { @@ -52,10 +51,10 @@ public KeyedItemFactoryMap(@NotNull P param, int capacity) { public boolean containsKey(@Nullable Object o) {return factoryMap.containsKey(o);} @Override - public @Nullable Function put(@NotNull K k, @NotNull Function factory) {return factoryMap.put(k, factory);} + public @Nullable Function put(K k, Function factory) {return factoryMap.put(k, factory);} @Override - public void putAll(@NotNull Map> map) {factoryMap.putAll(map);} + public void putAll(Map> map) {factoryMap.putAll(map);} @Override public @Nullable Function remove(@Nullable Object o) {return factoryMap.remove(o);} @@ -66,15 +65,12 @@ public KeyedItemFactoryMap(@NotNull P param, int capacity) { @Override public boolean containsValue(Object o) {return factoryMap.containsValue(o);} - @NotNull @Override public Set keySet() {return factoryMap.keySet();} - @NotNull @Override public Collection> values() {return factoryMap.values();} - @NotNull @Override public Set>> entrySet() {return factoryMap.entrySet();} } diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/NullCollectionHost.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/NullCollectionHost.java index 028ec9164..060af22fe 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/NullCollectionHost.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/NullCollectionHost.java @@ -1,7 +1,7 @@ package com.vladsch.flexmark.experimental.util.collection; import com.vladsch.flexmark.util.collection.CollectionHost; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public class NullCollectionHost implements CollectionHost { // @formatter:off diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPosition.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPosition.java index 332852c65..6c68eb8d2 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPosition.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPosition.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.experimental.util.collection.iteration; import com.vladsch.flexmark.util.sequence.PositionAnchor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.function.Predicate; @@ -202,8 +201,8 @@ public interface IPosition> extends IPositionHolder * @return true */ boolean add(int offset, T element); - boolean addAll(@NotNull Collection elements); - boolean addAll(int offset, @NotNull Collection elements); + boolean addAll(Collection elements); + boolean addAll(int offset, Collection elements); /** * @return removed current element, throws IllegalStateException if current index is not valid or after last element of list @@ -232,14 +231,14 @@ public interface IPosition> extends IPositionHolder // test isValidPosition() to see if actual element was found P indexOf(T o); P indexOf(int offset, T o); - P indexOf(@NotNull Predicate

predicate); - P indexOf(int offset, @NotNull Predicate

predicate); + P indexOf(Predicate

predicate); + P indexOf(int offset, Predicate

predicate); // these return position relative to current index and operate on elements before the current index // if not found returned position will point to index after the last element. ie. getIndex() == size() // test isValidPosition() to see if actual element was found P lastIndexOf(T o); - P lastIndexOf(@NotNull Predicate

predicate); + P lastIndexOf(Predicate

predicate); P lastIndexOf(int offset, T o); - P lastIndexOf(int offset, @NotNull Predicate

predicate); + P lastIndexOf(int offset, Predicate

predicate); } diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionBase.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionBase.java index 58b4e5c4f..0ec59ad18 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionBase.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionBase.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.misc.Utils; import com.vladsch.flexmark.util.sequence.PositionAnchor; -import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.List; @@ -18,12 +17,12 @@ public class IPositionBase> implements IPosition myParent; - final private @NotNull List myList; + final private IPositionUpdater myParent; + final private List myList; private int myIndex; private byte myFlags; - public IPositionBase(@NotNull IPositionUpdater parent, int index, @NotNull PositionAnchor anchor) { + public IPositionBase(IPositionUpdater parent, int index, PositionAnchor anchor) { myParent = parent; myList = myParent.getList(); myIndex = index; @@ -178,13 +177,12 @@ public void unframed() { } @Override - public @NotNull PositionAnchor getAnchor() { + public PositionAnchor getAnchor() { return ((myFlags & F_NEXT) != 0) ? NEXT : ((myFlags & F_PREVIOUS) != 0) ? PREVIOUS : CURRENT; } - @NotNull @Override - public P withAnchor(@NotNull PositionAnchor anchor) { + public P withAnchor(PositionAnchor anchor) { if (getAnchor() != anchor) { return myParent.getPosition(myIndex, anchor); } else { @@ -432,12 +430,12 @@ public boolean add(int offset, T element) { } @Override - public boolean addAll(@NotNull Collection elements) { + public boolean addAll(Collection elements) { return addAll(0, elements); } @Override - public boolean addAll(int offset, @NotNull Collection elements) { + public boolean addAll(int offset, Collection elements) { int index = getIndex(offset); validateWithIndex(index, offset); @@ -524,12 +522,12 @@ public P indexOf(int offset, T o) { } @Override - public P indexOf(@NotNull Predicate

predicate) { + public P indexOf(Predicate

predicate) { return indexOf(0, predicate); } @Override - public P indexOf(int offset, @NotNull Predicate

predicate) { + public P indexOf(int offset, Predicate

predicate) { int index = getIndex(offset); validateWithIndex(index, offset); @@ -560,12 +558,12 @@ public P lastIndexOf(int offset, T o) { } @Override - public P lastIndexOf(@NotNull Predicate

predicate) { + public P lastIndexOf(Predicate

predicate) { return lastIndexOf(0, predicate); } @Override - public P lastIndexOf(int offset, @NotNull Predicate

predicate) { + public P lastIndexOf(int offset, Predicate

predicate) { int index = getIndex(offset); validateWithIndex(index, offset); diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionHolder.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionHolder.java index 991303f15..05d2e1f74 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionHolder.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionHolder.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.experimental.util.collection.iteration; import com.vladsch.flexmark.util.sequence.PositionAnchor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface IPositionHolder> extends /*ListIterator

,*/ IPositionListener { @@ -68,7 +67,7 @@ public interface IPositionHolder> extends /*L * * @return position anchor */ - @NotNull PositionAnchor getAnchor(); + PositionAnchor getAnchor(); /** * Get a new position with requested anchor from this position @@ -85,7 +84,7 @@ public interface IPositionHolder> extends /*L */ // FIX: remove this, use previous() and next() to get the right anchor type and index, this should never be used. // positions need to be created with the right anchor or need to add isValidElement to this method for completion - @NotNull P withAnchor(@NotNull PositionAnchor anchor); + P withAnchor(PositionAnchor anchor); /** * Get previous index position relative to current, diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionUpdater.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionUpdater.java index 74a1259a1..05f81bb4a 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionUpdater.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/IPositionUpdater.java @@ -1,16 +1,14 @@ package com.vladsch.flexmark.experimental.util.collection.iteration; import com.vladsch.flexmark.util.sequence.PositionAnchor; -import org.jetbrains.annotations.NotNull; import java.util.Iterator; import java.util.List; public interface IPositionUpdater> extends IPreviewPositionListener { - void addPositionListener(@NotNull IPositionListener listener); - void removePositionListener(@NotNull IPositionListener listener); + void addPositionListener(IPositionListener listener); + void removePositionListener(IPositionListener listener); - @NotNull List getList(); default P getPosition(int index) { @@ -19,9 +17,9 @@ default P getPosition(int index) { void unframe(P position); - P getPosition(int index, @NotNull PositionAnchor anchor); + P getPosition(int index, PositionAnchor anchor); void clear(); - Iterator

iterator(@NotNull P position); + Iterator

iterator(P position); } diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/MappingIterable.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/MappingIterable.java index 3fa3931d2..681150421 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/MappingIterable.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/MappingIterable.java @@ -15,31 +15,29 @@ package com.vladsch.flexmark.experimental.util.collection.iteration; -import org.jetbrains.annotations.NotNull; import java.util.Iterator; import java.util.function.Function; public class MappingIterable implements Iterable { - final private @NotNull Iterable myIterable; - final private @NotNull Function myFunction; + final private Iterable myIterable; + final private Function myFunction; - public MappingIterable(@NotNull Iterable iterable, @NotNull Function function) { + public MappingIterable(Iterable iterable, Function function) { myIterable = iterable; myFunction = function; } - @NotNull @Override public Iterator iterator() { return new MyIterator<>(myIterable.iterator(), myFunction); } private static class MyIterator implements Iterator { - final private @NotNull Iterator myIterator; - final private @NotNull Function myFunction; + final private Iterator myIterator; + final private Function myFunction; - public MyIterator(@NotNull Iterator iterator, @NotNull Function function) { + public MyIterator(Iterator iterator, Function function) { myIterator = iterator; myFunction = function; } diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/Position.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/Position.java index ef0a79d22..864c121da 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/Position.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/Position.java @@ -1,10 +1,9 @@ package com.vladsch.flexmark.experimental.util.collection.iteration; import com.vladsch.flexmark.util.sequence.PositionAnchor; -import org.jetbrains.annotations.NotNull; public class Position extends IPositionBase> { - public Position(@NotNull IPositionUpdater> parent, int index, @NotNull PositionAnchor anchor) { + public Position(IPositionUpdater> parent, int index, PositionAnchor anchor) { super(parent, index, anchor); } } diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionFactory.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionFactory.java index 81000454d..85f39ec94 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionFactory.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionFactory.java @@ -1,9 +1,7 @@ package com.vladsch.flexmark.experimental.util.collection.iteration; import com.vladsch.flexmark.util.sequence.PositionAnchor; -import org.jetbrains.annotations.NotNull; public interface PositionFactory> { - @NotNull - P create(@NotNull IPositionUpdater parent, int index, @NotNull PositionAnchor anchor); + P create(IPositionUpdater parent, int index, PositionAnchor anchor); } diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionIterator.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionIterator.java index e38875433..8ba567144 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionIterator.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionIterator.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.experimental.util.collection.iteration; import com.vladsch.flexmark.util.sequence.PositionAnchor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Iterator; import java.util.NoSuchElementException; @@ -20,7 +19,7 @@ class PositionIterator> implements Iterator

extends PositionListBase> { - public PositionList(@NotNull List list) { + public PositionList(List list) { super(list, Position::new); } } diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionListBase.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionListBase.java index bb2554007..46b7760b6 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionListBase.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionListBase.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.misc.Utils; import com.vladsch.flexmark.util.sequence.PositionAnchor; import com.vladsch.flexmark.util.sequence.RepeatedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import java.util.*; @@ -20,22 +19,22 @@ */ public abstract class PositionListBase> implements Iterable

, IPositionUpdater { - final private @NotNull List myList; - final private @NotNull WeakHashMap myListeners = new WeakHashMap<>(); // != -1 if listener is P and framed, -1 otherwise + final private List myList; + final private WeakHashMap myListeners = new WeakHashMap<>(); // != -1 if listener is P and framed, -1 otherwise private @Nullable WeakHashMap myPreviewListeners = null; // used only for optimized setting notifications since most positions do nothing for this - final private @NotNull PositionFactory myFactory; - final private @NotNull Stack myFrames = new Stack<>(); // open frames + final private PositionFactory myFactory; + final private Stack myFrames = new Stack<>(); // open frames private int myLastFrameId; // starts at 0 and increments forever private int myMaxListeners; private static class FrameLevel { - final @NotNull String parentList; + final String parentList; final @Nullable FrameLevel parentFrame; final int frameLevel; final int frameId; final StackTraceElement[] openStackTrace; - public FrameLevel(@NotNull String parentList, @Nullable FrameLevel parentFrame, int frameId, StackTraceElement[] openStackTrace) { + public FrameLevel(String parentList, @Nullable FrameLevel parentFrame, int frameId, StackTraceElement[] openStackTrace) { this.parentList = parentList; this.parentFrame = parentFrame; this.frameLevel = parentFrame == null ? 0 : parentFrame.frameLevel + 1; @@ -43,11 +42,11 @@ public FrameLevel(@NotNull String parentList, @Nullable FrameLevel parentFrame, this.openStackTrace = openStackTrace; } - boolean isDescendantOf(@NotNull FrameLevel parentFrame) { + boolean isDescendantOf(FrameLevel parentFrame) { return parentFrame == this.parentFrame || this.parentFrame != null && this.parentFrame.isDescendantOf(parentFrame); } - void appendStackTrace(@NotNull StringBuilder out, @NotNull CharSequence indent, int stackOffset) { + void appendStackTrace(StringBuilder out, CharSequence indent, int stackOffset) { int iMax = openStackTrace.length; for (int i = stackOffset; i < iMax; i++) { StackTraceElement element = openStackTrace[i]; @@ -56,7 +55,7 @@ void appendStackTrace(@NotNull StringBuilder out, @NotNull CharSequence indent, } } - public PositionListBase(@NotNull List list, @NotNull PositionFactory factory) { + public PositionListBase(List list, PositionFactory factory) { myList = list; myFactory = factory; } @@ -102,7 +101,7 @@ public int getPreviewListeners() { * @param listener listener */ @Override - public void addPositionListener(@NotNull IPositionListener listener) { + public void addPositionListener(IPositionListener listener) { int frameId = myFrames.isEmpty() ? -1 : myFrames.peek().frameId; myListeners.put(listener, frameId); if (listener instanceof IPreviewPositionListener) { @@ -119,7 +118,7 @@ public void addPositionListener(@NotNull IPositionListener listener) { * @param listener listener */ @Override - public void removePositionListener(@NotNull IPositionListener listener) { + public void removePositionListener(IPositionListener listener) { myListeners.remove(listener); if (myPreviewListeners != null && listener instanceof IPreviewPositionListener) { myPreviewListeners.remove(listener); @@ -129,28 +128,23 @@ public void removePositionListener(@NotNull IPositionListener listener) { } } - @NotNull public Iterator

iterator() { return iterator(getPosition(0, PositionAnchor.NEXT)); } - @NotNull public Iterator

reversedIterator() { return iterator(getPosition(Math.max(0, myList.size() - 1), PositionAnchor.PREVIOUS)); } - @NotNull public Iterable

reversed() { return this::reversedIterator; } - @NotNull - public Iterator

iterator(@NotNull P position) { + public Iterator

iterator(P position) { assert position.getAnchor() != PositionAnchor.CURRENT; return new PositionIterator(position); } - @NotNull public List getList() { return myList; } @@ -188,7 +182,6 @@ public Object openFrame() { return frameLevel; } - @NotNull public String getListParentId() { return getClass().getSimpleName() + "@" + Integer.toString(super.hashCode(), 16); } @@ -256,7 +249,7 @@ private void throwIllegalStateWithOpenFrameTrace(@Nullable StringBuilder out, Fr } @Override - public P getPosition(int index, @NotNull PositionAnchor anchor) { + public P getPosition(int index, PositionAnchor anchor) { if (index < 0 || index > myList.size()) throw new IndexOutOfBoundsException("ListPosition.get(" + index + "), index out valid range [0, " + myList.size() + "]"); @@ -430,19 +423,19 @@ public boolean add(int index, T element) { return true; } - public boolean addAll(@NotNull PositionListBase other) { + public boolean addAll(PositionListBase other) { return addAll(myList.size(), other.myList); } - public boolean addAll(int index, @NotNull PositionListBase other) { + public boolean addAll(int index, PositionListBase other) { return addAll(index, other.myList); } - public boolean addAll(@NotNull Collection elements) { + public boolean addAll(Collection elements) { return addAll(myList.size(), elements); } - public boolean addAll(int index, @NotNull Collection elements) { + public boolean addAll(int index, Collection elements) { assert index >= 0 && index <= myList.size(); myList.addAll(index, elements); inserted(index, elements.size()); @@ -482,7 +475,7 @@ public int size() { // // @NotNull // @Override -// public T1[] toArray(@NotNull T1[] a) { +// public T1[] toArray(T1[] a) { // return myList.toArray(a); // } // @@ -502,22 +495,22 @@ public int size() { // } // // @Override -// public boolean containsAll(@NotNull Collection c) { +// public boolean containsAll(Collection c) { // return myList.containsAll(c); // } // // @Override -// public boolean addAll(@NotNull Collection c) { +// public boolean addAll(Collection c) { // return addAllItems(myList.size(), c); // } // // @Override -// public boolean addAll(int index, @NotNull Collection c) { +// public boolean addAll(int index, Collection c) { // return addAllItems(index, c); // } // // @Override -// public boolean removeAll(@NotNull Collection c) { +// public boolean removeAll(Collection c) { // boolean changed = false; // for (Object item : c) { // if (remove(item)) changed = true; @@ -526,7 +519,7 @@ public int size() { // } // // @Override -// public boolean retainAll(@NotNull Collection c) { +// public boolean retainAll(Collection c) { // int[] toRemove = new int[myList.size()]; // int iMax = 0; // int index = 0; diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/package-info.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/package-info.java index 38269b14c..5df6c3c47 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/package-info.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.experimental.util.collection.iteration; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/package-info.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/package-info.java new file mode 100644 index 000000000..88b64abbe --- /dev/null +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package com.vladsch.flexmark.experimental.util.collection; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/data/CollectionDataKey.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/data/CollectionDataKey.java index 376221694..bee82d361 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/data/CollectionDataKey.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/data/CollectionDataKey.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.data.DataNotNullValueFactory; -import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -14,11 +13,10 @@ public class CollectionDataKey extends DataKey> { * @param defaultValue default value for collection key * @param factory data value factory for creating a new default value for the key */ - public CollectionDataKey(@NotNull String name, @NotNull Collection defaultValue, DataNotNullValueFactory> factory) { + public CollectionDataKey(String name, Collection defaultValue, DataNotNullValueFactory> factory) { super(name, defaultValue, factory); } - @NotNull public DataNotNullValueFactory> getFactory() { return super.getFactory(); } diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/data/package-info.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/data/package-info.java new file mode 100644 index 000000000..0c39a2160 --- /dev/null +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/data/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package com.vladsch.flexmark.experimental.util.data; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/mappers/package-info.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/mappers/package-info.java new file mode 100644 index 000000000..f83a94d60 --- /dev/null +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/mappers/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package com.vladsch.flexmark.experimental.util.mappers; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/package-info.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/package-info.java index b03f5ab0b..154ecc62d 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/package-info.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.experimental.util; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceEntry.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceEntry.java index 5845e9ac7..7dac6a34d 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceEntry.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceEntry.java @@ -3,12 +3,11 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.IRichSequence; import com.vladsch.flexmark.util.sequence.SubSequence; -import org.jetbrains.annotations.NotNull; import java.util.WeakHashMap; public class BaseSequenceEntry { - final private @NotNull WeakHashMap quickEquals = new WeakHashMap<>(); + final private WeakHashMap quickEquals = new WeakHashMap<>(); private int hash; @@ -26,7 +25,7 @@ public BaseSequenceEntry() { * equality type used, 0 - quick class and/or length, 1 - hash, 2 - quick lookup, 3 - string content comparison, 4 - char sequence comparison * @return true if object equivalent to this entry's base sequence, false otherwise */ - public boolean testEquals(@NotNull BasedSequence baseSeq, @NotNull Object o, int[] equalsCall) { + public boolean testEquals(BasedSequence baseSeq, Object o, int[] equalsCall) { equalsCall[0] = 0; if (o == baseSeq || o == baseSeq.getBase()) return true; if (!(o instanceof CharSequence)) return false; diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceManager.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceManager.java index 0ee680fc1..00c10196b 100644 --- a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceManager.java +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceManager.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SubSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.lang.ref.WeakReference; import java.util.Map; @@ -13,8 +12,8 @@ public class BaseSequenceManager { // NOTE: baseMap will keep reference to BaseSequenceEntry as long as the underlying base object is in use // baseSet relies on baseMap to keep references alive for used BasedSequence and its BaseSequenceEntry for quick fail/pass on equals - final private @NotNull WeakHashMap> baseMap = new WeakHashMap<>(); - final private @NotNull WeakHashMap baseSet = new WeakHashMap<>(); + final private WeakHashMap> baseMap = new WeakHashMap<>(); + final private WeakHashMap baseSet = new WeakHashMap<>(); public BaseSequenceManager() { @@ -35,8 +34,7 @@ public BaseSequenceManager() { * @param factory factory to create based sequence from the object * @return existing equivalent base or newly created base */ - @NotNull - public BasedSequence getBaseSequence(@NotNull T object, @Nullable int[] callTypes, @NotNull Function factory) { + public BasedSequence getBaseSequence(T object, int @Nullable [] callTypes, Function factory) { WeakReference baseEntry; BasedSequence baseSeq; diff --git a/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/package-info.java b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/package-info.java new file mode 100644 index 000000000..86e8703bc --- /dev/null +++ b/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package com.vladsch.flexmark.experimental.util.sequence.managed; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-experimental/src/test/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionListTest.java b/flexmark-util-experimental/src/test/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionListTest.java index 2649553b9..dac5250c9 100644 --- a/flexmark-util-experimental/src/test/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionListTest.java +++ b/flexmark-util-experimental/src/test/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionListTest.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.test.util.ExceptionMatcher; import com.vladsch.flexmark.util.sequence.PositionAnchor; -import org.jetbrains.annotations.NotNull; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -1649,10 +1648,10 @@ public void posLastIndexOf1() { } static class PreviewTracker implements IPreviewPositionListener { - final @NotNull StringBuilder out; - final @NotNull List list; + final StringBuilder out; + final List list; - public PreviewTracker(@NotNull StringBuilder out, @NotNull List list) { + public PreviewTracker(StringBuilder out, List list) { this.out = out; this.list = list; } diff --git a/flexmark-util-format/pom.xml b/flexmark-util-format/pom.xml index 6ecd5f74d..238eb4255 100644 --- a/flexmark-util-format/pom.xml +++ b/flexmark-util-format/pom.xml @@ -48,9 +48,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/CharWidthProvider.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/CharWidthProvider.java index 2b8cb2d0d..4f6ea6f15 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/CharWidthProvider.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/CharWidthProvider.java @@ -1,17 +1,16 @@ package com.vladsch.flexmark.util.format; import com.vladsch.flexmark.util.misc.CharPredicate; -import org.jetbrains.annotations.NotNull; public interface CharWidthProvider { int getSpaceWidth(); int getCharWidth(char c); - default int getStringWidth(@NotNull CharSequence chars) { + default int getStringWidth(CharSequence chars) { return getStringWidth(chars, CharPredicate.NONE); } - default int getStringWidth(@NotNull CharSequence chars, @NotNull CharPredicate zeroWidthChars) { + default int getStringWidth(CharSequence chars, CharPredicate zeroWidthChars) { int iMax = chars.length(); int width = 0; diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/ColumnSort.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/ColumnSort.java index 6671ff207..c09474a13 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/ColumnSort.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/ColumnSort.java @@ -1,22 +1,19 @@ package com.vladsch.flexmark.util.format; -import org.jetbrains.annotations.NotNull; final public class ColumnSort { final public int column; - final public @NotNull Sort sort; + final public Sort sort; - private ColumnSort(int column, @NotNull Sort sort) { + private ColumnSort(int column, Sort sort) { this.column = column; this.sort = sort; } - @NotNull - public static ColumnSort columnSort(int column, @NotNull Sort sort) { + public static ColumnSort columnSort(int column, Sort sort) { return new ColumnSort(column, sort); } - @NotNull public static ColumnSort columnSort(int column, boolean descending, boolean numeric, boolean numericLast) { if (numeric) { if (numericLast) { diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownParagraph.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownParagraph.java index ccf930b9b..26b5f625c 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownParagraph.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownParagraph.java @@ -12,8 +12,7 @@ import com.vladsch.flexmark.util.sequence.builder.tree.OffsetInfo; import com.vladsch.flexmark.util.sequence.mappers.SpaceMapper; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInHandler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; @@ -27,9 +26,9 @@ public class MarkdownParagraph { final public static List EMPTY_LEAD_IN_HANDLERS = Collections.emptyList(); final public static List EMPTY_OFFSET_LIST = Collections.emptyList(); - final @NotNull BasedSequence baseSeq; - final @NotNull BasedSequence altSeq; - final @NotNull CharWidthProvider charWidthProvider; + final BasedSequence baseSeq; + final BasedSequence altSeq; + final CharWidthProvider charWidthProvider; private BasedSequence firstIndent = BasedSequence.NULL; private BasedSequence indent = BasedSequence.NULL; @@ -42,7 +41,7 @@ public class MarkdownParagraph { boolean restoreTrackedSpaces = false; @Nullable DataHolder options = null; - @NotNull List leadInHandlers = EMPTY_LEAD_IN_HANDLERS; + List leadInHandlers = EMPTY_LEAD_IN_HANDLERS; private List trackedOffsets = EMPTY_OFFSET_LIST; private boolean trackedOffsetsSorted = true; @@ -54,11 +53,11 @@ public MarkdownParagraph(BasedSequence chars) { this(chars, chars, CharWidthProvider.NULL); } - public MarkdownParagraph(@NotNull BasedSequence chars, @NotNull CharWidthProvider charWidthProvider) { + public MarkdownParagraph(BasedSequence chars, CharWidthProvider charWidthProvider) { this(chars, chars, charWidthProvider); } - public MarkdownParagraph(@NotNull BasedSequence chars, @NotNull BasedSequence altChars, @NotNull CharWidthProvider charWidthProvider) { + public MarkdownParagraph(BasedSequence chars, BasedSequence altChars, CharWidthProvider charWidthProvider) { baseSeq = chars; this.altSeq = altChars; this.charWidthProvider = charWidthProvider; @@ -71,7 +70,6 @@ public BasedSequence wrapTextNotTracked() { return wrapping.wrapText(); } - @NotNull public Range getContinuationStartSplice(int offset, boolean afterSpace, boolean afterDelete) { BasedSequence baseSequence = altSeq.getBaseSequence(); assert offset >= 0 && offset <= baseSequence.length(); @@ -82,7 +80,7 @@ public Range getContinuationStartSplice(int offset, boolean afterSpace, boolean int previousNonBlank = baseSequence.lastIndexOfAnyNot(SPACE_TAB_NBSP_EOL, offset - 1); if (previousNonBlank < startOfLine) { // delete range between last non-blank and offset index - @NotNull OffsetInfo offsetInfo = preFormatTracker.getOffsetInfo(offset, true); + OffsetInfo offsetInfo = preFormatTracker.getOffsetInfo(offset, true); int offsetIndex = offsetInfo.endIndex; int previousNonBlankIndex = altSeq.lastIndexOfAnyNot(SPACE_TAB_NBSP_EOL, offsetIndex - 1); return Range.of(previousNonBlankIndex + 1, offsetIndex); @@ -92,8 +90,7 @@ public Range getContinuationStartSplice(int offset, boolean afterSpace, boolean return Range.NULL; } - @NotNull - BasedSequence resolveTrackedOffsets(@NotNull BasedSequence unwrapped, @NotNull BasedSequence wrapped) { + BasedSequence resolveTrackedOffsets(BasedSequence unwrapped, BasedSequence wrapped) { // Now we map the tracked offsets to indexes in the resulting text BasedOffsetTracker tracker = BasedOffsetTracker.create(wrapped); int iMax = trackedOffsets.size(); @@ -404,7 +401,7 @@ BasedSequence resolveTrackedOffsetsEdit(BasedSequence baseSpliced, BasedSequence return wrapped; } - public void addTrackedOffset(@NotNull TrackedOffset trackedOffset) { + public void addTrackedOffset(TrackedOffset trackedOffset) { if (trackedOffsets == EMPTY_OFFSET_LIST) trackedOffsets = new ArrayList<>(); assert trackedOffset.getOffset() >= 0 && trackedOffset.getOffset() <= altSeq.getBaseSequence().length(); trackedOffsets.removeIf(it -> it.getOffset() == trackedOffset.getOffset()); @@ -435,12 +432,11 @@ public TrackedOffset getTrackedOffset(int offset) { return null; } - @NotNull public List getLeadInHandlers() { return leadInHandlers; } - public void setLeadInHandlers(@NotNull List leadInHandlers) { + public void setLeadInHandlers(List leadInHandlers) { this.leadInHandlers = leadInHandlers; } @@ -461,7 +457,6 @@ public void setRestoreTrackedSpaces(boolean restoreTrackedSpaces) { this.restoreTrackedSpaces = restoreTrackedSpaces; } - @NotNull public BasedSequence getChars() { return baseSeq; } @@ -535,7 +530,6 @@ public void setKeepSoftBreaks(boolean keepLineBreaks) { this.keepSoftLineBreaks = keepLineBreaks; } - @NotNull public CharWidthProvider getCharWidthProvider() { return charWidthProvider; } @@ -549,11 +543,11 @@ public enum TextType { } public static class Token { - final public @NotNull TextType type; - final public @NotNull Range range; + final public TextType type; + final public Range range; final public boolean isFirstWord; - private Token(@NotNull TextType type, @NotNull Range range, boolean isFirstWord) { + private Token(TextType type, Range range, boolean isFirstWord) { this.type = type; this.range = range; this.isFirstWord = isFirstWord; @@ -572,29 +566,25 @@ public CharSequence subSequence(CharSequence charSequence) { return range.charSubSequence(charSequence); } - @NotNull - public static Token of(@NotNull TextType type, @NotNull Range range) { + public static Token of(TextType type, Range range) { return new Token(type, range, false); } - @NotNull - public static Token of(@NotNull TextType type, int start, int end) { + public static Token of(TextType type, int start, int end) { return new Token(type, Range.of(start, end), false); } - @NotNull - public static Token of(@NotNull TextType type, @NotNull Range range, boolean isFirstWord) { + public static Token of(TextType type, Range range, boolean isFirstWord) { return new Token(type, range, isFirstWord); } - @NotNull - public static Token of(@NotNull TextType type, int start, int end, boolean isFirstWord) { + public static Token of(TextType type, int start, int end, boolean isFirstWord) { return new Token(type, Range.of(start, end), isFirstWord); } } class LeftAlignedWrapping { - final @NotNull BasedSequence baseSeq; + final BasedSequence baseSeq; final SequenceBuilder result; final TextTokenizer tokenizer; int col = 0; @@ -606,11 +596,11 @@ class LeftAlignedWrapping { final int nextWidth = width <= 0 ? Integer.MAX_VALUE : spaceWidth * width; int wordsOnLine = 0; BasedSequence lastSpace = null; - @NotNull List leadInHandlers = MarkdownParagraph.this.leadInHandlers; + List leadInHandlers = MarkdownParagraph.this.leadInHandlers; boolean unEscapeSpecialLeadInChars = MarkdownParagraph.this.unEscapeSpecialLeadInChars; boolean escapeSpecialLeadInChars = MarkdownParagraph.this.escapeSpecialLeadInChars; - LeftAlignedWrapping(@NotNull BasedSequence baseSeq) { + LeftAlignedWrapping(BasedSequence baseSeq) { this.baseSeq = baseSeq; result = SequenceBuilder.emptyBuilder(baseSeq); tokenizer = new TextTokenizer(baseSeq); @@ -685,7 +675,6 @@ void processLeadInUnEscape(List handlers, BasedS addChars(sequence); } - @NotNull BasedSequence wrapText() { while (true) { final Token token = tokenizer.getToken(); @@ -780,7 +769,7 @@ public static class TextTokenizer { private int lastConsecutiveSpaces = 0; private @Nullable Token token = null; - TextTokenizer(@NotNull CharSequence chars) { + TextTokenizer(CharSequence chars) { this.chars = chars; maxIndex = this.chars.length(); reset(); @@ -801,7 +790,6 @@ Token getToken() { return token; } - @NotNull public List asList() { ArrayList tokens = new ArrayList<>(); reset(); diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownTable.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownTable.java index abb83be2d..eb269eed0 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownTable.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownTable.java @@ -9,8 +9,7 @@ import com.vladsch.flexmark.util.html.CellAlignment; import com.vladsch.flexmark.util.misc.*; import com.vladsch.flexmark.util.sequence.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.BitSet; @@ -41,7 +40,7 @@ public class MarkdownTable { private int[] columnWidths; // generated by conversion to text - final private @NotNull ArrayList trackedOffsets = new ArrayList<>(); + final private ArrayList trackedOffsets = new ArrayList<>(); final private TableSection[] ALL_SECTIONS; // includes header, separator, body, caption final private TableSection[] ALL_TABLE_ROWS; // includes header, separator, body @@ -60,16 +59,16 @@ public boolean test(String s) { } @Override - public boolean sortSuffix(@NotNull String suffix) { + public boolean sortSuffix(String suffix) { return false; } }; - public MarkdownTable(@NotNull CharSequence tableChars, @Nullable DataHolder options) { + public MarkdownTable(CharSequence tableChars, @Nullable DataHolder options) { this(tableChars, new TableFormatOptions(options)); } - public MarkdownTable(@NotNull CharSequence tableChars, @Nullable TableFormatOptions options) { + public MarkdownTable(CharSequence tableChars, @Nullable TableFormatOptions options) { this.tableChars = tableChars; this.formatTableIndentPrefix = options == null ? "" : options.formatTableIndentPrefix; header = new TableSection(TableSectionType.HEADER); @@ -196,7 +195,6 @@ public int getMaxColumnsWithoutRows(boolean withSeparator, int... skipRows) { return aggregateTotalColumnsWithoutRows(withSeparator ? ALL_TABLE_ROWS : ALL_CONTENT_ROWS, MaxAggregator.INSTANCE, skipRows); } - @NotNull public List getTrackedOffsets() { return trackedOffsets; } @@ -307,7 +305,7 @@ public boolean addTrackedOffset(int offset, Character c, boolean afterDelete) { return addTrackedOffset(TrackedOffset.track(offset, c, afterDelete)); } - public boolean addTrackedOffset(@NotNull TrackedOffset trackedOffset) { + public boolean addTrackedOffset(TrackedOffset trackedOffset) { int offset = trackedOffset.getOffset(); trackedOffsets.removeIf(it -> it.getOffset() == offset); trackedOffsets.add(trackedOffset); @@ -633,7 +631,7 @@ public void nextRow() { /** * @param cell cell to add */ - public void addCell(@NotNull TableCell cell) { + public void addCell(TableCell cell) { TableSection tableSection = isSeparator ? separator : isHeading ? header : body; if (isSeparator && (cell.columnSpan != 1 || cell.rowSpan != 1)) { throw new IllegalStateException("Separator columns cannot span rows/columns"); } diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownWriterBase.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownWriterBase.java index 1cd5845c0..901ada096 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownWriterBase.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownWriterBase.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.util.sequence.LineAppendableImpl; import com.vladsch.flexmark.util.sequence.LineInfo; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.IOException; import java.util.Iterator; @@ -44,14 +43,12 @@ public C getContext() { } @SuppressWarnings("UnusedReturnValue") - @NotNull public T tailBlankLine() { return tailBlankLine(1); } - abstract public @NotNull BasedSequence lastBlockQuoteChildPrefix(BasedSequence prefix); + abstract public BasedSequence lastBlockQuoteChildPrefix(BasedSequence prefix); - @NotNull public T tailBlankLine(int count) { BasedSequence prefix = appendable.getPrefix(); BasedSequence replacedPrefix = lastBlockQuoteChildPrefix(prefix); @@ -68,13 +65,13 @@ public T tailBlankLine(int count) { } // @formatter:off - @NotNull @Override public Iterator iterator() {return appendable.iterator();} - @NotNull @Override public Iterable getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) {return appendable.getLines(maxTrailingBlankLines, startLine, endLine, true);} - @NotNull @Override public Iterable getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine) {return appendable.getLinesInfo(maxTrailingBlankLines, startLine, endLine);} + @Override public Iterator iterator() {return appendable.iterator();} + @Override public Iterable getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) {return appendable.getLines(maxTrailingBlankLines, startLine, endLine, true);} + @Override public Iterable getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine) {return appendable.getLinesInfo(maxTrailingBlankLines, startLine, endLine);} @Override public void setPrefixLength(int lineIndex, int prefixEndIndex) { appendable.setPrefixLength(lineIndex, prefixEndIndex); } - @Override public void insertLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence text) { appendable.insertLine(lineIndex, prefix, text); } - @Override public void setLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence text) { appendable.setLine(lineIndex, prefix, text); } - @Override public T appendTo(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { return appendable.appendTo(out, withPrefixes, maxBlankLines, maxTrailingBlankLines, startLine, endLine); } + @Override public void insertLine(int lineIndex, CharSequence prefix, CharSequence text) { appendable.insertLine(lineIndex, prefix, text); } + @Override public void setLine(int lineIndex, CharSequence prefix, CharSequence text) { appendable.setLine(lineIndex, prefix, text); } + @Override public T appendTo(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { return appendable.appendTo(out, withPrefixes, maxBlankLines, maxTrailingBlankLines, startLine, endLine); } @Override public boolean endsWithEOL() { return appendable.endsWithEOL(); } @Override public boolean isPendingSpace() { return appendable.isPendingSpace(); } @Override public boolean isPreFormatted() { return appendable.isPreFormatted(); } @@ -88,48 +85,48 @@ public T tailBlankLine(int count) { @Override public int offset() { return appendable.offset(); } @Override public int offsetWithPending() { return appendable.offsetWithPending(); } @Override public int getAfterEolPrefixDelta() { return appendable.getAfterEolPrefixDelta(); } - @NotNull @Override public ISequenceBuilder getBuilder() { return appendable.getBuilder(); } - @NotNull @Override public BasedSequence getPrefix() { return appendable.getPrefix(); } - @NotNull @Override public BasedSequence getBeforeEolPrefix() { return appendable.getBeforeEolPrefix(); } - @NotNull @Override public LineInfo getLineInfo(int lineIndex) { return appendable.getLineInfo(lineIndex); } - @NotNull @Override public BasedSequence getLine(int lineIndex) { return appendable.getLine(lineIndex); } - @NotNull @Override public BasedSequence getIndentPrefix() { return appendable.getIndentPrefix(); } - @NotNull @Override public CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { return appendable.toSequence(maxBlankLines, maxTrailingBlankLines, withPrefixes ); } - @NotNull @Override public String toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { return appendable.toString(maxBlankLines, maxTrailingBlankLines, withPrefixes ); } - @NotNull @Override public BitFieldSet getOptionSet() { return appendable.getOptionSet();} - @NotNull @Override public T removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) { appendable.removeExtraBlankLines(maxBlankLines, maxTrailingBlankLines, startLine, endLine); return (T) this; } - @NotNull @Override public T removeLines(int startLine, int endLine) { appendable.removeLines(startLine, endLine); return (T) this; } - @NotNull @Override public T pushOptions() { appendable.pushOptions(); return (T) this; } - @NotNull @Override public T popOptions() { appendable.popOptions(); return (T) this; } - @NotNull @Override public T changeOptions(int addFlags, int removeFlags) { appendable.changeOptions(addFlags, removeFlags); return (T) this; } - @NotNull @Override public T addIndentOnFirstEOL(@NotNull Runnable listener) { appendable.addIndentOnFirstEOL(listener); return (T)this; } - @NotNull @Override public T addPrefix(@NotNull CharSequence prefix) { appendable.addPrefix(prefix); return (T)this; } - @NotNull @Override public T addPrefix(@NotNull CharSequence prefix, boolean afterEol) { appendable.addPrefix(prefix, afterEol); return (T)this; } - @NotNull @Override public T append(char c) { appendable.append(c); return (T)this; } - @NotNull @Override public T append(@NotNull CharSequence csq) { appendable.append(csq); return (T)this; } - @NotNull @Override public T append(@NotNull CharSequence csq, int start, int end) { appendable.append(csq, start, end); return (T)this; } - @NotNull @Override public T append(@NotNull LineAppendable lines, int startLine, int endLine, boolean withPrefixes) { appendable.append(lines, startLine, endLine, withPrefixes); return (T)this; } - @NotNull @Override public T blankLine() { appendable.blankLine(); return (T)this; } - @NotNull @Override public T blankLine(int count) { appendable.blankLine(count); return (T)this; } - @NotNull @Override public T blankLineIf(boolean predicate) { appendable.blankLineIf(predicate); return (T)this; } - @NotNull @Override public T closePreFormatted() { appendable.closePreFormatted(); return (T)this; } - @NotNull @Override public T indent() { appendable.indent(); return (T)this; } - @NotNull @Override public T line() { appendable.line(); return (T)this; } - @NotNull @Override public T lineIf(boolean predicate) { appendable.lineIf(predicate); return (T)this; } - @NotNull @Override public T lineOnFirstText(boolean value) { appendable.lineOnFirstText(value); return (T)this; } - @NotNull @Override public T lineWithTrailingSpaces(int count) { appendable.lineWithTrailingSpaces(count); return (T)this; } - @NotNull @Override public T openPreFormatted(boolean keepIndent) { appendable.openPreFormatted(keepIndent); return (T)this; } - @NotNull @Override public T popPrefix() { appendable.popPrefix(); return (T)this; } - @NotNull @Override public T popPrefix(boolean afterEol) { appendable.popPrefix(afterEol); return (T)this; } - @NotNull @Override public T pushPrefix() { appendable.pushPrefix(); return (T)this; } - @NotNull @Override public T removeIndentOnFirstEOL(@NotNull Runnable listener) { appendable.removeIndentOnFirstEOL(listener); return (T)this; } - @NotNull @Override public T append(char c, int count) { appendable.append(c, count); return (T)this; } - @NotNull @Override public T setIndentPrefix(@Nullable CharSequence prefix) { appendable.setIndentPrefix(prefix); return (T)this; } - @NotNull @Override public T setOptions(int flags) { appendable.setOptions(flags); return (T)this; } - @NotNull @Override public T setPrefix(@NotNull CharSequence prefix) { appendable.setPrefix(prefix); return (T)this; } - @NotNull @Override public T setPrefix(@Nullable CharSequence prefix, boolean afterEol) { appendable.setPrefix(prefix, afterEol); return (T)this; } - @NotNull @Override public T unIndent() { appendable.unIndent(); return (T)this; } - @NotNull @Override public T unIndentNoEol() { appendable.unIndentNoEol(); return (T)this; } + @Override public ISequenceBuilder getBuilder() { return appendable.getBuilder(); } + @Override public BasedSequence getPrefix() { return appendable.getPrefix(); } + @Override public BasedSequence getBeforeEolPrefix() { return appendable.getBeforeEolPrefix(); } + @Override public LineInfo getLineInfo(int lineIndex) { return appendable.getLineInfo(lineIndex); } + @Override public BasedSequence getLine(int lineIndex) { return appendable.getLine(lineIndex); } + @Override public BasedSequence getIndentPrefix() { return appendable.getIndentPrefix(); } + @Override public CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { return appendable.toSequence(maxBlankLines, maxTrailingBlankLines, withPrefixes ); } + @Override public String toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { return appendable.toString(maxBlankLines, maxTrailingBlankLines, withPrefixes ); } + @Override public BitFieldSet getOptionSet() { return appendable.getOptionSet();} + @Override public T removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) { appendable.removeExtraBlankLines(maxBlankLines, maxTrailingBlankLines, startLine, endLine); return (T) this; } + @Override public T removeLines(int startLine, int endLine) { appendable.removeLines(startLine, endLine); return (T) this; } + @Override public T pushOptions() { appendable.pushOptions(); return (T) this; } + @Override public T popOptions() { appendable.popOptions(); return (T) this; } + @Override public T changeOptions(int addFlags, int removeFlags) { appendable.changeOptions(addFlags, removeFlags); return (T) this; } + @Override public T addIndentOnFirstEOL(Runnable listener) { appendable.addIndentOnFirstEOL(listener); return (T)this; } + @Override public T addPrefix(CharSequence prefix) { appendable.addPrefix(prefix); return (T)this; } + @Override public T addPrefix(CharSequence prefix, boolean afterEol) { appendable.addPrefix(prefix, afterEol); return (T)this; } + @Override public T append(char c) { appendable.append(c); return (T)this; } + @Override public T append(CharSequence csq) { appendable.append(csq); return (T)this; } + @Override public T append(CharSequence csq, int start, int end) { appendable.append(csq, start, end); return (T)this; } + @Override public T append(LineAppendable lines, int startLine, int endLine, boolean withPrefixes) { appendable.append(lines, startLine, endLine, withPrefixes); return (T)this; } + @Override public T blankLine() { appendable.blankLine(); return (T)this; } + @Override public T blankLine(int count) { appendable.blankLine(count); return (T)this; } + @Override public T blankLineIf(boolean predicate) { appendable.blankLineIf(predicate); return (T)this; } + @Override public T closePreFormatted() { appendable.closePreFormatted(); return (T)this; } + @Override public T indent() { appendable.indent(); return (T)this; } + @Override public T line() { appendable.line(); return (T)this; } + @Override public T lineIf(boolean predicate) { appendable.lineIf(predicate); return (T)this; } + @Override public T lineOnFirstText(boolean value) { appendable.lineOnFirstText(value); return (T)this; } + @Override public T lineWithTrailingSpaces(int count) { appendable.lineWithTrailingSpaces(count); return (T)this; } + @Override public T openPreFormatted(boolean keepIndent) { appendable.openPreFormatted(keepIndent); return (T)this; } + @Override public T popPrefix() { appendable.popPrefix(); return (T)this; } + @Override public T popPrefix(boolean afterEol) { appendable.popPrefix(afterEol); return (T)this; } + @Override public T pushPrefix() { appendable.pushPrefix(); return (T)this; } + @Override public T removeIndentOnFirstEOL(Runnable listener) { appendable.removeIndentOnFirstEOL(listener); return (T)this; } + @Override public T append(char c, int count) { appendable.append(c, count); return (T)this; } + @Override public T setIndentPrefix(@Nullable CharSequence prefix) { appendable.setIndentPrefix(prefix); return (T)this; } + @Override public T setOptions(int flags) { appendable.setOptions(flags); return (T)this; } + @Override public T setPrefix(CharSequence prefix) { appendable.setPrefix(prefix); return (T)this; } + @Override public T setPrefix(@Nullable CharSequence prefix, boolean afterEol) { appendable.setPrefix(prefix, afterEol); return (T)this; } + @Override public T unIndent() { appendable.unIndent(); return (T)this; } + @Override public T unIndentNoEol() { appendable.unIndentNoEol(); return (T)this; } // @formatter:on } diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/NodeContext.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/NodeContext.java index cec8e155d..6d7fa4ecf 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/NodeContext.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/NodeContext.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface NodeContext> { /** @@ -12,7 +11,7 @@ public interface NodeContext> { * * @return a new rendering context with a given appendable for its output */ - @NotNull C getSubContext(); + C getSubContext(); /** * Creates a child rendering context that can be used to collect rendered html text. The child context inherits @@ -21,7 +20,7 @@ public interface NodeContext> { * @param options options to use for the context (only options which do not affect the context construction will be used) * @return a new rendering context with a given appendable for its output */ - @NotNull C getSubContext(@Nullable DataHolder options); + C getSubContext(@Nullable DataHolder options); /** * Creates a child rendering context that can be used to collect rendered html text. The child context inherits @@ -31,7 +30,7 @@ public interface NodeContext> { * @param builder sequence builder to user for appended text for tracking original base offsets * @return a new rendering context with a given appendable for its output */ - @NotNull C getSubContext(@Nullable DataHolder options, @NotNull ISequenceBuilder builder); + C getSubContext(@Nullable DataHolder options, ISequenceBuilder builder); /** * @return the current node being rendered @@ -43,5 +42,5 @@ public interface NodeContext> { * * @return data holder */ - @NotNull DataHolder getOptions(); + DataHolder getOptions(); } diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/NumericSuffixPredicate.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/NumericSuffixPredicate.java index 69cc7b817..0dded5524 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/NumericSuffixPredicate.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/NumericSuffixPredicate.java @@ -1,11 +1,10 @@ package com.vladsch.flexmark.util.format; -import org.jetbrains.annotations.NotNull; import java.util.function.Predicate; public interface NumericSuffixPredicate extends Predicate { - default boolean sortSuffix(@NotNull String suffix) { + default boolean sortSuffix(String suffix) { return true; } } diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TableCell.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TableCell.java index c59ac19e0..119116e00 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TableCell.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TableCell.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.html.CellAlignment; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.PrefixedSubSequence; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.util.misc.Utils.*; @@ -95,7 +94,7 @@ public TableCell( this.afterDelete = afterDelete; } - public TableCell(@NotNull TableCell other, boolean copyNode, int rowSpan, int columnSpan, CellAlignment alignment) { + public TableCell(TableCell other, boolean copyNode, int rowSpan, int columnSpan, CellAlignment alignment) { this.tableCellNode = copyNode ? other.tableCellNode : null; this.openMarker = other.openMarker; this.closeMarker = other.closeMarker; diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TableFormatOptions.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TableFormatOptions.java index 0c1aab614..77334ea9e 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TableFormatOptions.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TableFormatOptions.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.format.options.TableCaptionHandling; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; @SuppressWarnings("WeakerAccess") public class TableFormatOptions implements MutableDataSetter { @@ -89,9 +88,8 @@ public TableFormatOptions(DataHolder options) { dashWidth = charWidthProvider.getCharWidth('-'); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { dataHolder.set(FORMAT_TABLE_LEAD_TRAIL_PIPES, leadTrailPipes); dataHolder.set(FORMAT_TABLE_SPACE_AROUND_PIPES, spaceAroundPipes); dataHolder.set(FORMAT_TABLE_ADJUST_COLUMN_WIDTH, adjustColumnWidth); diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffset.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffset.java index bdd76d149..951e5a12f 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffset.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffset.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.util.format; import com.vladsch.flexmark.util.misc.BitFieldSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * Tracked Offset information @@ -42,7 +41,7 @@ private TrackedOffset(int offset, boolean afterSpaceEdit, boolean afterInsert, b this.spacesAfter = -1; } - private TrackedOffset(@NotNull TrackedOffset other) { + private TrackedOffset(TrackedOffset other) { this.original = other.original; this.offset = other.offset; this.flags = other.flags; @@ -51,7 +50,7 @@ private TrackedOffset(@NotNull TrackedOffset other) { this.spacesAfter = other.spacesAfter; } - private TrackedOffset(@NotNull TrackedOffset other, int offset) { + private TrackedOffset(TrackedOffset other, int offset) { this.original = other; this.offset = offset; this.flags = other.flags; @@ -113,22 +112,20 @@ public boolean isAfterDelete() { return BitFieldSet.any(flags, F_AFTER_DELETE); } - @NotNull public TrackedOffset plusOffsetDelta(int delta) { return new TrackedOffset(this, offset + delta); } - @NotNull public TrackedOffset withOffset(int offset) { return new TrackedOffset(this, offset); } @Override - public int compareTo(@NotNull TrackedOffset o) { + public int compareTo(TrackedOffset o) { return Integer.compare(offset, o.offset); } - public int compareTo(@NotNull Integer o) { + public int compareTo(Integer o) { return Integer.compare(offset, o); } @@ -164,7 +161,7 @@ public String toString() { "}"; } - public static TrackedOffset track(@NotNull TrackedOffset other) { + public static TrackedOffset track(TrackedOffset other) { return new TrackedOffset(other); } diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffsetList.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffsetList.java index 5d780e4d4..52355dd35 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffsetList.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffsetList.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.sequence.builder.tree.BasedOffsetTracker; import com.vladsch.flexmark.util.sequence.builder.tree.OffsetInfo; import com.vladsch.flexmark.util.sequence.builder.tree.SegmentOffsetTree; -import org.jetbrains.annotations.NotNull; import java.util.*; import java.util.function.UnaryOperator; @@ -13,13 +12,11 @@ public class TrackedOffsetList implements List { public static TrackedOffsetList EMPTY_LIST = new TrackedOffsetList(BasedSequence.NULL, Collections.emptyList()); - @NotNull - public static TrackedOffsetList create(@NotNull BasedSequence baseSeq, @NotNull List trackedOffsets) { + public static TrackedOffsetList create(BasedSequence baseSeq, List trackedOffsets) { return trackedOffsets instanceof TrackedOffsetList ? (TrackedOffsetList) trackedOffsets : new TrackedOffsetList(baseSeq, trackedOffsets); } - @NotNull - public static TrackedOffsetList create(@NotNull BasedSequence baseSeq, @NotNull int[] offsets) { + public static TrackedOffsetList create(BasedSequence baseSeq, int[] offsets) { ArrayList trackedOffsets = new ArrayList<>(offsets.length); for (int offset : offsets) { trackedOffsets.add(TrackedOffset.track(offset)); @@ -27,11 +24,11 @@ public static TrackedOffsetList create(@NotNull BasedSequence baseSeq, @NotNull return new TrackedOffsetList(baseSeq, trackedOffsets); } - final private @NotNull BasedSequence myBaseSeq; - final private @NotNull List myTrackedOffsets; - final private @NotNull BasedOffsetTracker myBasedOffsetTracker; + final private BasedSequence myBaseSeq; + final private List myTrackedOffsets; + final private BasedOffsetTracker myBasedOffsetTracker; - private TrackedOffsetList(@NotNull BasedSequence baseSeq, @NotNull List trackedOffsets) { + private TrackedOffsetList(BasedSequence baseSeq, List trackedOffsets) { myBaseSeq = baseSeq; myTrackedOffsets = new ArrayList<>(trackedOffsets); myTrackedOffsets.sort(Comparator.comparing(TrackedOffset::getOffset)); @@ -44,7 +41,6 @@ private TrackedOffsetList(@NotNull BasedSequence baseSeq, @NotNull List unresolved = new ArrayList<>(); @@ -61,22 +57,18 @@ public boolean haveUnresolved() { return false; } - @NotNull public BasedSequence getBaseSeq() { return myBaseSeq; } - @NotNull public List getTrackedOffsets() { return myTrackedOffsets; } - @NotNull public BasedOffsetTracker getBasedOffsetTracker() { return myBasedOffsetTracker; } - @NotNull public TrackedOffsetList getTrackedOffsets(int startOffset, int endOffset) { OffsetInfo startInfo = myBasedOffsetTracker.getOffsetInfo(startOffset, startOffset == endOffset); OffsetInfo endInfo = myBasedOffsetTracker.getOffsetInfo(endOffset, true); @@ -114,10 +106,10 @@ public TrackedOffsetList getTrackedOffsets(int startOffset, int endOffset) { @Override public TrackedOffset set(int index, TrackedOffset element) { throw new IllegalStateException("Not supported. Immutable list."); } @Override public void add(int index, TrackedOffset element) { throw new IllegalStateException("Not supported. Immutable list."); } @Override public TrackedOffset remove(int index) { throw new IllegalStateException("Not supported. Immutable list."); } - @Override public boolean addAll(@NotNull Collection c) { throw new IllegalStateException("Not supported. Immutable list."); } - @Override public boolean addAll(int index, @NotNull Collection c) { throw new IllegalStateException("Not supported. Immutable list."); } - @Override public boolean removeAll(@NotNull Collection c) { throw new IllegalStateException("Not supported. Immutable list."); } - @Override public boolean retainAll(@NotNull Collection c) { throw new IllegalStateException("Not supported. Immutable list."); } + @Override public boolean addAll(Collection c) { throw new IllegalStateException("Not supported. Immutable list."); } + @Override public boolean addAll(int index, Collection c) { throw new IllegalStateException("Not supported. Immutable list."); } + @Override public boolean removeAll(Collection c) { throw new IllegalStateException("Not supported. Immutable list."); } + @Override public boolean retainAll(Collection c) { throw new IllegalStateException("Not supported. Immutable list."); } @Override public void replaceAll(UnaryOperator operator) { throw new IllegalStateException("Not supported. Immutable list."); } @Override public void sort(Comparator c) { throw new IllegalStateException("Not supported. Immutable list."); } @Override public void clear() { throw new IllegalStateException("Not supported. Immutable list."); } @@ -134,20 +126,17 @@ public TrackedOffsetList getTrackedOffsets(int startOffset, int endOffset) { @Override public boolean contains(Object o) {return myTrackedOffsets.contains(o);} - @NotNull @Override public Iterator iterator() {return myTrackedOffsets.iterator();} - @NotNull @Override public Object[] toArray() {return myTrackedOffsets.toArray();} - @NotNull @Override - public T[] toArray(@NotNull T[] a) {return myTrackedOffsets.toArray(a);} + public T[] toArray(T[] a) {return myTrackedOffsets.toArray(a);} @Override - public boolean containsAll(@NotNull Collection c) {return myTrackedOffsets.containsAll(c);} + public boolean containsAll(Collection c) {return myTrackedOffsets.containsAll(c);} @Override public boolean equals(Object o) {return myTrackedOffsets.equals(o);} @@ -164,15 +153,12 @@ public TrackedOffsetList getTrackedOffsets(int startOffset, int endOffset) { @Override public int lastIndexOf(Object o) {return myTrackedOffsets.lastIndexOf(o);} - @NotNull @Override public ListIterator listIterator() {return myTrackedOffsets.listIterator();} - @NotNull @Override public ListIterator listIterator(int index) {return myTrackedOffsets.listIterator(index);} - @NotNull @Override public List subList(int fromIndex, int toIndex) {return myTrackedOffsets.subList(fromIndex, toIndex);} diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/options/package-info.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/options/package-info.java index beaa9c4c7..5e3c5e13b 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/options/package-info.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/options/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.format.options; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/package-info.java b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/package-info.java index a63bcf24f..0fb68c0cc 100644 --- a/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/package-info.java +++ b/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.format; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-html/pom.xml b/flexmark-util-html/pom.xml index 01d94299c..89b56002a 100644 --- a/flexmark-util-html/pom.xml +++ b/flexmark-util-html/pom.xml @@ -26,9 +26,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/HtmlAppendable.java b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/HtmlAppendable.java index 87dc97402..487cfb335 100644 --- a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/HtmlAppendable.java +++ b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/HtmlAppendable.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.util.html; import com.vladsch.flexmark.util.sequence.LineAppendable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.List; import java.util.Stack; @@ -13,38 +12,38 @@ @SuppressWarnings("UnusedReturnValue") public interface HtmlAppendable extends LineAppendable { @Nullable Attributes getAttributes(); - @NotNull HtmlAppendable setAttributes(@NotNull Attributes attributes); + HtmlAppendable setAttributes(Attributes attributes); boolean inPre(); - @NotNull HtmlAppendable openPre(); - @NotNull HtmlAppendable closePre(); - @NotNull HtmlAppendable raw(@NotNull CharSequence s); - @NotNull HtmlAppendable raw(@NotNull CharSequence s, int count); - @NotNull HtmlAppendable rawPre(@NotNull CharSequence s); - @NotNull HtmlAppendable rawIndentedPre(@NotNull CharSequence s); - @NotNull HtmlAppendable text(@NotNull CharSequence s); - @NotNull HtmlAppendable attr(@NotNull CharSequence attrName, @NotNull CharSequence value); - @NotNull HtmlAppendable attr(@NotNull Attribute... attribute); - @NotNull HtmlAppendable attr(@NotNull Attributes attributes); - @NotNull HtmlAppendable withAttr(); + HtmlAppendable openPre(); + HtmlAppendable closePre(); + HtmlAppendable raw(CharSequence s); + HtmlAppendable raw(CharSequence s, int count); + HtmlAppendable rawPre(CharSequence s); + HtmlAppendable rawIndentedPre(CharSequence s); + HtmlAppendable text(CharSequence s); + HtmlAppendable attr(CharSequence attrName, CharSequence value); + HtmlAppendable attr(Attribute... attribute); + HtmlAppendable attr(Attributes attributes); + HtmlAppendable withAttr(); // tag tracking - @NotNull Stack getOpenTags(); - @NotNull List getOpenTagsAfterLast(@NotNull CharSequence latestTag); + Stack getOpenTags(); + List getOpenTagsAfterLast(CharSequence latestTag); - @NotNull HtmlAppendable withCondLineOnChildText(); - @NotNull HtmlAppendable withCondIndent(); + HtmlAppendable withCondLineOnChildText(); + HtmlAppendable withCondIndent(); - @NotNull HtmlAppendable tagVoid(@NotNull CharSequence tagName); - @NotNull HtmlAppendable tag(@NotNull CharSequence tagName); - @NotNull HtmlAppendable tag(@NotNull CharSequence tagName, @NotNull Runnable runnable); - @NotNull HtmlAppendable tag(@NotNull CharSequence tagName, boolean voidElement); - @NotNull HtmlAppendable tag(@NotNull CharSequence tagName, boolean withIndent, boolean withLine, @NotNull Runnable runnable); + HtmlAppendable tagVoid(CharSequence tagName); + HtmlAppendable tag(CharSequence tagName); + HtmlAppendable tag(CharSequence tagName, Runnable runnable); + HtmlAppendable tag(CharSequence tagName, boolean voidElement); + HtmlAppendable tag(CharSequence tagName, boolean withIndent, boolean withLine, Runnable runnable); - @NotNull HtmlAppendable tagVoidLine(@NotNull CharSequence tagName); - @NotNull HtmlAppendable tagLine(@NotNull CharSequence tagName); - @NotNull HtmlAppendable tagLine(@NotNull CharSequence tagName, boolean voidElement); - @NotNull HtmlAppendable tagLine(@NotNull CharSequence tagName, @NotNull Runnable runnable); - @NotNull HtmlAppendable tagIndent(@NotNull CharSequence tagName, @NotNull Runnable runnable); - @NotNull HtmlAppendable tagLineIndent(@NotNull CharSequence tagName, @NotNull Runnable runnable); - @NotNull HtmlAppendable closeTag(@NotNull CharSequence tagName); + HtmlAppendable tagVoidLine(CharSequence tagName); + HtmlAppendable tagLine(CharSequence tagName); + HtmlAppendable tagLine(CharSequence tagName, boolean voidElement); + HtmlAppendable tagLine(CharSequence tagName, Runnable runnable); + HtmlAppendable tagIndent(CharSequence tagName, Runnable runnable); + HtmlAppendable tagLineIndent(CharSequence tagName, Runnable runnable); + HtmlAppendable closeTag(CharSequence tagName); } diff --git a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/HtmlAppendableBase.java b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/HtmlAppendableBase.java index 156bcf48d..7fecc37a6 100644 --- a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/HtmlAppendableBase.java +++ b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/HtmlAppendableBase.java @@ -4,8 +4,7 @@ import com.vladsch.flexmark.util.misc.Utils; import com.vladsch.flexmark.util.sequence.*; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.IOException; import java.util.*; @@ -20,7 +19,7 @@ public class HtmlAppendableBase> implements Html private boolean withAttributes = false; private boolean suppressOpenTagLine = false; private boolean suppressCloseTagLine = false; - final private @NotNull Stack openTags = new Stack<>(); + final private Stack openTags = new Stack<>(); public HtmlAppendableBase(LineAppendable other, boolean inheritIndent) { this(other, inheritIndent ? other.getIndentPrefix().length() : 0, other.getOptions()); @@ -35,7 +34,6 @@ public HtmlAppendableBase(@Nullable Appendable other, int indentSize, int format this.appendable.setIndentPrefix(RepeatedSequence.repeatOf(" ", indentSize).toString()); } - @NotNull @Override public HtmlAppendable getEmptyAppendable() { return new HtmlAppendableBase<>(appendable, appendable.getIndentPrefix().length(), appendable.getOptions()); @@ -54,24 +52,24 @@ public boolean isSuppressCloseTagLine() { } @SuppressWarnings("UnusedReturnValue") - public @NotNull T setSuppressCloseTagLine(boolean suppressCloseTagLine) { + public T setSuppressCloseTagLine(boolean suppressCloseTagLine) { this.suppressCloseTagLine = suppressCloseTagLine; return (T) this; } @Override - public @NotNull String toString() { + public String toString() { return appendable.toString(); } @Override - public @NotNull T openPre() { + public T openPre() { appendable.openPreFormatted(true); return (T) this; } @Override - public @NotNull T closePre() { + public T closePre() { appendable.closePreFormatted(); return (T) this; } @@ -86,19 +84,19 @@ private boolean haveOptions(int options) { } @Override - public @NotNull T raw(@NotNull CharSequence s) { + public T raw(CharSequence s) { appendable.append(s); return (T) this; } - public @NotNull T raw(@NotNull CharSequence s, int count) { + public T raw(CharSequence s, int count) { int i = count; while (i-- > 0) appendable.append(s); return (T) this; } @Override - public @NotNull T rawPre(@NotNull CharSequence s) { + public T rawPre(CharSequence s) { // if previous pre-formatted did not have an EOL and this one does, need to transfer the EOL // to previous pre-formatted to have proper handling of first/last line, otherwise this opening // pre-formatted, blows away previous last line pre-formatted information @@ -113,25 +111,22 @@ private boolean haveOptions(int options) { return (T) this; } - @NotNull @Override - public T rawIndentedPre(@NotNull CharSequence s) { + public T rawIndentedPre(CharSequence s) { appendable.openPreFormatted(true) .append(s) .closePreFormatted(); return (T) this; } - @NotNull @Override - public T text(@NotNull CharSequence s) { + public T text(CharSequence s) { appendable.append(Escaping.escapeHtml(s, false)); return (T) this; } - @NotNull @Override - public T attr(@NotNull CharSequence attrName, @NotNull CharSequence value) { + public T attr(CharSequence attrName, CharSequence value) { if (currentAttributes == null) { currentAttributes = new MutableAttributes(); } @@ -139,9 +134,8 @@ public T attr(@NotNull CharSequence attrName, @NotNull CharSequence value) { return (T) this; } - @NotNull @Override - public T attr(@NotNull Attribute... attribute) { + public T attr(Attribute... attribute) { if (currentAttributes == null) { currentAttributes = new MutableAttributes(); } @@ -151,9 +145,8 @@ public T attr(@NotNull Attribute... attribute) { return (T) this; } - @NotNull @Override - public T attr(@NotNull Attributes attributes) { + public T attr(Attributes attributes) { if (!attributes.isEmpty()) { if (currentAttributes == null) { currentAttributes = new MutableAttributes(attributes); @@ -164,7 +157,6 @@ public T attr(@NotNull Attributes attributes) { return (T) this; } - @NotNull @Override public T withAttr() { withAttributes = true; @@ -176,42 +168,36 @@ public Attributes getAttributes() { return currentAttributes; } - @NotNull @Override - public T setAttributes(@NotNull Attributes attributes) { + public T setAttributes(Attributes attributes) { currentAttributes = attributes.toMutable(); return (T) this; } - @NotNull @Override public T withCondLineOnChildText() { lineOnChildText = true; return (T) this; } - @NotNull @Override public T withCondIndent() { indentOnFirstEol = true; return (T) this; } - @NotNull @Override - public T tag(@NotNull CharSequence tagName) { + public T tag(CharSequence tagName) { return tag(tagName, false); } - @NotNull @Override - public T tag(@NotNull CharSequence tagName, @NotNull Runnable runnable) { + public T tag(CharSequence tagName, Runnable runnable) { return tag(tagName, false, false, runnable); } - @NotNull @Override - public T tagVoid(@NotNull CharSequence tagName) { + public T tagVoid(CharSequence tagName) { return tag(tagName, true); } @@ -239,15 +225,13 @@ protected void tagClosed(CharSequence tagName) { popTag(tagName); } - @NotNull @Override public Stack getOpenTags() { return openTags; } - @NotNull @Override - public List getOpenTagsAfterLast(@NotNull CharSequence latestTag) { + public List getOpenTagsAfterLast(CharSequence latestTag) { if (openTags.isEmpty()) return Collections.EMPTY_LIST; List tagList = new ArrayList<>(openTags); @@ -263,9 +247,8 @@ public List getOpenTagsAfterLast(@NotNull CharSequence latestTag) { return tagList.subList(lastPos, iMax); } - @NotNull @Override - public T tag(@NotNull CharSequence tagName, boolean voidElement) { + public T tag(CharSequence tagName, boolean voidElement) { if (tagName.length() == 0 || tagName.charAt(0) == '/') return closeTag(tagName); Attributes attributes = null; @@ -303,9 +286,8 @@ public T tag(@NotNull CharSequence tagName, boolean voidElement) { return (T) this; } - @NotNull @Override - public T closeTag(@NotNull CharSequence tagName) { + public T closeTag(CharSequence tagName) { if (tagName.length() == 0) throw new IllegalStateException("closeTag called with tag:'" + tagName + "'"); if (tagName.charAt(0) == '/') { @@ -318,9 +300,8 @@ public T closeTag(@NotNull CharSequence tagName) { return (T) this; } - @NotNull @Override - public T tag(@NotNull CharSequence tagName, boolean withIndent, boolean withLine, @NotNull Runnable runnable) { + public T tag(CharSequence tagName, boolean withIndent, boolean withLine, Runnable runnable) { boolean isLineOnChildText = lineOnChildText; boolean isIndentOnFirstEol = indentOnFirstEol; lineOnChildText = false; @@ -371,57 +352,51 @@ public T tag(@NotNull CharSequence tagName, boolean withIndent, boolean withLine return (T) this; } - @NotNull @Override - public T tagVoidLine(@NotNull CharSequence tagName) { + public T tagVoidLine(CharSequence tagName) { lineIf(!suppressOpenTagLine).tagVoid(tagName).lineIf(!suppressCloseTagLine); return (T) this; } - @NotNull @Override - public T tagLine(@NotNull CharSequence tagName) { + public T tagLine(CharSequence tagName) { lineIf(!suppressOpenTagLine).tag(tagName).lineIf(!suppressCloseTagLine); return (T) this; } - @NotNull @Override - public T tagLine(@NotNull CharSequence tagName, boolean voidElement) { + public T tagLine(CharSequence tagName, boolean voidElement) { lineIf(!suppressOpenTagLine).tag(tagName, voidElement).lineIf(!suppressCloseTagLine); return (T) this; } - @NotNull @Override - public T tagLine(@NotNull CharSequence tagName, @NotNull Runnable runnable) { + public T tagLine(CharSequence tagName, Runnable runnable) { lineIf(!suppressOpenTagLine).tag(tagName, false, false, runnable).lineIf(!suppressCloseTagLine); return (T) this; } - @NotNull @Override - public T tagIndent(@NotNull CharSequence tagName, @NotNull Runnable runnable) { + public T tagIndent(CharSequence tagName, Runnable runnable) { tag(tagName, true, false, runnable); return (T) this; } - @NotNull @Override - public T tagLineIndent(@NotNull CharSequence tagName, @NotNull Runnable runnable) { + public T tagLineIndent(CharSequence tagName, Runnable runnable) { tag(tagName, true, true, runnable); return (T) this; } // delegated to LineFormattingAppendable // @formatter:off - @NotNull @Override public Iterator iterator() {return appendable.iterator();} - @NotNull @Override public Iterable getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) {return appendable.getLines(maxTrailingBlankLines, startLine, endLine, true);} - @NotNull @Override public Iterable getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine) {return appendable.getLinesInfo(maxTrailingBlankLines, startLine, endLine);} + @Override public Iterator iterator() {return appendable.iterator();} + @Override public Iterable getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) {return appendable.getLines(maxTrailingBlankLines, startLine, endLine, true);} + @Override public Iterable getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine) {return appendable.getLinesInfo(maxTrailingBlankLines, startLine, endLine);} @Override public void setPrefixLength(int lineIndex, int prefixEndIndex) { appendable.setPrefixLength(lineIndex, prefixEndIndex); } - @Override public void insertLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence text) { appendable.insertLine(lineIndex, prefix, text); } - @Override public void setLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence text) { appendable.setLine(lineIndex, prefix, text); } - @Override public T appendTo(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { return appendable.appendTo(out, withPrefixes, maxBlankLines, maxTrailingBlankLines, startLine, endLine); } + @Override public void insertLine(int lineIndex, CharSequence prefix, CharSequence text) { appendable.insertLine(lineIndex, prefix, text); } + @Override public void setLine(int lineIndex, CharSequence prefix, CharSequence text) { appendable.setLine(lineIndex, prefix, text); } + @Override public T appendTo(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { return appendable.appendTo(out, withPrefixes, maxBlankLines, maxTrailingBlankLines, startLine, endLine); } @Override public boolean endsWithEOL() { return appendable.endsWithEOL(); } @Override public boolean isPendingSpace() { return appendable.isPendingSpace(); } @Override public boolean isPreFormatted() { return appendable.isPreFormatted(); } @@ -435,47 +410,47 @@ public T tagLineIndent(@NotNull CharSequence tagName, @NotNull Runnable runnable @Override public int offset() { return appendable.offset(); } @Override public int offsetWithPending() { return appendable.offsetWithPending(); } @Override public int getAfterEolPrefixDelta() { return appendable.getAfterEolPrefixDelta(); } - @NotNull @Override public ISequenceBuilder getBuilder() { return appendable.getBuilder(); } - @NotNull @Override public BasedSequence getPrefix() { return appendable.getPrefix(); } - @NotNull @Override public BasedSequence getBeforeEolPrefix() { return appendable.getBeforeEolPrefix(); } - @NotNull @Override public LineInfo getLineInfo(int lineIndex) { return appendable.getLineInfo(lineIndex); } - @NotNull @Override public BasedSequence getLine(int lineIndex) { return appendable.getLine(lineIndex); } - @NotNull @Override public BasedSequence getIndentPrefix() { return appendable.getIndentPrefix(); } - @NotNull @Override public CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { return appendable.toSequence(maxBlankLines, maxTrailingBlankLines, withPrefixes ); } - @NotNull @Override public String toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { return appendable.toString(maxBlankLines, maxTrailingBlankLines, withPrefixes ); } - @NotNull @Override public BitFieldSet getOptionSet() { return appendable.getOptionSet();} - @NotNull @Override public T removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) { appendable.removeExtraBlankLines(maxBlankLines, maxTrailingBlankLines, startLine, endLine); return (T) this; } - @NotNull @Override public T removeLines(int startLine, int endLine) { appendable.removeLines(startLine, endLine); return (T) this; } - @NotNull @Override public T pushOptions() { appendable.pushOptions(); return (T) this; } - @NotNull @Override public T popOptions() { appendable.popOptions(); return (T) this; } - @NotNull @Override public T changeOptions(int addFlags, int removeFlags) { appendable.changeOptions(addFlags, removeFlags); return (T) this; } - @NotNull @Override public T addIndentOnFirstEOL(@NotNull Runnable listener) { appendable.addIndentOnFirstEOL(listener); return (T)this; } - @NotNull @Override public T addPrefix(@NotNull CharSequence prefix) { appendable.addPrefix(prefix); return (T)this; } - @NotNull @Override public T addPrefix(@NotNull CharSequence prefix, boolean afterEol) { appendable.addPrefix(prefix, afterEol); return (T)this; } - @NotNull @Override public T append(char c) { appendable.append(c); return (T)this; } - @NotNull @Override public T append(@NotNull CharSequence csq) { appendable.append(csq); return (T)this; } - @NotNull @Override public T append(@NotNull CharSequence csq, int start, int end) { appendable.append(csq, start, end); return (T)this; } - @NotNull @Override public T append(@NotNull LineAppendable lines, int startLine, int endLine, boolean withPrefixes) { appendable.append(lines, startLine, endLine, withPrefixes); return (T)this; } - @NotNull @Override public T blankLine() { appendable.blankLine(); return (T)this; } - @NotNull @Override public T blankLine(int count) { appendable.blankLine(count); return (T)this; } - @NotNull @Override public T blankLineIf(boolean predicate) { appendable.blankLineIf(predicate); return (T)this; } - @NotNull @Override public T closePreFormatted() { appendable.closePreFormatted(); return (T)this; } - @NotNull @Override public T indent() { appendable.indent(); return (T)this; } - @NotNull @Override public T line() { appendable.line(); return (T)this; } - @NotNull @Override public T lineIf(boolean predicate) { appendable.lineIf(predicate); return (T)this; } - @NotNull @Override public T lineOnFirstText(boolean value) { appendable.lineOnFirstText(value); return (T)this; } - @NotNull @Override public T lineWithTrailingSpaces(int count) { appendable.lineWithTrailingSpaces(count); return (T)this; } - @NotNull @Override public T openPreFormatted(boolean keepIndent) { appendable.openPreFormatted(keepIndent); return (T)this; } - @NotNull @Override public T popPrefix() { appendable.popPrefix(); return (T)this; } - @NotNull @Override public T popPrefix(boolean afterEol) { appendable.popPrefix(afterEol); return (T)this; } - @NotNull @Override public T pushPrefix() { appendable.pushPrefix(); return (T)this; } - @NotNull @Override public T removeIndentOnFirstEOL(@NotNull Runnable listener) { appendable.removeIndentOnFirstEOL(listener); return (T)this; } - @NotNull @Override public T append(char c, int count) { appendable.append(c, count); return (T)this; } - @NotNull @Override public T setIndentPrefix(@Nullable CharSequence prefix) { appendable.setIndentPrefix(prefix); return (T)this; } - @NotNull @Override public T setOptions(int flags) { appendable.setOptions(flags); return (T)this; } - @NotNull @Override public T setPrefix(@NotNull CharSequence prefix) { appendable.setPrefix(prefix); return (T)this; } - @NotNull @Override public T setPrefix(@Nullable CharSequence prefix, boolean afterEol) { appendable.setPrefix(prefix, afterEol); return (T)this; } - @NotNull @Override public T unIndent() { appendable.unIndent(); return (T)this; } - @NotNull @Override public T unIndentNoEol() { appendable.unIndentNoEol(); return (T)this; } + @Override public ISequenceBuilder getBuilder() { return appendable.getBuilder(); } + @Override public BasedSequence getPrefix() { return appendable.getPrefix(); } + @Override public BasedSequence getBeforeEolPrefix() { return appendable.getBeforeEolPrefix(); } + @Override public LineInfo getLineInfo(int lineIndex) { return appendable.getLineInfo(lineIndex); } + @Override public BasedSequence getLine(int lineIndex) { return appendable.getLine(lineIndex); } + @Override public BasedSequence getIndentPrefix() { return appendable.getIndentPrefix(); } + @Override public CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { return appendable.toSequence(maxBlankLines, maxTrailingBlankLines, withPrefixes ); } + @Override public String toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { return appendable.toString(maxBlankLines, maxTrailingBlankLines, withPrefixes ); } + @Override public BitFieldSet getOptionSet() { return appendable.getOptionSet();} + @Override public T removeExtraBlankLines(int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) { appendable.removeExtraBlankLines(maxBlankLines, maxTrailingBlankLines, startLine, endLine); return (T) this; } + @Override public T removeLines(int startLine, int endLine) { appendable.removeLines(startLine, endLine); return (T) this; } + @Override public T pushOptions() { appendable.pushOptions(); return (T) this; } + @Override public T popOptions() { appendable.popOptions(); return (T) this; } + @Override public T changeOptions(int addFlags, int removeFlags) { appendable.changeOptions(addFlags, removeFlags); return (T) this; } + @Override public T addIndentOnFirstEOL(Runnable listener) { appendable.addIndentOnFirstEOL(listener); return (T)this; } + @Override public T addPrefix(CharSequence prefix) { appendable.addPrefix(prefix); return (T)this; } + @Override public T addPrefix(CharSequence prefix, boolean afterEol) { appendable.addPrefix(prefix, afterEol); return (T)this; } + @Override public T append(char c) { appendable.append(c); return (T)this; } + @Override public T append(CharSequence csq) { appendable.append(csq); return (T)this; } + @Override public T append(CharSequence csq, int start, int end) { appendable.append(csq, start, end); return (T)this; } + @Override public T append(LineAppendable lines, int startLine, int endLine, boolean withPrefixes) { appendable.append(lines, startLine, endLine, withPrefixes); return (T)this; } + @Override public T blankLine() { appendable.blankLine(); return (T)this; } + @Override public T blankLine(int count) { appendable.blankLine(count); return (T)this; } + @Override public T blankLineIf(boolean predicate) { appendable.blankLineIf(predicate); return (T)this; } + @Override public T closePreFormatted() { appendable.closePreFormatted(); return (T)this; } + @Override public T indent() { appendable.indent(); return (T)this; } + @Override public T line() { appendable.line(); return (T)this; } + @Override public T lineIf(boolean predicate) { appendable.lineIf(predicate); return (T)this; } + @Override public T lineOnFirstText(boolean value) { appendable.lineOnFirstText(value); return (T)this; } + @Override public T lineWithTrailingSpaces(int count) { appendable.lineWithTrailingSpaces(count); return (T)this; } + @Override public T openPreFormatted(boolean keepIndent) { appendable.openPreFormatted(keepIndent); return (T)this; } + @Override public T popPrefix() { appendable.popPrefix(); return (T)this; } + @Override public T popPrefix(boolean afterEol) { appendable.popPrefix(afterEol); return (T)this; } + @Override public T pushPrefix() { appendable.pushPrefix(); return (T)this; } + @Override public T removeIndentOnFirstEOL(Runnable listener) { appendable.removeIndentOnFirstEOL(listener); return (T)this; } + @Override public T append(char c, int count) { appendable.append(c, count); return (T)this; } + @Override public T setIndentPrefix(@Nullable CharSequence prefix) { appendable.setIndentPrefix(prefix); return (T)this; } + @Override public T setOptions(int flags) { appendable.setOptions(flags); return (T)this; } + @Override public T setPrefix(CharSequence prefix) { appendable.setPrefix(prefix); return (T)this; } + @Override public T setPrefix(@Nullable CharSequence prefix, boolean afterEol) { appendable.setPrefix(prefix, afterEol); return (T)this; } + @Override public T unIndent() { appendable.unIndent(); return (T)this; } + @Override public T unIndentNoEol() { appendable.unIndentNoEol(); return (T)this; } // @formatter:on } diff --git a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/package-info.java b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/package-info.java index 0ce30574b..1b64afeb9 100644 --- a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/package-info.java +++ b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.html; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/HtmlBuilder.java b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/HtmlBuilder.java index 21bc61d34..532eb4135 100644 --- a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/HtmlBuilder.java +++ b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/HtmlBuilder.java @@ -22,8 +22,7 @@ import com.vladsch.flexmark.util.html.Attributes; import com.vladsch.flexmark.util.html.HtmlAppendableBase; import com.vladsch.flexmark.util.sequence.LineAppendable; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import javax.swing.plaf.FontUIResource; import java.awt.Font; @@ -78,9 +77,8 @@ public HtmlBuilder attr(Object... convertible) { return this; } - @NotNull @Override - public HtmlBuilder attr(@NotNull CharSequence name, @Nullable CharSequence value) { + public HtmlBuilder attr(CharSequence name, @Nullable CharSequence value) { super.withAttr(); return super.attr(name, value); } @@ -90,16 +88,14 @@ public HtmlBuilder style(CharSequence value) { return super.attr(Attribute.STYLE_ATTR, value); } - @NotNull @Override - public HtmlBuilder attr(@NotNull Attribute... attribute) { + public HtmlBuilder attr(Attribute... attribute) { super.withAttr(); return super.attr(attribute); } - @NotNull @Override - public HtmlBuilder attr(@NotNull Attributes attributes) { + public HtmlBuilder attr(Attributes attributes) { super.withAttr(); return super.attr(attributes); } @@ -188,11 +184,9 @@ public static Attribute getAttribute(Object item) { public HtmlBuilder append(StringBuffer sb) { return super.append(sb.toString()); } - @NotNull - public HtmlBuilder append(@NotNull CharSequence s) { return super.append(s); } + public HtmlBuilder append(CharSequence s) { return super.append(s); } - @NotNull - public HtmlBuilder append(@NotNull CharSequence s, int start, int end) { return super.append(s, start, end); } + public HtmlBuilder append(CharSequence s, int start, int end) { return super.append(s, start, end); } public HtmlBuilder append(char[] str) { return super.append(String.valueOf(str)); } @@ -200,7 +194,6 @@ public static Attribute getAttribute(Object item) { public HtmlBuilder append(boolean b) { return super.append(b ? "true" : "false"); } - @NotNull public HtmlBuilder append(char c) { return super.append(c); } public HtmlBuilder append(int i) { return super.append(String.valueOf(i)); } diff --git a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/package-info.java b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/package-info.java index da64d63b3..4ea0ca05d 100644 --- a/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/package-info.java +++ b/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.html.ui; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-misc/pom.xml b/flexmark-util-misc/pom.xml index 6deea469f..05c3663ed 100644 --- a/flexmark-util-misc/pom.xml +++ b/flexmark-util-misc/pom.xml @@ -18,9 +18,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/ArrayUtils.java b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/ArrayUtils.java index a4d4159bc..cdfda220c 100644 --- a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/ArrayUtils.java +++ b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/ArrayUtils.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.misc; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.lang.reflect.Array; import java.util.BitSet; @@ -143,7 +142,7 @@ public static int lastIndexOf(T[] ts, int startIndex, int fromIndex, Predica return -1; } - public static int[] toArray(@NotNull BitSet bitSet) { + public static int[] toArray(BitSet bitSet) { int i = bitSet.cardinality(); int[] bits = new int[i]; diff --git a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/BitFieldSet.java b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/BitFieldSet.java index 62fb72ca3..ebc49fa11 100644 --- a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/BitFieldSet.java +++ b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/BitFieldSet.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.misc; -import org.jetbrains.annotations.NotNull; import java.io.Serializable; import java.util.AbstractSet; @@ -34,7 +33,6 @@ static class UniverseLoader { @SuppressWarnings("rawtypes") final static ConcurrentHashMap enumBitMasksMap = new ConcurrentHashMap<>(); @SuppressWarnings("rawtypes") - @NotNull public static > Enum[] getUniverseSlow(Class elementType) { assert (elementType.isEnum()); Enum[] cachedUniverse = enumUniverseMap.get(elementType); @@ -521,7 +519,6 @@ final public long mask(E... rest) { * * @return an iterator over the elements contained in this set */ - @NotNull public Iterator iterator() { return bitMasks.length == totalBits ? new EnumBitSetIterator<>() : new EnumBitFieldIterator<>(); } @@ -778,7 +775,7 @@ public void clear() { * @param enum type * @return bit enum set */ - public static > BitFieldSet of(@NotNull Class enumClass, long mask) { + public static > BitFieldSet of(Class enumClass, long mask) { BitFieldSet optionSet = BitFieldSet.noneOf(enumClass); optionSet.orMask(mask); return optionSet; @@ -1267,7 +1264,7 @@ public static > BitFieldSet of(E first, E... rest) { * @throws NullPointerException if any of the specified elements are null, * or if rest is null */ - public static > BitFieldSet of(@NotNull Class declaringClass, E[] rest) { + public static > BitFieldSet of(Class declaringClass, E[] rest) { BitFieldSet result = noneOf(declaringClass); for (E e : rest) { result.add(e); } return result; diff --git a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/CharPredicate.java b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/CharPredicate.java index f89d34841..9eee6b403 100644 --- a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/CharPredicate.java +++ b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/CharPredicate.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.misc; -import org.jetbrains.annotations.NotNull; import java.util.BitSet; import java.util.Objects; @@ -71,8 +70,7 @@ default boolean test(char value) { * AND of this predicate and the {@code other} predicate * @throws NullPointerException if other is null */ - @NotNull - default CharPredicate and(@NotNull CharPredicate other) { + default CharPredicate and(CharPredicate other) { Objects.requireNonNull(other); return this == NONE || other == NONE ? NONE : this == ALL ? other : other == ALL ? this : (value) -> test(value) && other.test(value); } @@ -84,7 +82,6 @@ default CharPredicate and(@NotNull CharPredicate other) { * @return a predicate that represents the logical negation of this * predicate */ - @NotNull default CharPredicate negate() { return this == NONE ? ALL : this == ALL ? NONE : (value) -> !test(value); } @@ -105,13 +102,11 @@ default CharPredicate negate() { * OR of this predicate and the {@code other} predicate * @throws NullPointerException if other is null */ - @NotNull - default CharPredicate or(@NotNull CharPredicate other) { + default CharPredicate or(CharPredicate other) { Objects.requireNonNull(other); return this == ALL || other == ALL ? ALL : this == NONE ? other : other == NONE ? this : (value) -> test(value) || other.test(value); } - @NotNull static CharPredicate standardOrAnyOf(char c1) { return SPACE.test(c1) ? SPACE : EOL.test(c1) ? EOL @@ -119,7 +114,6 @@ static CharPredicate standardOrAnyOf(char c1) { : value1 -> value1 == (int) c1; } - @NotNull static CharPredicate standardOrAnyOf(char c1, char c2) { return c1 == c2 ? standardOrAnyOf(c1) : SPACE_TAB.test(c1) && SPACE_TAB.test(c2) ? SPACE_TAB @@ -127,7 +121,6 @@ static CharPredicate standardOrAnyOf(char c1, char c2) { : value -> value == (int) c1 || value == (int) c2; } - @NotNull static CharPredicate standardOrAnyOf(char c1, char c2, char c3) { return c1 == c2 && c2 == c3 ? standardOrAnyOf(c1) : c1 == c2 || c1 == c3 ? standardOrAnyOf(c2, c3) @@ -135,7 +128,6 @@ static CharPredicate standardOrAnyOf(char c1, char c2, char c3) { : value -> value == (int) c1 || value == (int) c2 || value == (int) c3; } - @NotNull static CharPredicate standardOrAnyOf(char c1, char c2, char c3, char c4) { return c1 == c2 && c2 == c3 && c3 == c4 ? standardOrAnyOf(c1) : c1 == c2 || c1 == c3 || c1 == c4 ? standardOrAnyOf(c2, c3, c4) @@ -145,7 +137,6 @@ static CharPredicate standardOrAnyOf(char c1, char c2, char c3, char c4) { : value -> value == (int) c1 || value == (int) c2 || value == (int) c3 || value == (int) c4; } - @NotNull static CharPredicate anyOf(char... chars) { switch (chars.length) { case 0: @@ -163,11 +154,11 @@ static CharPredicate anyOf(char... chars) { } } - static int indexOf(@NotNull CharSequence thizz, char c) { + static int indexOf(CharSequence thizz, char c) { return indexOf(thizz, c, 0, thizz.length()); } - static int indexOf(@NotNull CharSequence thizz, char c, int fromIndex, int endIndex) { + static int indexOf(CharSequence thizz, char c, int fromIndex, int endIndex) { fromIndex = Math.max(fromIndex, 0); endIndex = Math.min(thizz.length(), endIndex); @@ -177,8 +168,7 @@ static int indexOf(@NotNull CharSequence thizz, char c, int fromIndex, int endIn return -1; } - @NotNull - static CharPredicate anyOf(@NotNull CharSequence chars) { + static CharPredicate anyOf(CharSequence chars) { int maxFixed = 4; switch (chars.length()) { case 0: diff --git a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/FileUtil.java b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/FileUtil.java index 547926a2a..b5a4897fd 100644 --- a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/FileUtil.java +++ b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/FileUtil.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.misc; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.*; import java.nio.charset.StandardCharsets; @@ -58,7 +57,6 @@ public static String getFileContent(File receiver) { return null; } - @NotNull public static String getFileContentWithExceptions(File receiver) throws IOException { StringBuilder sb = new StringBuilder(); String line; @@ -85,7 +83,6 @@ public static byte[] getFileContentBytes(File receiver) { return null; } - @NotNull public static byte[] getFileContentBytesWithExceptions(File receiver) throws IOException { return Files.readAllBytes(receiver.toPath()); } diff --git a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/Utils.java b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/Utils.java index 0740c02b0..6df7023ee 100644 --- a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/Utils.java +++ b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/Utils.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.misc; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.*; import java.net.URLDecoder; @@ -599,7 +598,6 @@ public static String getResourceAsString(Class clazz, String resourcePath) { return sb.toString(); } - @NotNull public static String escapeJavaString(@Nullable CharSequence param) { if (param == null) return "null"; StringBuilder out = new StringBuilder(); @@ -607,7 +605,6 @@ public static String escapeJavaString(@Nullable CharSequence param) { return out.toString(); } - @NotNull public static String quoteJavaString(@Nullable CharSequence param) { if (param == null) return "null"; StringBuilder out = new StringBuilder(); @@ -617,7 +614,7 @@ public static String quoteJavaString(@Nullable CharSequence param) { return out.toString(); } - public static void escapeJavaString(@NotNull StringBuilder out, @NotNull CharSequence chars) { + public static void escapeJavaString(StringBuilder out, CharSequence chars) { int iMax = chars.length(); for (int i = 0; i < iMax; i++) { char c = chars.charAt(i); @@ -654,14 +651,14 @@ public static void escapeJavaString(@NotNull StringBuilder out, @NotNull CharSeq } } - public static T getOrNull(@NotNull List list, int index) { + public static T getOrNull(List list, int index) { if (index >= 0 && index < list.size()) { return list.get(index); } return null; } - public static S getOrNull(@NotNull List list, int index, Class elementClass) { + public static S getOrNull(List list, int index, Class elementClass) { if (index >= 0 && index < list.size()) { T value = list.get(index); //noinspection unchecked @@ -670,7 +667,7 @@ public static S getOrNull(@NotNull List list, int index, Cla return null; } - public static T setOrAdd(@NotNull List list, int index, T value) { + public static T setOrAdd(List list, int index, T value) { if (index == list.size()) { list.add(value); return null; diff --git a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/package-info.java b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/package-info.java index 9c969db66..a354eba7b 100644 --- a/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/package-info.java +++ b/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.misc; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-options/pom.xml b/flexmark-util-options/pom.xml index 444be4a17..555be49e3 100644 --- a/flexmark-util-options/pom.xml +++ b/flexmark-util-options/pom.xml @@ -26,9 +26,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-options/src/main/java/com/vladsch/flexmark/util/options/package-info.java b/flexmark-util-options/src/main/java/com/vladsch/flexmark/util/options/package-info.java index 701133ee9..caf709753 100644 --- a/flexmark-util-options/src/main/java/com/vladsch/flexmark/util/options/package-info.java +++ b/flexmark-util-options/src/main/java/com/vladsch/flexmark/util/options/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.options; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-sequence/pom.xml b/flexmark-util-sequence/pom.xml index 38e7e4e34..ebc25495d 100644 --- a/flexmark-util-sequence/pom.xml +++ b/flexmark-util-sequence/pom.xml @@ -29,6 +29,11 @@ junit test + + org.jspecify + jspecify + 1.0.0 + org.jetbrains annotations diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedOptionsHolder.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedOptionsHolder.java index f3e9b807c..5ac23ef12 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedOptionsHolder.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedOptionsHolder.java @@ -5,7 +5,7 @@ import com.vladsch.flexmark.util.data.NullableDataKey; import com.vladsch.flexmark.util.misc.BitFieldSet; import com.vladsch.flexmark.util.sequence.builder.SegmentedSequenceStats; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * Implemented by BasedOptionsSequence, use instance of it to pass to {@link BasedSequence#of(CharSequence)} and options enabled in it diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedOptionsSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedOptionsSequence.java index a073e53d1..74ae92725 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedOptionsSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedOptionsSequence.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKeyBase; import com.vladsch.flexmark.util.misc.BitFieldSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.stream.IntStream; @@ -14,11 +13,11 @@ * a subSequence() returns a sub-sequence from the original base sequence with updated offset tracking */ final public class BasedOptionsSequence implements CharSequence, BasedOptionsHolder { - final private @NotNull CharSequence chars; + final private CharSequence chars; final private int optionFlags; final private @Nullable DataHolder options; - private BasedOptionsSequence(@NotNull CharSequence chars, int optionFlags, @Nullable DataHolder options) { + private BasedOptionsSequence(CharSequence chars, int optionFlags, @Nullable DataHolder options) { this.chars = chars; this.optionFlags = optionFlags & ~(options == null || SEGMENTED_STATS.get(options) == null ? F_COLLECT_SEGMENTED_STATS : 0); this.options = options; @@ -79,19 +78,19 @@ public int hashCode() { return chars.hashCode(); } - public static BasedOptionsSequence of(@NotNull CharSequence chars, BitFieldSet optionFlags) { + public static BasedOptionsSequence of(CharSequence chars, BitFieldSet optionFlags) { return new BasedOptionsSequence(chars, optionFlags.toInt(), null); } - public static BasedOptionsSequence of(@NotNull CharSequence chars, int optionFlags) { + public static BasedOptionsSequence of(CharSequence chars, int optionFlags) { return new BasedOptionsSequence(chars, optionFlags, null); } - public static BasedOptionsSequence of(@NotNull CharSequence chars, BitFieldSet optionFlags, @Nullable DataHolder options) { + public static BasedOptionsSequence of(CharSequence chars, BitFieldSet optionFlags, @Nullable DataHolder options) { return new BasedOptionsSequence(chars, optionFlags.toInt(), options); } - public static BasedOptionsSequence of(@NotNull CharSequence chars, int optionFlags, @Nullable DataHolder options) { + public static BasedOptionsSequence of(CharSequence chars, int optionFlags, @Nullable DataHolder options) { return new BasedOptionsSequence(chars, optionFlags, options); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedSequence.java index 0dabaef55..dad51457a 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedSequence.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.util.sequence.builder.IBasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; import com.vladsch.flexmark.util.sequence.builder.tree.SegmentTree; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -35,34 +34,28 @@ public interface BasedSequence extends IRichSequence, BasedOption BasedSequence[] EMPTY_SEGMENTS = new BasedSequence[0]; BasedSequence LINE_SEP = CharSubSequence.of(SequenceUtils.LINE_SEP); - @NotNull static BasedSequence of(@Nullable CharSequence charSequence) { return BasedSequenceImpl.create(charSequence); } - @NotNull static BasedSequence ofSpaces(int count) { return of(RepeatedSequence.ofSpaces(count)); } - @NotNull static BasedSequence repeatOf(char c, int count) { return of(RepeatedSequence.repeatOf(String.valueOf(c), 0, count)); } - @NotNull - static BasedSequence repeatOf(@NotNull CharSequence chars, int count) { + static BasedSequence repeatOf(CharSequence chars, int count) { return of(RepeatedSequence.repeatOf(chars, 0, chars.length() * count)); } - @NotNull - static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int endIndex) { + static BasedSequence repeatOf(CharSequence chars, int startIndex, int endIndex) { return of(RepeatedSequence.repeatOf(chars, startIndex, endIndex)); } @SuppressWarnings("unchecked") @Override - @NotNull SequenceBuilder getBuilder(); /** @@ -70,7 +63,6 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * * @return underlying object containing original text */ - @NotNull Object getBase(); /** @@ -78,7 +70,6 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * * @return base sequence */ - @NotNull BasedSequence getBaseSequence(); /** @@ -109,14 +100,13 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * * @param builder builder */ - void addSegments(@NotNull IBasedSegmentBuilder builder); + void addSegments(IBasedSegmentBuilder builder); /** * Get the segment tree for this sequence * * @return segment tree */ - @NotNull SegmentTree getSegmentTree(); /** @@ -124,7 +114,6 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * * @return Range of start offset and end offset */ - @NotNull Range getSourceRange(); /** @@ -134,7 +123,6 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param endIndex offset from startIndex of this sequence * @return based sequence which represents the requested range of this sequence. */ - @NotNull @Override BasedSequence subSequence(int startIndex, int endIndex); /** @@ -148,7 +136,6 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param endIndex offset from 0 of original sequence * @return based sequence whose contents reflect the selected portion */ - @NotNull BasedSequence baseSubSequence(int startIndex, int endIndex); /** @@ -157,7 +144,6 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param startIndex offset from 0 of original sequence * @return based sequence from startIndex to the endIndex */ - @NotNull BasedSequence baseSubSequence(int startIndex); /** @@ -179,14 +165,13 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param predicate character set predicate * @return true if character at index tests true */ - boolean isBaseCharAt(int index, @NotNull CharPredicate predicate); + boolean isBaseCharAt(int index, CharPredicate predicate); /** * Get empty prefix to this sequence * * @return same as subSequence(0,0) */ - @NotNull BasedSequence getEmptyPrefix(); /** @@ -194,7 +179,6 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * * @return same as subSequence(length()) */ - @NotNull BasedSequence getEmptySuffix(); /** @@ -202,7 +186,6 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * * @return unescaped text */ - @NotNull String unescape(); /** @@ -210,7 +193,6 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * * @return unescaped text */ - @NotNull String unescapeNoEntities(); /** @@ -219,8 +201,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param textMapper replaced text mapper which will be uses to map unescaped index to original source index * @return unescaped text in based sequence */ - @NotNull - BasedSequence unescape(@NotNull ReplacedTextMapper textMapper); + BasedSequence unescape(ReplacedTextMapper textMapper); /** * replace any \r\n and \r by \n @@ -228,8 +209,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param textMapper replaced text mapper which will be uses to map unescaped index to original source index * @return based sequence with only \n for line separators */ - @NotNull - BasedSequence normalizeEOL(@NotNull ReplacedTextMapper textMapper); + BasedSequence normalizeEOL(ReplacedTextMapper textMapper); /** * replace any \r\n and \r by \n, append terminating EOL if one is not present @@ -237,8 +217,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param textMapper replaced text mapper which will be uses to map unescaped index to original source index * @return based sequence with only \n for line separators and terminated by \n */ - @NotNull - BasedSequence normalizeEndWithEOL(@NotNull ReplacedTextMapper textMapper); + BasedSequence normalizeEndWithEOL(ReplacedTextMapper textMapper); /** * Test if the given sequence is a continuation of this sequence in original source text @@ -246,7 +225,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param other sequence to test * @return true if the given sequence is a continuation of this one in the original text */ - boolean isContinuedBy(@NotNull BasedSequence other); + boolean isContinuedBy(BasedSequence other); /** * Test if this sequence is a continuation of the given sequence in original source text @@ -254,7 +233,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param other sequence to test * @return true if this sequence is a continuation of the given sequence in original source text */ - boolean isContinuationOf(@NotNull BasedSequence other); + boolean isContinuationOf(BasedSequence other); /** * Splice the given sequence to the end of this one and return a BasedSequence of the result. @@ -266,8 +245,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e *

* assertion will fail if the other sequence is not a continuation of this one */ - @NotNull - BasedSequence spliceAtEnd(@NotNull BasedSequence other); + BasedSequence spliceAtEnd(BasedSequence other); /** * start/end offset based containment, not textual @@ -275,7 +253,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param other based sequence from the same base * @return true if other is contained in this */ - boolean containsAllOf(@NotNull BasedSequence other); + boolean containsAllOf(BasedSequence other); /** * start/end offset based containment, not textual @@ -283,7 +261,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param other based sequence from the same base * @return true if other is contained in this */ - boolean containsSomeOf(@NotNull BasedSequence other); + boolean containsSomeOf(BasedSequence other); /** * Get the prefix part of this from other, start/end offset based containment, not textual @@ -291,8 +269,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param other based sequence from the same base * @return prefix part of this as compared to other, start/end offset based, not content */ - @NotNull - BasedSequence prefixOf(@NotNull BasedSequence other); + BasedSequence prefixOf(BasedSequence other); /** * Get the suffix part of this from other, start/end offset based containment, not textual @@ -300,8 +277,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param other based sequence from the same base * @return suffix part of this as compared to other, start/end offset based, not content */ - @NotNull - BasedSequence suffixOf(@NotNull BasedSequence other); + BasedSequence suffixOf(BasedSequence other); /** * start/end offset based intersection, not textual @@ -309,8 +285,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param other based sequence from the same parent * @return sequence which is the intersection of the range of this and other */ - @NotNull - BasedSequence intersect(@NotNull BasedSequence other); + BasedSequence intersect(BasedSequence other); /** * Extend this based sequence to include characters from underlying based sequence @@ -319,14 +294,11 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param maxCount maximum extra characters to include * @return sequence which */ - @NotNull - BasedSequence extendByAny(@NotNull CharPredicate charSet, int maxCount); + BasedSequence extendByAny(CharPredicate charSet, int maxCount); - @NotNull - BasedSequence extendByAny(@NotNull CharPredicate charSet); + BasedSequence extendByAny(CharPredicate charSet); - @NotNull - BasedSequence extendByOneOfAny(@NotNull CharPredicate charSet); + BasedSequence extendByOneOfAny(CharPredicate charSet); /** * Test for line containing some of the characters in the set @@ -334,7 +306,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param charSet set of characters to be tested * @return true if line contains some characters in the set */ - boolean containsSomeIn(@NotNull CharPredicate charSet); + boolean containsSomeIn(CharPredicate charSet); /** * Test for line containing some characters not in the set @@ -342,14 +314,14 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param charSet set of characters to be tested * @return true if line contains some characters not in the set */ - boolean containsSomeNotIn(@NotNull CharPredicate charSet); + boolean containsSomeNotIn(CharPredicate charSet); /** * Test for line contains only characters from the set * * @param charSet set of characters to be tested * @return true if line contains some characters from the set */ - boolean containsOnlyIn(@NotNull CharPredicate charSet); + boolean containsOnlyIn(CharPredicate charSet); /** * Test for line containing only characters not in the set @@ -357,7 +329,7 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param charSet set of characters to be tested * @return true if line contains some characters from the set */ - boolean containsOnlyNotIn(@NotNull CharPredicate charSet); + boolean containsOnlyNotIn(CharPredicate charSet); /** * Extend this based sequence to include characters from underlying based sequence not in character set @@ -366,24 +338,19 @@ static BasedSequence repeatOf(@NotNull CharSequence chars, int startIndex, int e * @param maxCount maximum extra characters to include * @return sequence which */ - @NotNull - BasedSequence extendByAnyNot(@NotNull CharPredicate charSet, int maxCount); + BasedSequence extendByAnyNot(CharPredicate charSet, int maxCount); - @NotNull - BasedSequence extendByAnyNot(@NotNull CharPredicate charSet); + BasedSequence extendByAnyNot(CharPredicate charSet); - @NotNull - BasedSequence extendByOneOfAnyNot(@NotNull CharPredicate charSet); + BasedSequence extendByOneOfAnyNot(CharPredicate charSet); - @NotNull @Deprecated - default BasedSequence extendToAny(@NotNull CharPredicate charSet, int maxCount) { + default BasedSequence extendToAny(CharPredicate charSet, int maxCount) { return extendByAnyNot(charSet, maxCount); } - @NotNull @Deprecated - default BasedSequence extendToAny(@NotNull CharPredicate charSet) { + default BasedSequence extendToAny(CharPredicate charSet) { return extendByAnyNot(charSet); } @@ -395,10 +362,10 @@ default BasedSequence extendToAny(@NotNull CharPredicate charSet) { * @return resulting sequence after extension. If already spanning the line then this sequence is returned. * if the last character of this sequence are found in eolChars then no extension will be performed since it already includes the line end */ - @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate eolChars, boolean includeEol); - @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate eolChars); - @NotNull BasedSequence extendToEndOfLine(boolean includeEol); - @NotNull BasedSequence extendToEndOfLine(); + BasedSequence extendToEndOfLine(CharPredicate eolChars, boolean includeEol); + BasedSequence extendToEndOfLine(CharPredicate eolChars); + BasedSequence extendToEndOfLine(boolean includeEol); + BasedSequence extendToEndOfLine(); /** * Extend in contained based sequence @@ -408,10 +375,10 @@ default BasedSequence extendToAny(@NotNull CharPredicate charSet) { * @return resulting sequence after extension. If already spanning the line then this sequence is returned. * if the first character of this sequence are found in eolChars then no extension will be performed since it already includes the line end */ - @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate eolChars, boolean includeEol); - @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate eolChars); - @NotNull BasedSequence extendToStartOfLine(boolean includeEol); - @NotNull BasedSequence extendToStartOfLine(); + BasedSequence extendToStartOfLine(CharPredicate eolChars, boolean includeEol); + BasedSequence extendToStartOfLine(CharPredicate eolChars); + BasedSequence extendToStartOfLine(boolean includeEol); + BasedSequence extendToStartOfLine(); /** * Extend this based sequence to include characters from underlying based sequence @@ -420,28 +387,28 @@ default BasedSequence extendToAny(@NotNull CharPredicate charSet) { * @param maxColumns maximum columns to include, default {@link Integer#MAX_VALUE} * @return sequence which */ - @NotNull BasedSequence prefixWithIndent(int maxColumns); - @NotNull BasedSequence prefixWithIndent(); + BasedSequence prefixWithIndent(int maxColumns); + BasedSequence prefixWithIndent(); /* These are convenience methods returning coordinates in Base Sequence of this sequence */ - @NotNull Pair baseLineColumnAtIndex(int index); - @NotNull Range baseLineRangeAtIndex(int index); + Pair baseLineColumnAtIndex(int index); + Range baseLineRangeAtIndex(int index); int baseEndOfLine(int index); int baseEndOfLineAnyEOL(int index); int baseStartOfLine(int index); int baseStartOfLineAnyEOL(int index); int baseColumnAtIndex(int index); - @NotNull Pair baseLineColumnAtStart(); - @NotNull Pair baseLineColumnAtEnd(); + Pair baseLineColumnAtStart(); + Pair baseLineColumnAtEnd(); int baseEndOfLine(); int baseEndOfLineAnyEOL(); int baseStartOfLine(); int baseStartOfLineAnyEOL(); - @NotNull Range baseLineRangeAtStart(); - @NotNull Range baseLineRangeAtEnd(); + Range baseLineRangeAtStart(); + Range baseLineRangeAtEnd(); int baseColumnAtEnd(); int baseColumnAtStart(); @@ -491,26 +458,22 @@ public int getIndexOffset(int index) { return 0; } - @NotNull @Override public BasedSequence subSequence(int i, int i1) { SequenceUtils.validateStartEnd(i, i1, length()); return this; } - @NotNull @Override public BasedSequence baseSubSequence(int startIndex, int endIndex) { return subSequence(startIndex, endIndex); } - @NotNull @Override public BasedSequence getBaseSequence() { return this; } - @NotNull @Override public BasedSequence getBase() { return this; @@ -526,7 +489,6 @@ public int getEndOffset() { return 0; } - @NotNull @Override public Range getSourceRange() { return Range.NULL; diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedSequenceImpl.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedSequenceImpl.java index 2a77d99c1..0636da89f 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedSequenceImpl.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedSequenceImpl.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; import com.vladsch.flexmark.util.sequence.builder.tree.SegmentTree; import com.vladsch.flexmark.util.sequence.mappers.CharMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * Implementation of BaseSequence @@ -27,33 +26,29 @@ public BasedSequenceImpl(int hash) { super(hash); } - @NotNull @Override public BasedSequence[] emptyArray() { return EMPTY_ARRAY; } - @NotNull @Override public BasedSequence nullSequence() { return NULL; } - @NotNull @Override public BasedSequence sequenceOf(@Nullable CharSequence charSequence, int startIndex, int endIndex) { return BasedSequence.of(charSequence).subSequence(startIndex, endIndex); } @SuppressWarnings("unchecked") - @NotNull @Override public SequenceBuilder getBuilder() { return SequenceBuilder.emptyBuilder(this); } @Override - public void addSegments(@NotNull IBasedSegmentBuilder builder) { + public void addSegments(IBasedSegmentBuilder builder) { builder.append(getStartOffset(), getEndOffset()); } @@ -62,7 +57,6 @@ public void addSegments(@NotNull IBasedSegmentBuilder builder) { * * @return null for contiguous sequences, else segment tree for this sequence */ - @NotNull @Override public SegmentTree getSegmentTree() { // default implementation @@ -71,20 +65,18 @@ public SegmentTree getSegmentTree() { return SegmentTree.build(segmentBuilder.getSegments(), segmentBuilder.getText()); } - @NotNull @Override public BasedSequence toMapped(CharMapper mapper) { return MappedBasedSequence.mappedOf(this, mapper); } - @NotNull @Override final public BasedSequence baseSubSequence(int startIndex) { return baseSubSequence(startIndex, getBaseSequence().getEndOffset()); } @Override - public @NotNull BasedSequence baseSubSequence(int startIndex, int endIndex) { + public BasedSequence baseSubSequence(int startIndex, int endIndex) { return getBaseSequence().subSequence(startIndex, endIndex); } @@ -103,17 +95,15 @@ public char safeBaseCharAt(int index) { } @Override - public boolean isBaseCharAt(int index, @NotNull CharPredicate predicate) { + public boolean isBaseCharAt(int index, CharPredicate predicate) { return predicate.test(safeBaseCharAt(index)); } - @NotNull @Override public BasedSequence getEmptyPrefix() { return subSequence(0, 0); } - @NotNull @Override public BasedSequence getEmptySuffix() { return subSequence(length()); @@ -124,49 +114,43 @@ public BasedSequence getEmptySuffix() { return isNull() ? null : toString(); } - @NotNull @Override public String unescape() { return Escaping.unescapeString(this); } - @NotNull @Override public String unescapeNoEntities() { return Escaping.unescapeString(this, false); } - @NotNull @Override - public BasedSequence unescape(@NotNull ReplacedTextMapper textMapper) { + public BasedSequence unescape(ReplacedTextMapper textMapper) { return Escaping.unescape(this, textMapper); } - @NotNull @Override - public BasedSequence normalizeEOL(@NotNull ReplacedTextMapper textMapper) { + public BasedSequence normalizeEOL(ReplacedTextMapper textMapper) { return Escaping.normalizeEOL(this, textMapper); } - @NotNull @Override - public BasedSequence normalizeEndWithEOL(@NotNull ReplacedTextMapper textMapper) { + public BasedSequence normalizeEndWithEOL(ReplacedTextMapper textMapper) { return Escaping.normalizeEndWithEOL(this, textMapper); } @Override - public boolean isContinuedBy(@NotNull BasedSequence other) { + public boolean isContinuedBy(BasedSequence other) { return other.length() > 0 && length() > 0 && other.getBase() == getBase() && other.getStartOffset() == getEndOffset(); } @Override - public boolean isContinuationOf(@NotNull BasedSequence other) { + public boolean isContinuationOf(BasedSequence other) { return other.length() > 0 && length() > 0 && other.getBase() == getBase() && other.getEndOffset() == getStartOffset(); } - @NotNull @Override - public BasedSequence spliceAtEnd(@NotNull BasedSequence other) { + public BasedSequence spliceAtEnd(BasedSequence other) { if (other.isEmpty()) { return this; } else if (isEmpty()) { @@ -177,18 +161,17 @@ public BasedSequence spliceAtEnd(@NotNull BasedSequence other) { } @Override - public boolean containsAllOf(@NotNull BasedSequence other) { + public boolean containsAllOf(BasedSequence other) { return getBase() == other.getBase() && other.getStartOffset() >= getStartOffset() && other.getEndOffset() <= getEndOffset(); } @Override - public boolean containsSomeOf(@NotNull BasedSequence other) { + public boolean containsSomeOf(BasedSequence other) { return getBase() == other.getBase() && !(getStartOffset() >= other.getEndOffset() || getEndOffset() <= other.getStartOffset()); } - @NotNull @Override - public BasedSequence intersect(@NotNull BasedSequence other) { + public BasedSequence intersect(BasedSequence other) { if (getBase() != other.getBase()) return BasedSequence.NULL; else if (other.getEndOffset() <= getStartOffset()) return subSequence(0, 0); else if (other.getStartOffset() >= getEndOffset()) return subSequence(length(), length()); @@ -196,7 +179,7 @@ public BasedSequence intersect(@NotNull BasedSequence other) { } @Override - public boolean containsSomeIn(@NotNull CharPredicate charSet) { + public boolean containsSomeIn(CharPredicate charSet) { int iMax = length(); for (int i = 0; i < iMax; i++) { if (charSet.test(charAt(i))) return true; @@ -205,7 +188,7 @@ public boolean containsSomeIn(@NotNull CharPredicate charSet) { } @Override - public boolean containsSomeNotIn(@NotNull CharPredicate charSet) { + public boolean containsSomeNotIn(CharPredicate charSet) { int iMax = length(); for (int i = 0; i < iMax; i++) { if (!charSet.test(charAt(i))) return true; @@ -214,54 +197,51 @@ public boolean containsSomeNotIn(@NotNull CharPredicate charSet) { } @Override - public boolean containsOnlyIn(@NotNull CharPredicate charSet) { + public boolean containsOnlyIn(CharPredicate charSet) { return !containsSomeNotIn(charSet); } @Override - public boolean containsOnlyNotIn(@NotNull CharPredicate charSet) { + public boolean containsOnlyNotIn(CharPredicate charSet) { return !containsSomeIn(charSet); } // @formatter:off - @NotNull @Override public BasedSequence extendByAny(@NotNull CharPredicate charSet) { return extendByAny(charSet, Integer.MAX_VALUE - getEndOffset()); } - @NotNull @Override public BasedSequence extendByOneOfAny(@NotNull CharPredicate charSet) { return extendByAny(charSet, 1); } + @Override public BasedSequence extendByAny(CharPredicate charSet) { return extendByAny(charSet, Integer.MAX_VALUE - getEndOffset()); } + @Override public BasedSequence extendByOneOfAny(CharPredicate charSet) { return extendByAny(charSet, 1); } // @formatter:on - @NotNull @Override - public BasedSequence extendByAny(@NotNull CharPredicate charSet, int maxCount) { + public BasedSequence extendByAny(CharPredicate charSet, int maxCount) { int count = getBaseSequence().countLeading(charSet, getEndOffset(), getEndOffset() + maxCount); return count == 0 ? this : baseSubSequence(getStartOffset(), getEndOffset() + count); } // @formatter:off - @NotNull @Override public BasedSequence extendByAnyNot(@NotNull CharPredicate charSet) { return extendByAnyNot(charSet, Integer.MAX_VALUE - getEndOffset()); } - @NotNull @Override public BasedSequence extendByOneOfAnyNot(@NotNull CharPredicate charSet) { return extendByAnyNot(charSet, 1); } + @Override public BasedSequence extendByAnyNot(CharPredicate charSet) { return extendByAnyNot(charSet, Integer.MAX_VALUE - getEndOffset()); } + @Override public BasedSequence extendByOneOfAnyNot(CharPredicate charSet) { return extendByAnyNot(charSet, 1); } // @formatter:on - @NotNull @Override - public BasedSequence extendByAnyNot(@NotNull CharPredicate charSet, int maxCount) { + public BasedSequence extendByAnyNot(CharPredicate charSet, int maxCount) { int count = getBaseSequence().countLeadingNot(charSet, getEndOffset(), getEndOffset() + maxCount); return count == getBaseSequence().length() - getEndOffset() ? this : baseSubSequence(getStartOffset(), getEndOffset() + count + 1); } // @formatter:off - @NotNull @Override final public BasedSequence extendToEndOfLine(@NotNull CharPredicate eolChars) { return extendToEndOfLine(eolChars, false);} - @NotNull @Override final public BasedSequence extendToEndOfLine(boolean includeEol) { return extendToEndOfLine(CharPredicate.EOL, includeEol);} - @NotNull @Override final public BasedSequence extendToEndOfLine() { return extendToEndOfLine(CharPredicate.EOL, false);} - @NotNull @Override final public BasedSequence extendToStartOfLine(@NotNull CharPredicate eolChars) { return extendToStartOfLine(eolChars, false);} - @NotNull @Override final public BasedSequence extendToStartOfLine(boolean includeEol) { return extendToStartOfLine(CharPredicate.EOL, includeEol);} - @NotNull @Override final public BasedSequence extendToStartOfLine() { return extendToStartOfLine(CharPredicate.EOL, false);} + @Override final public BasedSequence extendToEndOfLine(CharPredicate eolChars) { return extendToEndOfLine(eolChars, false);} + @Override final public BasedSequence extendToEndOfLine(boolean includeEol) { return extendToEndOfLine(CharPredicate.EOL, includeEol);} + @Override final public BasedSequence extendToEndOfLine() { return extendToEndOfLine(CharPredicate.EOL, false);} + @Override final public BasedSequence extendToStartOfLine(CharPredicate eolChars) { return extendToStartOfLine(eolChars, false);} + @Override final public BasedSequence extendToStartOfLine(boolean includeEol) { return extendToStartOfLine(CharPredicate.EOL, includeEol);} + @Override final public BasedSequence extendToStartOfLine() { return extendToStartOfLine(CharPredicate.EOL, false);} // @formatter:on - @NotNull @Override - final public BasedSequence extendToEndOfLine(@NotNull CharPredicate eolChars, boolean includeEol) { + final public BasedSequence extendToEndOfLine(CharPredicate eolChars, boolean includeEol) { int endOffset = getEndOffset(); // if already have eol then no need to check @@ -280,9 +260,8 @@ final public BasedSequence extendToEndOfLine(@NotNull CharPredicate eolChars, bo return this; } - @NotNull @Override - public BasedSequence extendToStartOfLine(@NotNull CharPredicate eolChars, boolean includeEol) { + public BasedSequence extendToStartOfLine(CharPredicate eolChars, boolean includeEol) { int startOffset = getStartOffset(); // if already have eol then no need to check @@ -301,18 +280,15 @@ public BasedSequence extendToStartOfLine(@NotNull CharPredicate eolChars, boolea return this; } - @NotNull @Override public BasedSequence prefixWith(@Nullable CharSequence prefix) { return prefix == null || prefix.length() == 0 ? this : PrefixedSubSequence.prefixOf(prefix.toString(), this); } - @NotNull final public BasedSequence prefixWithIndent() { return prefixWithIndent(Integer.MAX_VALUE); } - @NotNull @Override public BasedSequence prefixWithIndent(int maxColumns) { int offset = getStartOffset(); @@ -364,18 +340,16 @@ else if (c == '\n') { return offset == getStartOffset() ? this : baseSubSequence(offset, getEndOffset()); } - @NotNull @Override - public BasedSequence prefixOf(@NotNull BasedSequence other) { + public BasedSequence prefixOf(BasedSequence other) { if (getBase() != other.getBase()) return BasedSequence.NULL; else if (other.getStartOffset() <= getStartOffset()) return subSequence(0, 0); else if (other.getStartOffset() >= getEndOffset()) return this; else return this.baseSubSequence(getStartOffset(), other.getStartOffset()); } - @NotNull @Override - public BasedSequence suffixOf(@NotNull BasedSequence other) { + public BasedSequence suffixOf(BasedSequence other) { if (getBase() != other.getBase()) return BasedSequence.NULL; else if (other.getEndOffset() >= getEndOffset()) return subSequence(length(), length()); else if (other.getEndOffset() <= getStartOffset()) return this; @@ -384,8 +358,8 @@ public BasedSequence suffixOf(@NotNull BasedSequence other) { // @formatter:off // TEST: all these need tests - @Override public @NotNull Range baseLineRangeAtIndex(int index) { return getBaseSequence().lineRangeAt(index); } - @Override public @NotNull Pair baseLineColumnAtIndex(int index) { return getBaseSequence().lineColumnAtIndex(index);} + @Override public Range baseLineRangeAtIndex(int index) { return getBaseSequence().lineRangeAt(index); } + @Override public Pair baseLineColumnAtIndex(int index) { return getBaseSequence().lineColumnAtIndex(index);} @Override public int baseEndOfLine(int index) { return getBaseSequence().endOfLine(index); } @Override public int baseEndOfLineAnyEOL(int index) { return getBaseSequence().endOfLineAnyEOL(index); } @Override public int baseStartOfLine(int index) { return getBaseSequence().startOfLine(index); } @@ -395,14 +369,14 @@ public BasedSequence suffixOf(@NotNull BasedSequence other) { @Override public int baseEndOfLine() { return baseEndOfLine(getEndOffset()); } @Override public int baseEndOfLineAnyEOL() { return baseEndOfLineAnyEOL(getEndOffset()); } @Override public int baseColumnAtEnd() { return baseColumnAtIndex(getEndOffset()); } - @Override public @NotNull Range baseLineRangeAtEnd() { return baseLineRangeAtIndex(getEndOffset()); } - @Override public @NotNull Pair baseLineColumnAtEnd() { return baseLineColumnAtIndex(getEndOffset());} + @Override public Range baseLineRangeAtEnd() { return baseLineRangeAtIndex(getEndOffset()); } + @Override public Pair baseLineColumnAtEnd() { return baseLineColumnAtIndex(getEndOffset());} @Override public int baseStartOfLine() { return baseStartOfLine(getStartOffset()); } @Override public int baseStartOfLineAnyEOL() { return baseStartOfLineAnyEOL(getStartOffset()); } @Override public int baseColumnAtStart() { return baseColumnAtIndex(getStartOffset()); } - @Override public @NotNull Range baseLineRangeAtStart() { return baseLineRangeAtIndex(getStartOffset()); } - @Override public @NotNull Pair baseLineColumnAtStart() {return baseLineColumnAtIndex(getStartOffset());} + @Override public Range baseLineRangeAtStart() { return baseLineRangeAtIndex(getStartOffset()); } + @Override public Pair baseLineColumnAtStart() {return baseLineColumnAtIndex(getStartOffset());} // @formatter:on static BasedSequence create(@Nullable CharSequence charSequence) { diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedUtils.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedUtils.java index a790059be..6fca01721 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedUtils.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/BasedUtils.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.sequence; import com.vladsch.flexmark.util.sequence.builder.IBasedSegmentBuilder; -import org.jetbrains.annotations.NotNull; public interface BasedUtils { /** @@ -10,7 +9,7 @@ public interface BasedUtils { * @param segments segment builder * @param chars based sequence for which to generate segments */ - static void generateSegments(IBasedSegmentBuilder segments, @NotNull BasedSequence chars) { + static void generateSegments(IBasedSegmentBuilder segments, BasedSequence chars) { // find contiguous ranges of base chars and replaced chars, slower but only when optimizers are available int baseStart = -1; int baseEnd = -1; diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/CharSubSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/CharSubSequence.java index a6ba71c3c..e0b4ab587 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/CharSubSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/CharSubSequence.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKeyBase; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A CharSequence that references original char[] @@ -64,13 +63,11 @@ public T getOption(DataKeyBase dataKey) { return null; } - @NotNull @Override public CharSubSequence getBaseSequence() { return base; } - @NotNull @Override public char[] getBase() { return baseChars; @@ -89,7 +86,6 @@ public int length() { return endOffset - startOffset; } - @NotNull @Override public Range getSourceRange() { return Range.of(startOffset, endOffset); @@ -108,14 +104,12 @@ public char charAt(int index) { return c == SequenceUtils.NUL ? SequenceUtils.ENC_NUL : c; } - @NotNull @Override public CharSubSequence subSequence(int startIndex, int endIndex) { SequenceUtils.validateStartEnd(startIndex, endIndex, length()); return base.baseSubSequence(startOffset + startIndex, startOffset + endIndex); } - @NotNull @Override public CharSubSequence baseSubSequence(int startIndex, int endIndex) { SequenceUtils.validateStartEnd(startIndex, endIndex, baseChars.length); diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/Escaping.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/Escaping.java index e519884bb..d32eb56ad 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/Escaping.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/Escaping.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.misc.Utils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.nio.charset.StandardCharsets; import java.util.List; @@ -63,7 +62,7 @@ public class Escaping { final private static Replacer UNSAFE_CHAR_REPLACER = new Replacer() { @Override - public void replace(@NotNull String s, @NotNull StringBuilder sb) { + public void replace(String s, StringBuilder sb) { switch (s) { case "&": sb.append("&"); @@ -84,7 +83,7 @@ public void replace(@NotNull String s, @NotNull StringBuilder sb) { } @Override - public void replace(@NotNull BasedSequence original, int startIndex, int endIndex, @NotNull ReplacedTextMapper textMapper) { + public void replace(BasedSequence original, int startIndex, int endIndex, ReplacedTextMapper textMapper) { String s1 = original.subSequence(startIndex, endIndex).toString(); switch (s1) { case "&": @@ -108,19 +107,19 @@ public void replace(@NotNull BasedSequence original, int startIndex, int endInde final private static Replacer COLLAPSE_WHITESPACE_REPLACER = new Replacer() { @Override - public void replace(@NotNull String s, @NotNull StringBuilder sb) { + public void replace(String s, StringBuilder sb) { sb.append(" "); } @Override - public void replace(@NotNull BasedSequence original, int startIndex, int endIndex, @NotNull ReplacedTextMapper textMapper) { + public void replace(BasedSequence original, int startIndex, int endIndex, ReplacedTextMapper textMapper) { textMapper.addReplacedText(startIndex, endIndex, original.subSequence(startIndex, startIndex + 1)); } }; final private static Replacer UNESCAPE_REPLACER = new Replacer() { @Override - public void replace(@NotNull String s, @NotNull StringBuilder sb) { + public void replace(String s, StringBuilder sb) { if (s.charAt(0) == '\\') { sb.append(s, 1, s.length()); } else { @@ -129,7 +128,7 @@ public void replace(@NotNull String s, @NotNull StringBuilder sb) { } @Override - public void replace(@NotNull BasedSequence original, int startIndex, int endIndex, @NotNull ReplacedTextMapper textMapper) { + public void replace(BasedSequence original, int startIndex, int endIndex, ReplacedTextMapper textMapper) { if (original.charAt(startIndex) == '\\') { textMapper.addReplacedText(startIndex, endIndex, original.subSequence(startIndex + 1, endIndex)); } else { @@ -140,31 +139,31 @@ public void replace(@NotNull BasedSequence original, int startIndex, int endInde final private static Replacer REMOVE_REPLACER = new Replacer() { @Override - public void replace(@NotNull String s, @NotNull StringBuilder sb) { + public void replace(String s, StringBuilder sb) { } @Override - public void replace(@NotNull BasedSequence original, int startIndex, int endIndex, @NotNull ReplacedTextMapper textMapper) { + public void replace(BasedSequence original, int startIndex, int endIndex, ReplacedTextMapper textMapper) { textMapper.addReplacedText(startIndex, endIndex, original.subSequence(endIndex, endIndex)); } }; final private static Replacer ENTITY_REPLACER = new Replacer() { @Override - public void replace(@NotNull String s, @NotNull StringBuilder sb) { + public void replace(String s, StringBuilder sb) { sb.append(Html5Entities.entityToString(s)); } @Override - public void replace(@NotNull BasedSequence original, int startIndex, int endIndex, @NotNull ReplacedTextMapper textMapper) { + public void replace(BasedSequence original, int startIndex, int endIndex, ReplacedTextMapper textMapper) { textMapper.addReplacedText(startIndex, endIndex, Html5Entities.entityToSequence(original.subSequence(startIndex, endIndex))); } }; final private static Replacer URL_ENCODE_REPLACER = new Replacer() { @Override - public void replace(@NotNull String s, @NotNull StringBuilder sb) { + public void replace(String s, StringBuilder sb) { if (s.startsWith("%")) { if (s.length() == 3) { // Already percent-encoded, preserve @@ -185,7 +184,7 @@ public void replace(@NotNull String s, @NotNull StringBuilder sb) { } @Override - public void replace(@NotNull BasedSequence original, int startIndex, int endIndex, @NotNull ReplacedTextMapper textMapper) { + public void replace(BasedSequence original, int startIndex, int endIndex, ReplacedTextMapper textMapper) { BasedSequence s = original.subSequence(startIndex, endIndex); if (s.startsWith("%")) { if (s.length() == 3) { @@ -212,28 +211,27 @@ public void replace(@NotNull BasedSequence original, int startIndex, int endInde final private static Replacer URL_DECODE_REPLACER = new Replacer() { @Override - public void replace(@NotNull String s, @NotNull StringBuilder sb) { + public void replace(String s, StringBuilder sb) { String urlDecoded = Utils.urlDecode(s, null); sb.append(urlDecoded); } @Override - public void replace(@NotNull BasedSequence original, int startIndex, int endIndex, @NotNull ReplacedTextMapper textMapper) { + public void replace(BasedSequence original, int startIndex, int endIndex, ReplacedTextMapper textMapper) { BasedSequence s = original.subSequence(startIndex, endIndex); String decoded = Utils.urlDecode(s.toString(), null); textMapper.addReplacedText(startIndex, endIndex, PrefixedSubSequence.prefixOf(decoded, BasedSequence.NULL)); } }; - final public static @NotNull CharPredicate AMP_BACKSLASH_SET = CharPredicate.anyOf('\\', '&'); + final public static CharPredicate AMP_BACKSLASH_SET = CharPredicate.anyOf('\\', '&'); - public static String escapeHtml(@NotNull CharSequence s, boolean preserveEntities) { + public static String escapeHtml(CharSequence s, boolean preserveEntities) { Pattern p = preserveEntities ? XML_SPECIAL_OR_ENTITY : XML_SPECIAL_RE; return replaceAll(p, s, UNSAFE_CHAR_REPLACER); } - @NotNull - public static BasedSequence escapeHtml(@NotNull BasedSequence s, boolean preserveEntities, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence escapeHtml(BasedSequence s, boolean preserveEntities, ReplacedTextMapper textMapper) { Pattern p = preserveEntities ? XML_SPECIAL_OR_ENTITY : XML_SPECIAL_RE; return replaceAll(p, s, UNSAFE_CHAR_REPLACER, textMapper); } @@ -244,8 +242,7 @@ public static BasedSequence escapeHtml(@NotNull BasedSequence s, boolean preserv * @param s string to un-escape * @return un-escaped string */ - @NotNull - public static String unescapeString(@NotNull CharSequence s) { + public static String unescapeString(CharSequence s) { if (BACKSLASH_OR_AMP.matcher(s).find()) { return replaceAll(ENTITY_OR_ESCAPED_CHAR, s, UNESCAPE_REPLACER); } else { @@ -260,8 +257,7 @@ public static String unescapeString(@NotNull CharSequence s) { * @param unescapeEntities true if HTML entities are to be unescaped * @return un-escaped string */ - @NotNull - public static String unescapeString(@NotNull CharSequence s, boolean unescapeEntities) { + public static String unescapeString(CharSequence s, boolean unescapeEntities) { if (unescapeEntities) { if (BACKSLASH_OR_AMP.matcher(s).find()) { return replaceAll(ESCAPED_CHAR, s, UNESCAPE_REPLACER); @@ -284,8 +280,7 @@ public static String unescapeString(@NotNull CharSequence s, boolean unescapeEnt * @param textMapper replaced text mapper to update for the changed text * @return un-escaped sequence */ - @NotNull - public static BasedSequence unescape(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence unescape(BasedSequence s, ReplacedTextMapper textMapper) { int indexOfAny = s.indexOfAny(AMP_BACKSLASH_SET); if (indexOfAny != -1) { return replaceAll(ENTITY_OR_ESCAPED_CHAR, s, UNESCAPE_REPLACER, textMapper); @@ -302,8 +297,7 @@ public static BasedSequence unescape(@NotNull BasedSequence s, @NotNull Replaced * @param textMapper replaced text mapper to update for the changed text * @return un-escaped sequence */ - @NotNull - public static BasedSequence removeAll(@NotNull BasedSequence s, @NotNull CharSequence remove, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence removeAll(BasedSequence s, CharSequence remove, ReplacedTextMapper textMapper) { int indexOf = s.indexOf(remove); if (indexOf != -1) { return replaceAll(Pattern.compile("\\Q" + remove + "\\E"), s, REMOVE_REPLACER, textMapper); @@ -318,8 +312,7 @@ public static BasedSequence removeAll(@NotNull BasedSequence s, @NotNull CharSeq * @param s string to un-escape * @return un-escaped string */ - @NotNull - public static String unescapeHtml(@NotNull CharSequence s) { + public static String unescapeHtml(CharSequence s) { if (AMP_ONLY.matcher(s).find()) { return replaceAll(ENTITY_ONLY, s, ENTITY_REPLACER); } else { @@ -334,8 +327,7 @@ public static String unescapeHtml(@NotNull CharSequence s) { * @param textMapper replaced text mapper to update for the changed text * @return un-escaped sequence */ - @NotNull - public static BasedSequence unescapeHtml(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence unescapeHtml(BasedSequence s, ReplacedTextMapper textMapper) { int indexOfAny = s.indexOf('&'); if (indexOfAny != -1) { return replaceAll(ENTITY_ONLY, s, ENTITY_REPLACER, textMapper); @@ -351,8 +343,7 @@ public static BasedSequence unescapeHtml(@NotNull BasedSequence s, @NotNull Repl * @param textMapper replaced text mapper to update for the changed text * @return un-escaped sequence */ - @NotNull - public static BasedSequence unescapeHtml(@NotNull BasedSequence s, @NotNull List ranges, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence unescapeHtml(BasedSequence s, List ranges, ReplacedTextMapper textMapper) { int indexOfAny = s.indexOf('&'); if (indexOfAny != -1) { return replaceAll(ENTITY_ONLY, s, ranges, ENTITY_REPLACER, textMapper); @@ -369,8 +360,7 @@ public static BasedSequence unescapeHtml(@NotNull BasedSequence s, @NotNull List * @param s sequence to convert * @return converted sequence */ - @NotNull - public static String normalizeEndWithEOL(@NotNull CharSequence s) { + public static String normalizeEndWithEOL(CharSequence s) { return normalizeEOL(s, true); } @@ -380,8 +370,7 @@ public static String normalizeEndWithEOL(@NotNull CharSequence s) { * @param s sequence to convert * @return converted sequence */ - @NotNull - public static String normalizeEOL(@NotNull CharSequence s) { + public static String normalizeEOL(CharSequence s) { return normalizeEOL(s, false); } @@ -392,8 +381,7 @@ public static String normalizeEOL(@NotNull CharSequence s) { * @param endWithEOL true if an EOL is to be appended to the end of the sequence if not already ending with one. * @return converted sequence */ - @NotNull - public static String normalizeEOL(@NotNull CharSequence s, boolean endWithEOL) { + public static String normalizeEOL(CharSequence s, boolean endWithEOL) { StringBuilder sb = new StringBuilder(s.length()); int iMax = s.length(); boolean hadCR = false; @@ -427,8 +415,7 @@ public static String normalizeEOL(@NotNull CharSequence s, boolean endWithEOL) { * @param textMapper text mapper to update for the replaced text * @return converted sequence */ - @NotNull - public static BasedSequence normalizeEndWithEOL(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence normalizeEndWithEOL(BasedSequence s, ReplacedTextMapper textMapper) { return normalizeEOL(s, textMapper, true); } @@ -439,8 +426,7 @@ public static BasedSequence normalizeEndWithEOL(@NotNull BasedSequence s, @NotNu * @param textMapper text mapper to update for the replaced text * @return converted sequence */ - @NotNull - public static BasedSequence normalizeEOL(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence normalizeEOL(BasedSequence s, ReplacedTextMapper textMapper) { return normalizeEOL(s, textMapper, false); } @@ -454,8 +440,7 @@ public static BasedSequence normalizeEOL(@NotNull BasedSequence s, @NotNull Repl * @param endWithEOL whether an EOL is to be appended to the end of the sequence if it does not already end with one. * @return converted sequence */ - @NotNull - public static BasedSequence normalizeEOL(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper, boolean endWithEOL) { + public static BasedSequence normalizeEOL(BasedSequence s, ReplacedTextMapper textMapper, boolean endWithEOL) { int iMax = s.length(); int lastPos = 0; boolean hadCR = false; @@ -502,8 +487,7 @@ public static BasedSequence normalizeEOL(@NotNull BasedSequence s, @NotNull Repl * @param s string to encode * @return encoded string */ - @NotNull - public static String percentEncodeUrl(@NotNull CharSequence s) { + public static String percentEncodeUrl(CharSequence s) { return replaceAll(ESCAPE_IN_URI, s, URL_ENCODE_REPLACER); } @@ -512,8 +496,7 @@ public static String percentEncodeUrl(@NotNull CharSequence s) { * @param textMapper text mapper to update for the replaced text * @return encoded string */ - @NotNull - public static BasedSequence percentEncodeUrl(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence percentEncodeUrl(BasedSequence s, ReplacedTextMapper textMapper) { return replaceAll(ESCAPE_IN_URI, s, URL_ENCODE_REPLACER, textMapper); } @@ -521,8 +504,7 @@ public static BasedSequence percentEncodeUrl(@NotNull BasedSequence s, @NotNull * @param s string to encode * @return encoded string */ - @NotNull - public static String percentDecodeUrl(@NotNull CharSequence s) { + public static String percentDecodeUrl(CharSequence s) { return replaceAll(ESCAPE_URI_DECODE, s, URL_DECODE_REPLACER); } @@ -531,8 +513,7 @@ public static String percentDecodeUrl(@NotNull CharSequence s) { * @param textMapper text mapper to update for the replaced text * @return encoded string */ - @NotNull - public static BasedSequence percentDecodeUrl(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence percentDecodeUrl(BasedSequence s, ReplacedTextMapper textMapper) { return replaceAll(ESCAPE_URI_DECODE, s, URL_DECODE_REPLACER, textMapper); } @@ -543,8 +524,7 @@ public static BasedSequence percentDecodeUrl(@NotNull BasedSequence s, @NotNull * @param changeCase if true then reference will be converted to lowercase * @return normalized link reference id */ - @NotNull - public static String normalizeReference(@NotNull CharSequence s, boolean changeCase) { + public static String normalizeReference(CharSequence s, boolean changeCase) { if (changeCase) return Escaping.collapseWhitespace(s.toString(), true).toLowerCase(); else return Escaping.collapseWhitespace(s.toString(), true); } @@ -575,8 +555,7 @@ private static String encode(char c) { * @param randomize true to randomize, false for testing * @return obfuscated e-mail url */ - @NotNull - public static String obfuscate(@NotNull String email, boolean randomize) { + public static String obfuscate(String email, boolean randomize) { if (!randomize) random = new Random(0); StringBuilder sb = new StringBuilder(); @@ -609,8 +588,7 @@ public static String obfuscate(@NotNull String email, boolean randomize) { * @param changeCase if true then reference will be converted to lowercase * @return normalized link reference id */ - @NotNull - public static String normalizeReferenceChars(@NotNull CharSequence s, boolean changeCase) { + public static String normalizeReferenceChars(CharSequence s, boolean changeCase) { // Strip '[' and ']', then trim and convert to lowercase if (s.length() > 1) { int stripEnd = s.charAt(s.length() - 1) == ':' ? 2 : 1; @@ -627,8 +605,7 @@ public static String normalizeReferenceChars(@NotNull CharSequence s, boolean ch * @param trim true if the sequence should also be trimmed * @return processed sequence */ - @NotNull - public static String collapseWhitespace(@NotNull CharSequence s, boolean trim) { + public static String collapseWhitespace(CharSequence s, boolean trim) { StringBuilder sb = new StringBuilder(s.length()); int iMax = s.length(); boolean hadSpace = false; @@ -647,13 +624,11 @@ public static String collapseWhitespace(@NotNull CharSequence s, boolean trim) { return sb.toString(); } - @NotNull - public static BasedSequence collapseWhitespace(@NotNull BasedSequence s, @NotNull ReplacedTextMapper textMapper) { + public static BasedSequence collapseWhitespace(BasedSequence s, ReplacedTextMapper textMapper) { return replaceAll(COLLAPSE_WHITESPACE, s, COLLAPSE_WHITESPACE_REPLACER, textMapper); } - @NotNull - private static String replaceAll(@NotNull Pattern p, @NotNull CharSequence s, @NotNull Replacer replacer) { + private static String replaceAll(Pattern p, CharSequence s, Replacer replacer) { Matcher matcher = p.matcher(s); if (!matcher.find()) { @@ -674,13 +649,11 @@ private static String replaceAll(@NotNull Pattern p, @NotNull CharSequence s, @N return sb.toString(); } - @NotNull - private static BasedSequence replaceAll(@NotNull Pattern p, @NotNull BasedSequence s, @NotNull Replacer replacer, @NotNull ReplacedTextMapper textMapper) { + private static BasedSequence replaceAll(Pattern p, BasedSequence s, Replacer replacer, ReplacedTextMapper textMapper) { return replaceAll(p, s, 0, s.length(), replacer, textMapper); } - @NotNull - private static BasedSequence replaceAll(@NotNull Pattern p, @NotNull BasedSequence s, int startOffset, int endOffset, @NotNull Replacer replacer, @NotNull ReplacedTextMapper textMapper) { + private static BasedSequence replaceAll(Pattern p, BasedSequence s, int startOffset, int endOffset, Replacer replacer, ReplacedTextMapper textMapper) { Matcher matcher = p.matcher(s); matcher.region(startOffset, endOffset); matcher.useTransparentBounds(false); @@ -708,8 +681,7 @@ private static BasedSequence replaceAll(@NotNull Pattern p, @NotNull BasedSequen return textMapper.getReplacedSequence(); } - @NotNull - private static BasedSequence replaceAll(@NotNull Pattern p, @NotNull BasedSequence s, @NotNull List ranges, @NotNull Replacer replacer, @NotNull ReplacedTextMapper textMapper) { + private static BasedSequence replaceAll(Pattern p, BasedSequence s, List ranges, Replacer replacer, ReplacedTextMapper textMapper) { Matcher matcher = p.matcher(s); matcher.useTransparentBounds(false); @@ -739,8 +711,8 @@ private static BasedSequence replaceAll(@NotNull Pattern p, @NotNull BasedSequen } interface Replacer { - void replace(@NotNull String s, @NotNull StringBuilder sb); + void replace(String s, StringBuilder sb); - void replace(@NotNull BasedSequence s, int startIndex, int endIndex, @NotNull ReplacedTextMapper replacedTextMapper); + void replace(BasedSequence s, int startIndex, int endIndex, ReplacedTextMapper replacedTextMapper); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/IRichSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/IRichSequence.java index b3f1797e1..09050b229 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/IRichSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/IRichSequence.java @@ -4,8 +4,7 @@ import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; import com.vladsch.flexmark.util.sequence.mappers.CharMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.List; @@ -38,8 +37,8 @@ public interface IRichSequence> extends CharSequence, */ int hashCode(); - @NotNull T[] emptyArray(); - @NotNull T nullSequence(); + T[] emptyArray(); + T nullSequence(); /** * @return the last character of the sequence or '\0' if empty @@ -69,7 +68,7 @@ public interface IRichSequence> extends CharSequence, * @return based sequence whose contents reflect the selected portion */ @Override - @NotNull T subSequence(int startIndex, int endIndex); + T subSequence(int startIndex, int endIndex); /** * Get a portion of this sequence, if index < 0 use 0, if > length() use length @@ -80,7 +79,7 @@ public interface IRichSequence> extends CharSequence, * @param endIndex offset from startIndex of this sequence * @return based sequence whose contents reflect the selected portion */ - @NotNull T safeSubSequence(int startIndex, int endIndex); + T safeSubSequence(int startIndex, int endIndex); /** * Get a portion of this sequence, if index < 0 use 0, if > length() use length @@ -90,7 +89,7 @@ public interface IRichSequence> extends CharSequence, * @param startIndex offset from startIndex of this sequence * @return based sequence whose contents reflect the selected portion */ - @NotNull T safeSubSequence(int startIndex); + T safeSubSequence(int startIndex); /** * Get a portion of this sequence selected by range @@ -98,7 +97,7 @@ public interface IRichSequence> extends CharSequence, * @param range range to get, coordinates offset form start of this sequence * @return based sequence whose contents reflect the selected portion, if range.isNull() then {@link #nullSequence()} */ - @NotNull T subSequence(@NotNull Range range); + T subSequence(Range range); /** * Get a portion of this sequence before one selected by range @@ -106,7 +105,7 @@ public interface IRichSequence> extends CharSequence, * @param range range to get, coordinates offset form start of this sequence * @return based sequence whose contents reflect the selected portion, if range.isNull() then {@link #nullSequence()} */ - @NotNull T subSequenceBefore(@NotNull Range range); + T subSequenceBefore(Range range); /** * Get a portion of this sequence after one selected by range @@ -114,7 +113,7 @@ public interface IRichSequence> extends CharSequence, * @param range range to get, coordinates offset form start of this sequence * @return based sequence whose contents reflect the selected portion, if range.isNull() then {@link #nullSequence()} */ - @NotNull T subSequenceAfter(@NotNull Range range); + T subSequenceAfter(Range range); /** * Get a portion of this sequence starting from a given offset to endIndex of the sequence @@ -122,7 +121,7 @@ public interface IRichSequence> extends CharSequence, * @param startIndex offset from startIndex of this sequence * @return based sequence whose contents reflect the selected portion */ - @NotNull T subSequence(int startIndex); + T subSequence(int startIndex); /** * Convenience method to get characters offset from endIndex of sequence. @@ -132,7 +131,7 @@ public interface IRichSequence> extends CharSequence, * @param endIndex offset from endIndex of sequence [ 0..length() ) * @return selected portion spanning length() - startIndex to length() - endIndex of this sequence */ - @NotNull T endSequence(int startIndex, int endIndex); + T endSequence(int startIndex, int endIndex); /** * Convenience method to get characters offset from endIndex of sequence. @@ -141,7 +140,7 @@ public interface IRichSequence> extends CharSequence, * @param startIndex offset from endIndex of sequence [ 0..length() ) * @return selected portion spanning length() - startIndex to length() of this sequence */ - @NotNull T endSequence(int startIndex); + T endSequence(int startIndex); // index from the end of the sequence // no exceptions are thrown, instead a \0 is returned for an invalid index @@ -165,7 +164,7 @@ public interface IRichSequence> extends CharSequence, * @param endIndex offset into this sequence * @return selected portion spanning startIndex to endIndex of this sequence. If offset is <0 then it is taken as relative to length() */ - @NotNull T midSequence(int startIndex, int endIndex); + T midSequence(int startIndex, int endIndex); /** * Convenience method to get characters offset from start or end of sequence. @@ -177,7 +176,7 @@ public interface IRichSequence> extends CharSequence, * @param startIndex offset into this sequence * @return selected portion spanning startIndex to length() of this sequence. If offset is <0 then it is taken as relative to length() */ - @NotNull T midSequence(int startIndex); + T midSequence(int startIndex); /** * Convenience method to get characters offset from start or end of sequence. @@ -196,7 +195,7 @@ public interface IRichSequence> extends CharSequence, * @param charSequence char sequence from which to construct a rich char sequence * @return rich char sequence from given inputs */ - @NotNull T sequenceOf(@Nullable CharSequence charSequence); + T sequenceOf(@Nullable CharSequence charSequence); /** * Factory function @@ -205,7 +204,7 @@ public interface IRichSequence> extends CharSequence, * @param startIndex start index of the sequence to use * @return rich char sequence from given inputs */ - @NotNull T sequenceOf(@Nullable CharSequence charSequence, int startIndex); + T sequenceOf(@Nullable CharSequence charSequence, int startIndex); /** * Factory function @@ -215,7 +214,7 @@ public interface IRichSequence> extends CharSequence, * @param endIndex end index of the sequence to use * @return rich char sequence from given inputs */ - @NotNull T sequenceOf(@Nullable CharSequence charSequence, int startIndex, int endIndex); + T sequenceOf(@Nullable CharSequence charSequence, int startIndex, int endIndex); /** * Get a sequence builder for this sequence type @@ -223,7 +222,7 @@ public interface IRichSequence> extends CharSequence, * @param type of builder * @return builder which can build this type of sequence */ - @NotNull > B getBuilder(); + > B getBuilder(); /** * All index methods return the position or -1 if not found of the given character, characters or string. @@ -242,43 +241,43 @@ public interface IRichSequence> extends CharSequence, * @param s character pre whose occurrence to find * @return index where found or -1 */ - int indexOf(@NotNull CharSequence s); - int indexOf(@NotNull CharSequence s, int fromIndex); - int indexOf(@NotNull CharSequence s, int fromIndex, int endIndex); + int indexOf(CharSequence s); + int indexOf(CharSequence s, int fromIndex); + int indexOf(CharSequence s, int fromIndex, int endIndex); int indexOf(char c, int fromIndex, int endIndex); int indexOf(char c, int fromIndex); int indexOf(char c); - int indexOfAny(@NotNull CharPredicate s, int fromIndex, int endIndex); - int indexOfAny(@NotNull CharPredicate s, int fromIndex); - int indexOfAny(@NotNull CharPredicate s); + int indexOfAny(CharPredicate s, int fromIndex, int endIndex); + int indexOfAny(CharPredicate s, int fromIndex); + int indexOfAny(CharPredicate s); int indexOfNot(char c, int fromIndex, int endIndex); int indexOfNot(char c, int fromIndex); int indexOfNot(char c); - int indexOfAnyNot(@NotNull CharPredicate s, int fromIndex, int endIndex); - int indexOfAnyNot(@NotNull CharPredicate s, int fromIndex); - int indexOfAnyNot(@NotNull CharPredicate s); + int indexOfAnyNot(CharPredicate s, int fromIndex, int endIndex); + int indexOfAnyNot(CharPredicate s, int fromIndex); + int indexOfAnyNot(CharPredicate s); - int lastIndexOf(@NotNull CharSequence s); - int lastIndexOf(@NotNull CharSequence s, int fromIndex); - int lastIndexOf(@NotNull CharSequence s, int startIndex, int fromIndex); + int lastIndexOf(CharSequence s); + int lastIndexOf(CharSequence s, int fromIndex); + int lastIndexOf(CharSequence s, int startIndex, int fromIndex); int lastIndexOf(char c, int startIndex, int fromIndex); int lastIndexOf(char c, int fromIndex); int lastIndexOf(char c); - int lastIndexOfAny(@NotNull CharPredicate s, int startIndex, int fromIndex); - int lastIndexOfAny(@NotNull CharPredicate s, int fromIndex); - int lastIndexOfAny(@NotNull CharPredicate s); + int lastIndexOfAny(CharPredicate s, int startIndex, int fromIndex); + int lastIndexOfAny(CharPredicate s, int fromIndex); + int lastIndexOfAny(CharPredicate s); int lastIndexOfNot(char c); int lastIndexOfNot(char c, int fromIndex); int lastIndexOfNot(char c, int startIndex, int fromIndex); - int lastIndexOfAnyNot(@NotNull CharPredicate s, int startIndex, int fromIndex); - int lastIndexOfAnyNot(@NotNull CharPredicate s, int fromIndex); - int lastIndexOfAnyNot(@NotNull CharPredicate s); + int lastIndexOfAnyNot(CharPredicate s, int startIndex, int fromIndex); + int lastIndexOfAnyNot(CharPredicate s, int fromIndex); + int lastIndexOfAnyNot(CharPredicate s); /** * Count leading/trailing characters of this sequence @@ -298,12 +297,12 @@ public interface IRichSequence> extends CharSequence, * @param chars predicate for set of contiguous characters which should be counted * @return number of chars in contiguous span at start of sequence */ - int countLeading(@NotNull CharPredicate chars); - int countLeadingNot(@NotNull CharPredicate chars); - int countLeading(@NotNull CharPredicate chars, int startIndex); - int countLeadingNot(@NotNull CharPredicate chars, int startIndex); - int countLeading(@NotNull CharPredicate chars, int startIndex, int endIndex); - int countLeadingNot(@NotNull CharPredicate chars, int startIndex, int endIndex); + int countLeading(CharPredicate chars); + int countLeadingNot(CharPredicate chars); + int countLeading(CharPredicate chars, int startIndex); + int countLeadingNot(CharPredicate chars, int startIndex); + int countLeading(CharPredicate chars, int startIndex, int endIndex); + int countLeadingNot(CharPredicate chars, int startIndex, int endIndex); /** * @param c char @@ -315,12 +314,12 @@ default int countLeading(char c) { return countLeading(CharPredicate.anyOf(c)); } - int countTrailing(@NotNull CharPredicate chars); - int countTrailingNot(@NotNull CharPredicate chars); - int countTrailing(@NotNull CharPredicate chars, int startIndex); - int countTrailingNot(@NotNull CharPredicate chars, int startIndex); - int countTrailing(@NotNull CharPredicate chars, int startIndex, int endIndex); - int countTrailingNot(@NotNull CharPredicate chars, int startIndex, int endIndex); + int countTrailing(CharPredicate chars); + int countTrailingNot(CharPredicate chars); + int countTrailing(CharPredicate chars, int startIndex); + int countTrailingNot(CharPredicate chars, int startIndex); + int countTrailing(CharPredicate chars, int startIndex, int endIndex); + int countTrailingNot(CharPredicate chars, int startIndex, int endIndex); int countLeadingSpace(); int countLeadingNotSpace(); @@ -385,12 +384,12 @@ default int countOf(char c) { return countOfAny(CharPredicate.anyOf(c)); } - int countOfAny(@NotNull CharPredicate chars); - int countOfAnyNot(@NotNull CharPredicate chars); - int countOfAny(@NotNull CharPredicate chars, int startIndex); - int countOfAnyNot(@NotNull CharPredicate chars, int startIndex); - int countOfAny(@NotNull CharPredicate chars, int startIndex, int endIndex); - int countOfAnyNot(@NotNull CharPredicate chars, int startIndex, int endIndex); + int countOfAny(CharPredicate chars); + int countOfAnyNot(CharPredicate chars); + int countOfAny(CharPredicate chars, int startIndex); + int countOfAnyNot(CharPredicate chars, int startIndex); + int countOfAny(CharPredicate chars, int startIndex, int endIndex); + int countOfAnyNot(CharPredicate chars, int startIndex, int endIndex); /** * Count column of indent given by chars in the set in this sequence, expanding tabs to 4th column @@ -399,7 +398,7 @@ default int countOf(char c) { * @param chars whitespace characters * @return column of first non-whitespace as given by chars */ - int countLeadingColumns(int startColumn, @NotNull CharPredicate chars); + int countLeadingColumns(int startColumn, CharPredicate chars); /** * Range of kept sequence when trim start/end of this sequence is performed, characters to trim are passed in the sequence argument @@ -412,21 +411,21 @@ default int countOf(char c) { * @param chars set of characters to trim from start of line * @return range in this sequence to keep or Range.NULL if to keep all */ - @NotNull Range trimStartRange(int keep, @NotNull CharPredicate chars); - @NotNull Range trimEndRange(int keep, @NotNull CharPredicate chars); - @NotNull Range trimRange(int keep, @NotNull CharPredicate chars); + Range trimStartRange(int keep, CharPredicate chars); + Range trimEndRange(int keep, CharPredicate chars); + Range trimRange(int keep, CharPredicate chars); - @NotNull Range trimStartRange(@NotNull CharPredicate chars); - @NotNull Range trimEndRange(@NotNull CharPredicate chars); - @NotNull Range trimRange(@NotNull CharPredicate chars); + Range trimStartRange(CharPredicate chars); + Range trimEndRange(CharPredicate chars); + Range trimRange(CharPredicate chars); - @NotNull Range trimStartRange(int keep); - @NotNull Range trimEndRange(int keep); - @NotNull Range trimRange(int keep); + Range trimStartRange(int keep); + Range trimEndRange(int keep); + Range trimRange(int keep); - @NotNull Range trimStartRange(); - @NotNull Range trimEndRange(); - @NotNull Range trimRange(); + Range trimStartRange(); + Range trimEndRange(); + Range trimRange(); /** * Trim, Trim start/end of this sequence, characters to trim are passed in the sequence argument @@ -439,21 +438,21 @@ default int countOf(char c) { * @param chars set of characters to trim from start of line * @return sequence after it is trimmed */ - @NotNull T trimStart(int keep, @NotNull CharPredicate chars); - @NotNull T trimEnd(int keep, @NotNull CharPredicate chars); - @NotNull T trim(int keep, @NotNull CharPredicate chars); + T trimStart(int keep, CharPredicate chars); + T trimEnd(int keep, CharPredicate chars); + T trim(int keep, CharPredicate chars); - @NotNull T trimStart(int keep); - @NotNull T trimEnd(int keep); - @NotNull T trim(int keep); + T trimStart(int keep); + T trimEnd(int keep); + T trim(int keep); - @NotNull T trimStart(@NotNull CharPredicate chars); - @NotNull T trimEnd(@NotNull CharPredicate chars); - @NotNull T trim(@NotNull CharPredicate chars); + T trimStart(CharPredicate chars); + T trimEnd(CharPredicate chars); + T trim(CharPredicate chars); - @NotNull T trimStart(); - @NotNull T trimEnd(); - @NotNull T trim(); + T trimStart(); + T trimEnd(); + T trim(); /** * Get the characters Trimmed, Trimmed from start/end of this sequence, characters to trim are passed in the sequence argument @@ -466,21 +465,21 @@ default int countOf(char c) { * @param chars set of characters to trim from start of line * @return part of the sequence that was trimmed from the start */ - @NotNull T trimmedStart(int keep, @NotNull CharPredicate chars); - @NotNull T trimmedEnd(int keep, @NotNull CharPredicate chars); - @NotNull Pair trimmed(int keep, @NotNull CharPredicate chars); + T trimmedStart(int keep, CharPredicate chars); + T trimmedEnd(int keep, CharPredicate chars); + Pair trimmed(int keep, CharPredicate chars); - @NotNull T trimmedStart(int keep); - @NotNull T trimmedEnd(int keep); - @NotNull Pair trimmed(int keep); + T trimmedStart(int keep); + T trimmedEnd(int keep); + Pair trimmed(int keep); - @NotNull T trimmedStart(@NotNull CharPredicate chars); - @NotNull T trimmedEnd(@NotNull CharPredicate chars); - @NotNull Pair trimmed(@NotNull CharPredicate chars); + T trimmedStart(CharPredicate chars); + T trimmedEnd(CharPredicate chars); + Pair trimmed(CharPredicate chars); - @NotNull T trimmedStart(); - @NotNull T trimmedEnd(); - @NotNull Pair trimmed(); + T trimmedStart(); + T trimmedEnd(); + Pair trimmed(); /** * Get the chars needed for padding to length @@ -489,8 +488,8 @@ default int countOf(char c) { * @param pad char to use for padding * @return padding chars */ - @NotNull T padding(int length, char pad); - @NotNull T padding(int length); + T padding(int length, char pad); + T padding(int length); /** * Pad this sequence to given length @@ -499,10 +498,10 @@ default int countOf(char c) { * @param pad char to use for padding * @return sequence padded */ - @NotNull T padStart(int length, char pad); - @NotNull T padEnd(int length, char pad); - @NotNull T padStart(int length); - @NotNull T padEnd(int length); + T padStart(int length, char pad); + T padEnd(int length, char pad); + T padStart(int length); + T padEnd(int length); boolean isEmpty(); boolean isBlank(); @@ -518,7 +517,7 @@ default int countOf(char c) { * @param other based sequence to return if this is nullSequence() * @return this or other */ - @NotNull T ifNull(@NotNull T other); + T ifNull(T other); /** * If this sequence is the nullSequence() instance then returns an empty subSequence from the end of other, @@ -527,7 +526,7 @@ default int countOf(char c) { * @param other based sequence from which to take the empty sequence * @return this or other.subSequence(other.length(), other.length()) */ - @NotNull T ifNullEmptyAfter(@NotNull T other); + T ifNullEmptyAfter(T other); /** * If this sequence is the nullSequence() instance then returns an empty subSequence from the start of other, @@ -536,21 +535,21 @@ default int countOf(char c) { * @param other based sequence from which to take the empty sequence * @return this or other.subSequence(0, 0) */ - @NotNull T ifNullEmptyBefore(@NotNull T other); + T ifNullEmptyBefore(T other); /** * If this sequence is empty return nullSequence() otherwise returns this sequence. * * @return this or nullSequence() */ - @NotNull T nullIfEmpty(); + T nullIfEmpty(); /** * If this sequence is blank return nullSequence() otherwise returns this sequence. * * @return this or nullSequence() */ - @NotNull T nullIfBlank(); + T nullIfBlank(); /** * If condition is true return nullSequence() otherwise returns this sequence. @@ -558,7 +557,7 @@ default int countOf(char c) { * @param condition when true return NULL else this * @return this or nullSequence() */ - @NotNull T nullIf(boolean condition); + T nullIf(boolean condition); /** * If predicate returns true for this sequence and one of given sequences return nullSequence() otherwise returns this sequence. @@ -567,8 +566,8 @@ default int countOf(char c) { * @param matches match sequence list * @return this or nullSequence() */ - @NotNull T nullIf(@NotNull BiPredicate predicate, CharSequence... matches); - @NotNull T nullIfNot(@NotNull BiPredicate predicate, CharSequence... matches); + T nullIf(BiPredicate predicate, CharSequence... matches); + T nullIfNot(BiPredicate predicate, CharSequence... matches); /** * If predicate returns true for one of given sequences return nullSequence() otherwise returns this sequence. @@ -577,8 +576,8 @@ default int countOf(char c) { * @param matches match sequence list * @return this or nullSequence() */ - @NotNull T nullIf(@NotNull Predicate predicate, CharSequence... matches); - @NotNull T nullIfNot(@NotNull Predicate predicate, CharSequence... matches); + T nullIf(Predicate predicate, CharSequence... matches); + T nullIfNot(Predicate predicate, CharSequence... matches); /** * If this sequence matches one of given sequences return nullSequence() otherwise returns this sequence. @@ -586,30 +585,30 @@ default int countOf(char c) { * @param matches match sequence list * @return this or nullSequence() */ - @NotNull T nullIf(CharSequence... matches); - @NotNull T nullIfNot(CharSequence... matches); + T nullIf(CharSequence... matches); + T nullIfNot(CharSequence... matches); - @NotNull T nullIfStartsWith(CharSequence... matches); - @NotNull T nullIfNotStartsWith(CharSequence... matches); + T nullIfStartsWith(CharSequence... matches); + T nullIfNotStartsWith(CharSequence... matches); @Deprecated - default @NotNull T nullIfStartsWithNot(CharSequence... matches) { + default T nullIfStartsWithNot(CharSequence... matches) { return nullIfNotStartsWith(matches); } - @NotNull T nullIfEndsWith(CharSequence... matches); - @NotNull T nullIfNotEndsWith(CharSequence... matches); - @NotNull T nullIfStartsWithIgnoreCase(CharSequence... matches); - @NotNull T nullIfNotStartsWithIgnoreCase(CharSequence... matches); - @NotNull T nullIfEndsWithIgnoreCase(CharSequence... matches); - @NotNull T nullIfNotEndsWithIgnoreCase(CharSequence... matches); - @NotNull T nullIfStartsWith(boolean ignoreCase, CharSequence... matches); - @NotNull T nullIfNotStartsWith(boolean ignoreCase, CharSequence... matches); - @NotNull T nullIfEndsWith(boolean ignoreCase, CharSequence... matches); - @NotNull T nullIfNotEndsWith(boolean ignoreCase, CharSequence... matches); + T nullIfEndsWith(CharSequence... matches); + T nullIfNotEndsWith(CharSequence... matches); + T nullIfStartsWithIgnoreCase(CharSequence... matches); + T nullIfNotStartsWithIgnoreCase(CharSequence... matches); + T nullIfEndsWithIgnoreCase(CharSequence... matches); + T nullIfNotEndsWithIgnoreCase(CharSequence... matches); + T nullIfStartsWith(boolean ignoreCase, CharSequence... matches); + T nullIfNotStartsWith(boolean ignoreCase, CharSequence... matches); + T nullIfEndsWith(boolean ignoreCase, CharSequence... matches); + T nullIfNotEndsWith(boolean ignoreCase, CharSequence... matches); @Deprecated - default @NotNull T nullIfEndsWithNot(CharSequence... matches) { + default T nullIfEndsWithNot(CharSequence... matches) { return nullIfNotEndsWith(matches); } @@ -674,7 +673,7 @@ default int eolLength(int eolStart) { * if 0 or less then 0 is returned. * @return range of eol given by index of its end or Range.NULL if no eol ends at index */ - @NotNull Range eolEndRange(int eolEnd); + Range eolEndRange(int eolEnd); /** * Return Range of eol at given index @@ -684,21 +683,21 @@ default int eolLength(int eolStart) { * if 0 or less then it is the same as 0 * @return range of eol given by index of its end or Range.NULL if no eol starts at index */ - @NotNull Range eolStartRange(int eolStart); + Range eolStartRange(int eolStart); /** * Trim last eol at the end of this sequence, * * @return sequence with one EOL trimmed off if it had one */ - @NotNull T trimEOL(); + T trimEOL(); /** * Get Trimmed part by {@link #trimEOL()} * * @return trimmed off EOL if sequence had one or {@link #nullSequence()} */ - @NotNull T trimmedEOL(); + T trimmedEOL(); /** * Find start/end region in this sequence delimited by any characters in argument or the CharSequence @@ -709,13 +708,13 @@ default int eolLength(int eolStart) { * @param index from which to start looking for end of region * @return index of end of region delimited by s */ - int endOfDelimitedBy(@NotNull CharSequence s, int index); - int endOfDelimitedByAny(@NotNull CharPredicate s, int index); - int endOfDelimitedByAnyNot(@NotNull CharPredicate s, int index); + int endOfDelimitedBy(CharSequence s, int index); + int endOfDelimitedByAny(CharPredicate s, int index); + int endOfDelimitedByAnyNot(CharPredicate s, int index); - int startOfDelimitedBy(@NotNull CharSequence s, int index); - int startOfDelimitedByAny(@NotNull CharPredicate s, int index); - int startOfDelimitedByAnyNot(@NotNull CharPredicate s, int index); + int startOfDelimitedBy(CharSequence s, int index); + int startOfDelimitedByAny(CharPredicate s, int index); + int startOfDelimitedByAnyNot(CharPredicate s, int index); /** * Get the offset of the end of line at given index, end of line delimited by \n @@ -755,14 +754,14 @@ default int eolLength(int eolStart) { * @param index index at which to get the line * @return range in sequence for the line delimited by '\n', containing index */ - @NotNull Range lineRangeAt(int index); + Range lineRangeAt(int index); /** * Get the line characters at given index, line delimited by \n, \r or \r\n * * @param index index at which to get the line * @return range in sequence for the line delimited by end of line, containing index */ - @NotNull Range lineRangeAtAnyEOL(int index); + Range lineRangeAtAnyEOL(int index); /** * Get the line characters at given index, line delimited by \n @@ -770,7 +769,7 @@ default int eolLength(int eolStart) { * @param index index at which to get the line * @return sub-sequence for the line containing index */ - @NotNull T lineAt(int index); + T lineAt(int index); /** * Get the line characters at given index, line delimited by \n, \r or \r\n @@ -778,15 +777,15 @@ default int eolLength(int eolStart) { * @param index index at which to get the line * @return sub-sequence for the line containing index */ - @NotNull T lineAtAnyEOL(int index); + T lineAtAnyEOL(int index); /** * Trim leading trailing blank lines in this sequence * * @return return sequence with trailing blank lines trimmed off */ - @NotNull T trimTailBlankLines(); - @NotNull T trimLeadBlankLines(); + T trimTailBlankLines(); + T trimLeadBlankLines(); /** * Get Range of leading blank lines at given index offsets in sequence @@ -802,7 +801,7 @@ default int eolLength(int eolStart) { * if the range in sequence contains only whitespace characters then the whole range will be returned * even if contains no EOL characters */ - @NotNull Range leadingBlankLinesRange(@NotNull CharPredicate eolChars, int fromIndex, int endIndex); + Range leadingBlankLinesRange(CharPredicate eolChars, int fromIndex, int endIndex); /** * Get Range of trailing blank lines at given index offsets in sequence @@ -818,19 +817,19 @@ default int eolLength(int eolStart) { * if the range in sequence contains only whitespace characters then the whole range will be returned * even if contains no EOL characters */ - @NotNull Range trailingBlankLinesRange(CharPredicate eolChars, int startIndex, int fromIndex); + Range trailingBlankLinesRange(CharPredicate eolChars, int startIndex, int fromIndex); - @NotNull Range leadingBlankLinesRange(); - @NotNull Range leadingBlankLinesRange(int startIndex); - @NotNull Range leadingBlankLinesRange(int fromIndex, int endIndex); - @NotNull Range trailingBlankLinesRange(); - @NotNull Range trailingBlankLinesRange(int fromIndex); - @NotNull Range trailingBlankLinesRange(int startIndex, int fromIndex); + Range leadingBlankLinesRange(); + Range leadingBlankLinesRange(int startIndex); + Range leadingBlankLinesRange(int fromIndex, int endIndex); + Range trailingBlankLinesRange(); + Range trailingBlankLinesRange(int fromIndex); + Range trailingBlankLinesRange(int startIndex, int fromIndex); - @NotNull List blankLinesRemovedRanges(); - @NotNull List blankLinesRemovedRanges(int fromIndex); - @NotNull List blankLinesRemovedRanges(int fromIndex, int endIndex); - @NotNull List blankLinesRemovedRanges(@NotNull CharPredicate eolChars, int fromIndex, int endIndex); + List blankLinesRemovedRanges(); + List blankLinesRemovedRanges(int fromIndex); + List blankLinesRemovedRanges(int fromIndex, int endIndex); + List blankLinesRemovedRanges(CharPredicate eolChars, int fromIndex, int endIndex); /** * Trim end to end of line containing index @@ -842,11 +841,11 @@ default int eolLength(int eolStart) { * if greater than length() it is the same as length() * @return trimmed version of the sequence to given EOL or the original sequence */ - @NotNull T trimToEndOfLine(@NotNull CharPredicate eolChars, boolean includeEol, int index); - @NotNull T trimToEndOfLine(boolean includeEol, int index); - @NotNull T trimToEndOfLine(boolean includeEol); - @NotNull T trimToEndOfLine(int index); - @NotNull T trimToEndOfLine(); + T trimToEndOfLine(CharPredicate eolChars, boolean includeEol, int index); + T trimToEndOfLine(boolean includeEol, int index); + T trimToEndOfLine(boolean includeEol); + T trimToEndOfLine(int index); + T trimToEndOfLine(); /** * Trim start to start of line containing index @@ -858,25 +857,25 @@ default int eolLength(int eolStart) { * if greater than length() it is the same as length() * @return trimmed version of the sequence to given EOL or the original sequence */ - @NotNull T trimToStartOfLine(@NotNull CharPredicate eolChars, boolean includeEol, int index); - @NotNull T trimToStartOfLine(boolean includeEol, int index); - @NotNull T trimToStartOfLine(boolean includeEol); - @NotNull T trimToStartOfLine(int index); - @NotNull T trimToStartOfLine(); + T trimToStartOfLine(CharPredicate eolChars, boolean includeEol, int index); + T trimToStartOfLine(boolean includeEol, int index); + T trimToStartOfLine(boolean includeEol); + T trimToStartOfLine(int index); + T trimToStartOfLine(); /** * replace any \r\n and \r by \n * * @return string with only \n for line separators */ - @NotNull String normalizeEOL(); + String normalizeEOL(); /** * replace any \r\n and \r by \n, append terminating EOL if one is not present * * @return string with only \n for line separators and terminated by \n */ - @NotNull String normalizeEndWithEOL(); + String normalizeEndWithEOL(); /* * comparison helpers @@ -888,9 +887,9 @@ default int eolLength(int eolStart) { * @param chars characters to match against * @return true if match */ - boolean matches(@NotNull CharSequence chars); - boolean matchesIgnoreCase(@NotNull CharSequence chars); - boolean matches(@NotNull CharSequence chars, boolean ignoreCase); + boolean matches(CharSequence chars); + boolean matchesIgnoreCase(CharSequence chars); + boolean matches(CharSequence chars, boolean ignoreCase); /** * Test the sequence for a match to another CharSequence, ignoring case differences @@ -915,9 +914,9 @@ default int eolLength(int eolStart) { * @param chars characters to match against * @return true if characters at the start of this sequence match */ - boolean matchChars(@NotNull CharSequence chars); - boolean matchCharsIgnoreCase(@NotNull CharSequence chars); - boolean matchChars(@NotNull CharSequence chars, boolean ignoreCase); + boolean matchChars(CharSequence chars); + boolean matchCharsIgnoreCase(CharSequence chars); + boolean matchChars(CharSequence chars, boolean ignoreCase); /** * Test the sequence portion for a match to another CharSequence @@ -927,9 +926,9 @@ default int eolLength(int eolStart) { * @param ignoreCase if true match ignoring case differences * @return true if characters at the start index of this sequence match */ - boolean matchChars(@NotNull CharSequence chars, int startIndex, boolean ignoreCase); - boolean matchChars(@NotNull CharSequence chars, int startIndex); - boolean matchCharsIgnoreCase(@NotNull CharSequence chars, int startIndex); + boolean matchChars(CharSequence chars, int startIndex, boolean ignoreCase); + boolean matchChars(CharSequence chars, int startIndex); + boolean matchCharsIgnoreCase(CharSequence chars, int startIndex); /** * Test the sequence portion for a match to another CharSequence @@ -941,13 +940,13 @@ default int eolLength(int eolStart) { * @param ignoreCase if true match ignoring case differences * @return count of characters at the start index of this sequence matching corresponding characters in chars */ - int matchedCharCount(@NotNull CharSequence chars, int startIndex, int endIndex, boolean fullMatchOnly, boolean ignoreCase); - int matchedCharCount(@NotNull CharSequence chars, int startIndex, int endIndex, boolean ignoreCase); - int matchedCharCount(@NotNull CharSequence chars, int startIndex, boolean ignoreCase); - int matchedCharCount(@NotNull CharSequence chars, int startIndex, int endIndex); - int matchedCharCount(@NotNull CharSequence chars, int startIndex); - int matchedCharCountIgnoreCase(@NotNull CharSequence chars, int startIndex, int endIndex); - int matchedCharCountIgnoreCase(@NotNull CharSequence chars, int startIndex); + int matchedCharCount(CharSequence chars, int startIndex, int endIndex, boolean fullMatchOnly, boolean ignoreCase); + int matchedCharCount(CharSequence chars, int startIndex, int endIndex, boolean ignoreCase); + int matchedCharCount(CharSequence chars, int startIndex, boolean ignoreCase); + int matchedCharCount(CharSequence chars, int startIndex, int endIndex); + int matchedCharCount(CharSequence chars, int startIndex); + int matchedCharCountIgnoreCase(CharSequence chars, int startIndex, int endIndex); + int matchedCharCountIgnoreCase(CharSequence chars, int startIndex); /** * Test the sequence portion for a match to another CharSequence, reverse order @@ -957,9 +956,9 @@ default int eolLength(int eolStart) { * @param ignoreCase if true match ignoring case differences * @return true if characters at the start index of this sequence match */ - boolean matchCharsReversed(@NotNull CharSequence chars, int endIndex, boolean ignoreCase); - boolean matchCharsReversed(@NotNull CharSequence chars, int endIndex); - boolean matchCharsReversedIgnoreCase(@NotNull CharSequence chars, int endIndex); + boolean matchCharsReversed(CharSequence chars, int endIndex, boolean ignoreCase); + boolean matchCharsReversed(CharSequence chars, int endIndex); + boolean matchCharsReversedIgnoreCase(CharSequence chars, int endIndex); /** * Test the sequence portion for a match to another CharSequence, @@ -971,12 +970,12 @@ default int eolLength(int eolStart) { * @param ignoreCase if true match ignoring case differences * @return count of characters at the from index of this sequence matching corresponding characters in chars in reverse order */ - int matchedCharCountReversed(@NotNull CharSequence chars, int startIndex, int fromIndex, boolean ignoreCase); - int matchedCharCountReversed(@NotNull CharSequence chars, int startIndex, int fromIndex); - int matchedCharCountReversedIgnoreCase(@NotNull CharSequence chars, int startIndex, int fromIndex); - int matchedCharCountReversed(@NotNull CharSequence chars, int fromIndex, boolean ignoreCase); - int matchedCharCountReversed(@NotNull CharSequence chars, int fromIndex); - int matchedCharCountReversedIgnoreCase(@NotNull CharSequence chars, int fromIndex); + int matchedCharCountReversed(CharSequence chars, int startIndex, int fromIndex, boolean ignoreCase); + int matchedCharCountReversed(CharSequence chars, int startIndex, int fromIndex); + int matchedCharCountReversedIgnoreCase(CharSequence chars, int startIndex, int fromIndex); + int matchedCharCountReversed(CharSequence chars, int fromIndex, boolean ignoreCase); + int matchedCharCountReversed(CharSequence chars, int fromIndex); + int matchedCharCountReversedIgnoreCase(CharSequence chars, int fromIndex); /** * test if this sequence ends with given characters @@ -984,9 +983,9 @@ default int eolLength(int eolStart) { * @param suffix characters to test * @return true if ends with suffix */ - boolean endsWith(@NotNull CharSequence suffix); + boolean endsWith(CharSequence suffix); - boolean endsWith(@NotNull CharPredicate chars); + boolean endsWith(CharPredicate chars); boolean endsWithEOL(); // EOL "\n" boolean endsWithAnyEOL(); // EOL_CHARS "\r\n" boolean endsWithSpace(); // SPACE " " @@ -999,7 +998,7 @@ default int eolLength(int eolStart) { * @param suffix characters to test * @return true if ends with suffix */ - boolean endsWithIgnoreCase(@NotNull CharSequence suffix); + boolean endsWithIgnoreCase(CharSequence suffix); /** * test if this sequence ends with given characters @@ -1008,7 +1007,7 @@ default int eolLength(int eolStart) { * @param ignoreCase case ignored when true * @return true if ends with suffix */ - boolean endsWith(@NotNull CharSequence suffix, boolean ignoreCase); + boolean endsWith(CharSequence suffix, boolean ignoreCase); /** * test if this sequence starts with given characters @@ -1016,9 +1015,9 @@ default int eolLength(int eolStart) { * @param prefix characters to test * @return true if starts with prefix */ - boolean startsWith(@NotNull CharSequence prefix); + boolean startsWith(CharSequence prefix); - boolean startsWith(@NotNull CharPredicate chars); + boolean startsWith(CharPredicate chars); boolean startsWithEOL(); // EOL "\n" boolean startsWithAnyEOL(); // EOL_CHARS "\r\n" boolean startsWithSpace(); // SPACE " " @@ -1031,7 +1030,7 @@ default int eolLength(int eolStart) { * @param prefix characters to test * @return true if starts with prefix */ - boolean startsWithIgnoreCase(@NotNull CharSequence prefix); + boolean startsWithIgnoreCase(CharSequence prefix); /** * test if this sequence starts with given characters @@ -1040,7 +1039,7 @@ default int eolLength(int eolStart) { * @param ignoreCase case ignored when true * @return true if starts with prefix */ - boolean startsWith(@NotNull CharSequence prefix, boolean ignoreCase); + boolean startsWith(CharSequence prefix, boolean ignoreCase); /** * Remove suffix if present @@ -1048,7 +1047,7 @@ default int eolLength(int eolStart) { * @param suffix characters to remove * @return sequence with suffix removed, or same sequence if no suffix was present */ - @NotNull T removeSuffix(@NotNull CharSequence suffix); + T removeSuffix(CharSequence suffix); /** * Remove suffix if present, ignoring case differences @@ -1056,7 +1055,7 @@ default int eolLength(int eolStart) { * @param suffix characters to remove * @return sequence with suffix removed, or same sequence if no suffix was present */ - @NotNull T removeSuffixIgnoreCase(@NotNull CharSequence suffix); + T removeSuffixIgnoreCase(CharSequence suffix); /** * Remove suffix if present @@ -1065,7 +1064,7 @@ default int eolLength(int eolStart) { * @param ignoreCase case ignored when true * @return sequence with suffix removed, or same sequence if no suffix was present */ - @NotNull T removeSuffix(@NotNull CharSequence suffix, boolean ignoreCase); + T removeSuffix(CharSequence suffix, boolean ignoreCase); /** * Remove prefix if present @@ -1073,7 +1072,7 @@ default int eolLength(int eolStart) { * @param prefix characters to remove * @return sequence with prefix removed, or same sequence if no prefix was present */ - @NotNull T removePrefix(@NotNull CharSequence prefix); + T removePrefix(CharSequence prefix); /** * Remove prefix if present, ignoring case differences @@ -1081,7 +1080,7 @@ default int eolLength(int eolStart) { * @param prefix characters to remove * @return sequence with prefix removed, or same sequence if no prefix was present */ - @NotNull T removePrefixIgnoreCase(@NotNull CharSequence prefix); + T removePrefixIgnoreCase(CharSequence prefix); /** * Remove prefix if present @@ -1090,7 +1089,7 @@ default int eolLength(int eolStart) { * @param ignoreCase case ignored when true * @return sequence with prefix removed, or same sequence if no prefix was present */ - @NotNull T removePrefix(@NotNull CharSequence prefix, boolean ignoreCase); + T removePrefix(CharSequence prefix, boolean ignoreCase); /** * Remove suffix if present but only if this sequence is longer than the suffix @@ -1098,7 +1097,7 @@ default int eolLength(int eolStart) { * @param suffix characters to remove * @return sequence with suffix removed, or same sequence if no suffix was present */ - @NotNull T removeProperSuffix(@NotNull CharSequence suffix); + T removeProperSuffix(CharSequence suffix); /** * Remove suffix if present but only if this sequence is longer than the suffix, ignoring case differences @@ -1106,7 +1105,7 @@ default int eolLength(int eolStart) { * @param suffix characters to remove * @return sequence with suffix removed, or same sequence if no suffix was present */ - @NotNull T removeProperSuffixIgnoreCase(@NotNull CharSequence suffix); + T removeProperSuffixIgnoreCase(CharSequence suffix); /** * Remove suffix if present but only if this sequence is longer than the suffix @@ -1115,7 +1114,7 @@ default int eolLength(int eolStart) { * @param ignoreCase case ignored when true * @return sequence with suffix removed, or same sequence if no suffix was present */ - @NotNull T removeProperSuffix(@NotNull CharSequence suffix, boolean ignoreCase); + T removeProperSuffix(CharSequence suffix, boolean ignoreCase); /** * Remove prefix if present but only if this sequence is longer than the suffix @@ -1123,7 +1122,7 @@ default int eolLength(int eolStart) { * @param prefix characters to remove * @return sequence with prefix removed, or same sequence if no prefix was present */ - @NotNull T removeProperPrefix(@NotNull CharSequence prefix); + T removeProperPrefix(CharSequence prefix); /** * Remove prefix if present but only if this sequence is longer than the suffix, ignoring case differences @@ -1131,7 +1130,7 @@ default int eolLength(int eolStart) { * @param prefix characters to remove * @return sequence with prefix removed, or same sequence if no prefix was present */ - @NotNull T removeProperPrefixIgnoreCase(@NotNull CharSequence prefix); + T removeProperPrefixIgnoreCase(CharSequence prefix); /** * Remove prefix if present but only if this sequence is longer than the suffix @@ -1140,7 +1139,7 @@ default int eolLength(int eolStart) { * @param ignoreCase case ignored when true * @return sequence with prefix removed, or same sequence if no prefix was present */ - @NotNull T removeProperPrefix(@NotNull CharSequence prefix, boolean ignoreCase); + T removeProperPrefix(CharSequence prefix, boolean ignoreCase); /** * Insert char sequence at given index @@ -1151,7 +1150,7 @@ default int eolLength(int eolStart) { * based sequence implementation may throw an IllegalArgumentException * if inserting another based sequence out of order based on offsets */ - @NotNull T insert(int index, @NotNull CharSequence chars); + T insert(int index, CharSequence chars); /** * @param chars chars @@ -1159,9 +1158,8 @@ default int eolLength(int eolStart) { * @return resulting sequence * @deprecated use {@link #insert(int, CharSequence)} instead */ - @NotNull @Deprecated - default T insert(@NotNull CharSequence chars, int index) { + default T insert(CharSequence chars, int index) { return insert(index, chars); } @@ -1172,7 +1170,7 @@ default T insert(@NotNull CharSequence chars, int index) { * @param endIndex end index, not inclusive, of insertion * @return resulting sequence */ - @NotNull T delete(int startIndex, int endIndex); + T delete(int startIndex, int endIndex); /** * Replace part of the sequence with a char sequence @@ -1182,7 +1180,7 @@ default T insert(@NotNull CharSequence chars, int index) { * @param replacement char sequence * @return resulting sequence */ - @NotNull T replace(int startIndex, int endIndex, @NotNull CharSequence replacement); + T replace(int startIndex, int endIndex, CharSequence replacement); /** * Replace all occurrences of one sequence with another @@ -1191,32 +1189,32 @@ default T insert(@NotNull CharSequence chars, int index) { * @param replace replacement sequence * @return array of indices */ - @NotNull T replace(@NotNull CharSequence find, @NotNull CharSequence replace); + T replace(CharSequence find, CharSequence replace); /** * Map characters of this sequence to: Uppercase, Lowercase or use custom mapping * * @return lowercase version of sequence */ - @NotNull T toLowerCase(); - @NotNull T toUpperCase(); - @NotNull T toMapped(CharMapper mapper); + T toLowerCase(); + T toUpperCase(); + T toMapped(CharMapper mapper); /** * Map spaces to non break spaces * * @return mapped sequence with spc changed to NbSp */ - @NotNull T toNbSp(); + T toNbSp(); /** * Map non break spaces to spaces * * @return mapped sequence with NbSp changed to spc */ - @NotNull T toSpc(); + T toSpc(); - @NotNull String toVisibleWhitespaceString(); + String toVisibleWhitespaceString(); /** * Split helpers based on delimiter character sets contained in CharSequence @@ -1232,17 +1230,17 @@ default T insert(@NotNull CharSequence chars, int index) { * @param trimChars set of characters that should be used for trimming individual split results * @return List of split results */ - @NotNull List splitList(@NotNull CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars); - @NotNull List splitList(@NotNull CharSequence delimiter, int limit, int flags); - @NotNull List splitList(@NotNull CharSequence delimiter); - @NotNull T[] split(@NotNull CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars); - @NotNull T[] split(@NotNull CharSequence delimiter, int limit, int flags); - @NotNull T[] split(@NotNull CharSequence delimiter); + List splitList(CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars); + List splitList(CharSequence delimiter, int limit, int flags); + List splitList(CharSequence delimiter); + T[] split(CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars); + T[] split(CharSequence delimiter, int limit, int flags); + T[] split(CharSequence delimiter); // @formatter:off - @Deprecated default @NotNull T[] split(char delimiter, int limit, int flags) { return split(Character.toString(delimiter), limit, flags, null);} - @Deprecated default @NotNull T[] split(char delimiter, int limit) { return split(Character.toString(delimiter), limit, 0, null);} - @Deprecated default @NotNull T[] split(char delimiter) { return split(Character.toString(delimiter), 0, 0, null);} + @Deprecated default T[] split(char delimiter, int limit, int flags) { return split(Character.toString(delimiter), limit, flags, null);} + @Deprecated default T[] split(char delimiter, int limit) { return split(Character.toString(delimiter), limit, 0, null);} + @Deprecated default T[] split(char delimiter) { return split(Character.toString(delimiter), 0, 0, null);} // @formatter:on /** @@ -1254,17 +1252,17 @@ default T insert(@NotNull CharSequence chars, int index) { * @param trimChars set of characters that should be used for trimming individual split results * @return List of split results */ - @NotNull List splitList(@NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars); - @NotNull List splitList(@NotNull CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars); - @NotNull T[] split(@NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars); - @NotNull T[] split(@NotNull CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars); + List splitList(CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars); + List splitList(CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars); + T[] split(CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars); + T[] split(CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars); // NOTE: these default to including delimiters as part of split item - @NotNull T[] splitEOL(); - @NotNull T[] splitEOL(boolean includeDelims); - @NotNull List splitListEOL(); - @NotNull List splitListEOL(boolean includeDelims); - @NotNull List splitListEOL(boolean includeDelims, @Nullable CharPredicate trimChars); + T[] splitEOL(); + T[] splitEOL(boolean includeDelims); + List splitListEOL(); + List splitListEOL(boolean includeDelims); + List splitListEOL(boolean includeDelims, @Nullable CharPredicate trimChars); /** * Get indices of all occurrences of a sequence @@ -1272,7 +1270,7 @@ default T insert(@NotNull CharSequence chars, int index) { * @param s sequence whose indices to find * @return array of indices */ - @NotNull int[] indexOfAll(@NotNull CharSequence s); + int[] indexOfAll(CharSequence s); /** * Prefix this sequence with a char sequence @@ -1280,14 +1278,14 @@ default T insert(@NotNull CharSequence chars, int index) { * @param prefix char sequence * @return resulting sequence */ - @NotNull T prefixWith(@Nullable CharSequence prefix); + T prefixWith(@Nullable CharSequence prefix); /** * Prefix this sequence with a char sequence * * @param suffix char sequence * @return resulting sequence */ - @NotNull T suffixWith(@Nullable CharSequence suffix); + T suffixWith(@Nullable CharSequence suffix); /** * Prefix this sequence with a char sequence if not already starting with prefix @@ -1295,29 +1293,29 @@ default T insert(@NotNull CharSequence chars, int index) { * @param prefix char sequence * @return resulting sequence */ - @NotNull T prefixOnceWith(@Nullable CharSequence prefix); + T prefixOnceWith(@Nullable CharSequence prefix); /** * Suffix this sequence with a char sequence if not already ending with suffix * * @param suffix char sequence * @return resulting sequence */ - @NotNull T suffixOnceWith(@Nullable CharSequence suffix); + T suffixOnceWith(@Nullable CharSequence suffix); - @NotNull T appendEOL(); - @NotNull T suffixWithEOL(); - @NotNull T prefixWithEOL(); - @NotNull T prefixOnceWithEOL(); - @NotNull T suffixOnceWithEOL(); + T appendEOL(); + T suffixWithEOL(); + T prefixWithEOL(); + T prefixOnceWithEOL(); + T suffixOnceWithEOL(); - @NotNull T appendSpace(); - @NotNull T suffixWithSpace(); - @NotNull T prefixWithSpace(); - @NotNull T appendSpaces(int count); - @NotNull T suffixWithSpaces(int count); - @NotNull T prefixWithSpaces(int count); - @NotNull T prefixOnceWithSpace(); - @NotNull T suffixOnceWithSpace(); + T appendSpace(); + T suffixWithSpace(); + T prefixWithSpace(); + T appendSpaces(int count); + T suffixWithSpaces(int count); + T prefixWithSpaces(int count); + T prefixOnceWithSpace(); + T suffixOnceWithSpace(); /** * Append helpers * @@ -1327,12 +1325,12 @@ default T insert(@NotNull CharSequence chars, int index) { * @param charMapper mapping to use for output or null if none * @return this */ - @NotNull T appendTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper, int startIndex, int endIndex); - @NotNull T appendTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper); - @NotNull T appendTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper, int startIndex); - @NotNull T appendTo(@NotNull StringBuilder out, int startIndex, int endIndex); - @NotNull T appendTo(@NotNull StringBuilder out); - @NotNull T appendTo(@NotNull StringBuilder out, int startIndex); + T appendTo(StringBuilder out, @Nullable CharMapper charMapper, int startIndex, int endIndex); + T appendTo(StringBuilder out, @Nullable CharMapper charMapper); + T appendTo(StringBuilder out, @Nullable CharMapper charMapper, int startIndex); + T appendTo(StringBuilder out, int startIndex, int endIndex); + T appendTo(StringBuilder out); + T appendTo(StringBuilder out, int startIndex); /** * Append given ranges of this sequence to string builder @@ -1342,10 +1340,10 @@ default T insert(@NotNull CharSequence chars, int index) { * @param ranges ranges to append, null range or one for which range.isNull() is true ranges are skipped * @return this */ - @NotNull T appendRangesTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper, Range... ranges); - @NotNull T appendRangesTo(@NotNull StringBuilder out, Range... ranges); - @NotNull T appendRangesTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper, Iterable ranges); - @NotNull T appendRangesTo(@NotNull StringBuilder out, Iterable ranges); + T appendRangesTo(StringBuilder out, @Nullable CharMapper charMapper, Range... ranges); + T appendRangesTo(StringBuilder out, Range... ranges); + T appendRangesTo(StringBuilder out, @Nullable CharMapper charMapper, Iterable ranges); + T appendRangesTo(StringBuilder out, Iterable ranges); /** * Build a sequence of ranges in this sequence @@ -1356,8 +1354,8 @@ default T insert(@NotNull CharSequence chars, int index) { * @param ranges ranges to extract * @return resulting sequence */ - @NotNull T extractRanges(Range... ranges); - @NotNull T extractRanges(Iterable ranges); + T extractRanges(Range... ranges); + T extractRanges(Iterable ranges); /** * Concatenate this sequence and list of others, returning sequence of result @@ -1365,8 +1363,8 @@ default T insert(@NotNull CharSequence chars, int index) { * @param sequences list of char sequences to append to this sequence, null sequences are skipped * @return appended sequence */ - @NotNull T append(CharSequence... sequences); - @NotNull T append(Iterable sequences); + T append(CharSequence... sequences); + T append(Iterable sequences); /** * Get the line and column information from index into sequence @@ -1375,9 +1373,9 @@ default T insert(@NotNull CharSequence chars, int index) { * @return Pair(line, column) where line and column are 0 based, * throws IllegalArgumentException if index < 0 or > length. */ - @NotNull Pair lineColumnAtIndex(int index); + Pair lineColumnAtIndex(int index); @Deprecated - default @NotNull Pair getLineColumnAtIndex(int index) { + default Pair getLineColumnAtIndex(int index) { return lineColumnAtIndex(index); } @@ -1395,7 +1393,7 @@ default int getColumnAtIndex(int index) { * @param predicate character set predicate * @return true if character at index tests true */ - boolean isCharAt(int index, @NotNull CharPredicate predicate); + boolean isCharAt(int index, CharPredicate predicate); /** * Return string or null if BaseSequence.NULL @@ -1405,6 +1403,6 @@ default int getColumnAtIndex(int index) { @Nullable String toStringOrNull(); - boolean isIn(@NotNull String[] texts); - boolean isIn(@NotNull Collection texts); + boolean isIn(String[] texts); + boolean isIn(Collection texts); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/IRichSequenceBase.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/IRichSequenceBase.java index 9e30ec812..a4cc5d61e 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/IRichSequenceBase.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/IRichSequenceBase.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.sequence.mappers.CharMapper; import com.vladsch.flexmark.util.sequence.mappers.SpaceMapper; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Collection; import java.util.List; @@ -87,23 +86,20 @@ final public boolean equals(@Nullable Object other, boolean ignoreCase) { } @Override - public int compareTo(@NotNull CharSequence o) { + public int compareTo(CharSequence o) { return SequenceUtils.compare(this, o); } - @NotNull @Override final public T sequenceOf(@Nullable CharSequence charSequence) { return charSequence == null ? nullSequence() : sequenceOf(charSequence, 0, charSequence.length()); } - @NotNull @Override final public T sequenceOf(@Nullable CharSequence charSequence, int startIndex) { return charSequence == null ? nullSequence() : sequenceOf(charSequence, startIndex, charSequence.length()); } - @NotNull @Override final public T subSequence(int startIndex) { return subSequence(startIndex, length()); @@ -115,8 +111,7 @@ final public T subSequence(int startIndex) { * @param range range to get, coordinates offset form start of this sequence * @return sequence whose contents reflect the selected portion, if range.isNull() then this is returned */ - @NotNull - final public T subSequence(@NotNull Range range) { + final public T subSequence(Range range) { return range.isNull() ? (T) this : subSequence(range.getStart(), range.getEnd()); } @@ -126,8 +121,7 @@ final public T subSequence(@NotNull Range range) { * @param range range to get, coordinates offset form start of this sequence * @return sequence whose contents come before the selected range, if range.isNull() then {@link #nullSequence()} */ - @NotNull - final public T subSequenceBefore(@NotNull Range range) { + final public T subSequenceBefore(Range range) { return range.isNull() ? nullSequence() : subSequence(0, range.getStart()); } @@ -137,8 +131,7 @@ final public T subSequenceBefore(@NotNull Range range) { * @param range range to get, coordinates offset form start of this sequence * @return sequence whose contents come after the selected range, if range.isNull() then {@link #nullSequence()} */ - @NotNull - final public T subSequenceAfter(@NotNull Range range) { + final public T subSequenceAfter(Range range) { return range.isNull() ? nullSequence() : subSequence(range.getEnd()); } @@ -152,7 +145,6 @@ final public Pair subSequenceBeforeAfter(Range range) { return Pair.of(subSequenceBefore(range), subSequenceAfter(range)); } - @NotNull @Override final public T endSequence(int startIndex, int endIndex) { int length = length(); @@ -164,7 +156,6 @@ final public T endSequence(int startIndex, int endIndex) { return subSequence(useStart, useEnd); } - @NotNull @Override final public T endSequence(int startIndex) { return endSequence(startIndex, 0); @@ -177,7 +168,6 @@ final public char endCharAt(int index) { return charAt(length - index); } - @NotNull @Override final public T midSequence(int startIndex, int endIndex) { int length = length(); @@ -189,7 +179,6 @@ final public T midSequence(int startIndex, int endIndex) { return subSequence(useStart, useEnd); } - @NotNull @Override final public T midSequence(int startIndex) { return midSequence(startIndex, length()); @@ -229,7 +218,6 @@ public char safeCharAt(int index) { return index < 0 || index >= length() ? SequenceUtils.NUL : charAt(index); } - @NotNull @Override public T safeSubSequence(int startIndex, int endIndex) { int length = length(); @@ -238,7 +226,6 @@ public T safeSubSequence(int startIndex, int endIndex) { return subSequence(startIndex, endIndex); } - @NotNull @Override public T safeSubSequence(int startIndex) { int length = length(); @@ -247,7 +234,7 @@ public T safeSubSequence(int startIndex) { } @Override - public boolean isCharAt(int index, @NotNull CharPredicate predicate) { + public boolean isCharAt(int index, CharPredicate predicate) { return predicate.test(safeCharAt(index)); } @@ -257,36 +244,36 @@ public boolean isCharAt(int index, @NotNull CharPredicate predicate) { } // @formatter:off - @Override final public int indexOf(@NotNull CharSequence s) { return SequenceUtils.indexOf(this, s); } - @Override final public int indexOf(@NotNull CharSequence s, int fromIndex) { return SequenceUtils.indexOf(this, s, fromIndex); } - @Override final public int indexOf(@NotNull CharSequence s, int fromIndex, int endIndex) { return SequenceUtils.indexOf(this, s, fromIndex, endIndex);} + @Override final public int indexOf(CharSequence s) { return SequenceUtils.indexOf(this, s); } + @Override final public int indexOf(CharSequence s, int fromIndex) { return SequenceUtils.indexOf(this, s, fromIndex); } + @Override final public int indexOf(CharSequence s, int fromIndex, int endIndex) { return SequenceUtils.indexOf(this, s, fromIndex, endIndex);} @Override final public int indexOf(char c) { return SequenceUtils.indexOf(this, c); } @Override final public int indexOf(char c, int fromIndex) { return SequenceUtils.indexOf(this, c, fromIndex); } - @Override final public int indexOfAny(@NotNull CharPredicate s) { return SequenceUtils.indexOfAny(this, s); } - @Override final public int indexOfAny(@NotNull CharPredicate s, int index) { return SequenceUtils.indexOfAny(this, s, index); } - @Override final public int indexOfAnyNot(@NotNull CharPredicate s) { return SequenceUtils.indexOfAnyNot(this, s); } - @Override final public int indexOfAnyNot(@NotNull CharPredicate s, int fromIndex) { return SequenceUtils.indexOfAnyNot(this, s, fromIndex); } - @Override final public int indexOfAnyNot(@NotNull CharPredicate s, int fromIndex, int endIndex) { return SequenceUtils.indexOfAnyNot(this, s,fromIndex, endIndex);} + @Override final public int indexOfAny(CharPredicate s) { return SequenceUtils.indexOfAny(this, s); } + @Override final public int indexOfAny(CharPredicate s, int index) { return SequenceUtils.indexOfAny(this, s, index); } + @Override final public int indexOfAnyNot(CharPredicate s) { return SequenceUtils.indexOfAnyNot(this, s); } + @Override final public int indexOfAnyNot(CharPredicate s, int fromIndex) { return SequenceUtils.indexOfAnyNot(this, s, fromIndex); } + @Override final public int indexOfAnyNot(CharPredicate s, int fromIndex, int endIndex) { return SequenceUtils.indexOfAnyNot(this, s,fromIndex, endIndex);} @Override final public int indexOfNot(char c) { return SequenceUtils.indexOfNot(this, c); } @Override final public int indexOfNot(char c, int fromIndex) { return SequenceUtils.indexOfNot(this, c, fromIndex); } @Override final public int lastIndexOf(char c) { return SequenceUtils.lastIndexOf(this, c); } @Override final public int lastIndexOf(char c, int fromIndex) { return SequenceUtils.lastIndexOf(this, c, fromIndex); } @Override final public int lastIndexOfNot(char c) { return SequenceUtils.lastIndexOfNot(this, c); } @Override final public int lastIndexOfNot(char c, int fromIndex) { return SequenceUtils.lastIndexOfNot(this, c, fromIndex); } - @Override final public int lastIndexOf(@NotNull CharSequence s) { return SequenceUtils.lastIndexOf(this, s); } - @Override final public int lastIndexOf(@NotNull CharSequence s, int fromIndex) { return SequenceUtils.lastIndexOf(this, s, fromIndex); } - @Override final public int lastIndexOfAny(@NotNull CharPredicate s, int fromIndex) { return SequenceUtils.lastIndexOfAny(this, s, fromIndex); } - @Override final public int lastIndexOfAny(@NotNull CharPredicate s) { return SequenceUtils.lastIndexOfAny(this, s); } - @Override final public int lastIndexOfAnyNot(@NotNull CharPredicate s) { return SequenceUtils.lastIndexOfAnyNot(this, s); } - @Override final public int lastIndexOfAnyNot(@NotNull CharPredicate s, int fromIndex) { return SequenceUtils.lastIndexOfAnyNot(this, s, fromIndex); } - @Override final public int lastIndexOfAnyNot(@NotNull CharPredicate s, int startIndex, int fromIndex) { return SequenceUtils.lastIndexOfAnyNot(this, s, startIndex, fromIndex); } + @Override final public int lastIndexOf(CharSequence s) { return SequenceUtils.lastIndexOf(this, s); } + @Override final public int lastIndexOf(CharSequence s, int fromIndex) { return SequenceUtils.lastIndexOf(this, s, fromIndex); } + @Override final public int lastIndexOfAny(CharPredicate s, int fromIndex) { return SequenceUtils.lastIndexOfAny(this, s, fromIndex); } + @Override final public int lastIndexOfAny(CharPredicate s) { return SequenceUtils.lastIndexOfAny(this, s); } + @Override final public int lastIndexOfAnyNot(CharPredicate s) { return SequenceUtils.lastIndexOfAnyNot(this, s); } + @Override final public int lastIndexOfAnyNot(CharPredicate s, int fromIndex) { return SequenceUtils.lastIndexOfAnyNot(this, s, fromIndex); } + @Override final public int lastIndexOfAnyNot(CharPredicate s, int startIndex, int fromIndex) { return SequenceUtils.lastIndexOfAnyNot(this, s, startIndex, fromIndex); } @Override final public int indexOf(char c, int fromIndex, int endIndex) { return SequenceUtils.indexOf(this, c, fromIndex, endIndex); } @Override final public int indexOfNot(char c, int fromIndex, int endIndex) { return SequenceUtils.indexOfNot(this, c, fromIndex, endIndex); } - @Override final public int indexOfAny(@NotNull CharPredicate s, int fromIndex, int endIndex) { return SequenceUtils.indexOfAny(this, s, fromIndex, endIndex); } - @Override final public int lastIndexOf(@NotNull CharSequence s, int startIndex, int fromIndex) { return SequenceUtils.lastIndexOf(this, s, startIndex, fromIndex); } + @Override final public int indexOfAny(CharPredicate s, int fromIndex, int endIndex) { return SequenceUtils.indexOfAny(this, s, fromIndex, endIndex); } + @Override final public int lastIndexOf(CharSequence s, int startIndex, int fromIndex) { return SequenceUtils.lastIndexOf(this, s, startIndex, fromIndex); } @Override final public int lastIndexOf(char c, int startIndex, int fromIndex) { return SequenceUtils.lastIndexOf(this, c, startIndex, fromIndex); } @Override final public int lastIndexOfNot(char c, int startIndex, int fromIndex) { return SequenceUtils.lastIndexOfNot(this, c, startIndex, fromIndex); } - @Override final public int lastIndexOfAny(@NotNull CharPredicate s, int startIndex, int fromIndex) { return SequenceUtils.lastIndexOfAny(this, s, startIndex, fromIndex); } + @Override final public int lastIndexOfAny(CharPredicate s, int startIndex, int fromIndex) { return SequenceUtils.lastIndexOfAny(this, s, startIndex, fromIndex); } // @formatter:on // @formatter:off @@ -295,31 +282,31 @@ public boolean isCharAt(int index, @NotNull CharPredicate predicate) { @Override final public int countOfWhitespace() { return SequenceUtils.countOfWhitespace(this); } @Override final public int countOfNotWhitespace() { return SequenceUtils.countOfNotWhitespace(this); } - @Override final public int countOfAny(@NotNull CharPredicate chars, int fromIndex) { return SequenceUtils.countOfAny(this, chars, fromIndex); } - @Override final public int countOfAny(@NotNull CharPredicate chars) { return SequenceUtils.countOfAny(this, chars); } - @Override final public int countOfAnyNot(@NotNull CharPredicate chars, int fromIndex) { return SequenceUtils.countOfAnyNot(this, chars, fromIndex); } - @Override final public int countOfAnyNot(@NotNull CharPredicate chars) { return SequenceUtils.countOfAnyNot(this, chars); } - @Override final public int countOfAny(@NotNull CharPredicate s, int fromIndex, int endIndex) { return SequenceUtils.countOfAny(this, s, fromIndex, endIndex);} - @Override final public int countOfAnyNot(@NotNull CharPredicate chars, int startIndex, int endIndex) { return SequenceUtils.countOfAnyNot(this, chars, startIndex, endIndex); } + @Override final public int countOfAny(CharPredicate chars, int fromIndex) { return SequenceUtils.countOfAny(this, chars, fromIndex); } + @Override final public int countOfAny(CharPredicate chars) { return SequenceUtils.countOfAny(this, chars); } + @Override final public int countOfAnyNot(CharPredicate chars, int fromIndex) { return SequenceUtils.countOfAnyNot(this, chars, fromIndex); } + @Override final public int countOfAnyNot(CharPredicate chars) { return SequenceUtils.countOfAnyNot(this, chars); } + @Override final public int countOfAny(CharPredicate s, int fromIndex, int endIndex) { return SequenceUtils.countOfAny(this, s, fromIndex, endIndex);} + @Override final public int countOfAnyNot(CharPredicate chars, int startIndex, int endIndex) { return SequenceUtils.countOfAnyNot(this, chars, startIndex, endIndex); } // @formatter:on // @formatter:off - @Override final public int countLeading(@NotNull CharPredicate chars) { return SequenceUtils.countLeading(this, chars); } - @Override final public int countLeading(@NotNull CharPredicate chars, int fromIndex) { return SequenceUtils.countLeading(this, chars, fromIndex); } - @Override final public int countLeadingNot(@NotNull CharPredicate chars) { return SequenceUtils.countLeadingNot(this, chars); } - @Override final public int countLeadingNot(@NotNull CharPredicate chars, int fromIndex) { return SequenceUtils.countLeadingNot(this, chars, fromIndex); } + @Override final public int countLeading(CharPredicate chars) { return SequenceUtils.countLeading(this, chars); } + @Override final public int countLeading(CharPredicate chars, int fromIndex) { return SequenceUtils.countLeading(this, chars, fromIndex); } + @Override final public int countLeadingNot(CharPredicate chars) { return SequenceUtils.countLeadingNot(this, chars); } + @Override final public int countLeadingNot(CharPredicate chars, int fromIndex) { return SequenceUtils.countLeadingNot(this, chars, fromIndex); } - @Override final public int countTrailing(@NotNull CharPredicate chars) { return SequenceUtils.countTrailing(this, chars); } - @Override final public int countTrailing(@NotNull CharPredicate chars, int fromIndex) { return SequenceUtils.countTrailing(this, chars, fromIndex); } - @Override final public int countTrailingNot(@NotNull CharPredicate chars) { return SequenceUtils.countTrailingNot(this, chars); } - @Override final public int countTrailingNot(@NotNull CharPredicate chars, int fromIndex) { return SequenceUtils.countTrailingNot(this, chars, fromIndex); } + @Override final public int countTrailing(CharPredicate chars) { return SequenceUtils.countTrailing(this, chars); } + @Override final public int countTrailing(CharPredicate chars, int fromIndex) { return SequenceUtils.countTrailing(this, chars, fromIndex); } + @Override final public int countTrailingNot(CharPredicate chars) { return SequenceUtils.countTrailingNot(this, chars); } + @Override final public int countTrailingNot(CharPredicate chars, int fromIndex) { return SequenceUtils.countTrailingNot(this, chars, fromIndex); } - @Override final public int countLeadingNot(@NotNull CharPredicate chars, int startIndex, int endIndex) { return SequenceUtils.countLeadingNot(this, chars, startIndex, endIndex); } - @Override final public int countTrailingNot(@NotNull CharPredicate chars, int startIndex, int endIndex) { return SequenceUtils.countTrailingNot(this, chars, startIndex, endIndex); } - @Override final public int countLeading(@NotNull CharPredicate chars, int fromIndex, int endIndex) { return SequenceUtils.countLeading(this, chars, fromIndex, endIndex);} + @Override final public int countLeadingNot(CharPredicate chars, int startIndex, int endIndex) { return SequenceUtils.countLeadingNot(this, chars, startIndex, endIndex); } + @Override final public int countTrailingNot(CharPredicate chars, int startIndex, int endIndex) { return SequenceUtils.countTrailingNot(this, chars, startIndex, endIndex); } + @Override final public int countLeading(CharPredicate chars, int fromIndex, int endIndex) { return SequenceUtils.countLeading(this, chars, fromIndex, endIndex);} - @Override final public int countLeadingColumns(int startColumn, @NotNull CharPredicate chars) { return SequenceUtils.countLeadingColumns(this, startColumn, chars); } - @Override final public int countTrailing(@NotNull CharPredicate chars, int startIndex, int fromIndex) { return SequenceUtils.countTrailing(this, chars, startIndex, fromIndex); } + @Override final public int countLeadingColumns(int startColumn, CharPredicate chars) { return SequenceUtils.countLeadingColumns(this, startColumn, chars); } + @Override final public int countTrailing(CharPredicate chars, int startIndex, int fromIndex) { return SequenceUtils.countTrailing(this, chars, startIndex, fromIndex); } @Override final public int countLeadingSpace() { return SequenceUtils.countLeadingSpace(this); } @Override final public int countLeadingNotSpace() { return SequenceUtils.countLeadingNotSpace(this); } @@ -366,80 +353,74 @@ public boolean isCharAt(int index, @NotNull CharPredicate predicate) { // @formatter:on // @formatter:off - @NotNull @Override final public T trimStart(@NotNull CharPredicate chars) { return subSequence(trimStartRange(0, chars)); } - @NotNull @Override final public T trimmedStart(@NotNull CharPredicate chars) { return trimmedStart(0, chars); } - @NotNull @Override final public T trimEnd(@NotNull CharPredicate chars) { return trimEnd(0, chars); } - @NotNull @Override final public T trimmedEnd(@NotNull CharPredicate chars) { return trimmedEnd(0, chars); } - @NotNull @Override final public T trim(@NotNull CharPredicate chars) { return trim(0, chars); } - @NotNull @Override final public Pair trimmed(@NotNull CharPredicate chars) { return trimmed(0, chars); } - @NotNull @Override final public T trimStart(int keep) { return trimStart(keep, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trimmedStart(int keep) { return trimmedStart(keep, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trimEnd(int keep) { return trimEnd(keep, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trimmedEnd(int keep) { return trimmedEnd(keep, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trim(int keep) { return trim(keep, CharPredicate.WHITESPACE); } - @NotNull @Override final public Pair trimmed(int keep) { return trimmed(keep, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trimStart() { return trimStart(0, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trimmedStart() { return trimmedStart(0, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trimEnd() { return trimEnd(0, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trimmedEnd() { return trimmedEnd(0, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trim() { return trim(0, CharPredicate.WHITESPACE); } - @NotNull @Override final public Pair trimmed() { return trimmed(0, CharPredicate.WHITESPACE); } - @NotNull @Override final public T trimStart(int keep, @NotNull CharPredicate chars) { return subSequence(trimStartRange(keep, chars)); } - @NotNull @Override final public T trimmedStart(int keep, @NotNull CharPredicate chars) { return subSequenceBefore(trimStartRange(keep, chars)); } - @NotNull @Override final public T trimEnd(int keep, @NotNull CharPredicate chars) { return subSequence(trimEndRange(keep, chars)); } - @NotNull @Override final public T trimmedEnd(int keep, @NotNull CharPredicate chars) { return subSequenceAfter(trimEndRange(keep, chars)); } - @NotNull @Override final public T trim(int keep, @NotNull CharPredicate chars) { return subSequence(trimRange(keep, chars)); } - @NotNull @Override final public Pair trimmed(int keep, @NotNull CharPredicate chars) { return subSequenceBeforeAfter(trimRange(keep, chars)); } + @Override final public T trimStart(CharPredicate chars) { return subSequence(trimStartRange(0, chars)); } + @Override final public T trimmedStart(CharPredicate chars) { return trimmedStart(0, chars); } + @Override final public T trimEnd(CharPredicate chars) { return trimEnd(0, chars); } + @Override final public T trimmedEnd(CharPredicate chars) { return trimmedEnd(0, chars); } + @Override final public T trim(CharPredicate chars) { return trim(0, chars); } + @Override final public Pair trimmed(CharPredicate chars) { return trimmed(0, chars); } + @Override final public T trimStart(int keep) { return trimStart(keep, CharPredicate.WHITESPACE); } + @Override final public T trimmedStart(int keep) { return trimmedStart(keep, CharPredicate.WHITESPACE); } + @Override final public T trimEnd(int keep) { return trimEnd(keep, CharPredicate.WHITESPACE); } + @Override final public T trimmedEnd(int keep) { return trimmedEnd(keep, CharPredicate.WHITESPACE); } + @Override final public T trim(int keep) { return trim(keep, CharPredicate.WHITESPACE); } + @Override final public Pair trimmed(int keep) { return trimmed(keep, CharPredicate.WHITESPACE); } + @Override final public T trimStart() { return trimStart(0, CharPredicate.WHITESPACE); } + @Override final public T trimmedStart() { return trimmedStart(0, CharPredicate.WHITESPACE); } + @Override final public T trimEnd() { return trimEnd(0, CharPredicate.WHITESPACE); } + @Override final public T trimmedEnd() { return trimmedEnd(0, CharPredicate.WHITESPACE); } + @Override final public T trim() { return trim(0, CharPredicate.WHITESPACE); } + @Override final public Pair trimmed() { return trimmed(0, CharPredicate.WHITESPACE); } + @Override final public T trimStart(int keep, CharPredicate chars) { return subSequence(trimStartRange(keep, chars)); } + @Override final public T trimmedStart(int keep, CharPredicate chars) { return subSequenceBefore(trimStartRange(keep, chars)); } + @Override final public T trimEnd(int keep, CharPredicate chars) { return subSequence(trimEndRange(keep, chars)); } + @Override final public T trimmedEnd(int keep, CharPredicate chars) { return subSequenceAfter(trimEndRange(keep, chars)); } + @Override final public T trim(int keep, CharPredicate chars) { return subSequence(trimRange(keep, chars)); } + @Override final public Pair trimmed(int keep, CharPredicate chars) { return subSequenceBeforeAfter(trimRange(keep, chars)); } // @formatter:on // @formatter:off - @NotNull @Override final public Range trimStartRange(int keep, @NotNull CharPredicate chars) { return SequenceUtils.trimStartRange(this, keep, chars); } - @NotNull @Override final public Range trimEndRange(int keep, @NotNull CharPredicate chars) { return SequenceUtils.trimEndRange(this, keep, chars); } - @NotNull @Override final public Range trimRange(int keep, @NotNull CharPredicate chars) { return SequenceUtils.trimRange(this, keep, chars); } - @NotNull @Override final public Range trimStartRange(@NotNull CharPredicate chars) { return SequenceUtils.trimStartRange(this, chars); } - @NotNull @Override final public Range trimEndRange(@NotNull CharPredicate chars) { return SequenceUtils.trimEndRange(this, chars); } - @NotNull @Override final public Range trimRange(@NotNull CharPredicate chars) { return SequenceUtils.trimRange(this, chars); } - @NotNull @Override final public Range trimStartRange(int keep) { return SequenceUtils.trimStartRange(this, keep); } - @NotNull @Override final public Range trimEndRange(int keep) { return SequenceUtils.trimEndRange(this, keep); } - @NotNull @Override final public Range trimRange(int keep) { return SequenceUtils.trimRange(this, keep); } - @NotNull @Override final public Range trimStartRange() { return SequenceUtils.trimStartRange(this); } - @NotNull @Override final public Range trimEndRange() { return SequenceUtils.trimEndRange(this); } - @NotNull @Override final public Range trimRange() { return SequenceUtils.trimRange(this); } + @Override final public Range trimStartRange(int keep, CharPredicate chars) { return SequenceUtils.trimStartRange(this, keep, chars); } + @Override final public Range trimEndRange(int keep, CharPredicate chars) { return SequenceUtils.trimEndRange(this, keep, chars); } + @Override final public Range trimRange(int keep, CharPredicate chars) { return SequenceUtils.trimRange(this, keep, chars); } + @Override final public Range trimStartRange(CharPredicate chars) { return SequenceUtils.trimStartRange(this, chars); } + @Override final public Range trimEndRange(CharPredicate chars) { return SequenceUtils.trimEndRange(this, chars); } + @Override final public Range trimRange(CharPredicate chars) { return SequenceUtils.trimRange(this, chars); } + @Override final public Range trimStartRange(int keep) { return SequenceUtils.trimStartRange(this, keep); } + @Override final public Range trimEndRange(int keep) { return SequenceUtils.trimEndRange(this, keep); } + @Override final public Range trimRange(int keep) { return SequenceUtils.trimRange(this, keep); } + @Override final public Range trimStartRange() { return SequenceUtils.trimStartRange(this); } + @Override final public Range trimEndRange() { return SequenceUtils.trimEndRange(this); } + @Override final public Range trimRange() { return SequenceUtils.trimRange(this); } // @formatter:on - @NotNull @Override final public T padding(int length, char pad) { return length <= length() ? nullSequence() : sequenceOf(RepeatedSequence.repeatOf(pad, length - length())); } - @NotNull @Override final public T padding(int length) { return padStart(length, ' '); } - @NotNull @Override public T padStart(int length, char pad) { T padding = padding(length, pad); return padding.isEmpty() ? (T) this : getBuilder().append(padding).append(this).toSequence(); } - @NotNull @Override public T padEnd(int length, char pad) { T padding = padding(length, pad); return padding.isEmpty() ? (T) this : getBuilder().append(this).append(padding).toSequence(); } - @NotNull @Override public T padStart(int length) { return padStart(length, ' '); } - @NotNull @Override public T padEnd(int length) { return padEnd(length, ' '); @@ -459,46 +440,42 @@ public T padEnd(int length) { @Override final public int startOfLine(int index) { return SequenceUtils.startOfLine(this, index); } @Override final public int startOfLineAnyEOL(int index) { return SequenceUtils.startOfLineAnyEOL(this, index); } - @Override final public int startOfDelimitedByAnyNot(@NotNull CharPredicate s, int index) { return startOfDelimitedByAny(s.negate(),index); } - @Override final public int endOfDelimitedByAnyNot(@NotNull CharPredicate s, int index) { return endOfDelimitedByAny(s.negate(),index); } + @Override final public int startOfDelimitedByAnyNot(CharPredicate s, int index) { return startOfDelimitedByAny(s.negate(),index); } + @Override final public int endOfDelimitedByAnyNot(CharPredicate s, int index) { return endOfDelimitedByAny(s.negate(),index); } - @Override final public int startOfDelimitedBy(@NotNull CharSequence s, int index) { return SequenceUtils.startOfDelimitedBy(this, s, index); } - @Override final public int startOfDelimitedByAny(@NotNull CharPredicate s, int index) { return SequenceUtils.startOfDelimitedByAny(this, s, index); } - @Override final public int endOfDelimitedBy(@NotNull CharSequence s, int index) { return SequenceUtils.endOfDelimitedBy(this, s, index); } - @Override final public int endOfDelimitedByAny(@NotNull CharPredicate s, int index) { return SequenceUtils.endOfDelimitedByAny(this, s, index); } + @Override final public int startOfDelimitedBy(CharSequence s, int index) { return SequenceUtils.startOfDelimitedBy(this, s, index); } + @Override final public int startOfDelimitedByAny(CharPredicate s, int index) { return SequenceUtils.startOfDelimitedByAny(this, s, index); } + @Override final public int endOfDelimitedBy(CharSequence s, int index) { return SequenceUtils.endOfDelimitedBy(this, s, index); } + @Override final public int endOfDelimitedByAny(CharPredicate s, int index) { return SequenceUtils.endOfDelimitedByAny(this, s, index); } - @Override @NotNull final public Range lineRangeAt(int index) { return SequenceUtils.lineRangeAt(this, index); } - @Override @NotNull final public Range lineRangeAtAnyEOL(int index) { return SequenceUtils.lineRangeAtAnyEOL(this, index); } + @Override final public Range lineRangeAt(int index) { return SequenceUtils.lineRangeAt(this, index); } + @Override final public Range lineRangeAtAnyEOL(int index) { return SequenceUtils.lineRangeAtAnyEOL(this, index); } - @NotNull @Override final public T lineAt(int index) { return subSequence(lineRangeAt(index)); } - @NotNull @Override final public T lineAtAnyEOL(int index) { return subSequence(lineRangeAtAnyEOL(index)); } + @Override final public T lineAt(int index) { return subSequence(lineRangeAt(index)); } + @Override final public T lineAtAnyEOL(int index) { return subSequence(lineRangeAtAnyEOL(index)); } - @NotNull @Override final public Range eolEndRange(int eolEnd) { return SequenceUtils.eolEndRange(this, eolEnd); } - @NotNull @Override public Range eolStartRange(int eolStart) { return SequenceUtils.eolStartRange(this, eolStart); } + @Override final public Range eolEndRange(int eolEnd) { return SequenceUtils.eolEndRange(this, eolEnd); } + @Override public Range eolStartRange(int eolStart) { return SequenceUtils.eolStartRange(this, eolStart); } // @formatter:on - @NotNull @Override final public T trimEOL() { int eolLength = eolEndLength(); return eolLength > 0 ? subSequence(0, length() - eolLength) : (T) this; } - @NotNull @Override final public T trimmedEOL() { int eolLength = eolEndLength(); return eolLength > 0 ? subSequence(length() - eolLength) : nullSequence(); } - @NotNull @Override final public T trimTailBlankLines() { Range range = trailingBlankLinesRange(); return range.isNull() ? (T) this : subSequenceBefore(range); } - @NotNull @Override final public T trimLeadBlankLines() { Range range = leadingBlankLinesRange(); @@ -506,39 +483,38 @@ final public T trimLeadBlankLines() { } // @formatter:off - @NotNull @Override final public Range leadingBlankLinesRange() { return SequenceUtils.leadingBlankLinesRange(this); } - @NotNull @Override final public Range leadingBlankLinesRange(int startIndex) { return SequenceUtils.leadingBlankLinesRange(this, startIndex); } - @NotNull @Override final public Range leadingBlankLinesRange(int fromIndex, int endIndex) { return SequenceUtils.leadingBlankLinesRange(this, fromIndex, endIndex); } - @NotNull @Override final public Range trailingBlankLinesRange() { return SequenceUtils.trailingBlankLinesRange(this); } - @NotNull @Override final public Range trailingBlankLinesRange(int fromIndex) { return SequenceUtils.trailingBlankLinesRange(this, fromIndex); } - @NotNull @Override final public Range trailingBlankLinesRange(int startIndex, int fromIndex) { return SequenceUtils.trailingBlankLinesRange(this, startIndex,fromIndex); } - - @NotNull @Override final public Range trailingBlankLinesRange(CharPredicate eolChars, int startIndex, int fromIndex) { return SequenceUtils.trailingBlankLinesRange(this, eolChars, startIndex, fromIndex);} - @NotNull @Override final public Range leadingBlankLinesRange(@NotNull CharPredicate eolChars, int fromIndex, int endIndex) { return SequenceUtils.leadingBlankLinesRange(this, eolChars, fromIndex, endIndex);} + @Override final public Range leadingBlankLinesRange() { return SequenceUtils.leadingBlankLinesRange(this); } + @Override final public Range leadingBlankLinesRange(int startIndex) { return SequenceUtils.leadingBlankLinesRange(this, startIndex); } + @Override final public Range leadingBlankLinesRange(int fromIndex, int endIndex) { return SequenceUtils.leadingBlankLinesRange(this, fromIndex, endIndex); } + @Override final public Range trailingBlankLinesRange() { return SequenceUtils.trailingBlankLinesRange(this); } + @Override final public Range trailingBlankLinesRange(int fromIndex) { return SequenceUtils.trailingBlankLinesRange(this, fromIndex); } + @Override final public Range trailingBlankLinesRange(int startIndex, int fromIndex) { return SequenceUtils.trailingBlankLinesRange(this, startIndex,fromIndex); } + + @Override final public Range trailingBlankLinesRange(CharPredicate eolChars, int startIndex, int fromIndex) { return SequenceUtils.trailingBlankLinesRange(this, eolChars, startIndex, fromIndex);} + @Override final public Range leadingBlankLinesRange(CharPredicate eolChars, int fromIndex, int endIndex) { return SequenceUtils.leadingBlankLinesRange(this, eolChars, fromIndex, endIndex);} // @formatter:on // @formatter:off - @NotNull @Override final public List blankLinesRemovedRanges() { return SequenceUtils.blankLinesRemovedRanges(this); } - @NotNull @Override final public List blankLinesRemovedRanges(int fromIndex) { return SequenceUtils.blankLinesRemovedRanges(this, fromIndex); } - @NotNull @Override final public List blankLinesRemovedRanges(int fromIndex, int endIndex) { return SequenceUtils.blankLinesRemovedRanges(this, fromIndex, endIndex); } - @NotNull @Override final public List blankLinesRemovedRanges(@NotNull CharPredicate eolChars, int fromIndex, int endIndex) { return SequenceUtils.blankLinesRemovedRanges(this, eolChars, fromIndex, endIndex); } + @Override final public List blankLinesRemovedRanges() { return SequenceUtils.blankLinesRemovedRanges(this); } + @Override final public List blankLinesRemovedRanges(int fromIndex) { return SequenceUtils.blankLinesRemovedRanges(this, fromIndex); } + @Override final public List blankLinesRemovedRanges(int fromIndex, int endIndex) { return SequenceUtils.blankLinesRemovedRanges(this, fromIndex, endIndex); } + @Override final public List blankLinesRemovedRanges(CharPredicate eolChars, int fromIndex, int endIndex) { return SequenceUtils.blankLinesRemovedRanges(this, eolChars, fromIndex, endIndex); } // @formatter:on // @formatter:off - @NotNull @Override public T trimToEndOfLine(boolean includeEol) { return trimToEndOfLine(CharPredicate.EOL, includeEol, 0); } - @NotNull @Override public T trimToEndOfLine(int index) { return trimToEndOfLine(CharPredicate.EOL, false, index); } - @NotNull @Override public T trimToEndOfLine() { return trimToEndOfLine(CharPredicate.EOL, false, 0); } - @NotNull @Override public T trimToEndOfLine(boolean includeEol, int index) { return trimToEndOfLine(CharPredicate.EOL, includeEol, index); } - - @NotNull @Override public T trimToStartOfLine(boolean includeEol) { return trimToStartOfLine(CharPredicate.EOL, includeEol, 0); } - @NotNull @Override public T trimToStartOfLine(int index) { return trimToStartOfLine(CharPredicate.EOL, false, index); } - @NotNull @Override public T trimToStartOfLine() { return trimToStartOfLine(CharPredicate.EOL, false, 0); } - @NotNull @Override public T trimToStartOfLine(boolean includeEol, int index) { return trimToStartOfLine(CharPredicate.EOL, includeEol, index); } + @Override public T trimToEndOfLine(boolean includeEol) { return trimToEndOfLine(CharPredicate.EOL, includeEol, 0); } + @Override public T trimToEndOfLine(int index) { return trimToEndOfLine(CharPredicate.EOL, false, index); } + @Override public T trimToEndOfLine() { return trimToEndOfLine(CharPredicate.EOL, false, 0); } + @Override public T trimToEndOfLine(boolean includeEol, int index) { return trimToEndOfLine(CharPredicate.EOL, includeEol, index); } + + @Override public T trimToStartOfLine(boolean includeEol) { return trimToStartOfLine(CharPredicate.EOL, includeEol, 0); } + @Override public T trimToStartOfLine(int index) { return trimToStartOfLine(CharPredicate.EOL, false, index); } + @Override public T trimToStartOfLine() { return trimToStartOfLine(CharPredicate.EOL, false, 0); } + @Override public T trimToStartOfLine(boolean includeEol, int index) { return trimToStartOfLine(CharPredicate.EOL, includeEol, index); } // @formatter:on - @NotNull @Override - public T trimToEndOfLine(@NotNull CharPredicate eolChars, boolean includeEol, int index) { + public T trimToEndOfLine(CharPredicate eolChars, boolean includeEol, int index) { int eolPos = endOfDelimitedByAny(eolChars, index); if (eolPos < length()) { int endIndex = includeEol ? eolPos + eolStartLength(eolPos) : eolPos; @@ -547,9 +523,8 @@ public T trimToEndOfLine(@NotNull CharPredicate eolChars, boolean includeEol, in return (T) this; } - @NotNull @Override - public T trimToStartOfLine(@NotNull CharPredicate eolChars, boolean includeEol, int index) { + public T trimToStartOfLine(CharPredicate eolChars, boolean includeEol, int index) { int eolPos = startOfDelimitedByAny(eolChars, index); if (eolPos > 0) { int startIndex = includeEol ? eolPos - eolEndLength(eolPos - 1) : eolPos; @@ -559,34 +534,33 @@ public T trimToStartOfLine(@NotNull CharPredicate eolChars, boolean includeEol, } // @formatter:off - @NotNull @Override final public T ifNull(@NotNull T other) { return isNull() ? other : (T) this; } - @NotNull @Override final public T ifNullEmptyAfter(@NotNull T other) { return isNull() ? other.subSequence(other.length(), other.length()) : (T) this; } - @NotNull @Override final public T ifNullEmptyBefore(@NotNull T other) { return isNull() ? other.subSequence(0, 0) : (T) this; } - @NotNull @Override final public T nullIfEmpty() { return isEmpty() ? nullSequence() : (T) this; } - @NotNull @Override final public T nullIfBlank() { return isBlank() ? nullSequence() : (T) this; } - @NotNull @Override final public T nullIf(boolean condition) { return condition ? nullSequence() : (T) this; } - @NotNull @Override final public T nullIfNot(@NotNull BiPredicate predicate, CharSequence... matches) { return nullIf(predicate.negate(),matches); } - @NotNull @Override final public T nullIf(@NotNull Predicate predicate, CharSequence... matches) { return nullIf((o1, o2) -> predicate.test(o2), matches); } - @NotNull @Override final public T nullIfNot(@NotNull Predicate predicate, CharSequence... matches) { return nullIfNot((o1, o2) -> predicate.test(o2), matches); } - @NotNull @Override final public T nullIf(CharSequence... matches) { return nullIf((Predicate) this::matches,matches); } - @NotNull @Override final public T nullIfNot(CharSequence... matches) { return nullIfNot((Predicate) this::matches,matches); } - @NotNull @Override final public T nullIfStartsWith(CharSequence... matches) { return nullIf((Predicate) this::startsWith,matches); } - @NotNull @Override final public T nullIfNotStartsWith(CharSequence... matches) { return nullIfNot((Predicate) this::startsWith,matches); } - @NotNull @Override final public T nullIfEndsWith(CharSequence... matches) { return nullIf((Predicate) this::endsWith,matches); } - @NotNull @Override final public T nullIfNotEndsWith(CharSequence... matches) { return nullIfNot((Predicate) this::endsWith,matches); } - @NotNull @Override final public T nullIfStartsWithIgnoreCase(CharSequence... matches) { return nullIf((Predicate) this::startsWithIgnoreCase,matches); } - @NotNull @Override final public T nullIfNotStartsWithIgnoreCase(CharSequence... matches) { return nullIfNot((Predicate) this::startsWithIgnoreCase,matches); } - @NotNull @Override final public T nullIfEndsWithIgnoreCase(CharSequence... matches) { return nullIf((Predicate) this::endsWithIgnoreCase,matches); } - @NotNull @Override final public T nullIfNotEndsWithIgnoreCase(CharSequence... matches) { return nullIfNot((Predicate) this::endsWithIgnoreCase,matches); } - @NotNull @Override final public T nullIfStartsWith(boolean ignoreCase, CharSequence... matches) { return nullIf((Predicate) prefix -> startsWith(prefix, ignoreCase),matches); } - @NotNull @Override final public T nullIfNotStartsWith(boolean ignoreCase, CharSequence... matches) { return nullIfNot((Predicate) prefix -> startsWith(prefix, ignoreCase),matches); } - @NotNull @Override final public T nullIfEndsWith(boolean ignoreCase, CharSequence... matches) { return nullIf((Predicate) suffix -> endsWith(suffix, ignoreCase),matches); } - @NotNull @Override final public T nullIfNotEndsWith(boolean ignoreCase, CharSequence... matches) { return nullIfNot((Predicate) suffix -> endsWith(suffix, ignoreCase),matches); } + @Override final public T ifNull(T other) { return isNull() ? other : (T) this; } + @Override final public T ifNullEmptyAfter(T other) { return isNull() ? other.subSequence(other.length(), other.length()) : (T) this; } + @Override final public T ifNullEmptyBefore(T other) { return isNull() ? other.subSequence(0, 0) : (T) this; } + @Override final public T nullIfEmpty() { return isEmpty() ? nullSequence() : (T) this; } + @Override final public T nullIfBlank() { return isBlank() ? nullSequence() : (T) this; } + @Override final public T nullIf(boolean condition) { return condition ? nullSequence() : (T) this; } + @Override final public T nullIfNot(BiPredicate predicate, CharSequence... matches) { return nullIf(predicate.negate(),matches); } + @Override final public T nullIf(Predicate predicate, CharSequence... matches) { return nullIf((o1, o2) -> predicate.test(o2), matches); } + @Override final public T nullIfNot(Predicate predicate, CharSequence... matches) { return nullIfNot((o1, o2) -> predicate.test(o2), matches); } + @Override final public T nullIf(CharSequence... matches) { return nullIf((Predicate) this::matches,matches); } + @Override final public T nullIfNot(CharSequence... matches) { return nullIfNot((Predicate) this::matches,matches); } + @Override final public T nullIfStartsWith(CharSequence... matches) { return nullIf((Predicate) this::startsWith,matches); } + @Override final public T nullIfNotStartsWith(CharSequence... matches) { return nullIfNot((Predicate) this::startsWith,matches); } + @Override final public T nullIfEndsWith(CharSequence... matches) { return nullIf((Predicate) this::endsWith,matches); } + @Override final public T nullIfNotEndsWith(CharSequence... matches) { return nullIfNot((Predicate) this::endsWith,matches); } + @Override final public T nullIfStartsWithIgnoreCase(CharSequence... matches) { return nullIf((Predicate) this::startsWithIgnoreCase,matches); } + @Override final public T nullIfNotStartsWithIgnoreCase(CharSequence... matches) { return nullIfNot((Predicate) this::startsWithIgnoreCase,matches); } + @Override final public T nullIfEndsWithIgnoreCase(CharSequence... matches) { return nullIf((Predicate) this::endsWithIgnoreCase,matches); } + @Override final public T nullIfNotEndsWithIgnoreCase(CharSequence... matches) { return nullIfNot((Predicate) this::endsWithIgnoreCase,matches); } + @Override final public T nullIfStartsWith(boolean ignoreCase, CharSequence... matches) { return nullIf((Predicate) prefix -> startsWith(prefix, ignoreCase),matches); } + @Override final public T nullIfNotStartsWith(boolean ignoreCase, CharSequence... matches) { return nullIfNot((Predicate) prefix -> startsWith(prefix, ignoreCase),matches); } + @Override final public T nullIfEndsWith(boolean ignoreCase, CharSequence... matches) { return nullIf((Predicate) suffix -> endsWith(suffix, ignoreCase),matches); } + @Override final public T nullIfNotEndsWith(boolean ignoreCase, CharSequence... matches) { return nullIfNot((Predicate) suffix -> endsWith(suffix, ignoreCase),matches); } // @formatter:on - @NotNull @Override - final public T nullIf(@NotNull BiPredicate predicate, CharSequence... matches) { + final public T nullIf(BiPredicate predicate, CharSequence... matches) { for (CharSequence match : matches) { if (predicate.test((T) this, match)) return nullSequence(); } @@ -602,13 +576,13 @@ final public T nullIf(@NotNull BiPredicate pred @Override final public boolean isNotEmpty() { return SequenceUtils.isNotEmpty(this); } @Override final public boolean isNotBlank() { return SequenceUtils.isNotBlank(this); } - @Override final public boolean endsWith(@NotNull CharSequence suffix) { return SequenceUtils.endsWith(this, suffix); } - @Override final public boolean endsWith(@NotNull CharSequence suffix, boolean ignoreCase) { return SequenceUtils.endsWith(this, suffix, ignoreCase); } - @Override final public boolean startsWith(@NotNull CharSequence prefix) { return SequenceUtils.startsWith(this, prefix); } - @Override final public boolean startsWith(@NotNull CharSequence prefix, boolean ignoreCase) { return SequenceUtils.startsWith(this, prefix, ignoreCase); } + @Override final public boolean endsWith(CharSequence suffix) { return SequenceUtils.endsWith(this, suffix); } + @Override final public boolean endsWith(CharSequence suffix, boolean ignoreCase) { return SequenceUtils.endsWith(this, suffix, ignoreCase); } + @Override final public boolean startsWith(CharSequence prefix) { return SequenceUtils.startsWith(this, prefix); } + @Override final public boolean startsWith(CharSequence prefix, boolean ignoreCase) { return SequenceUtils.startsWith(this, prefix, ignoreCase); } - @Override final public boolean endsWith(@NotNull CharPredicate chars) { return SequenceUtils.endsWith(this, chars); } - @Override final public boolean startsWith(@NotNull CharPredicate chars) { return SequenceUtils.startsWith(this, chars); } + @Override final public boolean endsWith(CharPredicate chars) { return SequenceUtils.endsWith(this, chars); } + @Override final public boolean startsWith(CharPredicate chars) { return SequenceUtils.startsWith(this, chars); } @Override final public boolean endsWithEOL() { return SequenceUtils.endsWithEOL(this); } @Override final public boolean endsWithAnyEOL() { return SequenceUtils.endsWithAnyEOL(this); } @@ -622,25 +596,24 @@ final public T nullIf(@NotNull BiPredicate pred @Override final public boolean startsWithSpaceTab() { return SequenceUtils.startsWithSpaceTab(this); } @Override final public boolean startsWithWhitespace() { return SequenceUtils.startsWithWhitespace(this); } - @NotNull @Override final public T removeSuffix(@NotNull CharSequence suffix) { return !endsWith(suffix) ? (T) this : subSequence(0, length() - suffix.length()); } - @NotNull @Override final public T removePrefix(@NotNull CharSequence prefix) { return !startsWith(prefix) ? (T) this : subSequence(prefix.length(), length()); } - @NotNull @Override final public T removeProperSuffix(@NotNull CharSequence suffix) { return length() <= suffix.length() || !endsWith(suffix) ? (T) this : subSequence(0, length() - suffix.length()); } - @NotNull @Override final public T removeProperPrefix(@NotNull CharSequence prefix) { return length() <= prefix.length() || !startsWith(prefix) ? (T) this : subSequence(prefix.length(), length()); } - @Override final public boolean endsWithIgnoreCase(@NotNull CharSequence suffix) { return length() > 0 && matchCharsReversed(suffix, length() - 1, true); } - @Override final public boolean startsWithIgnoreCase(@NotNull CharSequence prefix) { return length() > 0 && matchChars(prefix, 0, true); } - @NotNull @Override final public T removeSuffixIgnoreCase(@NotNull CharSequence suffix) { return !endsWithIgnoreCase(suffix) ? (T) this : subSequence(0, length() - suffix.length()); } - @NotNull @Override final public T removePrefixIgnoreCase(@NotNull CharSequence prefix) { return !startsWithIgnoreCase(prefix) ? (T) this : subSequence(prefix.length(), length()); } - @NotNull @Override final public T removeProperSuffixIgnoreCase(@NotNull CharSequence suffix) { return length() <= suffix.length() || !endsWithIgnoreCase(suffix) ? (T) this : subSequence(0, length() - suffix.length()); } - @NotNull @Override final public T removeProperPrefixIgnoreCase(@NotNull CharSequence prefix) { return length() <= prefix.length() || !startsWithIgnoreCase(prefix) ? (T) this : subSequence(prefix.length(), length()); } - @NotNull @Override final public T removeSuffix(@NotNull CharSequence suffix, boolean ignoreCase) { return !endsWith(suffix, ignoreCase) ? (T) this : subSequence(0, length() - suffix.length()); } - @NotNull @Override final public T removePrefix(@NotNull CharSequence prefix, boolean ignoreCase) { return !startsWith(prefix, ignoreCase) ? (T) this : subSequence(prefix.length(), length()); } - @NotNull @Override final public T removeProperSuffix(@NotNull CharSequence suffix, boolean ignoreCase) { return length() <= suffix.length() || !endsWith(suffix, ignoreCase) ? (T) this : subSequence(0, length() - suffix.length()); } - @NotNull @Override final public T removeProperPrefix(@NotNull CharSequence prefix, boolean ignoreCase) { return length() <= prefix.length() || !startsWith(prefix, ignoreCase) ? (T) this : subSequence(prefix.length(), length()); } + @Override final public T removeSuffix(CharSequence suffix) { return !endsWith(suffix) ? (T) this : subSequence(0, length() - suffix.length()); } + @Override final public T removePrefix(CharSequence prefix) { return !startsWith(prefix) ? (T) this : subSequence(prefix.length(), length()); } + @Override final public T removeProperSuffix(CharSequence suffix) { return length() <= suffix.length() || !endsWith(suffix) ? (T) this : subSequence(0, length() - suffix.length()); } + @Override final public T removeProperPrefix(CharSequence prefix) { return length() <= prefix.length() || !startsWith(prefix) ? (T) this : subSequence(prefix.length(), length()); } + @Override final public boolean endsWithIgnoreCase(CharSequence suffix) { return length() > 0 && matchCharsReversed(suffix, length() - 1, true); } + @Override final public boolean startsWithIgnoreCase(CharSequence prefix) { return length() > 0 && matchChars(prefix, 0, true); } + @Override final public T removeSuffixIgnoreCase(CharSequence suffix) { return !endsWithIgnoreCase(suffix) ? (T) this : subSequence(0, length() - suffix.length()); } + @Override final public T removePrefixIgnoreCase(CharSequence prefix) { return !startsWithIgnoreCase(prefix) ? (T) this : subSequence(prefix.length(), length()); } + @Override final public T removeProperSuffixIgnoreCase(CharSequence suffix) { return length() <= suffix.length() || !endsWithIgnoreCase(suffix) ? (T) this : subSequence(0, length() - suffix.length()); } + @Override final public T removeProperPrefixIgnoreCase(CharSequence prefix) { return length() <= prefix.length() || !startsWithIgnoreCase(prefix) ? (T) this : subSequence(prefix.length(), length()); } + @Override final public T removeSuffix(CharSequence suffix, boolean ignoreCase) { return !endsWith(suffix, ignoreCase) ? (T) this : subSequence(0, length() - suffix.length()); } + @Override final public T removePrefix(CharSequence prefix, boolean ignoreCase) { return !startsWith(prefix, ignoreCase) ? (T) this : subSequence(prefix.length(), length()); } + @Override final public T removeProperSuffix(CharSequence suffix, boolean ignoreCase) { return length() <= suffix.length() || !endsWith(suffix, ignoreCase) ? (T) this : subSequence(0, length() - suffix.length()); } + @Override final public T removeProperPrefix(CharSequence prefix, boolean ignoreCase) { return length() <= prefix.length() || !startsWith(prefix, ignoreCase) ? (T) this : subSequence(prefix.length(), length()); } // @formatter:on - @NotNull @Override - public T insert(int index, @NotNull CharSequence chars) { + public T insert(int index, CharSequence chars) { index = Math.max(0, Math.min(length(), index)); if (chars.length() == 0) { @@ -654,7 +627,6 @@ public T insert(int index, @NotNull CharSequence chars) { } } - @NotNull @Override public T delete(int startIndex, int endIndex) { endIndex = Math.max(0, Math.min(length(), endIndex)); @@ -672,47 +644,46 @@ public T delete(int startIndex, int endIndex) { } // @formatter:off - @NotNull @Override final public T toLowerCase() { return toMapped(ChangeCase.toLowerCase); } - @NotNull @Override final public T toUpperCase() { return toMapped(ChangeCase.toUpperCase); } - @NotNull @Override final public T toNbSp() { return toMapped(SpaceMapper.toNonBreakSpace); } - @NotNull @Override final public T toSpc() { return toMapped(SpaceMapper.fromNonBreakSpace); } + @Override final public T toLowerCase() { return toMapped(ChangeCase.toLowerCase); } + @Override final public T toUpperCase() { return toMapped(ChangeCase.toUpperCase); } + @Override final public T toNbSp() { return toMapped(SpaceMapper.toNonBreakSpace); } + @Override final public T toSpc() { return toMapped(SpaceMapper.fromNonBreakSpace); } // @formatter:on // @formatter:off - @Override final public boolean matches(@NotNull CharSequence chars, boolean ignoreCase) { return SequenceUtils.matches(this, chars, ignoreCase);} - @Override final public boolean matches(@NotNull CharSequence chars) { return SequenceUtils.matches(this, chars);} - @Override final public boolean matchesIgnoreCase(@NotNull CharSequence chars) { return SequenceUtils.matchesIgnoreCase(this, chars); } - - @Override final public boolean matchChars(@NotNull CharSequence chars, int startIndex, boolean ignoreCase) { return SequenceUtils.matchChars(this, chars, startIndex, ignoreCase); } - @Override final public boolean matchChars(@NotNull CharSequence chars, int startIndex) { return SequenceUtils.matchChars(this, chars, startIndex);} - @Override final public boolean matchCharsIgnoreCase(@NotNull CharSequence chars, int startIndex) { return SequenceUtils.matchCharsIgnoreCase(this, chars, startIndex); } - - @Override final public boolean matchChars(@NotNull CharSequence chars, boolean ignoreCase) { return SequenceUtils.matchChars(this, chars, ignoreCase); } - @Override final public boolean matchChars(@NotNull CharSequence chars) { return SequenceUtils.matchChars(this, chars); } - @Override final public boolean matchCharsIgnoreCase(@NotNull CharSequence chars) { return SequenceUtils.matchCharsIgnoreCase(this, chars); } - - @Override final public boolean matchCharsReversed(@NotNull CharSequence chars, int endIndex, boolean ignoreCase) { return SequenceUtils.matchCharsReversed(this, chars, endIndex, ignoreCase); } - @Override final public boolean matchCharsReversed(@NotNull CharSequence chars, int endIndex) { return SequenceUtils.matchCharsReversed(this, chars, endIndex); } - @Override final public boolean matchCharsReversedIgnoreCase(@NotNull CharSequence chars, int endIndex) { return SequenceUtils.matchCharsReversedIgnoreCase(this, chars, endIndex); } - - @Override final public int matchedCharCount(@NotNull CharSequence chars, int startIndex, int endIndex, boolean ignoreCase) { return SequenceUtils.matchedCharCount(this, chars, startIndex, endIndex, ignoreCase); } - @Override final public int matchedCharCount(@NotNull CharSequence chars, int startIndex, boolean ignoreCase) { return SequenceUtils.matchedCharCount(this, chars, startIndex, ignoreCase); } - @Override final public int matchedCharCount(@NotNull CharSequence chars, int startIndex, int endIndex) { return SequenceUtils.matchedCharCount(this, chars, startIndex, endIndex); } - @Override final public int matchedCharCount(@NotNull CharSequence chars, int startIndex) { return SequenceUtils.matchedCharCount(this, chars, startIndex); } - @Override final public int matchedCharCountIgnoreCase(@NotNull CharSequence chars, int startIndex) { return SequenceUtils.matchedCharCountIgnoreCase(this, chars, startIndex); } - @Override final public int matchedCharCountIgnoreCase(@NotNull CharSequence chars, int startIndex, int endIndex) { return SequenceUtils.matchedCharCountIgnoreCase(this, chars, startIndex, endIndex); } - - @Override final public int matchedCharCountReversedIgnoreCase(@NotNull CharSequence chars, int startIndex, int fromIndex) { return SequenceUtils.matchedCharCountReversedIgnoreCase(this, chars, startIndex, fromIndex); } - @Override final public int matchedCharCountReversed(@NotNull CharSequence chars, int startIndex, int fromIndex) { return SequenceUtils.matchedCharCountReversed(this, chars, startIndex, fromIndex); } - - @Override final public int matchedCharCountReversed(@NotNull CharSequence chars, int fromIndex, boolean ignoreCase) { return SequenceUtils.matchedCharCountReversed(this, chars, fromIndex, ignoreCase); } - @Override final public int matchedCharCountReversed(@NotNull CharSequence chars, int fromIndex) { return SequenceUtils.matchedCharCountReversed(this, chars, fromIndex); } - @Override final public int matchedCharCountReversedIgnoreCase(@NotNull CharSequence chars, int fromIndex) { return SequenceUtils.matchedCharCountReversedIgnoreCase(this, chars, fromIndex); } - @Override final public int matchedCharCount(@NotNull CharSequence chars, int startIndex, int endIndex, boolean fullMatchOnly, boolean ignoreCase) { return SequenceUtils.matchedCharCount(this, chars, startIndex, endIndex, fullMatchOnly, ignoreCase); } - @Override final public int matchedCharCountReversed(@NotNull CharSequence chars, int startIndex, int fromIndex, boolean ignoreCase) { return SequenceUtils.matchedCharCountReversed(this, chars, startIndex, fromIndex, ignoreCase);} + @Override final public boolean matches(CharSequence chars, boolean ignoreCase) { return SequenceUtils.matches(this, chars, ignoreCase);} + @Override final public boolean matches(CharSequence chars) { return SequenceUtils.matches(this, chars);} + @Override final public boolean matchesIgnoreCase(CharSequence chars) { return SequenceUtils.matchesIgnoreCase(this, chars); } + + @Override final public boolean matchChars(CharSequence chars, int startIndex, boolean ignoreCase) { return SequenceUtils.matchChars(this, chars, startIndex, ignoreCase); } + @Override final public boolean matchChars(CharSequence chars, int startIndex) { return SequenceUtils.matchChars(this, chars, startIndex);} + @Override final public boolean matchCharsIgnoreCase(CharSequence chars, int startIndex) { return SequenceUtils.matchCharsIgnoreCase(this, chars, startIndex); } + + @Override final public boolean matchChars(CharSequence chars, boolean ignoreCase) { return SequenceUtils.matchChars(this, chars, ignoreCase); } + @Override final public boolean matchChars(CharSequence chars) { return SequenceUtils.matchChars(this, chars); } + @Override final public boolean matchCharsIgnoreCase(CharSequence chars) { return SequenceUtils.matchCharsIgnoreCase(this, chars); } + + @Override final public boolean matchCharsReversed(CharSequence chars, int endIndex, boolean ignoreCase) { return SequenceUtils.matchCharsReversed(this, chars, endIndex, ignoreCase); } + @Override final public boolean matchCharsReversed(CharSequence chars, int endIndex) { return SequenceUtils.matchCharsReversed(this, chars, endIndex); } + @Override final public boolean matchCharsReversedIgnoreCase(CharSequence chars, int endIndex) { return SequenceUtils.matchCharsReversedIgnoreCase(this, chars, endIndex); } + + @Override final public int matchedCharCount(CharSequence chars, int startIndex, int endIndex, boolean ignoreCase) { return SequenceUtils.matchedCharCount(this, chars, startIndex, endIndex, ignoreCase); } + @Override final public int matchedCharCount(CharSequence chars, int startIndex, boolean ignoreCase) { return SequenceUtils.matchedCharCount(this, chars, startIndex, ignoreCase); } + @Override final public int matchedCharCount(CharSequence chars, int startIndex, int endIndex) { return SequenceUtils.matchedCharCount(this, chars, startIndex, endIndex); } + @Override final public int matchedCharCount(CharSequence chars, int startIndex) { return SequenceUtils.matchedCharCount(this, chars, startIndex); } + @Override final public int matchedCharCountIgnoreCase(CharSequence chars, int startIndex) { return SequenceUtils.matchedCharCountIgnoreCase(this, chars, startIndex); } + @Override final public int matchedCharCountIgnoreCase(CharSequence chars, int startIndex, int endIndex) { return SequenceUtils.matchedCharCountIgnoreCase(this, chars, startIndex, endIndex); } + + @Override final public int matchedCharCountReversedIgnoreCase(CharSequence chars, int startIndex, int fromIndex) { return SequenceUtils.matchedCharCountReversedIgnoreCase(this, chars, startIndex, fromIndex); } + @Override final public int matchedCharCountReversed(CharSequence chars, int startIndex, int fromIndex) { return SequenceUtils.matchedCharCountReversed(this, chars, startIndex, fromIndex); } + + @Override final public int matchedCharCountReversed(CharSequence chars, int fromIndex, boolean ignoreCase) { return SequenceUtils.matchedCharCountReversed(this, chars, fromIndex, ignoreCase); } + @Override final public int matchedCharCountReversed(CharSequence chars, int fromIndex) { return SequenceUtils.matchedCharCountReversed(this, chars, fromIndex); } + @Override final public int matchedCharCountReversedIgnoreCase(CharSequence chars, int fromIndex) { return SequenceUtils.matchedCharCountReversedIgnoreCase(this, chars, fromIndex); } + @Override final public int matchedCharCount(CharSequence chars, int startIndex, int endIndex, boolean fullMatchOnly, boolean ignoreCase) { return SequenceUtils.matchedCharCount(this, chars, startIndex, endIndex, fullMatchOnly, ignoreCase); } + @Override final public int matchedCharCountReversed(CharSequence chars, int startIndex, int fromIndex, boolean ignoreCase) { return SequenceUtils.matchedCharCountReversed(this, chars, startIndex, fromIndex, ignoreCase);} // @formatter:on - @NotNull @Override public String toString() { int iMax = length(); @@ -726,57 +697,55 @@ public String toString() { } // @formatter:off - @NotNull @Override final public String normalizeEOL() { return Escaping.normalizeEOL(toString());} - @NotNull @Override final public String normalizeEndWithEOL() { return Escaping.normalizeEndWithEOL(toString());} - @NotNull @Override final public String toVisibleWhitespaceString() { return SequenceUtils.toVisibleWhitespaceString(this);} + @Override final public String normalizeEOL() { return Escaping.normalizeEOL(toString());} + @Override final public String normalizeEndWithEOL() { return Escaping.normalizeEndWithEOL(toString());} + @Override final public String toVisibleWhitespaceString() { return SequenceUtils.toVisibleWhitespaceString(this);} // @formatter:on // @formatter:off - @NotNull @Override final public List splitList(@NotNull CharSequence delimiter) { return SequenceUtils.splitList((T)this, delimiter, 0, 0, null); } - @NotNull @Override final public List splitList(@NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T)this, delimiter, limit, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } - @NotNull @Override final public List splitList(@NotNull CharSequence delimiter, int limit, int flags) { return SequenceUtils.splitList((T)this, delimiter, limit, flags, null); } - @NotNull @Override final public List splitList(@NotNull CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T)this, delimiter, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + @Override final public List splitList(CharSequence delimiter) { return SequenceUtils.splitList((T)this, delimiter, 0, 0, null); } + @Override final public List splitList(CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T)this, delimiter, limit, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + @Override final public List splitList(CharSequence delimiter, int limit, int flags) { return SequenceUtils.splitList((T)this, delimiter, limit, flags, null); } + @Override final public List splitList(CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T)this, delimiter, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } // NOTE: these default to including delimiters as part of split item - @NotNull @Override final public List splitListEOL() { return SequenceUtils.splitList((T)this, SequenceUtils.EOL, 0, SequenceUtils.SPLIT_INCLUDE_DELIMS, null); } - @NotNull @Override final public List splitListEOL(boolean includeDelims) { return SequenceUtils.splitList((T)this, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, null); } - @NotNull @Override final public List splitListEOL(boolean includeDelims, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T)this, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } - @NotNull @Override final public List splitList(@NotNull CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T) this, delimiter, limit, flags, trimChars); } - - @NotNull @Override final public T[] splitEOL() { return split(SequenceUtils.EOL, 0, SequenceUtils.SPLIT_INCLUDE_DELIMS,null); } - @NotNull @Override final public T[] splitEOL(boolean includeDelims) { return split(SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, null); } - @NotNull @Override final public T[] split(@NotNull CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) { return split(delimiter, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } - @NotNull @Override final public T[] split(@NotNull CharSequence delimiter) { return split(delimiter, 0, 0, null); } - @NotNull @Override final public T[] split(@NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) { return split(delimiter, limit, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } - @NotNull @Override final public T[] split(@NotNull CharSequence delimiter, int limit, int flags) { return split(delimiter, limit, flags, null); } - @NotNull @Override final public T[] split(@NotNull CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T)this, delimiter, limit, flags, trimChars).toArray(emptyArray()); } + @Override final public List splitListEOL() { return SequenceUtils.splitList((T)this, SequenceUtils.EOL, 0, SequenceUtils.SPLIT_INCLUDE_DELIMS, null); } + @Override final public List splitListEOL(boolean includeDelims) { return SequenceUtils.splitList((T)this, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, null); } + @Override final public List splitListEOL(boolean includeDelims, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T)this, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + @Override final public List splitList(CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T) this, delimiter, limit, flags, trimChars); } + + @Override final public T[] splitEOL() { return split(SequenceUtils.EOL, 0, SequenceUtils.SPLIT_INCLUDE_DELIMS,null); } + @Override final public T[] splitEOL(boolean includeDelims) { return split(SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, null); } + @Override final public T[] split(CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) { return split(delimiter, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + @Override final public T[] split(CharSequence delimiter) { return split(delimiter, 0, 0, null); } + @Override final public T[] split(CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) { return split(delimiter, limit, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + @Override final public T[] split(CharSequence delimiter, int limit, int flags) { return split(delimiter, limit, flags, null); } + @Override final public T[] split(CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) { return SequenceUtils.splitList((T)this, delimiter, limit, flags, trimChars).toArray(emptyArray()); } // @formatter:on // @formatter:off - @NotNull @Override final public T appendTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper) {return appendTo(out, charMapper, 0, length());} - @NotNull @Override final public T appendTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper, int startIndex) {return appendTo(out, charMapper, startIndex, length());} - @NotNull @Override final public T appendTo(@NotNull StringBuilder out) {return appendTo(out, null, 0, length());} - @NotNull @Override final public T appendTo(@NotNull StringBuilder out, int startIndex) {return appendTo(out, null, startIndex, length());} - @NotNull @Override final public T appendTo(@NotNull StringBuilder out, int startIndex, int endIndex) {return appendTo(out, null, startIndex, endIndex);} + @Override final public T appendTo(StringBuilder out, @Nullable CharMapper charMapper) {return appendTo(out, charMapper, 0, length());} + @Override final public T appendTo(StringBuilder out, @Nullable CharMapper charMapper, int startIndex) {return appendTo(out, charMapper, startIndex, length());} + @Override final public T appendTo(StringBuilder out) {return appendTo(out, null, 0, length());} + @Override final public T appendTo(StringBuilder out, int startIndex) {return appendTo(out, null, startIndex, length());} + @Override final public T appendTo(StringBuilder out, int startIndex, int endIndex) {return appendTo(out, null, startIndex, endIndex);} // @formatter:on - @NotNull @Override - final public T appendTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper, int startIndex, int endIndex) { + final public T appendTo(StringBuilder out, @Nullable CharMapper charMapper, int startIndex, int endIndex) { CharSequence useSequence = charMapper == null ? this : toMapped(charMapper); out.append(useSequence, startIndex, endIndex); return (T) this; } // @formatter:off - @NotNull @Override final public T appendRangesTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper, Range... ranges) {return appendRangesTo(out, charMapper, new ArrayIterable<>(ranges));} - @NotNull @Override final public T appendRangesTo(@NotNull StringBuilder out, Range... ranges) {return appendRangesTo(out, null, new ArrayIterable<>(ranges));} - @NotNull @Override final public T appendRangesTo(@NotNull StringBuilder out, Iterable ranges) {return appendRangesTo(out, null, ranges);} + @Override final public T appendRangesTo(StringBuilder out, @Nullable CharMapper charMapper, Range... ranges) {return appendRangesTo(out, charMapper, new ArrayIterable<>(ranges));} + @Override final public T appendRangesTo(StringBuilder out, Range... ranges) {return appendRangesTo(out, null, new ArrayIterable<>(ranges));} + @Override final public T appendRangesTo(StringBuilder out, Iterable ranges) {return appendRangesTo(out, null, ranges);} // @formatter:on - @NotNull @Override - final public T appendRangesTo(@NotNull StringBuilder out, @Nullable CharMapper charMapper, Iterable ranges) { + final public T appendRangesTo(StringBuilder out, @Nullable CharMapper charMapper, Iterable ranges) { CharSequence useSequence = charMapper == null ? this : toMapped(charMapper); for (Range range : ranges) { @@ -786,31 +755,29 @@ final public T appendRangesTo(@NotNull StringBuilder out, @Nullable CharMapper c } // @formatter:off - @NotNull @Override final public int[] indexOfAll(@NotNull CharSequence s) { return SequenceUtils.indexOfAll(this, s);} - - @Override @NotNull final public T appendEOL() { return suffixWith(SequenceUtils.EOL); } - @Override @NotNull final public T suffixWithEOL() { return suffixWith(SequenceUtils.EOL); } - @Override @NotNull final public T prefixWithEOL() { return prefixWith(SequenceUtils.EOL); } - @Override @NotNull final public T prefixOnceWithEOL() { return prefixOnceWith(SequenceUtils.EOL); } - @Override @NotNull final public T suffixOnceWithEOL() { return suffixOnceWith(SequenceUtils.EOL); } - - @Override @NotNull final public T appendSpace() { return suffixWith(SequenceUtils.SPACE); } - @Override @NotNull final public T suffixWithSpace() { return suffixWith(SequenceUtils.SPACE); } - @Override @NotNull final public T prefixWithSpace() { return prefixWith(SequenceUtils.SPACE); } - @Override @NotNull final public T appendSpaces(int count) { return suffixWith(RepeatedSequence.ofSpaces(count)); } - @Override @NotNull final public T suffixWithSpaces(int count) { return suffixWith(RepeatedSequence.ofSpaces(count)); } - @Override @NotNull final public T prefixWithSpaces(int count) { return prefixWith(RepeatedSequence.ofSpaces(count)); } - @Override @NotNull final public T prefixOnceWithSpace() { return prefixOnceWith(SequenceUtils.SPACE); } - @Override @NotNull final public T suffixOnceWithSpace() { return suffixOnceWith(SequenceUtils.SPACE); } + @Override final public int[] indexOfAll(CharSequence s) { return SequenceUtils.indexOfAll(this, s);} + + @Override final public T appendEOL() { return suffixWith(SequenceUtils.EOL); } + @Override final public T suffixWithEOL() { return suffixWith(SequenceUtils.EOL); } + @Override final public T prefixWithEOL() { return prefixWith(SequenceUtils.EOL); } + @Override final public T prefixOnceWithEOL() { return prefixOnceWith(SequenceUtils.EOL); } + @Override final public T suffixOnceWithEOL() { return suffixOnceWith(SequenceUtils.EOL); } + + @Override final public T appendSpace() { return suffixWith(SequenceUtils.SPACE); } + @Override final public T suffixWithSpace() { return suffixWith(SequenceUtils.SPACE); } + @Override final public T prefixWithSpace() { return prefixWith(SequenceUtils.SPACE); } + @Override final public T appendSpaces(int count) { return suffixWith(RepeatedSequence.ofSpaces(count)); } + @Override final public T suffixWithSpaces(int count) { return suffixWith(RepeatedSequence.ofSpaces(count)); } + @Override final public T prefixWithSpaces(int count) { return prefixWith(RepeatedSequence.ofSpaces(count)); } + @Override final public T prefixOnceWithSpace() { return prefixOnceWith(SequenceUtils.SPACE); } + @Override final public T suffixOnceWithSpace() { return suffixOnceWith(SequenceUtils.SPACE); } // @formatter:on - @NotNull @Override public T prefixWith(@Nullable CharSequence prefix) { return prefix == null || prefix.length() == 0 ? (T) this : getBuilder().add(prefix).add(this).toSequence(); } - @NotNull @Override public T suffixWith(@Nullable CharSequence suffix) { // convoluted to allow BasedCharSequence to use PrefixedCharSequence so all fits into SegmentedCharSequence @@ -818,21 +785,18 @@ public T suffixWith(@Nullable CharSequence suffix) { return getBuilder().add(this).add(suffix).toSequence(); } - @NotNull @Override final public T prefixOnceWith(@Nullable CharSequence prefix) { return prefix == null || prefix.length() == 0 || startsWith(prefix) ? (T) this : prefixWith(prefix); } - @NotNull @Override final public T suffixOnceWith(@Nullable CharSequence suffix) { return suffix == null || suffix.length() == 0 || endsWith(suffix) ? (T) this : suffixWith(suffix); } - @NotNull @Override - final public T replace(int startIndex, int endIndex, @NotNull CharSequence replacement) { + final public T replace(int startIndex, int endIndex, CharSequence replacement) { int length = length(); startIndex = Math.max(startIndex, 0); endIndex = Math.min(endIndex, length); @@ -841,9 +805,8 @@ final public T replace(int startIndex, int endIndex, @NotNull CharSequence repla return segments.add(subSequence(0, startIndex)).add(replacement).add(subSequence(endIndex)).toSequence(); } - @NotNull @Override - final public T replace(@NotNull CharSequence find, @NotNull CharSequence replace) { + final public T replace(CharSequence find, CharSequence replace) { int[] indices = indexOfAll(find); if (indices.length == 0) return (T) this; ISequenceBuilder segments = getBuilder(); @@ -867,13 +830,11 @@ final public T replace(@NotNull CharSequence find, @NotNull CharSequence replace return segments.toSequence(); } - @NotNull @Override final public T append(CharSequence... sequences) { return append(new ArrayIterable<>(sequences)); } - @NotNull @Override final public T append(Iterable sequences) { ISequenceBuilder segments = getBuilder(); @@ -884,13 +845,11 @@ final public T append(Iterable sequences) { return segments.toSequence(); } - @NotNull @Override final public T extractRanges(Range... ranges) { return extractRanges(new ArrayIterable<>(ranges)); } - @NotNull @Override final public T extractRanges(Iterable ranges) { ISequenceBuilder segments = getBuilder(); @@ -902,16 +861,16 @@ final public T extractRanges(Iterable ranges) { // @formatter:off @Override final public int columnAtIndex(int index) { return SequenceUtils.columnAtIndex(this, index);} - @NotNull @Override final public Pair lineColumnAtIndex(int index) {return SequenceUtils.lineColumnAtIndex(this, index);} + @Override final public Pair lineColumnAtIndex(int index) {return SequenceUtils.lineColumnAtIndex(this, index);} // @formatter:on @Override - public boolean isIn(@NotNull String[] texts) { + public boolean isIn(String[] texts) { return SequenceUtils.containedBy(texts, this); } @Override - public boolean isIn(@NotNull Collection texts) { + public boolean isIn(Collection texts) { return SequenceUtils.containedBy(texts, this); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineAppendable.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineAppendable.java index e11b7f85d..7db3a77f8 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineAppendable.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineAppendable.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.misc.BitFieldSet; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.IOException; import java.util.Iterator; @@ -98,7 +97,6 @@ default int getOptions() { return getOptionSet().toInt(); } - @NotNull LineAppendable getEmptyAppendable(); /** @@ -109,27 +107,22 @@ default int getOptions() { * @param withPrefixes true if to include prefixes * @return copy of appendable with requested content */ - @NotNull default LineAppendable copyAppendable(int startLine, int endLine, boolean withPrefixes) { return getEmptyAppendable().append(this, startLine, endLine, withPrefixes); } - @NotNull default LineAppendable copyAppendable(int startLine, int endLine) { return getEmptyAppendable().append(this, startLine, endLine, false); } - @NotNull default LineAppendable copyAppendable(int startLine) { return getEmptyAppendable().append(this, startLine, Integer.MAX_VALUE, false); } - @NotNull default LineAppendable copyAppendable() { return getEmptyAppendable().append(this, 0, Integer.MAX_VALUE, false); } - @NotNull default LineAppendable copyAppendable(boolean withPrefixes) { return getEmptyAppendable().append(this, 0, Integer.MAX_VALUE, withPrefixes); } @@ -139,46 +132,36 @@ default LineAppendable copyAppendable(boolean withPrefixes) { * * @return mutable option set */ - @NotNull BitFieldSet getOptionSet(); - @NotNull LineAppendable pushOptions(); - @NotNull LineAppendable popOptions(); - @NotNull default LineAppendable noTrimLeading() { return changeOptions(0, F_TRIM_LEADING_WHITESPACE); } - @NotNull default LineAppendable trimLeading() { return changeOptions(F_TRIM_LEADING_WHITESPACE, 0); } - @NotNull default LineAppendable preserveSpaces() { return changeOptions(0, F_TRIM_LEADING_WHITESPACE | F_COLLAPSE_WHITESPACE); } - @NotNull default LineAppendable noPreserveSpaces() { return changeOptions(F_TRIM_LEADING_WHITESPACE | F_COLLAPSE_WHITESPACE, 0); } - @NotNull default LineAppendable removeOptions(int flags) { return changeOptions(0, flags); } - @NotNull default LineAppendable addOptions(int flags) { return changeOptions(flags, 0); } - @NotNull LineAppendable changeOptions(int addFlags, int removeFlags); /** @@ -187,12 +170,10 @@ default LineAppendable addOptions(int flags) { * @param flags option flags * @return this */ - @NotNull default LineAppendable setOptions(int flags) { return setOptions(toOptionSet(flags)); } - @NotNull default LineAppendable setOptions(Options... options) { return setOptions(toOptionSet(options).toInt()); } @@ -203,7 +184,6 @@ default LineAppendable setOptions(Options... options) { * @param options option set * @return this */ - @NotNull default LineAppendable setOptions(BitFieldSet options) { return setOptions(options.toInt()); } @@ -213,7 +193,6 @@ default LineAppendable setOptions(BitFieldSet options) { * * @return builder used for accumulation */ - @NotNull ISequenceBuilder getBuilder(); /** @@ -235,18 +214,17 @@ default int getTrailingBlankLines() { // these methods are monitored for content and formatting applied @Override - @NotNull LineAppendable append(@NotNull CharSequence csq); + LineAppendable append(CharSequence csq); @Override - @NotNull LineAppendable append(@NotNull CharSequence csq, int start, int end); + LineAppendable append(CharSequence csq, int start, int end); @Override - @NotNull LineAppendable append(char c); + LineAppendable append(char c); - @NotNull LineAppendable append(char c, int count); + LineAppendable append(char c, int count); - @NotNull - default LineAppendable appendAll(@NotNull Iterable sequences) { + default LineAppendable appendAll(Iterable sequences) { for (CharSequence sequence : sequences) { append(sequence); } @@ -267,7 +245,7 @@ default LineAppendable appendAll(@NotNull Iterable sequences) { * @param withPrefixes true if to include prefixes from the lineAppendable. * @return this */ - @NotNull LineAppendable append(@NotNull LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes); + LineAppendable append(LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes); /** * Append lines from another line formatting appendable. @@ -279,8 +257,7 @@ default LineAppendable appendAll(@NotNull Iterable sequences) { * @param lineAppendable lines to append * @return this */ - @NotNull - default LineAppendable append(@NotNull LineAppendable lineAppendable) { + default LineAppendable append(LineAppendable lineAppendable) { return append(lineAppendable, 0, Integer.MAX_VALUE, true); } @@ -295,8 +272,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable) { * @param withPrefixes true if to include prefixes from the lineAppendable. * @return this */ - @NotNull - default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean withPrefixes) { + default LineAppendable append(LineAppendable lineAppendable, boolean withPrefixes) { return append(lineAppendable, 0, Integer.MAX_VALUE, withPrefixes); } @@ -305,7 +281,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * * @return this */ - @NotNull LineAppendable line(); + LineAppendable line(); /** * Add a new line, keep trailing spaces if there was any unterminated text appended @@ -315,7 +291,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * @param count number of trailing spaces to add * @return this */ - @NotNull LineAppendable lineWithTrailingSpaces(int count); + LineAppendable lineWithTrailingSpaces(int count); /** * Add a new line, if predicate is true and line() would add an EOL. @@ -323,14 +299,14 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * @param predicate call {@link #line()} if value is true. * @return this */ - @NotNull LineAppendable lineIf(boolean predicate); + LineAppendable lineIf(boolean predicate); /** * Add a blank line, if there is not one already appended. * * @return this */ - @NotNull LineAppendable blankLine(); + LineAppendable blankLine(); /** * Add a blank line, if predicate is true and there isn't already blank lines appended. @@ -338,7 +314,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * @param predicate when true append blank line * @return this */ - @NotNull LineAppendable blankLineIf(boolean predicate); + LineAppendable blankLineIf(boolean predicate); /** * Add a blank lines, if there isn't already given number of blank lines appended. @@ -347,7 +323,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * @param count number of blank lines to append * @return this */ - @NotNull LineAppendable blankLine(int count); + LineAppendable blankLine(int count); /** * @return true if in pre-formatted region @@ -360,14 +336,14 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * @param addPrefixToFirstLine if true will add the current prefix to first line * @return this */ - @NotNull LineAppendable openPreFormatted(boolean addPrefixToFirstLine); + LineAppendable openPreFormatted(boolean addPrefixToFirstLine); /** * Close preformatted section and suspend content modification * * @return this */ - @NotNull LineAppendable closePreFormatted(); + LineAppendable closePreFormatted(); /** * Increase the indent level, will terminate the current line if there is unterminated text @@ -377,7 +353,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * * @return this */ - @NotNull LineAppendable indent(); + LineAppendable indent(); /** * Decrease the indent level, min level is 0, will terminate the current line if there is unterminated text @@ -387,7 +363,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * * @return this */ - @NotNull LineAppendable unIndent(); + LineAppendable unIndent(); /** * Decrease the indent level, if there is unterminated text then unindented prefix @@ -399,14 +375,14 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * * @return this */ - @NotNull LineAppendable unIndentNoEol(); + LineAppendable unIndentNoEol(); /** * Get prefix appended after a new line character for every indent level * * @return char sequence of the current indent prefix used for each indent level */ - @NotNull BasedSequence getIndentPrefix(); + BasedSequence getIndentPrefix(); /** * Set prefix to append after a new line character for every indent level @@ -414,7 +390,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * @param prefix prefix characters for new lines appended after this is set * @return this */ - @NotNull LineAppendable setIndentPrefix(@Nullable CharSequence prefix); + LineAppendable setIndentPrefix(@Nullable CharSequence prefix); /** * Get prefix being applied to all lines, even in pre-formatted sections @@ -422,14 +398,14 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * * @return char sequence of the current prefix */ - @NotNull BasedSequence getPrefix(); + BasedSequence getPrefix(); /** * Get prefix used before EOL * * @return char sequence of the current prefix */ - @NotNull BasedSequence getBeforeEolPrefix(); + BasedSequence getBeforeEolPrefix(); /** * Add to prefix appended after a new line character for every line @@ -441,7 +417,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * @param afterEol if true prefix will take effect after EOL * @return this */ - @NotNull LineAppendable addPrefix(@NotNull CharSequence prefix, boolean afterEol); + LineAppendable addPrefix(CharSequence prefix, boolean afterEol); /** * Set prefix appended after a new line character for every line @@ -453,7 +429,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * @param afterEol if true prefix will take effect after EOL * @return this */ - @NotNull LineAppendable setPrefix(@Nullable CharSequence prefix, boolean afterEol); + LineAppendable setPrefix(@Nullable CharSequence prefix, boolean afterEol); /** * Add to prefix appended after a new line character for every line @@ -464,8 +440,7 @@ default LineAppendable append(@NotNull LineAppendable lineAppendable, boolean wi * @param prefix prefix characters to add to current prefix for new lines appended after this is set * @return this */ - @NotNull - default LineAppendable addPrefix(@NotNull CharSequence prefix) { + default LineAppendable addPrefix(CharSequence prefix) { return addPrefix(prefix, getPendingEOL() == 0); } @@ -478,8 +453,7 @@ default LineAppendable addPrefix(@NotNull CharSequence prefix) { * @param prefix prefix characters to add to current prefix for new lines appended after this is set * @return this */ - @NotNull - default LineAppendable setPrefix(@NotNull CharSequence prefix) { + default LineAppendable setPrefix(CharSequence prefix) { return setPrefix(prefix, getPendingEOL() == 0); } @@ -488,7 +462,7 @@ default LineAppendable setPrefix(@NotNull CharSequence prefix) { * * @return this */ - @NotNull LineAppendable pushPrefix(); + LineAppendable pushPrefix(); /** * Pop a prefix from the stack and set the current prefix @@ -496,14 +470,13 @@ default LineAppendable setPrefix(@NotNull CharSequence prefix) { * @param afterEol if true prefix will take effect after EOL * @return this */ - @NotNull LineAppendable popPrefix(boolean afterEol); + LineAppendable popPrefix(boolean afterEol); /** * Pop a prefix from the stack and set the current prefix * * @return this */ - @NotNull default LineAppendable popPrefix() { return popPrefix(false); } @@ -557,14 +530,12 @@ default LineAppendable popPrefix() { */ int getPendingEOL(); - @NotNull LineAppendable lineOnFirstText(boolean value); + LineAppendable lineOnFirstText(boolean value); - @NotNull default LineAppendable setLineOnFirstText() { return lineOnFirstText(true); } - @NotNull default LineAppendable clearLineOnFirstText() { return lineOnFirstText(false); } @@ -575,7 +546,7 @@ default LineAppendable clearLineOnFirstText() { * @param listener runnable to run if adding indent on first EOL * @return this */ - @NotNull LineAppendable addIndentOnFirstEOL(@NotNull Runnable listener); + LineAppendable addIndentOnFirstEOL(Runnable listener); /** * Remove runnable, has no effect if EOL was already appended and runnable was run @@ -583,7 +554,7 @@ default LineAppendable clearLineOnFirstText() { * @param listener runnable added with addIndentOnFirstEOL * @return this */ - @NotNull LineAppendable removeIndentOnFirstEOL(@NotNull Runnable listener); + LineAppendable removeIndentOnFirstEOL(Runnable listener); /** * Get the number of lines appended, not including any unterminated ones @@ -627,7 +598,6 @@ default boolean isNotEmpty() { * @param lineIndex line index for the info to get * @return line info */ - @NotNull LineInfo getLineInfo(int lineIndex); /** @@ -636,7 +606,6 @@ default boolean isNotEmpty() { * @param lineIndex line index * @return line info */ - @NotNull default LineInfo get(int lineIndex) { return getLineInfo(lineIndex); } @@ -649,7 +618,7 @@ default LineInfo get(int lineIndex) { * @param lineIndex line index * @return line char sequence */ - @NotNull BasedSequence getLine(int lineIndex); + BasedSequence getLine(int lineIndex); /** * Full line iterator @@ -657,7 +626,6 @@ default LineInfo get(int lineIndex) { * * @return iterator over lines */ - @NotNull @Override Iterator iterator(); @@ -672,25 +640,20 @@ default LineInfo get(int lineIndex) { * @param withPrefixes true if prefixes should be included, else only non-prefix line text * @return iterator over lines */ - @NotNull Iterable getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes); - @NotNull default Iterable getLines(int maxTrailingBlankLines) { return getLines(maxTrailingBlankLines, 0, Integer.MAX_VALUE, true); } - @NotNull default Iterable getLines() { return getLines(Integer.MAX_VALUE, 0, Integer.MAX_VALUE, true); } - @NotNull default Iterable getLines(int maxTrailingBlankLines, boolean withPrefixes) { return getLines(maxTrailingBlankLines, 0, Integer.MAX_VALUE, withPrefixes); } - @NotNull default Iterable getLines(boolean withPrefixes) { return getLines(Integer.MAX_VALUE, 0, Integer.MAX_VALUE, withPrefixes); } @@ -705,15 +668,12 @@ default Iterable getLines(boolean withPrefixes) { * @param endLine end line index, exclusive * @return iterator over lines */ - @NotNull Iterable getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine); - @NotNull default Iterable getLinesInfo(int maxTrailingBlankLines) { return getLinesInfo(maxTrailingBlankLines, 0, Integer.MAX_VALUE); } - @NotNull default Iterable getLinesInfo() { return getLinesInfo(Integer.MAX_VALUE, 0, Integer.MAX_VALUE); } @@ -724,7 +684,6 @@ default Iterable getLinesInfo() { * @param lineIndex line index * @return char sequence for the line */ - @NotNull default BasedSequence getLineContent(int lineIndex) { LineInfo lineInfo = getLineInfo(lineIndex); BasedSequence line = getLine(lineIndex); @@ -737,7 +696,6 @@ default BasedSequence getLineContent(int lineIndex) { * @param lineIndex line index * @return line prefix char sequence */ - @NotNull default BasedSequence getLinePrefix(int lineIndex) { LineInfo lineInfo = getLineInfo(lineIndex); BasedSequence line = getLine(lineIndex); @@ -759,7 +717,7 @@ default BasedSequence getLinePrefix(int lineIndex) { * @param prefix prefix of the line * @param text content text of the line */ - void setLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence text); + void setLine(int lineIndex, CharSequence prefix, CharSequence text); /** * Insert a line at the index with given content and prefix for a line @@ -768,9 +726,9 @@ default BasedSequence getLinePrefix(int lineIndex) { * @param prefix prefix of the line * @param text content text of the line */ - void insertLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence text); + void insertLine(int lineIndex, CharSequence prefix, CharSequence text); - @NotNull LineAppendable removeLines(int startLine, int endLine); + LineAppendable removeLines(int startLine, int endLine); /** * get the resulting text for all lines @@ -780,20 +738,16 @@ default BasedSequence getLinePrefix(int lineIndex) { * @param withPrefixes true if to include prefixes * @return resulting text */ - @NotNull String toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes); - @NotNull default String toString(int maxBlankLines, int maxTrailingBlankLines) { return toString(maxBlankLines, maxTrailingBlankLines, true); } - @NotNull default String toString(int maxBlankLines, boolean withPrefixes) { return toString(maxBlankLines, maxBlankLines, withPrefixes); } - @NotNull default String toString(boolean withPrefixes) { return toString(Integer.MAX_VALUE, Integer.MAX_VALUE, withPrefixes); } @@ -804,7 +758,6 @@ default String toString(boolean withPrefixes) { * @param maxBlankLines maximum blank lines to allow, if -1 then no trailing EOL will be generated * @return resulting text */ - @NotNull default String toString(int maxBlankLines) { return toString(maxBlankLines, maxBlankLines, true); } @@ -817,31 +770,26 @@ default String toString(int maxBlankLines) { * @param withPrefixes true if to include prefixes * @return resulting text */ - @NotNull CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes); - @NotNull default CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines) { return toSequence(maxBlankLines, maxTrailingBlankLines, true); } - @NotNull default CharSequence toSequence(int maxBlankLines, boolean withPrefixes) { return toSequence(maxBlankLines, maxBlankLines, withPrefixes); } - @NotNull default CharSequence toSequence(boolean withPrefixes) { return toSequence(Integer.MAX_VALUE, Integer.MAX_VALUE, withPrefixes); } - @NotNull default CharSequence toSequence() { return toSequence(Integer.MAX_VALUE, Integer.MAX_VALUE, true); } @Deprecated - default T appendTo(@NotNull T out, int maxTrailingBlankLines) throws IOException { + default T appendTo(T out, int maxTrailingBlankLines) throws IOException { return appendTo(out, Integer.MAX_VALUE, maxTrailingBlankLines); } @@ -860,13 +808,13 @@ default T appendTo(@NotNull T out, int maxTrailingBlankLi * @return out * @throws IOException if thrown by appendable */ - T appendTo(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException; + T appendTo(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException; - default T appendTo(@NotNull T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { + default T appendTo(T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { return appendTo(out, true, maxBlankLines, maxTrailingBlankLines, startLine, endLine); } - default T appendTo(@NotNull T out, int maxBlankLines, int maxTrailingBlankLines) throws IOException { + default T appendTo(T out, int maxBlankLines, int maxTrailingBlankLines) throws IOException { return appendTo(out, maxBlankLines, maxTrailingBlankLines, 0, Integer.MAX_VALUE); } @@ -878,11 +826,11 @@ default T appendTo(@NotNull T out, int maxBlankLines, int * @return out * @throws IOException thrown by {@code out}. */ - default T appendTo(@NotNull T out) throws IOException { + default T appendTo(T out) throws IOException { return appendTo(out, 0, 0, 0, Integer.MAX_VALUE); } - default T appendToSilently(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) { + default T appendToSilently(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) { try { appendTo(out, withPrefixes, maxBlankLines, maxTrailingBlankLines, startLine, endLine); } catch (IOException ignored) { @@ -891,17 +839,17 @@ default T appendToSilently(@NotNull T out, boolean withPr return out; } - default T appendToSilently(@NotNull T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) { + default T appendToSilently(T out, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) { appendToSilently(out, true, maxBlankLines, maxTrailingBlankLines, startLine, endLine); return out; } - default T appendToSilently(@NotNull T out, int maxBlankLines, int maxTrailingBlankLines) { + default T appendToSilently(T out, int maxBlankLines, int maxTrailingBlankLines) { appendToSilently(out, maxBlankLines, maxTrailingBlankLines, 0, Integer.MAX_VALUE); return out; } - default T appendToSilently(@NotNull T out) { + default T appendToSilently(T out) { return appendToSilently(out, 0, 0, 0, Integer.MAX_VALUE); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineAppendableImpl.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineAppendableImpl.java index 4dd591aa3..1ab0edc3a 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineAppendableImpl.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineAppendableImpl.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; import com.vladsch.flexmark.util.sequence.builder.StringSequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.IOException; import java.util.ArrayList; @@ -84,17 +83,15 @@ public LineAppendableImpl(@Nullable Appendable appendable, BitFieldSet } @Override - public @NotNull LineAppendable getEmptyAppendable() { + public LineAppendable getEmptyAppendable() { return new LineAppendableImpl(this, getOptions()); } - @NotNull @Override public BitFieldSet getOptionSet() { return options; } - @NotNull @Override public LineAppendable setOptions(int flags) { options.setAll(flags); @@ -102,13 +99,13 @@ public LineAppendable setOptions(int flags) { } @Override - public @NotNull LineAppendable pushOptions() { + public LineAppendable pushOptions() { optionStack.push(options.toInt()); return this; } @Override - public @NotNull LineAppendable popOptions() { + public LineAppendable popOptions() { if (optionStack.isEmpty()) { throw new IllegalStateException("Option stack is empty"); } @@ -118,7 +115,7 @@ public LineAppendable setOptions(int flags) { } @Override - public @NotNull LineAppendable changeOptions(int addFlags, int removeFlags) { + public LineAppendable changeOptions(int addFlags, int removeFlags) { if ((addFlags & removeFlags) != 0) { throw new IllegalStateException(String.format("Add flags:%d and remove flags:%d overlap:%d", addFlags, removeFlags, addFlags & removeFlags)); } @@ -147,13 +144,11 @@ private boolean isCollapseWhitespace() { return any(F_COLLAPSE_WHITESPACE); } - @NotNull @Override public BasedSequence getIndentPrefix() { return BasedSequence.of(indentPrefix); } - @NotNull @Override public LineAppendable setIndentPrefix(@Nullable CharSequence prefix) { indentPrefix = prefix == null ? BasedSequence.NULL : prefix; @@ -161,18 +156,17 @@ public LineAppendable setIndentPrefix(@Nullable CharSequence prefix) { } @Override - public @NotNull BasedSequence getPrefix() { + public BasedSequence getPrefix() { return BasedSequence.of(prefixAfterEol); } @Override - public @NotNull BasedSequence getBeforeEolPrefix() { + public BasedSequence getBeforeEolPrefix() { return BasedSequence.of(prefix); } - @NotNull @Override - public LineAppendable addPrefix(@NotNull CharSequence prefix, boolean afterEol) { + public LineAppendable addPrefix(CharSequence prefix, boolean afterEol) { if (!passThrough && prefix.length() != 0) { if (afterEol) { prefixAfterEol = LineAppendable.combinedPrefix(prefixAfterEol, prefix); @@ -188,7 +182,6 @@ public int getAfterEolPrefixDelta() { return prefixAfterEol.length() - prefix.length(); } - @NotNull @Override public LineAppendable setPrefix(@Nullable CharSequence prefix, boolean afterEol) { if (!passThrough) { @@ -202,7 +195,6 @@ public LineAppendable setPrefix(@Nullable CharSequence prefix, boolean afterEol) return this; } - @NotNull @Override public LineAppendable indent() { if (!passThrough) { @@ -228,7 +220,6 @@ private void rawUnIndent() { indentPrefixStack.pop(); } - @NotNull @Override public LineAppendable unIndent() { if (!passThrough) { @@ -238,7 +229,6 @@ public LineAppendable unIndent() { return this; } - @NotNull @Override public LineAppendable unIndentNoEol() { if (!passThrough) { @@ -254,7 +244,6 @@ public LineAppendable unIndentNoEol() { return this; } - @NotNull @Override public LineAppendable pushPrefix() { if (!passThrough) { @@ -264,7 +253,6 @@ public LineAppendable pushPrefix() { return this; } - @NotNull @Override public LineAppendable popPrefix(boolean afterEol) { if (!passThrough) { @@ -280,7 +268,6 @@ public LineAppendable popPrefix(boolean afterEol) { return this; } - @NotNull LineInfo getLastLineInfo() { return lines.isEmpty() ? LineInfo.NULL : lines.get(lines.size() - 1); } @@ -356,7 +343,7 @@ private void addLineRange(int start, int end, CharSequence prefix) { resetBuilder(); } - private void appendEol(@NotNull CharSequence eol) { + private void appendEol(CharSequence eol) { appendable.append(eol); int endOffset = appendable.length(); @@ -541,9 +528,8 @@ private void appendImpl(CharSequence csq, int start, int end) { } } - @NotNull @Override - public LineAppendable append(@NotNull CharSequence csq) { + public LineAppendable append(CharSequence csq) { if (csq.length() > 0) { appendImpl(csq, 0, csq.length()); } else { @@ -552,47 +538,40 @@ public LineAppendable append(@NotNull CharSequence csq) { return this; } - @NotNull @Override public ISequenceBuilder getBuilder() { return appendable.getBuilder(); } - @NotNull @Override - public LineAppendable append(@NotNull CharSequence csq, int start, int end) { + public LineAppendable append(CharSequence csq, int start, int end) { if (start < end) { appendImpl(csq, start, end); } return this; } - @NotNull @Override public LineAppendable append(char c) { appendImpl(Character.toString(c), 0); return this; } - @NotNull public LineAppendable append(char c, int count) { append(RepeatedSequence.repeatOf(c, count)); return this; } - @NotNull - public LineAppendable repeat(@NotNull CharSequence csq, int count) { + public LineAppendable repeat(CharSequence csq, int count) { append(RepeatedSequence.repeatOf(csq, count)); return this; } - @NotNull - public LineAppendable repeat(@NotNull CharSequence csq, int start, int end, int count) { + public LineAppendable repeat(CharSequence csq, int start, int end, int count) { append(RepeatedSequence.repeatOf(csq.subSequence(start, end), count)); return this; } - @NotNull @Override public LineAppendable line() { if (preFormattedNesting > 0 || appendable.length() != 0) { @@ -613,7 +592,6 @@ public LineAppendable line() { return this; } - @NotNull @Override public LineAppendable lineWithTrailingSpaces(int count) { if (preFormattedNesting > 0 || appendable.length() != 0) { @@ -626,14 +604,12 @@ public LineAppendable lineWithTrailingSpaces(int count) { return this; } - @NotNull @Override public LineAppendable lineIf(boolean predicate) { if (predicate) line(); return this; } - @NotNull @Override public LineAppendable blankLine() { line(); @@ -641,14 +617,12 @@ public LineAppendable blankLine() { return this; } - @NotNull @Override public LineAppendable blankLineIf(boolean predicate) { if (predicate) blankLine(); return this; } - @NotNull @Override public LineAppendable blankLine(int count) { line(); @@ -659,7 +633,6 @@ public LineAppendable blankLine(int count) { return this; } - @NotNull @Override public LineAppendable lineOnFirstText(boolean value) { if (value) eolOnFirstText++; @@ -667,16 +640,14 @@ public LineAppendable lineOnFirstText(boolean value) { return this; } - @NotNull @Override - public LineAppendable removeIndentOnFirstEOL(@NotNull Runnable listener) { + public LineAppendable removeIndentOnFirstEOL(Runnable listener) { indentsOnFirstEol.remove(listener); return this; } - @NotNull @Override - public LineAppendable addIndentOnFirstEOL(@NotNull Runnable listener) { + public LineAppendable addIndentOnFirstEOL(Runnable listener) { indentsOnFirstEol.add(listener); return this; } @@ -696,7 +667,6 @@ public int column() { return appendable.length(); } - @NotNull @Override public LineInfo getLineInfo(int lineIndex) { if (lineIndex == lines.size()) { @@ -719,7 +689,7 @@ public LineInfo getLineInfo(int lineIndex) { } @Override - public @NotNull BasedSequence getLine(int lineIndex) { + public BasedSequence getLine(int lineIndex) { return getLineInfo(lineIndex).getLine(); } @@ -761,7 +731,6 @@ public boolean isPreFormatted() { return preFormattedNesting > 0; } - @NotNull @Override public LineAppendable openPreFormatted(boolean addPrefixToFirstLine) { if (preFormattedNesting == 0) { @@ -775,7 +744,6 @@ public LineAppendable openPreFormatted(boolean addPrefixToFirstLine) { return this; } - @NotNull @Override public LineAppendable closePreFormatted() { if (preFormattedNesting <= 0) throw new IllegalStateException("closePreFormatted called with nesting == 0"); @@ -800,7 +768,6 @@ public String toString() { return out.toString(); } - @NotNull @Override public String toString(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { StringBuilder out = new StringBuilder(); @@ -812,7 +779,6 @@ public String toString(int maxBlankLines, int maxTrailingBlankLines, boolean wit return out.toString(); } - @NotNull @Override public CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boolean withPrefixes) { ISequenceBuilder out = getBuilder(); @@ -825,12 +791,12 @@ public CharSequence toSequence(int maxBlankLines, int maxTrailingBlankLines, boo } @Override - public T appendTo(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { + public T appendTo(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { line(); return appendToNoLine(out, withPrefixes, maxBlankLines, maxTrailingBlankLines, startLine, endLine); } - public T appendToNoLine(@NotNull T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { + public T appendToNoLine(T out, boolean withPrefixes, int maxBlankLines, int maxTrailingBlankLines, int startLine, int endLine) throws IOException { boolean tailEOL = maxTrailingBlankLines >= 0; maxBlankLines = Math.max(0, maxBlankLines); maxTrailingBlankLines = Math.max(0, maxTrailingBlankLines); @@ -875,9 +841,8 @@ public T appendToNoLine(@NotNull T out, boolean withPrefi return out; } - @NotNull @Override - public LineAppendable append(@NotNull LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes) { + public LineAppendable append(LineAppendable lineAppendable, int startLine, int endLine, boolean withPrefixes) { int iMax = Math.min(endLine, lineAppendable.getLineCountWithPending()); startLine = Math.max(0, startLine); @@ -950,7 +915,6 @@ void recomputeLineInfo(int startLine) { } } - @NotNull @Override public LineAppendable removeLines(int startLine, int endLine) { int useStartLine = removeLinesRaw(startLine, endLine); @@ -1018,7 +982,7 @@ public void setPrefixLength(int lineIndex, int prefixLength) { } } - private LineInfo createLineInfo(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence content) { + private LineInfo createLineInfo(int lineIndex, CharSequence prefix, CharSequence content) { LineInfo prevInfo = lineIndex == 0 ? LineInfo.NULL : lines.get(lineIndex - 1); LineInfo info = lineIndex == lines.size() ? LineInfo.NULL : lines.get(lineIndex); CharSequence text = content; @@ -1054,7 +1018,7 @@ private LineInfo createLineInfo(int lineIndex, @NotNull CharSequence prefix, @No } @Override - public void setLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence content) { + public void setLine(int lineIndex, CharSequence prefix, CharSequence content) { if (lineIndex == lines.size() && appendable.length() > 0) { line(); } @@ -1064,7 +1028,7 @@ public void setLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSe } @Override - public void insertLine(int lineIndex, @NotNull CharSequence prefix, @NotNull CharSequence content) { + public void insertLine(int lineIndex, CharSequence prefix, CharSequence content) { lines.add(lineIndex, createLineInfo(lineIndex, prefix, content)); this.recomputeLineInfo(lineIndex + 1); } @@ -1074,19 +1038,18 @@ int tailBlankLinesToRemove(int endLine, int maxTrailingBlankLines) { } static class IndexedLineInfoProxy implements Indexed { - final @NotNull LineAppendableImpl appendable; + final LineAppendableImpl appendable; final int startLine; final int endLine; final int maxTrailingBlankLines; - public IndexedLineInfoProxy(@NotNull LineAppendableImpl appendable, int maxTrailingBlankLines, int startLine, int endLine) { + public IndexedLineInfoProxy(LineAppendableImpl appendable, int maxTrailingBlankLines, int startLine, int endLine) { this.appendable = appendable; this.startLine = startLine; this.endLine = Math.min(endLine, appendable.getLineCountWithPending()); this.maxTrailingBlankLines = maxTrailingBlankLines; } - @NotNull @Override public LineInfo get(int index) { if (index + startLine >= endLine) @@ -1096,7 +1059,7 @@ public LineInfo get(int index) { } @Override - public void set(int index, @NotNull LineInfo item) { + public void set(int index, LineInfo item) { if (index + startLine >= endLine) throw new IndexOutOfBoundsException(String.format("index %d is out of valid range [%d, %d)", index, startLine, endLine)); @@ -1124,10 +1087,10 @@ public int modificationCount() { } static class IndexedLineProxy implements Indexed { - final @NotNull IndexedLineInfoProxy proxy; + final IndexedLineInfoProxy proxy; final boolean withPrefixes; - public IndexedLineProxy(@NotNull IndexedLineInfoProxy proxy, boolean withPrefixes) { + public IndexedLineProxy(IndexedLineInfoProxy proxy, boolean withPrefixes) { this.proxy = proxy; this.withPrefixes = withPrefixes; } @@ -1166,28 +1129,26 @@ public int modificationCount() { } } - @NotNull IndexedLineInfoProxy getIndexedLineInfoProxy(int maxTrailingBlankLines, int startLine, int endLine) { return new IndexedLineInfoProxy(this, maxTrailingBlankLines, startLine, endLine); } - @NotNull IndexedLineProxy getIndexedLineProxy(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) { return new IndexedLineProxy(getIndexedLineInfoProxy(maxTrailingBlankLines, startLine, endLine), withPrefixes); } @Override - public @NotNull Iterator iterator() { + public Iterator iterator() { return new IndexedItemIterator<>(getIndexedLineInfoProxy(MAX_VALUE, 0, getLineCount())); } @Override - public @NotNull Iterable getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) { + public Iterable getLines(int maxTrailingBlankLines, int startLine, int endLine, boolean withPrefixes) { return new IndexedItemIterable<>(getIndexedLineProxy(maxTrailingBlankLines, startLine, endLine, withPrefixes)); } @Override - public @NotNull Iterable getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine) { + public Iterable getLinesInfo(int maxTrailingBlankLines, int startLine, int endLine) { return new IndexedItemIterable<>(getIndexedLineInfoProxy(maxTrailingBlankLines, startLine, endLine)); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineInfo.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineInfo.java index db8999080..00e41f8ac 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineInfo.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/LineInfo.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.misc.BitField; import com.vladsch.flexmark.util.misc.BitFieldSet; import com.vladsch.flexmark.util.misc.Utils; -import org.jetbrains.annotations.NotNull; /** * Line information in LineAppendable @@ -39,7 +38,6 @@ public enum Preformatted { // System.out.println(String.format("Preformatted.%s ordinal: %d mask: %s", this.name(), this.ordinal(), Long.toBinaryString(this.mask))); } - @NotNull static Preformatted get(int flags) { int preformatted = flags & F_PREFORMATTED; @@ -70,7 +68,7 @@ static Preformatted get(int flags) { final public int sumLength; // total length of previous lines final public int flags; - private LineInfo(@NotNull CharSequence lineSeq, int index, int prefixLength, int textLength, int length, int sumPrefixLength, int sumTextLength, int sumLength, boolean isBlankPrefix, boolean isBlankText, @NotNull Preformatted preformatted) { + private LineInfo(CharSequence lineSeq, int index, int prefixLength, int textLength, int length, int sumPrefixLength, int sumTextLength, int sumLength, boolean isBlankPrefix, boolean isBlankText, Preformatted preformatted) { assert lineSeq == BasedSequence.NULL && index == -1 || prefixLength + textLength < length : "Line must be terminated by an EOL"; assert lineSeq.length() == length; @@ -115,7 +113,6 @@ public boolean isPreformatted() { return BitFieldSet.any(flags, F_PREFORMATTED); } - @NotNull public Preformatted getPreformatted() { return Preformatted.get(flags); } @@ -137,32 +134,26 @@ public int getTextEnd() { return prefixLength + textLength; } - @NotNull public BasedSequence getLine() { return lineSeq instanceof BasedSequence ? (BasedSequence) lineSeq : BasedSequence.of(lineSeq); } - @NotNull public BasedSequence getPrefix() { return getLine().subSequence(0, prefixLength); } - @NotNull public BasedSequence getTextNoEOL() { return getLine().subSequence(prefixLength, prefixLength + textLength); } - @NotNull public BasedSequence getText() { return getLine().subSequence(prefixLength, length); } - @NotNull public BasedSequence getLineNoEOL() { return getLine().subSequence(0, prefixLength + textLength); } - @NotNull public BasedSequence getEOL() { return getLine().subSequence(prefixLength + textLength, length); } @@ -182,13 +173,11 @@ public String toString() { '}'; } - @NotNull - public static LineInfo create(@NotNull CharSequence line, int prefixLength, int textLength, int length, boolean isBlankPrefix, boolean isBlankText, @NotNull Preformatted preformatted) { + public static LineInfo create(CharSequence line, int prefixLength, int textLength, int length, boolean isBlankPrefix, boolean isBlankText, Preformatted preformatted) { return new LineInfo(line, 0, prefixLength, textLength, length, 0, 0, 0, isBlankPrefix, isBlankText, preformatted); } - @NotNull - public static LineInfo create(@NotNull CharSequence line, @NotNull LineInfo prevInfo, int prefixLength, int textLength, int length, boolean isBlankPrefix, boolean isBlankText, @NotNull Preformatted preformatted) { + public static LineInfo create(CharSequence line, LineInfo prevInfo, int prefixLength, int textLength, int length, boolean isBlankPrefix, boolean isBlankText, Preformatted preformatted) { return new LineInfo( line, prevInfo.index + 1, @@ -204,8 +193,7 @@ public static LineInfo create(@NotNull CharSequence line, @NotNull LineInfo prev ); } - @NotNull - public static LineInfo create(@NotNull LineInfo prevInfo, @NotNull LineInfo info) { + public static LineInfo create(LineInfo prevInfo, LineInfo info) { return new LineInfo( info.lineSeq, prevInfo.index + 1, diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedBasedSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedBasedSequence.java index 44901ce3b..7f3caa480 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedBasedSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedBasedSequence.java @@ -4,8 +4,7 @@ import com.vladsch.flexmark.util.data.DataKeyBase; import com.vladsch.flexmark.util.sequence.builder.IBasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.mappers.CharMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A BasedSequence which maps characters according to CharMapper @@ -21,7 +20,6 @@ private MappedBasedSequence(BasedSequence baseSeq, CharMapper mapper) { this.mapper = mapper; } - @NotNull @Override public CharMapper getCharMapper() { return mapper; @@ -32,7 +30,6 @@ public char charAt(int index) { return mapper.map(baseSeq.charAt(index)); } - @NotNull @Override public BasedSequence getCharSequence() { return baseSeq; @@ -44,7 +41,7 @@ public int length() { } @Override - public @NotNull BasedSequence toMapped(CharMapper mapper) { + public BasedSequence toMapped(CharMapper mapper) { return mapper == CharMapper.IDENTITY ? this : new MappedBasedSequence(baseSeq, this.mapper.andThen(mapper)); } @@ -73,7 +70,6 @@ public T getOption(DataKeyBase dataKey) { return getBaseSequence().getOptions(); } - @NotNull @Override public BasedSequence sequenceOf(@Nullable CharSequence baseSeq, int startIndex, int endIndex) { if (baseSeq instanceof MappedBasedSequence) { @@ -81,7 +77,6 @@ public BasedSequence sequenceOf(@Nullable CharSequence baseSeq, int startIndex, } else return new MappedBasedSequence(this.baseSeq.sequenceOf(baseSeq, startIndex, endIndex), mapper); } - @NotNull @Override public BasedSequence subSequence(int startIndex, int endIndex) { SequenceUtils.validateStartEnd(startIndex, endIndex, length()); @@ -92,13 +87,11 @@ public BasedSequence subSequence(int startIndex, int endIndex) { return new MappedBasedSequence(baseSeq.subSequence(startIndex, endIndex), mapper); } - @NotNull @Override public Object getBase() { return baseSeq.getBase(); } - @NotNull @Override public BasedSequence getBaseSequence() { return baseSeq.getBaseSequence(); @@ -120,18 +113,16 @@ public int getIndexOffset(int index) { } @Override - public void addSegments(@NotNull IBasedSegmentBuilder builder) { + public void addSegments(IBasedSegmentBuilder builder) { BasedUtils.generateSegments(builder, this); } - @NotNull @Override public Range getSourceRange() { return baseSeq.getSourceRange(); } - @NotNull - public static BasedSequence mappedOf(@NotNull BasedSequence baseSeq, @NotNull CharMapper mapper) { + public static BasedSequence mappedOf(BasedSequence baseSeq, CharMapper mapper) { return new MappedBasedSequence(baseSeq, mapper); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedRichSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedRichSequence.java index 2b6908119..10a72f400 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedRichSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedRichSequence.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; import com.vladsch.flexmark.util.sequence.builder.RichSequenceBuilder; import com.vladsch.flexmark.util.sequence.mappers.CharMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A CharSequence that maps characters according to CharMapper @@ -20,13 +19,11 @@ private MappedRichSequence(CharMapper mapper, RichSequence baseSeq) { this.mapper = mapper; } - @NotNull @Override public CharMapper getCharMapper() { return mapper; } - @NotNull @Override public RichSequence getCharSequence() { return base; @@ -46,19 +43,16 @@ public int length() { return base.length(); } - @NotNull @Override public RichSequence[] emptyArray() { return base.emptyArray(); } - @NotNull @Override public RichSequence nullSequence() { return base.nullSequence(); } - @NotNull @Override public RichSequence sequenceOf(@Nullable CharSequence baseSeq, int startIndex, int endIndex) { if (baseSeq instanceof MappedRichSequence) { @@ -67,18 +61,16 @@ public RichSequence sequenceOf(@Nullable CharSequence baseSeq, int startIndex, i } @Override - public > @NotNull B getBuilder() { + public > B getBuilder() { //noinspection unchecked return (B) RichSequenceBuilder.emptyBuilder(); } - @NotNull @Override public RichSequence toMapped(CharMapper mapper) { return mapper == CharMapper.IDENTITY ? this : new MappedRichSequence(this.mapper.andThen(mapper), base); } - @NotNull @Override public RichSequence subSequence(int startIndex, int endIndex) { RichSequence baseSequence = base.subSequence(startIndex, endIndex); diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedSequence.java index 5135222af..bce4b2b25 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedSequence.java @@ -1,12 +1,11 @@ package com.vladsch.flexmark.util.sequence; import com.vladsch.flexmark.util.sequence.mappers.CharMapper; -import org.jetbrains.annotations.NotNull; /** * A CharSequence that maps characters according to CharMapper */ public interface MappedSequence extends CharSequence { - @NotNull CharMapper getCharMapper(); - @NotNull T getCharSequence(); + CharMapper getCharMapper(); + T getCharSequence(); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/PrefixedSubSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/PrefixedSubSequence.java index ccc213c00..ef7fa09b5 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/PrefixedSubSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/PrefixedSubSequence.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKeyBase; import com.vladsch.flexmark.util.sequence.builder.IBasedSegmentBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A BasedSequence with an out of scope of original char sequence prefix @@ -22,13 +21,11 @@ private PrefixedSubSequence(CharSequence prefix, BasedSequence baseSeq, int star this.base = baseSeq.subSequence(startIndex, endIndex); } - @NotNull @Override public Object getBase() { return base.getBase(); } - @NotNull @Override public BasedSequence getBaseSequence() { return base.getBaseSequence(); @@ -44,13 +41,11 @@ public int getEndOffset() { return base.getEndOffset(); } - @NotNull @Override public Range getSourceRange() { return base.getSourceRange(); } - @NotNull @Override public BasedSequence baseSubSequence(int startIndex, int endIndex) { return base.baseSubSequence(startIndex, endIndex); @@ -98,7 +93,7 @@ public int getIndexOffset(int index) { } @Override - public void addSegments(@NotNull IBasedSegmentBuilder builder) { + public void addSegments(IBasedSegmentBuilder builder) { if (prefix.length() != 0) { builder.append(base.getStartOffset(), base.getStartOffset()); builder.append(prefix.toString()); @@ -118,7 +113,6 @@ public char charAt(int index) { } } - @NotNull @Override public BasedSequence subSequence(int startIndex, int endIndex) { SequenceUtils.validateStartEnd(startIndex, endIndex, length()); @@ -138,7 +132,6 @@ public BasedSequence subSequence(int startIndex, int endIndex) { } } - @NotNull @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/Range.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/Range.java index 6f4ba2ba6..fcdb46d3e 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/Range.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/Range.java @@ -1,22 +1,18 @@ package com.vladsch.flexmark.util.sequence; -import org.jetbrains.annotations.NotNull; public class Range { final public static Range NULL = new Range(Integer.MAX_VALUE, Integer.MIN_VALUE); final public static Range EMPTY = new Range(0, 0); - @NotNull public static Range of(int start, int end) { return start == NULL.start && end == NULL.end ? NULL : new Range(start, end); } - @NotNull public static Range emptyOf(int position) { return new Range(position, position); } - @NotNull public static Range ofLength(int start, int length) { return new Range(start, start + length); } @@ -35,8 +31,7 @@ protected Range(int start, int end) { this.end = end; } - @NotNull - protected Range(@NotNull Range other) { + protected Range(Range other) { start = other.start; end = other.end; } @@ -86,8 +81,8 @@ protected Range(@NotNull Range other) { // TEST: // @formatter:off - public boolean contains(@NotNull Range other) { return end >= other.end && start <= other.start; } - public boolean doesContain(@NotNull Range other) { return end >= other.end && start <= other.start; } + public boolean contains(Range other) { return end >= other.end && start <= other.start; } + public boolean doesContain(Range other) { return end >= other.end && start <= other.start; } public boolean contains(int index) { return start <= index && index < end;} public boolean doesContain(int index) { return start <= index && index < end; } @@ -95,31 +90,31 @@ protected Range(@NotNull Range other) { public boolean contains(int start, int end) { return this.start <= start && end <= this.end;} public boolean doesContain(int start, int end) { return this.start <= start && end <= this.end;} - public boolean overlaps(@NotNull Range other) { return !(other.end <= start || other.start >= end); } - public boolean doesOverlap(@NotNull Range other) { return !(other.end <= start || other.start >= end); } - public boolean doesNotOverlap(@NotNull Range other) { return other.end <= start || other.start >= end; } + public boolean overlaps(Range other) { return !(other.end <= start || other.start >= end); } + public boolean doesOverlap(Range other) { return !(other.end <= start || other.start >= end); } + public boolean doesNotOverlap(Range other) { return other.end <= start || other.start >= end; } - public boolean overlapsOrAdjacent(@NotNull Range other) { return !(other.end < start || other.start > end); } - public boolean doesOverlapOrAdjacent(@NotNull Range other) { return !(other.end < start || other.start > end); } - public boolean doesNotOverlapOrAdjacent(@NotNull Range other) { return other.end < start || other.start > end; } - public boolean doesNotOverlapNorAdjacent(@NotNull Range other) { return other.end < start || other.start > end; } + public boolean overlapsOrAdjacent(Range other) { return !(other.end < start || other.start > end); } + public boolean doesOverlapOrAdjacent(Range other) { return !(other.end < start || other.start > end); } + public boolean doesNotOverlapOrAdjacent(Range other) { return other.end < start || other.start > end; } + public boolean doesNotOverlapNorAdjacent(Range other) { return other.end < start || other.start > end; } - public boolean properlyContains(@NotNull Range other) { return end > other.end && start < other.start; } - public boolean doesProperlyContain(@NotNull Range other) { return end > other.end && start < other.start; } + public boolean properlyContains(Range other) { return end > other.end && start < other.start; } + public boolean doesProperlyContain(Range other) { return end > other.end && start < other.start; } public boolean isAdjacent(int index) { return index == start - 1 || index == end;} public boolean isAdjacentAfter(int index) { return start - 1 == index;} public boolean isAdjacentBefore(int index) { return end == index;} - public boolean isAdjacent(@NotNull Range other) { return start == other.end || end == other.start;} - public boolean isAdjacentBefore(@NotNull Range other) { return end == other.start;} - public boolean isAdjacentAfter(@NotNull Range other) { return start == other.end;} + public boolean isAdjacent(Range other) { return start == other.end || end == other.start;} + public boolean isAdjacentBefore(Range other) { return end == other.start;} + public boolean isAdjacentAfter(Range other) { return start == other.end;} - public boolean isContainedBy(@NotNull Range other) { return other.end >= end && other.start <= start; } + public boolean isContainedBy(Range other) { return other.end >= end && other.start <= start; } public boolean isContainedBy(int start, int end) { return end >= this.end && start <= this.start; } - public boolean isProperlyContainedBy(@NotNull Range other) { return other.end > end && other.start < start; } + public boolean isProperlyContainedBy(Range other) { return other.end > end && other.start < start; } public boolean isProperlyContainedBy(int start, int end) { return end > this.end && start < this.start; } - public boolean isEqual(@NotNull Range other) { return end == other.end && start == other.start; } + public boolean isEqual(Range other) { return end == other.end && start == other.start; } public boolean isValidIndex(int index) { return index >= start && index <= end; } public boolean isStart(int index) { return index == start;} @@ -132,8 +127,7 @@ protected Range(@NotNull Range other) { public boolean trails(int index) { return index <= start;} // @formatter:on - @NotNull - public Range intersect(@NotNull Range other) { + public Range intersect(Range other) { int thisStart = Math.max(start, other.start); int thisEnd = Math.min(end, other.end); @@ -141,8 +135,7 @@ public Range intersect(@NotNull Range other) { return withRange(thisStart, thisEnd); } - @NotNull - public Range exclude(@NotNull Range other) { + public Range exclude(Range other) { int thisStart = start; if (thisStart >= other.start && thisStart < other.end) thisStart = other.end; @@ -153,7 +146,7 @@ public Range exclude(@NotNull Range other) { return withRange(thisStart, thisEnd); } - public int compare(@NotNull Range other) { + public int compare(Range other) { if (start < other.start) { return -1; } else if (start > other.start) { @@ -166,27 +159,22 @@ public int compare(@NotNull Range other) { return 0; } - @NotNull - public Range include(@NotNull Range other) { + public Range include(Range other) { return other.isNull() ? (this.isNull() ? NULL : this) : expandToInclude(other); } - @NotNull public Range include(int pos) { return include(pos, pos); } - @NotNull public Range include(int start, int end) { return this.isNull() ? Range.of(start, end) : expandToInclude(start, end); } - @NotNull - public Range expandToInclude(@NotNull Range other) { + public Range expandToInclude(Range other) { return expandToInclude(other.start, other.end); } - @NotNull public Range expandToInclude(int start, int end) { return withRange(Math.min(this.start, start), Math.max(this.end, end)); } @@ -198,41 +186,34 @@ public Range expandToInclude(int start, int end) { * @return resulting based subsequence * @deprecated use {@link #basedSubSequence(CharSequence)} instead */ - @NotNull @Deprecated - public BasedSequence subSequence(@NotNull CharSequence charSequence) { + public BasedSequence subSequence(CharSequence charSequence) { return basedSubSequence(charSequence); } - @NotNull - public BasedSequence basedSubSequence(@NotNull CharSequence charSequence) { + public BasedSequence basedSubSequence(CharSequence charSequence) { return BasedSequence.of(charSequence).subSequence(start, end); } - @NotNull - public BasedSequence basedSafeSubSequence(@NotNull CharSequence charSequence) { + public BasedSequence basedSafeSubSequence(CharSequence charSequence) { int end = Math.min(charSequence.length(), this.end); return isNull() ? BasedSequence.NULL : BasedSequence.of(charSequence).subSequence(Math.min(end, Math.max(0, start)), end); } - @NotNull - public RichSequence richSubSequence(@NotNull CharSequence charSequence) { + public RichSequence richSubSequence(CharSequence charSequence) { return RichSequence.of(charSequence.subSequence(start, end)); } - @NotNull - public RichSequence richSafeSubSequence(@NotNull CharSequence charSequence) { + public RichSequence richSafeSubSequence(CharSequence charSequence) { int end = Math.min(charSequence.length(), this.end); return isNull() ? RichSequence.NULL : RichSequence.of(charSequence, Math.min(end, Math.max(0, start)), end); } - @NotNull - public CharSequence charSubSequence(@NotNull CharSequence charSequence) { + public CharSequence charSubSequence(CharSequence charSequence) { return charSequence.subSequence(start, end); } - @NotNull - public CharSequence safeSubSequence(@NotNull CharSequence charSequence) { + public CharSequence safeSubSequence(CharSequence charSequence) { int end = Math.min(charSequence.length(), this.end); return isNull() ? charSequence.subSequence(0, 0) : charSequence.subSequence(Math.min(end, Math.max(0, start)), end); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RepeatedSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RepeatedSequence.java index e0dfec20a..c0140d2dc 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RepeatedSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RepeatedSequence.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.sequence; -import org.jetbrains.annotations.NotNull; /** * CharSequence that repeats in a wraparound the given sequence. @@ -65,7 +64,6 @@ public boolean equals(Object obj) { return obj == this || (obj instanceof CharSequence && toString().equals(obj.toString())); } - @NotNull @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -73,41 +71,34 @@ public String toString() { return sb.toString(); } - @NotNull public static CharSequence ofSpaces(int count) { return new RepeatedSequence(" ", 0, count); } - @NotNull public static CharSequence repeatOf(char c, int count) { return new RepeatedSequence(String.valueOf(c), 0, count); } - @NotNull - public static CharSequence repeatOf(@NotNull CharSequence chars, int count) { + public static CharSequence repeatOf(CharSequence chars, int count) { return new RepeatedSequence(chars, 0, chars.length() * count); } - @NotNull - public static CharSequence repeatOf(@NotNull CharSequence chars, int startIndex, int endIndex) { + public static CharSequence repeatOf(CharSequence chars, int startIndex, int endIndex) { return new RepeatedSequence(chars, startIndex, endIndex); } - @NotNull @Deprecated public static CharSequence of(char c, int count) { return repeatOf(c, count); } - @NotNull @Deprecated - public static CharSequence of(@NotNull CharSequence chars, int count) { + public static CharSequence of(CharSequence chars, int count) { return repeatOf(chars, count); } - @NotNull @Deprecated - public static CharSequence of(@NotNull CharSequence chars, int startIndex, int endIndex) { + public static CharSequence of(CharSequence chars, int startIndex, int endIndex) { return repeatOf(chars, startIndex, endIndex); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RichSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RichSequence.java index 0a7648b3b..de7e060a8 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RichSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RichSequence.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.sequence; -import org.jetbrains.annotations.NotNull; public interface RichSequence extends IRichSequence { RichSequence NULL = RichSequenceImpl.create("", 0, 0); @@ -18,23 +17,19 @@ static RichSequence of(CharSequence charSequence, int startIndex, int endIndex) return RichSequenceImpl.create(charSequence, startIndex, endIndex); } - @NotNull static RichSequence ofSpaces(int count) { return of(RepeatedSequence.ofSpaces(count)); } - @NotNull static RichSequence repeatOf(char c, int count) { return of(RepeatedSequence.repeatOf(String.valueOf(c), 0, count)); } - @NotNull - static RichSequence repeatOf(@NotNull CharSequence chars, int count) { + static RichSequence repeatOf(CharSequence chars, int count) { return of(RepeatedSequence.repeatOf(chars, 0, chars.length() * count)); } - @NotNull - static RichSequence repeatOf(@NotNull CharSequence chars, int startIndex, int endIndex) { + static RichSequence repeatOf(CharSequence chars, int startIndex, int endIndex) { return of(RepeatedSequence.repeatOf(chars, startIndex, endIndex)); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RichSequenceImpl.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RichSequenceImpl.java index e2d9042d5..1f0bc7eb6 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RichSequenceImpl.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RichSequenceImpl.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; import com.vladsch.flexmark.util.sequence.builder.RichSequenceBuilder; import com.vladsch.flexmark.util.sequence.mappers.CharMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A RichSequence implementation @@ -19,31 +18,27 @@ private RichSequenceImpl(CharSequence charSequence) { this.charSequence = charSequence; } - @NotNull @Override public RichSequence[] emptyArray() { return EMPTY_ARRAY; } - @NotNull @Override public RichSequence nullSequence() { return NULL; } - @NotNull @Override public RichSequence sequenceOf(@Nullable CharSequence charSequence, int startIndex, int endIndex) { return of(charSequence, startIndex, endIndex); } @Override - public > @NotNull B getBuilder() { + public > B getBuilder() { //noinspection unchecked return (B) RichSequenceBuilder.emptyBuilder(); } - @NotNull @Override public RichSequence subSequence(int startIndex, int endIndex) { SequenceUtils.validateStartEnd(startIndex, endIndex, length()); @@ -62,7 +57,6 @@ public char charAt(int index) { return c == SequenceUtils.NUL ? SequenceUtils.ENC_NUL : c; } - @NotNull @Override public RichSequence toMapped(CharMapper mapper) { return MappedRichSequence.mappedOf(mapper, this); diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequence.java index bd6b965ae..221cc81d0 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequence.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.util.data.DataKeyBase; import com.vladsch.flexmark.util.sequence.builder.BasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A BasedSequence which consists of segments of other BasedSequences @@ -36,13 +35,11 @@ protected SegmentedSequence(BasedSequence baseSeq, int startOffset, int endOffse this.length = length; } - @NotNull @Override final public Object getBase() { return baseSeq.getBase(); } - @NotNull @Override final public BasedSequence getBaseSequence() { return baseSeq; @@ -102,13 +99,11 @@ final public int length() { return length; } - @NotNull @Override final public Range getSourceRange() { return Range.of(getStartOffset(), getEndOffset()); } - @NotNull @Override final public BasedSequence baseSubSequence(int startIndex, int endIndex) { SequenceUtils.validateStartEnd(startIndex, endIndex, baseSeq.length()); @@ -131,7 +126,7 @@ final public BasedSequence baseSubSequence(int startIndex, int endIndex) { * all the segments were concatenated, while still maintaining * the original offset for each character when using {@link #getIndexOffset(int)}(int index) */ - public static BasedSequence create(BasedSequence basedSequence, @NotNull Iterable segments) { + public static BasedSequence create(BasedSequence basedSequence, Iterable segments) { return create(basedSequence.getBuilder().addAll(segments)); } @@ -168,7 +163,7 @@ public static BasedSequence create(SequenceBuilder builder) { * If you absolutely need to use the old method then use {@link SegmentedSequence#create(BasedSequence, Iterable)} */ @Deprecated - public static BasedSequence of(BasedSequence basedSequence, @NotNull Iterable segments) { + public static BasedSequence of(BasedSequence basedSequence, Iterable segments) { return create(basedSequence, segments); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceFull.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceFull.java index ed1d028e5..526df4d24 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceFull.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceFull.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.sequence; import com.vladsch.flexmark.util.sequence.builder.*; -import org.jetbrains.annotations.NotNull; /** * A BasedSequence which consists of segments of other BasedSequences @@ -29,7 +28,7 @@ public int getIndexOffset(int index) { } @Override - public void addSegments(@NotNull IBasedSegmentBuilder builder) { + public void addSegments(IBasedSegmentBuilder builder) { // FIX: clean up and optimize the structure. it is error prone and inefficient BasedUtils.generateSegments(builder, this); } @@ -52,7 +51,6 @@ public char charAt(int index) { } } - @NotNull @Override public BasedSequence subSequence(int startIndex, int endIndex) { SequenceUtils.validateStartEnd(startIndex, endIndex, length()); @@ -71,7 +69,7 @@ public BasedSequence subSequence(int startIndex, int endIndex) { * @param builder builder for which to construct segmented sequence * @return segmented sequence */ - public static SegmentedSequenceFull create(@NotNull BasedSequence baseSequence, ISegmentBuilder builder) { + public static SegmentedSequenceFull create(BasedSequence baseSequence, ISegmentBuilder builder) { BasedSequence baseSeq = baseSequence.getBaseSequence(); int length = builder.length(); int baseStartOffset = 0; @@ -202,7 +200,7 @@ private SegmentedSequenceFull subSequence(final BasedSequence baseSeq, final int * which does the builder calls for you. */ @Deprecated - public static BasedSequence of(BasedSequence basedSequence, @NotNull Iterable segments) { + public static BasedSequence of(BasedSequence basedSequence, Iterable segments) { return SegmentedSequence.create(basedSequence, segments); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceTree.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceTree.java index b7af17d5a..d5047bfb9 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceTree.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceTree.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.util.sequence.builder.tree.Segment; import com.vladsch.flexmark.util.sequence.builder.tree.SegmentTree; import com.vladsch.flexmark.util.sequence.builder.tree.SegmentTreeRange; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A BasedSequence which consists of segments of other BasedSequences @@ -22,11 +21,11 @@ final public class SegmentedSequenceTree extends SegmentedSequence { final private ThreadLocal cache = new ThreadLocal<>(); private static class Cache { - final @NotNull Segment segment; - final @NotNull CharSequence chars; + final Segment segment; + final CharSequence chars; final int indexDelta; - public Cache(@NotNull Segment segment, @NotNull CharSequence chars, int startIndex) { + public Cache(Segment segment, CharSequence chars, int startIndex) { this.segment = segment; this.chars = chars; indexDelta = startIndex - segment.getStartIndex(); @@ -41,7 +40,7 @@ public int charIndex(int index) { } } - private SegmentedSequenceTree(BasedSequence baseSeq, int startOffset, int endOffset, int length, @NotNull SegmentTree segmentTree) { + private SegmentedSequenceTree(BasedSequence baseSeq, int startOffset, int endOffset, int length, SegmentTree segmentTree) { super(baseSeq, startOffset, endOffset, length); this.segmentTree = segmentTree; startIndex = 0; @@ -49,7 +48,7 @@ private SegmentedSequenceTree(BasedSequence baseSeq, int startOffset, int endOff endPos = segmentTree.size(); } - private SegmentedSequenceTree(BasedSequence baseSeq, @NotNull SegmentTree segmentTree, @NotNull SegmentTreeRange subSequenceRange) { + private SegmentedSequenceTree(BasedSequence baseSeq, SegmentTree segmentTree, SegmentTreeRange subSequenceRange) { super(baseSeq, subSequenceRange.startOffset, subSequenceRange.endOffset, subSequenceRange.length); this.segmentTree = segmentTree; startIndex = subSequenceRange.startIndex; @@ -57,7 +56,6 @@ private SegmentedSequenceTree(BasedSequence baseSeq, @NotNull SegmentTree segmen endPos = subSequenceRange.endPos; } - @NotNull private Cache getCache(int index) { Cache cache = this.cache.get(); @@ -101,11 +99,10 @@ public int getIndexOffset(int index) { } @Override - public void addSegments(@NotNull IBasedSegmentBuilder builder) { + public void addSegments(IBasedSegmentBuilder builder) { segmentTree.addSegments(builder, startIndex, startIndex + length, startOffset, endOffset, startPos, endPos); } - @NotNull @Override public SegmentTree getSegmentTree() { return segmentTree; @@ -117,7 +114,6 @@ public char charAt(int index) { return getCache(index).charAt(index); } - @NotNull @Override public BasedSequence subSequence(int startIndex, int endIndex) { if (startIndex == 0 && endIndex == length) { @@ -136,7 +132,7 @@ public BasedSequence subSequence(int startIndex, int endIndex) { * @param builder builder containing segments for this sequence * @return segmented sequence */ - public static SegmentedSequenceTree create(@NotNull BasedSequence baseSeq, ISegmentBuilder builder) { + public static SegmentedSequenceTree create(BasedSequence baseSeq, ISegmentBuilder builder) { SegmentTree segmentTree = SegmentTree.build(builder.getSegments(), builder.getText()); if (baseSeq.anyOptions(F_COLLECT_SEGMENTED_STATS)) { diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SequenceUtils.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SequenceUtils.java index d89e20c78..4726c04c4 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SequenceUtils.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SequenceUtils.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.misc.Pair; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.text.NumberFormat; import java.text.ParsePosition; @@ -86,8 +85,7 @@ static Map getVisibleSpacesMap() { int[] EMPTY_INDICES = { }; - @NotNull - static T subSequence(@NotNull T thizz, int startIndex) { + static T subSequence(T thizz, int startIndex) { return (T) thizz.subSequence(startIndex, thizz.length()); } @@ -99,8 +97,7 @@ static T subSequence(@NotNull T thizz, int startIndex) * @param range range to get, coordinates offset form start of this sequence * @return sequence whose contents reflect the selected portion, if range.isNull() then this is returned */ - @NotNull - static T subSequence(@NotNull T thizz, @NotNull Range range) { + static T subSequence(T thizz, Range range) { return range.isNull() ? (T) thizz : (T) thizz.subSequence(range.getStart(), range.getEnd()); } @@ -113,7 +110,7 @@ static T subSequence(@NotNull T thizz, @NotNull Range r * @return sequence whose contents come before the selected range, if range.isNull() then null */ @Nullable - static T subSequenceBefore(@NotNull T thizz, @NotNull Range range) { + static T subSequenceBefore(T thizz, Range range) { return range.isNull() ? null : (T) thizz.subSequence(0, range.getStart()); } @@ -126,7 +123,7 @@ static T subSequenceBefore(@NotNull T thizz, @NotNull R * @return sequence whose contents come after the selected range, if range.isNull() then null */ @Nullable - static T subSequenceAfter(@NotNull T thizz, @NotNull Range range) { + static T subSequenceAfter(T thizz, Range range) { return range.isNull() ? null : (T) thizz.subSequence(range.getEnd(), thizz.length()); } @@ -138,44 +135,43 @@ static T subSequenceAfter(@NotNull T thizz, @NotNull Ra * @param range range to get, coordinates offset form start of this sequence * @return sequence whose contents come before and after the selected range, if range.isNull() then pair of nulls */ - @NotNull - static Pair subSequenceBeforeAfter(@NotNull T thizz, Range range) { + static Pair subSequenceBeforeAfter(T thizz, Range range) { return Pair.of(subSequenceBefore(thizz, range), subSequenceAfter(thizz, range)); } // @formatter:off - static boolean containsAny(@NotNull CharSequence thizz, @NotNull CharPredicate s) { return indexOfAny(thizz, s, 0, Integer.MAX_VALUE) != -1; } - static boolean containsAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int index) { return indexOfAny(thizz, s, index, Integer.MAX_VALUE) != -1; } - static boolean containsAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s) { return indexOfAny(thizz, s.negate(), 0, Integer.MAX_VALUE) != -1; } - static boolean containsAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s, int fromIndex) { return indexOfAny(thizz, s.negate(), fromIndex, Integer.MAX_VALUE) != -1; } - static boolean containsAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s, int fromIndex, int endIndex) { return indexOfAny(thizz, s.negate(), fromIndex, endIndex) != -1; } - - static int indexOf(@NotNull CharSequence thizz, @NotNull CharSequence s) { return indexOf(thizz, s, 0, Integer.MAX_VALUE); } - static int indexOf(@NotNull CharSequence thizz, @NotNull CharSequence s, int fromIndex) { return indexOf(thizz, s, fromIndex, Integer.MAX_VALUE); } - static int indexOf(@NotNull CharSequence thizz, char c) { return indexOf(thizz, c, 0, Integer.MAX_VALUE); } - static int indexOf(@NotNull CharSequence thizz, char c, int fromIndex) { return indexOf(thizz, c, fromIndex, Integer.MAX_VALUE); } - static int indexOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s) { return indexOfAny(thizz, s, 0, Integer.MAX_VALUE); } - static int indexOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int index) { return indexOfAny(thizz, s, index, Integer.MAX_VALUE); } - static int indexOfAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s) { return indexOfAny(thizz, s.negate(), 0, Integer.MAX_VALUE); } - static int indexOfAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s, int fromIndex) { return indexOfAny(thizz, s.negate(), fromIndex, Integer.MAX_VALUE); } - static int indexOfAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s, int fromIndex, int endIndex) { return indexOfAny(thizz, s.negate(), fromIndex, endIndex);} - static int indexOfNot(@NotNull CharSequence thizz, char c) { return indexOfNot(thizz, c, 0, Integer.MAX_VALUE); } - static int indexOfNot(@NotNull CharSequence thizz, char c, int fromIndex) { return indexOfNot(thizz, c, fromIndex, Integer.MAX_VALUE); } - - static int lastIndexOf(@NotNull CharSequence thizz, @NotNull CharSequence s) { return lastIndexOf(thizz, s, 0, Integer.MAX_VALUE); } - static int lastIndexOf(@NotNull CharSequence thizz, @NotNull CharSequence s, int fromIndex) { return lastIndexOf(thizz, s, 0, fromIndex); } - static int lastIndexOf(@NotNull CharSequence thizz, char c) { return lastIndexOf(thizz, c, 0, Integer.MAX_VALUE);} - static int lastIndexOf(@NotNull CharSequence thizz, char c, int fromIndex) { return lastIndexOf(thizz, c, 0, fromIndex);} - static int lastIndexOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s) { return lastIndexOfAny(thizz, s, 0, Integer.MAX_VALUE); } - static int lastIndexOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int fromIndex) { return lastIndexOfAny(thizz, s, 0, fromIndex); } - static int lastIndexOfAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s) { return lastIndexOfAny(thizz, s.negate(), 0, Integer.MAX_VALUE); } - static int lastIndexOfAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s, int fromIndex) { return lastIndexOfAny(thizz, s.negate(), 0, fromIndex); } - static int lastIndexOfAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s, int startIndex, int fromIndex) { return lastIndexOfAny(thizz, s.negate(), startIndex, fromIndex);} - static int lastIndexOfNot(@NotNull CharSequence thizz, char c) { return lastIndexOfNot(thizz, c, 0, Integer.MAX_VALUE); } - static int lastIndexOfNot(@NotNull CharSequence thizz, char c, int fromIndex) { return lastIndexOfNot(thizz, c, 0, fromIndex); } + static boolean containsAny(CharSequence thizz, CharPredicate s) { return indexOfAny(thizz, s, 0, Integer.MAX_VALUE) != -1; } + static boolean containsAny(CharSequence thizz, CharPredicate s, int index) { return indexOfAny(thizz, s, index, Integer.MAX_VALUE) != -1; } + static boolean containsAnyNot(CharSequence thizz, CharPredicate s) { return indexOfAny(thizz, s.negate(), 0, Integer.MAX_VALUE) != -1; } + static boolean containsAnyNot(CharSequence thizz, CharPredicate s, int fromIndex) { return indexOfAny(thizz, s.negate(), fromIndex, Integer.MAX_VALUE) != -1; } + static boolean containsAnyNot(CharSequence thizz, CharPredicate s, int fromIndex, int endIndex) { return indexOfAny(thizz, s.negate(), fromIndex, endIndex) != -1; } + + static int indexOf(CharSequence thizz, CharSequence s) { return indexOf(thizz, s, 0, Integer.MAX_VALUE); } + static int indexOf(CharSequence thizz, CharSequence s, int fromIndex) { return indexOf(thizz, s, fromIndex, Integer.MAX_VALUE); } + static int indexOf(CharSequence thizz, char c) { return indexOf(thizz, c, 0, Integer.MAX_VALUE); } + static int indexOf(CharSequence thizz, char c, int fromIndex) { return indexOf(thizz, c, fromIndex, Integer.MAX_VALUE); } + static int indexOfAny(CharSequence thizz, CharPredicate s) { return indexOfAny(thizz, s, 0, Integer.MAX_VALUE); } + static int indexOfAny(CharSequence thizz, CharPredicate s, int index) { return indexOfAny(thizz, s, index, Integer.MAX_VALUE); } + static int indexOfAnyNot(CharSequence thizz, CharPredicate s) { return indexOfAny(thizz, s.negate(), 0, Integer.MAX_VALUE); } + static int indexOfAnyNot(CharSequence thizz, CharPredicate s, int fromIndex) { return indexOfAny(thizz, s.negate(), fromIndex, Integer.MAX_VALUE); } + static int indexOfAnyNot(CharSequence thizz, CharPredicate s, int fromIndex, int endIndex) { return indexOfAny(thizz, s.negate(), fromIndex, endIndex);} + static int indexOfNot(CharSequence thizz, char c) { return indexOfNot(thizz, c, 0, Integer.MAX_VALUE); } + static int indexOfNot(CharSequence thizz, char c, int fromIndex) { return indexOfNot(thizz, c, fromIndex, Integer.MAX_VALUE); } + + static int lastIndexOf(CharSequence thizz, CharSequence s) { return lastIndexOf(thizz, s, 0, Integer.MAX_VALUE); } + static int lastIndexOf(CharSequence thizz, CharSequence s, int fromIndex) { return lastIndexOf(thizz, s, 0, fromIndex); } + static int lastIndexOf(CharSequence thizz, char c) { return lastIndexOf(thizz, c, 0, Integer.MAX_VALUE);} + static int lastIndexOf(CharSequence thizz, char c, int fromIndex) { return lastIndexOf(thizz, c, 0, fromIndex);} + static int lastIndexOfAny(CharSequence thizz, CharPredicate s) { return lastIndexOfAny(thizz, s, 0, Integer.MAX_VALUE); } + static int lastIndexOfAny(CharSequence thizz, CharPredicate s, int fromIndex) { return lastIndexOfAny(thizz, s, 0, fromIndex); } + static int lastIndexOfAnyNot(CharSequence thizz, CharPredicate s) { return lastIndexOfAny(thizz, s.negate(), 0, Integer.MAX_VALUE); } + static int lastIndexOfAnyNot(CharSequence thizz, CharPredicate s, int fromIndex) { return lastIndexOfAny(thizz, s.negate(), 0, fromIndex); } + static int lastIndexOfAnyNot(CharSequence thizz, CharPredicate s, int startIndex, int fromIndex) { return lastIndexOfAny(thizz, s.negate(), startIndex, fromIndex);} + static int lastIndexOfNot(CharSequence thizz, char c) { return lastIndexOfNot(thizz, c, 0, Integer.MAX_VALUE); } + static int lastIndexOfNot(CharSequence thizz, char c, int fromIndex) { return lastIndexOfNot(thizz, c, 0, fromIndex); } // @formatter:on - static int indexOf(@NotNull CharSequence thizz, char c, int fromIndex, int endIndex) { + static int indexOf(CharSequence thizz, char c, int fromIndex, int endIndex) { fromIndex = Math.max(fromIndex, 0); endIndex = Math.min(thizz.length(), endIndex); @@ -186,7 +182,7 @@ static int indexOf(@NotNull CharSequence thizz, char c, int fromIndex, int endIn } // TEST: - static int indexOf(@NotNull CharSequence thizz, @NotNull CharSequence s, int fromIndex, int endIndex) { + static int indexOf(CharSequence thizz, CharSequence s, int fromIndex, int endIndex) { fromIndex = Math.max(fromIndex, 0); int sMax = s.length(); @@ -208,7 +204,7 @@ static int indexOf(@NotNull CharSequence thizz, @NotNull CharSequence s, int fro return -1; } - static int lastIndexOf(@NotNull CharSequence thizz, char c, int startIndex, int fromIndex) { + static int lastIndexOf(CharSequence thizz, char c, int startIndex, int fromIndex) { fromIndex = Math.min(fromIndex, thizz.length() - 1); fromIndex++; @@ -220,7 +216,7 @@ static int lastIndexOf(@NotNull CharSequence thizz, char c, int startIndex, int return -1; } - static int indexOfNot(@NotNull CharSequence thizz, char c, int fromIndex, int endIndex) { + static int indexOfNot(CharSequence thizz, char c, int fromIndex, int endIndex) { fromIndex = Math.max(fromIndex, 0); endIndex = Math.min(endIndex, thizz.length()); @@ -230,7 +226,7 @@ static int indexOfNot(@NotNull CharSequence thizz, char c, int fromIndex, int en return -1; } - static int indexOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int fromIndex, int endIndex) { + static int indexOfAny(CharSequence thizz, CharPredicate s, int fromIndex, int endIndex) { fromIndex = Math.max(fromIndex, 0); endIndex = Math.min(endIndex, thizz.length()); @@ -242,7 +238,7 @@ static int indexOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int } // TEST: - static int lastIndexOf(@NotNull CharSequence thizz, @NotNull CharSequence s, int startIndex, int fromIndex) { + static int lastIndexOf(CharSequence thizz, CharSequence s, int startIndex, int fromIndex) { startIndex = Math.max(startIndex, 0); int sMax = s.length(); @@ -266,7 +262,7 @@ static int lastIndexOf(@NotNull CharSequence thizz, @NotNull CharSequence s, int } // TEST: - static int lastIndexOfNot(@NotNull CharSequence thizz, char c, int startIndex, int fromIndex) { + static int lastIndexOfNot(CharSequence thizz, char c, int startIndex, int fromIndex) { fromIndex = Math.min(fromIndex, thizz.length() - 1); fromIndex++; @@ -279,7 +275,7 @@ static int lastIndexOfNot(@NotNull CharSequence thizz, char c, int startIndex, i } // TEST: - static int lastIndexOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int startIndex, int fromIndex) { + static int lastIndexOfAny(CharSequence thizz, CharPredicate s, int startIndex, int fromIndex) { fromIndex = Math.min(fromIndex, thizz.length() - 1); fromIndex++; @@ -301,7 +297,7 @@ static int lastIndexOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, * @return true if character contents are equal */ @Contract(pure = true, value = "_, null -> false") - static boolean equals(@NotNull CharSequence thizz, Object o) { + static boolean equals(CharSequence thizz, Object o) { // do quick failure of equality if (o == thizz) return true; if (!(o instanceof CharSequence)) return false; @@ -325,7 +321,7 @@ static boolean equals(@NotNull CharSequence thizz, Object o) { } @Contract(pure = true) - static public int hashCode(@NotNull CharSequence thizz) { + static public int hashCode(CharSequence thizz) { int h = 0; int length = thizz.length(); if (length > 0) { @@ -393,7 +389,6 @@ static int compare(@Nullable CharSequence o1, @Nullable CharSequence o2, boolean return len1 - len2; } - @NotNull static String[] toStringArray(CharSequence... sequences) { String[] result = new String[sequences.length]; int i = 0; @@ -413,8 +408,7 @@ static int columnsToNextTabStop(int column) { return 4 - (column % 4); } - @NotNull - static int[] expandTo(@NotNull int[] indices, int length, int step) { + static int[] expandTo(int[] indices, int length, int step) { int remainder = length & step; int next = length + (remainder != 0 ? step : 0); if (indices.length < next) { @@ -425,8 +419,7 @@ static int[] expandTo(@NotNull int[] indices, int length, int step) { return indices; } - @NotNull - static int[] truncateTo(@NotNull int[] indices, int length) { + static int[] truncateTo(int[] indices, int length) { if (indices.length > length) { int[] replace = new int[length]; System.arraycopy(indices, 0, replace, 0, length); @@ -435,8 +428,7 @@ static int[] truncateTo(@NotNull int[] indices, int length) { return indices; } - @NotNull - static int[] indexOfAll(@NotNull CharSequence thizz, @NotNull CharSequence s) { + static int[] indexOfAll(CharSequence thizz, CharSequence s) { int length = s.length(); if (length == 0) return SequenceUtils.EMPTY_INDICES; int pos = indexOf(thizz, s); @@ -457,38 +449,38 @@ static int[] indexOfAll(@NotNull CharSequence thizz, @NotNull CharSequence s) { // TEST: // @formatter:off - static boolean matches(@NotNull CharSequence thizz, @NotNull CharSequence chars, boolean ignoreCase) { return chars.length() == thizz.length() && matchChars(thizz, chars, 0, ignoreCase); } - static boolean matches(@NotNull CharSequence thizz, @NotNull CharSequence chars) { return chars.length() == thizz.length() && matchChars(thizz, chars, 0, false); } - static boolean matchesIgnoreCase(@NotNull CharSequence thizz, @NotNull CharSequence chars) { return chars.length() == thizz.length() && matchChars(thizz, chars, 0, true); } - - static boolean matchChars(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex, boolean ignoreCase) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, true, ignoreCase) == chars.length(); } - static boolean matchChars(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex) { return matchChars(thizz, chars, startIndex, false); } - static boolean matchCharsIgnoreCase(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex) { return matchChars(thizz, chars, startIndex, true); } - - static boolean matchChars(@NotNull CharSequence thizz, @NotNull CharSequence chars, boolean ignoreCase) { return matchChars(thizz, chars, 0, ignoreCase); } - static boolean matchChars(@NotNull CharSequence thizz, @NotNull CharSequence chars) { return matchChars(thizz, chars, 0, false); } - static boolean matchCharsIgnoreCase(@NotNull CharSequence thizz, @NotNull CharSequence chars) { return matchChars(thizz, chars, 0, true); } - - static boolean matchCharsReversed(@NotNull CharSequence thizz, @NotNull CharSequence chars, int endIndex, boolean ignoreCase) { return endIndex + 1 >= chars.length() && matchChars(thizz, chars, endIndex + 1 - chars.length(), ignoreCase); } - static boolean matchCharsReversed(@NotNull CharSequence thizz, @NotNull CharSequence chars, int endIndex) { return endIndex + 1 >= chars.length() && matchChars(thizz, chars, endIndex + 1 - chars.length(), false); } - static boolean matchCharsReversedIgnoreCase(@NotNull CharSequence thizz, @NotNull CharSequence chars, int endIndex) { return endIndex + 1 >= chars.length() && matchChars(thizz, chars, endIndex + 1 - chars.length(), true); } - - static int matchedCharCount(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex, int endIndex, boolean ignoreCase) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, ignoreCase); } - static int matchedCharCount(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex, boolean ignoreCase) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, ignoreCase); } - static int matchedCharCount(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex, int endIndex) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, false); } - static int matchedCharCount(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, false); } - static int matchedCharCountIgnoreCase(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex, int endIndex) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, true); } - static int matchedCharCountIgnoreCase(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, true); } - - static int matchedCharCountReversed(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex, int fromIndex) { return matchedCharCountReversed(thizz, chars, startIndex, fromIndex, false); } - static int matchedCharCountReversedIgnoreCase(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex, int fromIndex) { return matchedCharCountReversed(thizz, chars, startIndex, fromIndex, true); } - - static int matchedCharCountReversed(@NotNull CharSequence thizz, @NotNull CharSequence chars, int fromIndex, boolean ignoreCase) { return matchedCharCountReversed(thizz, chars, 0, fromIndex, ignoreCase); } - static int matchedCharCountReversed(@NotNull CharSequence thizz, @NotNull CharSequence chars, int fromIndex) { return matchedCharCountReversed(thizz, chars, 0, fromIndex, false); } - static int matchedCharCountReversedIgnoreCase(@NotNull CharSequence thizz, @NotNull CharSequence chars, int fromIndex) { return matchedCharCountReversed(thizz, chars, 0, fromIndex, true); } + static boolean matches(CharSequence thizz, CharSequence chars, boolean ignoreCase) { return chars.length() == thizz.length() && matchChars(thizz, chars, 0, ignoreCase); } + static boolean matches(CharSequence thizz, CharSequence chars) { return chars.length() == thizz.length() && matchChars(thizz, chars, 0, false); } + static boolean matchesIgnoreCase(CharSequence thizz, CharSequence chars) { return chars.length() == thizz.length() && matchChars(thizz, chars, 0, true); } + + static boolean matchChars(CharSequence thizz, CharSequence chars, int startIndex, boolean ignoreCase) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, true, ignoreCase) == chars.length(); } + static boolean matchChars(CharSequence thizz, CharSequence chars, int startIndex) { return matchChars(thizz, chars, startIndex, false); } + static boolean matchCharsIgnoreCase(CharSequence thizz, CharSequence chars, int startIndex) { return matchChars(thizz, chars, startIndex, true); } + + static boolean matchChars(CharSequence thizz, CharSequence chars, boolean ignoreCase) { return matchChars(thizz, chars, 0, ignoreCase); } + static boolean matchChars(CharSequence thizz, CharSequence chars) { return matchChars(thizz, chars, 0, false); } + static boolean matchCharsIgnoreCase(CharSequence thizz, CharSequence chars) { return matchChars(thizz, chars, 0, true); } + + static boolean matchCharsReversed(CharSequence thizz, CharSequence chars, int endIndex, boolean ignoreCase) { return endIndex + 1 >= chars.length() && matchChars(thizz, chars, endIndex + 1 - chars.length(), ignoreCase); } + static boolean matchCharsReversed(CharSequence thizz, CharSequence chars, int endIndex) { return endIndex + 1 >= chars.length() && matchChars(thizz, chars, endIndex + 1 - chars.length(), false); } + static boolean matchCharsReversedIgnoreCase(CharSequence thizz, CharSequence chars, int endIndex) { return endIndex + 1 >= chars.length() && matchChars(thizz, chars, endIndex + 1 - chars.length(), true); } + + static int matchedCharCount(CharSequence thizz, CharSequence chars, int startIndex, int endIndex, boolean ignoreCase) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, ignoreCase); } + static int matchedCharCount(CharSequence thizz, CharSequence chars, int startIndex, boolean ignoreCase) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, ignoreCase); } + static int matchedCharCount(CharSequence thizz, CharSequence chars, int startIndex, int endIndex) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, false); } + static int matchedCharCount(CharSequence thizz, CharSequence chars, int startIndex) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, false); } + static int matchedCharCountIgnoreCase(CharSequence thizz, CharSequence chars, int startIndex, int endIndex) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, true); } + static int matchedCharCountIgnoreCase(CharSequence thizz, CharSequence chars, int startIndex) { return matchedCharCount(thizz, chars, startIndex, Integer.MAX_VALUE, false, true); } + + static int matchedCharCountReversed(CharSequence thizz, CharSequence chars, int startIndex, int fromIndex) { return matchedCharCountReversed(thizz, chars, startIndex, fromIndex, false); } + static int matchedCharCountReversedIgnoreCase(CharSequence thizz, CharSequence chars, int startIndex, int fromIndex) { return matchedCharCountReversed(thizz, chars, startIndex, fromIndex, true); } + + static int matchedCharCountReversed(CharSequence thizz, CharSequence chars, int fromIndex, boolean ignoreCase) { return matchedCharCountReversed(thizz, chars, 0, fromIndex, ignoreCase); } + static int matchedCharCountReversed(CharSequence thizz, CharSequence chars, int fromIndex) { return matchedCharCountReversed(thizz, chars, 0, fromIndex, false); } + static int matchedCharCountReversedIgnoreCase(CharSequence thizz, CharSequence chars, int fromIndex) { return matchedCharCountReversed(thizz, chars, 0, fromIndex, true); } // @formatter:on - static int matchedCharCount(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex, int endIndex, boolean fullMatchOnly, boolean ignoreCase) { + static int matchedCharCount(CharSequence thizz, CharSequence chars, int startIndex, int endIndex, boolean fullMatchOnly, boolean ignoreCase) { int length = chars.length(); endIndex = Math.min(thizz.length(), endIndex); int iMax = Math.min(endIndex - startIndex, length); @@ -523,7 +515,7 @@ static int matchedCharCount(@NotNull CharSequence thizz, @NotNull CharSequence c } // TEST: - static int matchedCharCountReversed(@NotNull CharSequence thizz, @NotNull CharSequence chars, int startIndex, int fromIndex, boolean ignoreCase) { + static int matchedCharCountReversed(CharSequence thizz, CharSequence chars, int startIndex, int fromIndex, boolean ignoreCase) { startIndex = Math.max(0, startIndex); fromIndex = Math.max(0, Math.min(thizz.length(), fromIndex)); @@ -560,21 +552,21 @@ static int matchedCharCountReversed(@NotNull CharSequence thizz, @NotNull CharSe } // @formatter:off - static int countOfSpaceTab(@NotNull CharSequence thizz) { return countOfAny(thizz, CharPredicate.SPACE_TAB, 0, Integer.MAX_VALUE); } - static int countOfNotSpaceTab(@NotNull CharSequence thizz) { return countOfAny(thizz, CharPredicate.SPACE_TAB.negate(), 0, Integer.MAX_VALUE); } + static int countOfSpaceTab(CharSequence thizz) { return countOfAny(thizz, CharPredicate.SPACE_TAB, 0, Integer.MAX_VALUE); } + static int countOfNotSpaceTab(CharSequence thizz) { return countOfAny(thizz, CharPredicate.SPACE_TAB.negate(), 0, Integer.MAX_VALUE); } - static int countOfWhitespace(@NotNull CharSequence thizz) { return countOfAny(thizz, CharPredicate.WHITESPACE, Integer.MAX_VALUE); } - static int countOfNotWhitespace(@NotNull CharSequence thizz) { return countOfAny(thizz, CharPredicate.WHITESPACE.negate(), 0, Integer.MAX_VALUE); } + static int countOfWhitespace(CharSequence thizz) { return countOfAny(thizz, CharPredicate.WHITESPACE, Integer.MAX_VALUE); } + static int countOfNotWhitespace(CharSequence thizz) { return countOfAny(thizz, CharPredicate.WHITESPACE.negate(), 0, Integer.MAX_VALUE); } - static int countOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int fromIndex) { return countOfAny(thizz, chars, fromIndex, Integer.MAX_VALUE); } - static int countOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return countOfAny(thizz, chars, 0, Integer.MAX_VALUE); } + static int countOfAny(CharSequence thizz, CharPredicate chars, int fromIndex) { return countOfAny(thizz, chars, fromIndex, Integer.MAX_VALUE); } + static int countOfAny(CharSequence thizz, CharPredicate chars) { return countOfAny(thizz, chars, 0, Integer.MAX_VALUE); } - static int countOfAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int fromIndex, int endIndex) { return countOfAny(thizz, chars.negate(), fromIndex, endIndex); } - static int countOfAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int fromIndex) { return countOfAny(thizz, chars.negate(), fromIndex, Integer.MAX_VALUE); } - static int countOfAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return countOfAny(thizz, chars.negate(), 0, Integer.MAX_VALUE); } + static int countOfAnyNot(CharSequence thizz, CharPredicate chars, int fromIndex, int endIndex) { return countOfAny(thizz, chars.negate(), fromIndex, endIndex); } + static int countOfAnyNot(CharSequence thizz, CharPredicate chars, int fromIndex) { return countOfAny(thizz, chars.negate(), fromIndex, Integer.MAX_VALUE); } + static int countOfAnyNot(CharSequence thizz, CharPredicate chars) { return countOfAny(thizz, chars.negate(), 0, Integer.MAX_VALUE); } // @formatter:on - static int countOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int fromIndex, int endIndex) { + static int countOfAny(CharSequence thizz, CharPredicate s, int fromIndex, int endIndex) { fromIndex = Math.max(fromIndex, 0); endIndex = Math.min(endIndex, thizz.length()); @@ -587,63 +579,63 @@ static int countOfAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int } // @formatter:off - static int countLeadingSpace(@NotNull CharSequence thizz) { return countLeading(thizz, CharPredicate.SPACE, 0, Integer.MAX_VALUE); } - static int countLeadingSpace(@NotNull CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.SPACE, startIndex, Integer.MAX_VALUE); } - static int countLeadingSpace(@NotNull CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.SPACE, startIndex, endIndex); } - static int countLeadingNotSpace(@NotNull CharSequence thizz) { return countLeading(thizz, CharPredicate.SPACE.negate(), 0, Integer.MAX_VALUE); } - static int countLeadingNotSpace(@NotNull CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.SPACE.negate(), startIndex, Integer.MAX_VALUE); } - static int countLeadingNotSpace(@NotNull CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.SPACE.negate(), startIndex, endIndex); } - - static int countTrailingSpace(@NotNull CharSequence thizz) { return countTrailing(thizz, CharPredicate.SPACE, 0, Integer.MAX_VALUE); } - static int countTrailingSpace(@NotNull CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE, 0, fromIndex); } - static int countTrailingSpace(@NotNull CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE, startIndex, fromIndex); } - static int countTrailingNotSpace(@NotNull CharSequence thizz) { return countTrailing(thizz, CharPredicate.SPACE.negate(), 0, Integer.MAX_VALUE); } - static int countTrailingNotSpace(@NotNull CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE.negate(), 0, fromIndex); } - static int countTrailingNotSpace(@NotNull CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE.negate(), startIndex, fromIndex); } - - static int countLeadingSpaceTab(@NotNull CharSequence thizz) { return countLeading(thizz, CharPredicate.SPACE_TAB, 0, Integer.MAX_VALUE); } - static int countLeadingSpaceTab(@NotNull CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.SPACE_TAB, startIndex, Integer.MAX_VALUE); } - static int countLeadingSpaceTab(@NotNull CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.SPACE_TAB, startIndex, endIndex); } - static int countLeadingNotSpaceTab(@NotNull CharSequence thizz) { return countLeading(thizz, CharPredicate.SPACE_TAB.negate(), 0, Integer.MAX_VALUE); } - static int countLeadingNotSpaceTab(@NotNull CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.SPACE_TAB.negate(), startIndex, Integer.MAX_VALUE); } - static int countLeadingNotSpaceTab(@NotNull CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.SPACE_TAB.negate(), startIndex, endIndex); } - - static int countTrailingSpaceTab(@NotNull CharSequence thizz) { return countTrailing(thizz, CharPredicate.SPACE_TAB, 0, Integer.MAX_VALUE); } - static int countTrailingSpaceTab(@NotNull CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE_TAB, 0, fromIndex); } - static int countTrailingSpaceTab(@NotNull CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE_TAB, startIndex, fromIndex); } - static int countTrailingNotSpaceTab(@NotNull CharSequence thizz) { return countTrailing(thizz, CharPredicate.SPACE_TAB.negate(), 0, Integer.MAX_VALUE); } - static int countTrailingNotSpaceTab(@NotNull CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE_TAB.negate(), 0, fromIndex); } - static int countTrailingNotSpaceTab(@NotNull CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE_TAB.negate(), startIndex, fromIndex); } - - static int countLeadingWhitespace(@NotNull CharSequence thizz) { return countLeading(thizz, CharPredicate.WHITESPACE, 0, Integer.MAX_VALUE); } - static int countLeadingWhitespace(@NotNull CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.WHITESPACE, startIndex, Integer.MAX_VALUE); } - static int countLeadingWhitespace(@NotNull CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.WHITESPACE, startIndex, endIndex); } - static int countLeadingNotWhitespace(@NotNull CharSequence thizz) { return countLeading(thizz, CharPredicate.WHITESPACE.negate(), 0, Integer.MAX_VALUE); } - static int countLeadingNotWhitespace(@NotNull CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.WHITESPACE.negate(), startIndex, Integer.MAX_VALUE); } - static int countLeadingNotWhitespace(@NotNull CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.WHITESPACE.negate(), startIndex, endIndex); } - - static int countTrailingWhitespace(@NotNull CharSequence thizz) { return countTrailing(thizz, CharPredicate.WHITESPACE, 0, Integer.MAX_VALUE); } - static int countTrailingWhitespace(@NotNull CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.WHITESPACE, 0, fromIndex); } - static int countTrailingWhitespace(@NotNull CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.WHITESPACE, startIndex, fromIndex); } - static int countTrailingNotWhitespace(@NotNull CharSequence thizz) { return countTrailing(thizz, CharPredicate.WHITESPACE.negate(), 0, Integer.MAX_VALUE); } - static int countTrailingNotWhitespace(@NotNull CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.WHITESPACE.negate(), 0, fromIndex); } - static int countTrailingNotWhitespace(@NotNull CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.WHITESPACE.negate(), startIndex, fromIndex); } - - static int countLeading(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return countLeading(thizz, chars, 0, Integer.MAX_VALUE); } - static int countLeading(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int fromIndex) { return countLeading(thizz, chars, fromIndex, Integer.MAX_VALUE); } - static int countLeadingNot(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return countLeading(thizz, chars.negate(), 0, Integer.MAX_VALUE); } - static int countLeadingNot(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int fromIndex) { return countLeading(thizz, chars.negate(), fromIndex, Integer.MAX_VALUE); } - - static int countTrailing(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return countTrailing(thizz, chars, 0, Integer.MAX_VALUE); } - static int countTrailing(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int fromIndex) { return countTrailing(thizz, chars, 0, fromIndex); } - static int countTrailingNot(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return countTrailing(thizz, chars.negate(), 0, Integer.MAX_VALUE); } - static int countTrailingNot(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int fromIndex) { return countTrailing(thizz, chars.negate(), 0, fromIndex); } - - static int countLeadingNot(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int startIndex, int endIndex) { return countLeading(thizz, chars.negate(), startIndex, endIndex); } - static int countTrailingNot(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int startIndex, int endIndex) { return countTrailing(thizz, chars.negate(), startIndex, endIndex); } + static int countLeadingSpace(CharSequence thizz) { return countLeading(thizz, CharPredicate.SPACE, 0, Integer.MAX_VALUE); } + static int countLeadingSpace(CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.SPACE, startIndex, Integer.MAX_VALUE); } + static int countLeadingSpace(CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.SPACE, startIndex, endIndex); } + static int countLeadingNotSpace(CharSequence thizz) { return countLeading(thizz, CharPredicate.SPACE.negate(), 0, Integer.MAX_VALUE); } + static int countLeadingNotSpace(CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.SPACE.negate(), startIndex, Integer.MAX_VALUE); } + static int countLeadingNotSpace(CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.SPACE.negate(), startIndex, endIndex); } + + static int countTrailingSpace(CharSequence thizz) { return countTrailing(thizz, CharPredicate.SPACE, 0, Integer.MAX_VALUE); } + static int countTrailingSpace(CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE, 0, fromIndex); } + static int countTrailingSpace(CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE, startIndex, fromIndex); } + static int countTrailingNotSpace(CharSequence thizz) { return countTrailing(thizz, CharPredicate.SPACE.negate(), 0, Integer.MAX_VALUE); } + static int countTrailingNotSpace(CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE.negate(), 0, fromIndex); } + static int countTrailingNotSpace(CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE.negate(), startIndex, fromIndex); } + + static int countLeadingSpaceTab(CharSequence thizz) { return countLeading(thizz, CharPredicate.SPACE_TAB, 0, Integer.MAX_VALUE); } + static int countLeadingSpaceTab(CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.SPACE_TAB, startIndex, Integer.MAX_VALUE); } + static int countLeadingSpaceTab(CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.SPACE_TAB, startIndex, endIndex); } + static int countLeadingNotSpaceTab(CharSequence thizz) { return countLeading(thizz, CharPredicate.SPACE_TAB.negate(), 0, Integer.MAX_VALUE); } + static int countLeadingNotSpaceTab(CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.SPACE_TAB.negate(), startIndex, Integer.MAX_VALUE); } + static int countLeadingNotSpaceTab(CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.SPACE_TAB.negate(), startIndex, endIndex); } + + static int countTrailingSpaceTab(CharSequence thizz) { return countTrailing(thizz, CharPredicate.SPACE_TAB, 0, Integer.MAX_VALUE); } + static int countTrailingSpaceTab(CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE_TAB, 0, fromIndex); } + static int countTrailingSpaceTab(CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE_TAB, startIndex, fromIndex); } + static int countTrailingNotSpaceTab(CharSequence thizz) { return countTrailing(thizz, CharPredicate.SPACE_TAB.negate(), 0, Integer.MAX_VALUE); } + static int countTrailingNotSpaceTab(CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE_TAB.negate(), 0, fromIndex); } + static int countTrailingNotSpaceTab(CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.SPACE_TAB.negate(), startIndex, fromIndex); } + + static int countLeadingWhitespace(CharSequence thizz) { return countLeading(thizz, CharPredicate.WHITESPACE, 0, Integer.MAX_VALUE); } + static int countLeadingWhitespace(CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.WHITESPACE, startIndex, Integer.MAX_VALUE); } + static int countLeadingWhitespace(CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.WHITESPACE, startIndex, endIndex); } + static int countLeadingNotWhitespace(CharSequence thizz) { return countLeading(thizz, CharPredicate.WHITESPACE.negate(), 0, Integer.MAX_VALUE); } + static int countLeadingNotWhitespace(CharSequence thizz, int startIndex) { return countLeading(thizz, CharPredicate.WHITESPACE.negate(), startIndex, Integer.MAX_VALUE); } + static int countLeadingNotWhitespace(CharSequence thizz, int startIndex, int endIndex) { return countLeading(thizz, CharPredicate.WHITESPACE.negate(), startIndex, endIndex); } + + static int countTrailingWhitespace(CharSequence thizz) { return countTrailing(thizz, CharPredicate.WHITESPACE, 0, Integer.MAX_VALUE); } + static int countTrailingWhitespace(CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.WHITESPACE, 0, fromIndex); } + static int countTrailingWhitespace(CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.WHITESPACE, startIndex, fromIndex); } + static int countTrailingNotWhitespace(CharSequence thizz) { return countTrailing(thizz, CharPredicate.WHITESPACE.negate(), 0, Integer.MAX_VALUE); } + static int countTrailingNotWhitespace(CharSequence thizz, int fromIndex) { return countTrailing(thizz, CharPredicate.WHITESPACE.negate(), 0, fromIndex); } + static int countTrailingNotWhitespace(CharSequence thizz, int startIndex, int fromIndex) { return countTrailing(thizz, CharPredicate.WHITESPACE.negate(), startIndex, fromIndex); } + + static int countLeading(CharSequence thizz, CharPredicate chars) { return countLeading(thizz, chars, 0, Integer.MAX_VALUE); } + static int countLeading(CharSequence thizz, CharPredicate chars, int fromIndex) { return countLeading(thizz, chars, fromIndex, Integer.MAX_VALUE); } + static int countLeadingNot(CharSequence thizz, CharPredicate chars) { return countLeading(thizz, chars.negate(), 0, Integer.MAX_VALUE); } + static int countLeadingNot(CharSequence thizz, CharPredicate chars, int fromIndex) { return countLeading(thizz, chars.negate(), fromIndex, Integer.MAX_VALUE); } + + static int countTrailing(CharSequence thizz, CharPredicate chars) { return countTrailing(thizz, chars, 0, Integer.MAX_VALUE); } + static int countTrailing(CharSequence thizz, CharPredicate chars, int fromIndex) { return countTrailing(thizz, chars, 0, fromIndex); } + static int countTrailingNot(CharSequence thizz, CharPredicate chars) { return countTrailing(thizz, chars.negate(), 0, Integer.MAX_VALUE); } + static int countTrailingNot(CharSequence thizz, CharPredicate chars, int fromIndex) { return countTrailing(thizz, chars.negate(), 0, fromIndex); } + + static int countLeadingNot(CharSequence thizz, CharPredicate chars, int startIndex, int endIndex) { return countLeading(thizz, chars.negate(), startIndex, endIndex); } + static int countTrailingNot(CharSequence thizz, CharPredicate chars, int startIndex, int endIndex) { return countTrailing(thizz, chars.negate(), startIndex, endIndex); } // @formatter:on - static int countLeading(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int fromIndex, int endIndex) { + static int countLeading(CharSequence thizz, CharPredicate chars, int fromIndex, int endIndex) { endIndex = Math.min(endIndex, thizz.length()); fromIndex = rangeLimit(fromIndex, 0, endIndex); @@ -651,7 +643,7 @@ static int countLeading(@NotNull CharSequence thizz, @NotNull CharPredicate char return index == -1 ? endIndex - fromIndex : index - fromIndex; } - static int countLeadingColumns(@NotNull CharSequence thizz, int startColumn, @NotNull CharPredicate chars) { + static int countLeadingColumns(CharSequence thizz, int startColumn, CharPredicate chars) { int fromIndex = 0; int endIndex = thizz.length(); int index = indexOfAnyNot(thizz, chars, fromIndex, endIndex); @@ -672,7 +664,7 @@ static int countLeadingColumns(@NotNull CharSequence thizz, int startColumn, @No } // TEST: this - static int countTrailing(@NotNull CharSequence thizz, @NotNull CharPredicate chars, int startIndex, int fromIndex) { + static int countTrailing(CharSequence thizz, CharPredicate chars, int startIndex, int fromIndex) { fromIndex = Math.min(fromIndex, thizz.length()); startIndex = rangeLimit(startIndex, 0, fromIndex); @@ -681,60 +673,57 @@ static int countTrailing(@NotNull CharSequence thizz, @NotNull CharPredicate cha } // @formatter:off - @NotNull static T trimStart(@NotNull T thizz, @NotNull CharPredicate chars) { return subSequence(thizz, trimStartRange(thizz, 0, chars)); } - @Nullable static T trimmedStart(@NotNull T thizz, @NotNull CharPredicate chars) { return trimmedStart(thizz, 0, chars); } - @NotNull static T trimEnd(@NotNull T thizz, @NotNull CharPredicate chars) { return trimEnd(thizz, 0, chars); } - @Nullable static T trimmedEnd(@NotNull T thizz, @NotNull CharPredicate chars) { return trimmedEnd(thizz, 0, chars); } - @NotNull static T trim(@NotNull T thizz, @NotNull CharPredicate chars) { return trim(thizz, 0, chars); } - @NotNull static Pair trimmed(@NotNull T thizz, @NotNull CharPredicate chars) { return trimmed(thizz, 0, chars); } - @NotNull static T trimStart(@NotNull T thizz, int keep) { return trimStart(thizz, keep, CharPredicate.WHITESPACE); } - @Nullable static T trimmedStart(@NotNull T thizz, int keep) { return trimmedStart(thizz, keep, CharPredicate.WHITESPACE); } - @NotNull static T trimEnd(@NotNull T thizz, int keep) { return trimEnd(thizz, keep, CharPredicate.WHITESPACE); } - @Nullable static T trimmedEnd(@NotNull T thizz, int keep) { return trimmedEnd(thizz, keep, CharPredicate.WHITESPACE); } - @NotNull static T trim(@NotNull T thizz, int keep) { return trim(thizz, keep, CharPredicate.WHITESPACE); } - @NotNull static Pair trimmed(@NotNull T thizz, int keep) { return trimmed(thizz, keep, CharPredicate.WHITESPACE); } - @NotNull static T trimStart(@NotNull T thizz) { return trimStart(thizz, 0, CharPredicate.WHITESPACE); } - @Nullable static T trimmedStart(@NotNull T thizz) { return trimmedStart(thizz, 0, CharPredicate.WHITESPACE); } - @NotNull static T trimEnd(@NotNull T thizz) { return trimEnd(thizz, 0, CharPredicate.WHITESPACE); } - @Nullable static T trimmedEnd(@NotNull T thizz) { return trimmedEnd(thizz, 0, CharPredicate.WHITESPACE); } - @NotNull static T trim(@NotNull T thizz) { return trim(thizz, 0, CharPredicate.WHITESPACE); } - @NotNull static Pair trimmed(@NotNull T thizz) { return trimmed(thizz, 0, CharPredicate.WHITESPACE); } - @NotNull static T trimStart(@NotNull T thizz, int keep, @NotNull CharPredicate chars) { return subSequence(thizz, trimStartRange(thizz, keep, chars)); } - @Nullable static T trimmedStart(@NotNull T thizz, int keep, @NotNull CharPredicate chars) { return subSequenceBefore(thizz, trimStartRange(thizz, keep, chars)); } - @NotNull static T trimEnd(@NotNull T thizz, int keep, @NotNull CharPredicate chars) { return subSequence(thizz, trimEndRange(thizz, keep, chars)); } - @Nullable static T trimmedEnd(@NotNull T thizz, int keep, @NotNull CharPredicate chars) { return subSequenceAfter(thizz, trimEndRange(thizz, keep, chars)); } - @NotNull static T trim(@NotNull T thizz, int keep, @NotNull CharPredicate chars) { return subSequence(thizz, trimRange(thizz, keep, chars)); } - @NotNull static Pair trimmed(@NotNull T thizz, int keep, @NotNull CharPredicate chars) { return subSequenceBeforeAfter(thizz, trimRange(thizz, keep, chars)); } + static T trimStart(T thizz, CharPredicate chars) { return subSequence(thizz, trimStartRange(thizz, 0, chars)); } + @Nullable static T trimmedStart(T thizz, CharPredicate chars) { return trimmedStart(thizz, 0, chars); } + static T trimEnd(T thizz, CharPredicate chars) { return trimEnd(thizz, 0, chars); } + @Nullable static T trimmedEnd(T thizz, CharPredicate chars) { return trimmedEnd(thizz, 0, chars); } + static T trim(T thizz, CharPredicate chars) { return trim(thizz, 0, chars); } + static Pair trimmed(T thizz, CharPredicate chars) { return trimmed(thizz, 0, chars); } + static T trimStart(T thizz, int keep) { return trimStart(thizz, keep, CharPredicate.WHITESPACE); } + @Nullable static T trimmedStart(T thizz, int keep) { return trimmedStart(thizz, keep, CharPredicate.WHITESPACE); } + static T trimEnd(T thizz, int keep) { return trimEnd(thizz, keep, CharPredicate.WHITESPACE); } + @Nullable static T trimmedEnd(T thizz, int keep) { return trimmedEnd(thizz, keep, CharPredicate.WHITESPACE); } + static T trim(T thizz, int keep) { return trim(thizz, keep, CharPredicate.WHITESPACE); } + static Pair trimmed(T thizz, int keep) { return trimmed(thizz, keep, CharPredicate.WHITESPACE); } + static T trimStart(T thizz) { return trimStart(thizz, 0, CharPredicate.WHITESPACE); } + @Nullable static T trimmedStart(T thizz) { return trimmedStart(thizz, 0, CharPredicate.WHITESPACE); } + static T trimEnd(T thizz) { return trimEnd(thizz, 0, CharPredicate.WHITESPACE); } + @Nullable static T trimmedEnd(T thizz) { return trimmedEnd(thizz, 0, CharPredicate.WHITESPACE); } + static T trim(T thizz) { return trim(thizz, 0, CharPredicate.WHITESPACE); } + static Pair trimmed(T thizz) { return trimmed(thizz, 0, CharPredicate.WHITESPACE); } + static T trimStart(T thizz, int keep, CharPredicate chars) { return subSequence(thizz, trimStartRange(thizz, keep, chars)); } + @Nullable static T trimmedStart(T thizz, int keep, CharPredicate chars) { return subSequenceBefore(thizz, trimStartRange(thizz, keep, chars)); } + static T trimEnd(T thizz, int keep, CharPredicate chars) { return subSequence(thizz, trimEndRange(thizz, keep, chars)); } + @Nullable static T trimmedEnd(T thizz, int keep, CharPredicate chars) { return subSequenceAfter(thizz, trimEndRange(thizz, keep, chars)); } + static T trim(T thizz, int keep, CharPredicate chars) { return subSequence(thizz, trimRange(thizz, keep, chars)); } + static Pair trimmed(T thizz, int keep, CharPredicate chars) { return subSequenceBeforeAfter(thizz, trimRange(thizz, keep, chars)); } // @formatter:on // @formatter:off - static Range trimStartRange(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return trimStartRange(thizz, 0, chars);} - static Range trimEndRange(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return trimEndRange(thizz, 0, chars);} - static Range trimRange(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return trimRange(thizz, 0, chars);} - static Range trimStartRange(@NotNull CharSequence thizz, int keep) { return trimStartRange(thizz, keep, CharPredicate.WHITESPACE);} - static Range trimEndRange(@NotNull CharSequence thizz, int keep) { return trimEndRange(thizz, keep, CharPredicate.WHITESPACE);} - static Range trimRange(@NotNull CharSequence thizz, int keep) { return trimRange(thizz, keep, CharPredicate.WHITESPACE);} - static Range trimStartRange(@NotNull CharSequence thizz) { return trimStartRange(thizz, 0, CharPredicate.WHITESPACE);} - static Range trimEndRange(@NotNull CharSequence thizz) { return trimEndRange(thizz, 0, CharPredicate.WHITESPACE);} - static Range trimRange(@NotNull CharSequence thizz) { return trimRange(thizz, 0, CharPredicate.WHITESPACE);} + static Range trimStartRange(CharSequence thizz, CharPredicate chars) { return trimStartRange(thizz, 0, chars);} + static Range trimEndRange(CharSequence thizz, CharPredicate chars) { return trimEndRange(thizz, 0, chars);} + static Range trimRange(CharSequence thizz, CharPredicate chars) { return trimRange(thizz, 0, chars);} + static Range trimStartRange(CharSequence thizz, int keep) { return trimStartRange(thizz, keep, CharPredicate.WHITESPACE);} + static Range trimEndRange(CharSequence thizz, int keep) { return trimEndRange(thizz, keep, CharPredicate.WHITESPACE);} + static Range trimRange(CharSequence thizz, int keep) { return trimRange(thizz, keep, CharPredicate.WHITESPACE);} + static Range trimStartRange(CharSequence thizz) { return trimStartRange(thizz, 0, CharPredicate.WHITESPACE);} + static Range trimEndRange(CharSequence thizz) { return trimEndRange(thizz, 0, CharPredicate.WHITESPACE);} + static Range trimRange(CharSequence thizz) { return trimRange(thizz, 0, CharPredicate.WHITESPACE);} // @formatter:on - @NotNull - static Range trimStartRange(@NotNull CharSequence thizz, int keep, @NotNull CharPredicate chars) { + static Range trimStartRange(CharSequence thizz, int keep, CharPredicate chars) { int length = thizz.length(); int trim = countLeading(thizz, chars, 0, length); return trim > keep ? Range.of(trim - keep, length) : Range.NULL; } - @NotNull - static Range trimEndRange(@NotNull CharSequence thizz, int keep, @NotNull CharPredicate chars) { + static Range trimEndRange(CharSequence thizz, int keep, CharPredicate chars) { int length = thizz.length(); int trim = countTrailing(thizz, chars, 0, length); return trim > keep ? Range.of(0, length - trim + keep) : Range.NULL; } - @NotNull - static Range trimRange(@NotNull CharSequence thizz, int keep, @NotNull CharPredicate chars) { + static Range trimRange(CharSequence thizz, int keep, CharPredicate chars) { int length = thizz.length(); if (keep >= length) return Range.NULL; @@ -748,28 +737,23 @@ static Range trimRange(@NotNull CharSequence thizz, int keep, @NotNull CharPredi } } - @NotNull - static String padStart(@NotNull CharSequence thizz, int length, char pad) { + static String padStart(CharSequence thizz, int length, char pad) { return length <= thizz.length() ? "" : RepeatedSequence.repeatOf(pad, length - thizz.length()).toString(); } - @NotNull - static String padEnd(@NotNull CharSequence thizz, int length, char pad) { + static String padEnd(CharSequence thizz, int length, char pad) { return length <= thizz.length() ? "" : RepeatedSequence.repeatOf(pad, length - thizz.length()).toString(); } - @NotNull - static String padStart(@NotNull CharSequence thizz, int length) { + static String padStart(CharSequence thizz, int length) { return padStart(thizz, length, ' '); } - @NotNull - static String padEnd(@NotNull CharSequence thizz, int length) { + static String padEnd(CharSequence thizz, int length) { return padEnd(thizz, length, ' '); } - @NotNull - static String toVisibleWhitespaceString(@NotNull CharSequence thizz) { + static String toVisibleWhitespaceString(CharSequence thizz) { StringBuilder sb = new StringBuilder(); int iMax = thizz.length(); for (int i = 0; i < iMax; i++) { @@ -789,23 +773,23 @@ static String toVisibleWhitespaceString(@NotNull CharSequence thizz) { // EOL Helpers // ***************************************************************** - static char lastChar(@NotNull CharSequence thizz) { + static char lastChar(CharSequence thizz) { return thizz.length() == 0 ? SequenceUtils.NUL : thizz.charAt(thizz.length() - 1); } - static char firstChar(@NotNull CharSequence thizz) { + static char firstChar(CharSequence thizz) { return thizz.length() == 0 ? SequenceUtils.NUL : thizz.charAt(0); } - static char safeCharAt(@NotNull CharSequence thizz, int index) { + static char safeCharAt(CharSequence thizz, int index) { return index < 0 || index >= thizz.length() ? SequenceUtils.NUL : thizz.charAt(index); } - static int eolEndLength(@NotNull CharSequence thizz) { + static int eolEndLength(CharSequence thizz) { return eolEndLength(thizz, thizz.length()); } - static int eolEndLength(@NotNull CharSequence thizz, int eolEnd) { + static int eolEndLength(CharSequence thizz, int eolEnd) { int pos = Math.min(eolEnd - 1, thizz.length() - 1); if (pos < 0) return 0; @@ -825,7 +809,7 @@ static int eolEndLength(@NotNull CharSequence thizz, int eolEnd) { return len; } - static int eolStartLength(@NotNull CharSequence thizz, int eolStart) { + static int eolStartLength(CharSequence thizz, int eolStart) { int length = thizz.length(); int pos = Math.min(eolStart, length); @@ -850,98 +834,92 @@ static int eolStartLength(@NotNull CharSequence thizz, int eolStart) { } // @formatter:off - static int endOfLine(@NotNull CharSequence thizz, int index) { return endOfDelimitedBy(thizz, SequenceUtils.EOL, index); } - static int endOfLineAnyEOL(@NotNull CharSequence thizz, int index) { return endOfDelimitedByAny(thizz, CharPredicate.ANY_EOL, index); } - static int startOfLine(@NotNull CharSequence thizz, int index) { return startOfDelimitedBy(thizz, SequenceUtils.EOL, index); } - static int startOfLineAnyEOL(@NotNull CharSequence thizz, int index) { return startOfDelimitedByAny(thizz, CharPredicate.ANY_EOL, index); } + static int endOfLine(CharSequence thizz, int index) { return endOfDelimitedBy(thizz, SequenceUtils.EOL, index); } + static int endOfLineAnyEOL(CharSequence thizz, int index) { return endOfDelimitedByAny(thizz, CharPredicate.ANY_EOL, index); } + static int startOfLine(CharSequence thizz, int index) { return startOfDelimitedBy(thizz, SequenceUtils.EOL, index); } + static int startOfLineAnyEOL(CharSequence thizz, int index) { return startOfDelimitedByAny(thizz, CharPredicate.ANY_EOL, index); } - static int startOfDelimitedByAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s, int index) { return startOfDelimitedByAny(thizz, s.negate(),index); } - static int endOfDelimitedByAnyNot(@NotNull CharSequence thizz, @NotNull CharPredicate s, int index) { return endOfDelimitedByAny(thizz, s.negate(),index); } + static int startOfDelimitedByAnyNot(CharSequence thizz, CharPredicate s, int index) { return startOfDelimitedByAny(thizz, s.negate(),index); } + static int endOfDelimitedByAnyNot(CharSequence thizz, CharPredicate s, int index) { return endOfDelimitedByAny(thizz, s.negate(),index); } // @formatter:on - static int startOfDelimitedBy(@NotNull CharSequence thizz, @NotNull CharSequence s, int index) { + static int startOfDelimitedBy(CharSequence thizz, CharSequence s, int index) { index = rangeLimit(index, 0, thizz.length()); int offset = lastIndexOf(thizz, s, index - 1); return offset == -1 ? 0 : offset + 1; } - static int startOfDelimitedByAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int index) { + static int startOfDelimitedByAny(CharSequence thizz, CharPredicate s, int index) { index = rangeLimit(index, 0, thizz.length()); int offset = lastIndexOfAny(thizz, s, index - 1); return offset == -1 ? 0 : offset + 1; } - static int endOfDelimitedBy(@NotNull CharSequence thizz, @NotNull CharSequence s, int index) { + static int endOfDelimitedBy(CharSequence thizz, CharSequence s, int index) { int length = thizz.length(); index = rangeLimit(index, 0, length); int offset = indexOf(thizz, s, index); return offset == -1 ? length : offset; } - static int endOfDelimitedByAny(@NotNull CharSequence thizz, @NotNull CharPredicate s, int index) { + static int endOfDelimitedByAny(CharSequence thizz, CharPredicate s, int index) { int length = thizz.length(); index = rangeLimit(index, 0, length); int offset = indexOfAny(thizz, s, index); return offset == -1 ? length : offset; } - @NotNull - static Range lineRangeAt(@NotNull CharSequence thizz, int index) { + static Range lineRangeAt(CharSequence thizz, int index) { return Range.of(startOfLine(thizz, index), endOfLine(thizz, index)); } - @NotNull - static Range lineRangeAtAnyEOL(@NotNull CharSequence thizz, int index) { + static Range lineRangeAtAnyEOL(CharSequence thizz, int index) { return Range.of(startOfLineAnyEOL(thizz, index), endOfLineAnyEOL(thizz, index)); } - @NotNull - static Range eolEndRange(@NotNull CharSequence thizz, int eolEnd) { + static Range eolEndRange(CharSequence thizz, int eolEnd) { int eolLength = eolEndLength(thizz, eolEnd); return eolLength == 0 ? Range.NULL : Range.of(eolEnd - eolLength, eolEnd); } - @NotNull - static Range eolStartRange(@NotNull CharSequence thizz, int eolStart) { + static Range eolStartRange(CharSequence thizz, int eolStart) { int eolLength = eolStartLength(thizz, eolStart); return eolLength == 0 ? Range.NULL : Range.of(eolStart, eolStart + eolLength); } - @NotNull - static T trimEOL(@NotNull T thizz) { + static T trimEOL(T thizz) { int eolLength = eolEndLength(thizz); return eolLength > 0 ? (T) thizz.subSequence(0, thizz.length() - eolLength) : (T) thizz; } @Nullable - static T trimmedEOL(@NotNull T thizz) { + static T trimmedEOL(T thizz) { int eolLength = eolEndLength(thizz); return eolLength > 0 ? (T) thizz.subSequence(thizz.length() - eolLength, thizz.length()) : null; } @Nullable - static T trimTailBlankLines(@NotNull T thizz) { + static T trimTailBlankLines(T thizz) { Range range = trailingBlankLinesRange(thizz); return range.isNull() ? (T) thizz : (T) subSequenceBefore(thizz, range); } @Nullable - static T trimLeadBlankLines(@NotNull T thizz) { + static T trimLeadBlankLines(T thizz) { Range range = leadingBlankLinesRange(thizz); return range.isNull() ? (T) thizz : subSequenceAfter(thizz, range); } // @formatter:off - @NotNull static Range leadingBlankLinesRange(@NotNull CharSequence thizz) { return leadingBlankLinesRange(thizz, CharPredicate.EOL, 0, Integer.MAX_VALUE); } - @NotNull static Range leadingBlankLinesRange(@NotNull CharSequence thizz, int startIndex) { return leadingBlankLinesRange(thizz, CharPredicate.EOL, startIndex, Integer.MAX_VALUE); } - @NotNull static Range leadingBlankLinesRange(@NotNull CharSequence thizz, int fromIndex, int endIndex) { return leadingBlankLinesRange(thizz, CharPredicate.EOL, fromIndex, endIndex); } - @NotNull static Range trailingBlankLinesRange(@NotNull CharSequence thizz) { return trailingBlankLinesRange(thizz, CharPredicate.EOL, 0, Integer.MAX_VALUE); } - @NotNull static Range trailingBlankLinesRange(@NotNull CharSequence thizz, int fromIndex) { return trailingBlankLinesRange(thizz, CharPredicate.EOL, fromIndex, Integer.MAX_VALUE); } - @NotNull static Range trailingBlankLinesRange(@NotNull CharSequence thizz, int startIndex, int fromIndex) { return trailingBlankLinesRange(thizz, CharPredicate.EOL, startIndex,fromIndex); } + static Range leadingBlankLinesRange(CharSequence thizz) { return leadingBlankLinesRange(thizz, CharPredicate.EOL, 0, Integer.MAX_VALUE); } + static Range leadingBlankLinesRange(CharSequence thizz, int startIndex) { return leadingBlankLinesRange(thizz, CharPredicate.EOL, startIndex, Integer.MAX_VALUE); } + static Range leadingBlankLinesRange(CharSequence thizz, int fromIndex, int endIndex) { return leadingBlankLinesRange(thizz, CharPredicate.EOL, fromIndex, endIndex); } + static Range trailingBlankLinesRange(CharSequence thizz) { return trailingBlankLinesRange(thizz, CharPredicate.EOL, 0, Integer.MAX_VALUE); } + static Range trailingBlankLinesRange(CharSequence thizz, int fromIndex) { return trailingBlankLinesRange(thizz, CharPredicate.EOL, fromIndex, Integer.MAX_VALUE); } + static Range trailingBlankLinesRange(CharSequence thizz, int startIndex, int fromIndex) { return trailingBlankLinesRange(thizz, CharPredicate.EOL, startIndex,fromIndex); } // @formatter:on - @NotNull - static Range trailingBlankLinesRange(@NotNull CharSequence thizz, @NotNull CharPredicate eolChars, int startIndex, int fromIndex) { + static Range trailingBlankLinesRange(CharSequence thizz, CharPredicate eolChars, int startIndex, int fromIndex) { fromIndex = Math.min(fromIndex, thizz.length()); startIndex = rangeLimit(startIndex, 0, fromIndex); @@ -960,8 +938,7 @@ static Range trailingBlankLinesRange(@NotNull CharSequence thizz, @NotNull CharP else return Range.NULL; } - @NotNull - static Range leadingBlankLinesRange(@NotNull CharSequence thizz, @NotNull CharPredicate eolChars, int fromIndex, int endIndex) { + static Range leadingBlankLinesRange(CharSequence thizz, CharPredicate eolChars, int fromIndex, int endIndex) { endIndex = Math.min(endIndex, thizz.length()); fromIndex = rangeLimit(fromIndex, 0, endIndex); @@ -981,13 +958,12 @@ static Range leadingBlankLinesRange(@NotNull CharSequence thizz, @NotNull CharPr } // @formatter:off - @NotNull static List blankLinesRemovedRanges(@NotNull CharSequence thizz) { return blankLinesRemovedRanges(thizz, CharPredicate.EOL, 0, Integer.MAX_VALUE); } - @NotNull static List blankLinesRemovedRanges(@NotNull CharSequence thizz, int fromIndex) { return blankLinesRemovedRanges(thizz, CharPredicate.EOL, fromIndex, Integer.MAX_VALUE); } - @NotNull static List blankLinesRemovedRanges(@NotNull CharSequence thizz, int fromIndex, int endIndex) { return blankLinesRemovedRanges(thizz, CharPredicate.EOL, fromIndex, endIndex); } + static List blankLinesRemovedRanges(CharSequence thizz) { return blankLinesRemovedRanges(thizz, CharPredicate.EOL, 0, Integer.MAX_VALUE); } + static List blankLinesRemovedRanges(CharSequence thizz, int fromIndex) { return blankLinesRemovedRanges(thizz, CharPredicate.EOL, fromIndex, Integer.MAX_VALUE); } + static List blankLinesRemovedRanges(CharSequence thizz, int fromIndex, int endIndex) { return blankLinesRemovedRanges(thizz, CharPredicate.EOL, fromIndex, endIndex); } // @formatter:on - @NotNull - static List blankLinesRemovedRanges(@NotNull CharSequence thizz, @NotNull CharPredicate eolChars, int fromIndex, int endIndex) { + static List blankLinesRemovedRanges(CharSequence thizz, CharPredicate eolChars, int fromIndex, int endIndex) { endIndex = Math.min(endIndex, thizz.length()); fromIndex = rangeLimit(fromIndex, 0, endIndex); int lastPos = fromIndex; @@ -1008,55 +984,54 @@ static List blankLinesRemovedRanges(@NotNull CharSequence thizz, @NotNull } // @formatter:off - static boolean isEmpty(@NotNull CharSequence thizz) { return thizz.length() == 0; } - static boolean isBlank(@NotNull CharSequence thizz) { return isEmpty(thizz) || countLeading(thizz, CharPredicate.WHITESPACE, 0, Integer.MAX_VALUE) == thizz.length(); } - static boolean isNotEmpty(@NotNull CharSequence thizz) { return thizz.length() != 0; } - static boolean isNotBlank(@NotNull CharSequence thizz) { return !isBlank(thizz); } - - static boolean endsWith(@NotNull CharSequence thizz, @NotNull CharSequence suffix) { return thizz.length() > 0 && matchCharsReversed(thizz, suffix, thizz.length() - 1, false); } - static boolean endsWith(@NotNull CharSequence thizz, @NotNull CharSequence suffix, boolean ignoreCase) { return thizz.length() > 0 && matchCharsReversed(thizz, suffix, thizz.length() - 1, ignoreCase); } - static boolean startsWith(@NotNull CharSequence thizz, @NotNull CharSequence prefix) { return thizz.length() > 0 && matchChars(thizz, prefix, 0, false); } - static boolean startsWith(@NotNull CharSequence thizz, @NotNull CharSequence prefix, boolean ignoreCase) { return thizz.length() > 0 && matchChars(thizz, prefix, 0, ignoreCase); } - - static boolean endsWith(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return countTrailing(thizz, chars) > 0; } - static boolean startsWith(@NotNull CharSequence thizz, @NotNull CharPredicate chars) { return countLeading(thizz, chars) > 0; } - - static boolean endsWithEOL(@NotNull CharSequence thizz) { return endsWith(thizz, CharPredicate.EOL); } - static boolean endsWithAnyEOL(@NotNull CharSequence thizz) { return endsWith(thizz, CharPredicate.ANY_EOL); } - static boolean endsWithSpace(@NotNull CharSequence thizz) { return endsWith(thizz, CharPredicate.SPACE); } - static boolean endsWithSpaceTab(@NotNull CharSequence thizz) { return endsWith(thizz, CharPredicate.SPACE_TAB); } - static boolean endsWithWhitespace(@NotNull CharSequence thizz) { return endsWith(thizz, CharPredicate.WHITESPACE); } - - static boolean startsWithEOL(@NotNull CharSequence thizz) { return startsWith(thizz, CharPredicate.EOL); } - static boolean startsWithAnyEOL(@NotNull CharSequence thizz) { return startsWith(thizz, CharPredicate.ANY_EOL); } - static boolean startsWithSpace(@NotNull CharSequence thizz) { return startsWith(thizz, CharPredicate.SPACE); } - static boolean startsWithSpaceTab(@NotNull CharSequence thizz) { return startsWith(thizz, CharPredicate.SPACE_TAB); } - static boolean startsWithWhitespace(@NotNull CharSequence thizz) { return startsWith(thizz, CharPredicate.WHITESPACE); } + static boolean isEmpty(CharSequence thizz) { return thizz.length() == 0; } + static boolean isBlank(CharSequence thizz) { return isEmpty(thizz) || countLeading(thizz, CharPredicate.WHITESPACE, 0, Integer.MAX_VALUE) == thizz.length(); } + static boolean isNotEmpty(CharSequence thizz) { return thizz.length() != 0; } + static boolean isNotBlank(CharSequence thizz) { return !isBlank(thizz); } + + static boolean endsWith(CharSequence thizz, CharSequence suffix) { return thizz.length() > 0 && matchCharsReversed(thizz, suffix, thizz.length() - 1, false); } + static boolean endsWith(CharSequence thizz, CharSequence suffix, boolean ignoreCase) { return thizz.length() > 0 && matchCharsReversed(thizz, suffix, thizz.length() - 1, ignoreCase); } + static boolean startsWith(CharSequence thizz, CharSequence prefix) { return thizz.length() > 0 && matchChars(thizz, prefix, 0, false); } + static boolean startsWith(CharSequence thizz, CharSequence prefix, boolean ignoreCase) { return thizz.length() > 0 && matchChars(thizz, prefix, 0, ignoreCase); } + + static boolean endsWith(CharSequence thizz, CharPredicate chars) { return countTrailing(thizz, chars) > 0; } + static boolean startsWith(CharSequence thizz, CharPredicate chars) { return countLeading(thizz, chars) > 0; } + + static boolean endsWithEOL(CharSequence thizz) { return endsWith(thizz, CharPredicate.EOL); } + static boolean endsWithAnyEOL(CharSequence thizz) { return endsWith(thizz, CharPredicate.ANY_EOL); } + static boolean endsWithSpace(CharSequence thizz) { return endsWith(thizz, CharPredicate.SPACE); } + static boolean endsWithSpaceTab(CharSequence thizz) { return endsWith(thizz, CharPredicate.SPACE_TAB); } + static boolean endsWithWhitespace(CharSequence thizz) { return endsWith(thizz, CharPredicate.WHITESPACE); } + + static boolean startsWithEOL(CharSequence thizz) { return startsWith(thizz, CharPredicate.EOL); } + static boolean startsWithAnyEOL(CharSequence thizz) { return startsWith(thizz, CharPredicate.ANY_EOL); } + static boolean startsWithSpace(CharSequence thizz) { return startsWith(thizz, CharPredicate.SPACE); } + static boolean startsWithSpaceTab(CharSequence thizz) { return startsWith(thizz, CharPredicate.SPACE_TAB); } + static boolean startsWithWhitespace(CharSequence thizz) { return startsWith(thizz, CharPredicate.WHITESPACE); } // @formatter:on // @formatter:off - static @NotNull List splitList(@NotNull T thizz, @NotNull CharSequence delimiter) { return splitList(thizz, delimiter, 0, 0, null); } - static @NotNull List splitList(@NotNull T thizz, @NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) { return splitList(thizz, delimiter, limit, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } - static @NotNull List splitList(@NotNull T thizz, @NotNull CharSequence delimiter, int limit, int flags) { return splitList(thizz, delimiter, limit, flags, null); } - static @NotNull List splitList(@NotNull T thizz, @NotNull CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) { return splitList(thizz, delimiter, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + static List splitList(T thizz, CharSequence delimiter) { return splitList(thizz, delimiter, 0, 0, null); } + static List splitList(T thizz, CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) { return splitList(thizz, delimiter, limit, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + static List splitList(T thizz, CharSequence delimiter, int limit, int flags) { return splitList(thizz, delimiter, limit, flags, null); } + static List splitList(T thizz, CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) { return splitList(thizz, delimiter, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } // NOTE: these default to including delimiters as part of split item - static @NotNull List splitListEOL(@NotNull T thizz) { return splitList(thizz, SequenceUtils.EOL, 0, SequenceUtils.SPLIT_INCLUDE_DELIMS, null); } - static @NotNull List splitListEOL(@NotNull T thizz, boolean includeDelims) { return splitList(thizz, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, null); } - static @NotNull List splitListEOL(@NotNull T thizz, boolean includeDelims, @Nullable CharPredicate trimChars) { return splitList(thizz, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } - - static @NotNull T[] splitEOL(@NotNull T thizz, T[] emptyArray) { return split(thizz, emptyArray, SequenceUtils.EOL, 0, SequenceUtils.SPLIT_INCLUDE_DELIMS,null); } - static @NotNull T[] splitEOL(@NotNull T thizz, T[] emptyArray, boolean includeDelims) { return split(thizz, emptyArray, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, null); } - static @NotNull T[] split(@NotNull T thizz, T[] emptyArray, @NotNull CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) { return split(thizz, emptyArray, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } - static @NotNull T[] split(@NotNull T thizz, T[] emptyArray, @NotNull CharSequence delimiter) { return split(thizz, emptyArray, delimiter, 0, 0, null); } - static @NotNull T[] split(@NotNull T thizz, T[] emptyArray, @NotNull CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) { return split(thizz, emptyArray, delimiter, limit, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } - static @NotNull T[] split(@NotNull T thizz, T[] emptyArray, @NotNull CharSequence delimiter, int limit, int flags) { return split(thizz, emptyArray, delimiter, limit, flags, null); } - static @NotNull T[] split(@NotNull T thizz, T[] emptyArray, @NotNull CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) { return splitList((T)thizz, delimiter, limit, flags, trimChars).toArray(emptyArray);} + static List splitListEOL(T thizz) { return splitList(thizz, SequenceUtils.EOL, 0, SequenceUtils.SPLIT_INCLUDE_DELIMS, null); } + static List splitListEOL(T thizz, boolean includeDelims) { return splitList(thizz, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, null); } + static List splitListEOL(T thizz, boolean includeDelims, @Nullable CharPredicate trimChars) { return splitList(thizz, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + + static T[] splitEOL(T thizz, T[] emptyArray) { return split(thizz, emptyArray, SequenceUtils.EOL, 0, SequenceUtils.SPLIT_INCLUDE_DELIMS,null); } + static T[] splitEOL(T thizz, T[] emptyArray, boolean includeDelims) { return split(thizz, emptyArray, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, null); } + static T[] split(T thizz, T[] emptyArray, CharSequence delimiter, boolean includeDelims, @Nullable CharPredicate trimChars) { return split(thizz, emptyArray, SequenceUtils.EOL, 0, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + static T[] split(T thizz, T[] emptyArray, CharSequence delimiter) { return split(thizz, emptyArray, delimiter, 0, 0, null); } + static T[] split(T thizz, T[] emptyArray, CharSequence delimiter, int limit, boolean includeDelims, @Nullable CharPredicate trimChars) { return split(thizz, emptyArray, delimiter, limit, includeDelims ? SequenceUtils.SPLIT_INCLUDE_DELIMS : 0, trimChars); } + static T[] split(T thizz, T[] emptyArray, CharSequence delimiter, int limit, int flags) { return split(thizz, emptyArray, delimiter, limit, flags, null); } + static T[] split(T thizz, T[] emptyArray, CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) { return splitList((T)thizz, delimiter, limit, flags, trimChars).toArray(emptyArray);} // @formatter:on @SuppressWarnings("unchecked") - @NotNull - static List splitList(@NotNull T thizz, @NotNull CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) { + static List splitList(T thizz, CharSequence delimiter, int limit, int flags, @Nullable CharPredicate trimChars) { if (trimChars == null) trimChars = CharPredicate.WHITESPACE; else flags |= SPLIT_TRIM_PARTS; @@ -1103,13 +1078,12 @@ static List splitList(@NotNull T thizz, @NotNull Cha return items; } - static int columnAtIndex(@NotNull CharSequence thizz, int index) { + static int columnAtIndex(CharSequence thizz, int index) { int lineStart = lastIndexOfAny(thizz, CharPredicate.ANY_EOL, index); return index - (lineStart == -1 ? 0 : lineStart + eolStartLength(thizz, lineStart)); } - @NotNull - static Pair lineColumnAtIndex(@NotNull CharSequence thizz, int index) { + static Pair lineColumnAtIndex(CharSequence thizz, int index) { int iMax = thizz.length(); if (index < 0 || index > iMax) { throw new IllegalArgumentException("Index: " + index + " out of range [0, " + iMax + "]"); @@ -1294,14 +1268,14 @@ static Pair parseNumberPrefixOrNull(@Nullable String text, @Null return null; } - static boolean containedBy(@NotNull T[] items, @NotNull CharSequence element) { + static boolean containedBy(T[] items, CharSequence element) { for (T item : items) { if (equals(element, item)) return true; } return false; } - static boolean containedBy(@NotNull Collection items, @NotNull CharSequence element) { + static boolean containedBy(Collection items, CharSequence element) { for (CharSequence item : items) { if (equals(element, item)) return true; } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SubSequence.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SubSequence.java index 4a4653355..9ad9f7191 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SubSequence.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SubSequence.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKeyBase; import com.vladsch.flexmark.util.sequence.builder.IBasedSegmentBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A BasedSequence implementation which wraps original CharSequence to provide a BasedSequence for @@ -13,12 +12,11 @@ * NOTE: '\0' changed to '\uFFFD' use {@link com.vladsch.flexmark.util.sequence.mappers.NullEncoder#decodeNull} mapper to get original null chars. */ final public class SubSequence extends BasedSequenceImpl { - final private @NotNull CharSequence charSequence; - final private @NotNull SubSequence baseSeq; + final private CharSequence charSequence; + final private SubSequence baseSeq; final private int startOffset; final private int endOffset; - @NotNull @Override public SubSequence getBaseSequence() { return baseSeq; @@ -40,7 +38,7 @@ public boolean anyOptions(int options) { } @Override - public T getOption(@NotNull DataKeyBase dataKey) { + public T getOption(DataKeyBase dataKey) { return charSequence instanceof BasedOptionsHolder ? ((BasedOptionsHolder) charSequence).getOption(dataKey) : dataKey.get(null); } @@ -49,7 +47,6 @@ public T getOption(@NotNull DataKeyBase dataKey) { return charSequence instanceof BasedOptionsHolder ? ((BasedOptionsHolder) charSequence).getOptions() : null; } - @NotNull @Override public CharSequence getBase() { return charSequence; @@ -63,7 +60,7 @@ public int getEndOffset() { return endOffset; } - private SubSequence(@NotNull CharSequence charSequence) { + private SubSequence(CharSequence charSequence) { super(charSequence instanceof String ? charSequence.hashCode() : 0); assert !(charSequence instanceof BasedSequence); baseSeq = this; @@ -73,7 +70,7 @@ private SubSequence(@NotNull CharSequence charSequence) { } // NOTE: called only from baseSubSequence - private SubSequence(@NotNull SubSequence subSequence, int startIndex, int endIndex) { + private SubSequence(SubSequence subSequence, int startIndex, int endIndex) { super(0); assert startIndex >= 0 && endIndex >= startIndex && endIndex <= subSequence.length() : String.format("SubSequence must have startIndex >= 0 && endIndex >= startIndex && endIndex <= %d, got startIndex:%d, endIndex: %d", subSequence.length(), startIndex, endIndex); @@ -85,7 +82,7 @@ private SubSequence(@NotNull SubSequence subSequence, int startIndex, int endInd } @Override - public void addSegments(@NotNull IBasedSegmentBuilder builder) { + public void addSegments(IBasedSegmentBuilder builder) { assert builder.getBaseSequence() == baseSeq || builder.getBaseSequence().equals(baseSeq); builder.append(startOffset, endOffset); @@ -96,7 +93,6 @@ public int length() { return endOffset - startOffset; } - @NotNull @Override public Range getSourceRange() { return Range.of(startOffset, endOffset); @@ -116,14 +112,12 @@ public char charAt(int index) { return c == SequenceUtils.NUL ? SequenceUtils.ENC_NUL : c; } - @NotNull @Override public SubSequence subSequence(int startIndex, int endIndex) { SequenceUtils.validateStartEnd(startIndex, endIndex, length()); return baseSubSequence(startOffset + startIndex, startOffset + endIndex); } - @NotNull @Override public SubSequence baseSubSequence(int startIndex, int endIndex) { SequenceUtils.validateStartEnd(startIndex, endIndex, baseSeq.length()); diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/BasedSegmentBuilder.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/BasedSegmentBuilder.java index d0be68226..1a04214f0 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/BasedSegmentBuilder.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/BasedSegmentBuilder.java @@ -3,44 +3,43 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.PositionAnchor; import com.vladsch.flexmark.util.sequence.Range; -import org.jetbrains.annotations.NotNull; public class BasedSegmentBuilder extends SegmentBuilderBase implements IBasedSegmentBuilder { - final @NotNull BasedSequence baseSeq; - final @NotNull SegmentOptimizer optimizer; + final BasedSequence baseSeq; + final SegmentOptimizer optimizer; - protected BasedSegmentBuilder(@NotNull BasedSequence baseSeq) { + protected BasedSegmentBuilder(BasedSequence baseSeq) { this(baseSeq, new CharRecoveryOptimizer(PositionAnchor.CURRENT)); } - protected BasedSegmentBuilder(@NotNull BasedSequence baseSeq, @NotNull SegmentOptimizer optimizer) { + protected BasedSegmentBuilder(BasedSequence baseSeq, SegmentOptimizer optimizer) { super(); this.baseSeq = baseSeq.getBaseSequence(); this.optimizer = optimizer; } - protected BasedSegmentBuilder(@NotNull BasedSequence baseSeq, int options) { + protected BasedSegmentBuilder(BasedSequence baseSeq, int options) { this(baseSeq, new CharRecoveryOptimizer(PositionAnchor.CURRENT), options); } - protected BasedSegmentBuilder(@NotNull BasedSequence baseSeq, @NotNull SegmentOptimizer optimizer, int options) { + protected BasedSegmentBuilder(BasedSequence baseSeq, SegmentOptimizer optimizer, int options) { super(options); this.baseSeq = baseSeq.getBaseSequence(); this.optimizer = optimizer; } @Override - public @NotNull BasedSequence getBaseSequence() { + public BasedSequence getBaseSequence() { return baseSeq; } @Override - protected Object[] optimizeText(@NotNull Object[] parts) { + protected Object[] optimizeText(Object[] parts) { return optimizer.apply(baseSeq, parts); } @Override - protected Object[] handleOverlap(@NotNull Object[] parts) { + protected Object[] handleOverlap(Object[] parts) { // convert overlap to text from our base // range overlaps with last segment in the list Range lastSeg = (Range) parts[0]; @@ -83,41 +82,34 @@ protected Object[] handleOverlap(@NotNull Object[] parts) { return parts; } - @NotNull @Override public String toStringWithRangesVisibleWhitespace() { return super.toStringWithRangesVisibleWhitespace(baseSeq); } - @NotNull @Override public String toStringWithRanges() { return super.toStringWithRanges(baseSeq); } - @NotNull @Override public String toStringChars() { return super.toString(baseSeq); } - @NotNull - public static BasedSegmentBuilder emptyBuilder(@NotNull BasedSequence sequence) { + public static BasedSegmentBuilder emptyBuilder(BasedSequence sequence) { return new BasedSegmentBuilder(sequence); } - @NotNull - public static BasedSegmentBuilder emptyBuilder(@NotNull BasedSequence sequence, int options) { + public static BasedSegmentBuilder emptyBuilder(BasedSequence sequence, int options) { return new BasedSegmentBuilder(sequence, options); } - @NotNull - public static BasedSegmentBuilder emptyBuilder(@NotNull BasedSequence sequence, @NotNull SegmentOptimizer optimizer) { + public static BasedSegmentBuilder emptyBuilder(BasedSequence sequence, SegmentOptimizer optimizer) { return new BasedSegmentBuilder(sequence, optimizer); } - @NotNull - public static BasedSegmentBuilder emptyBuilder(@NotNull BasedSequence sequence, @NotNull SegmentOptimizer optimizer, int options) { + public static BasedSegmentBuilder emptyBuilder(BasedSequence sequence, SegmentOptimizer optimizer, int options) { return new BasedSegmentBuilder(sequence, optimizer, options); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/CharRecoveryOptimizer.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/CharRecoveryOptimizer.java index a0ecf8340..c9b621111 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/CharRecoveryOptimizer.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/CharRecoveryOptimizer.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.sequence.PositionAnchor; import com.vladsch.flexmark.util.sequence.Range; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.util.sequence.SequenceUtils.*; @@ -17,7 +16,7 @@ public CharRecoveryOptimizer(PositionAnchor anchor) { private int prevEolPos; - int prevMatchPos(@NotNull CharSequence base, CharSequence chars, int startIndex, int endIndex) { + int prevMatchPos(CharSequence base, CharSequence chars, int startIndex, int endIndex) { int length = chars.length(); endIndex = Math.min(base.length(), endIndex); int iMax = Math.min(endIndex - startIndex, length); @@ -32,7 +31,7 @@ int prevMatchPos(@NotNull CharSequence base, CharSequence chars, int startIndex, return iMax; } - int nextMatchPos(@NotNull CharSequence base, CharSequence chars, int startIndex, int fromIndex) { + int nextMatchPos(CharSequence base, CharSequence chars, int startIndex, int fromIndex) { startIndex = Math.max(0, startIndex); fromIndex = Math.min(base.length(), fromIndex); @@ -51,13 +50,13 @@ int nextMatchPos(@NotNull CharSequence base, CharSequence chars, int startIndex, return charsOffset; } - public Object[] apply(@NotNull CharSequence chars, Object[] parts) { + public Object[] apply(CharSequence chars, Object[] parts) { // optimizer already applied if (parts.length != 3 || !(parts[0] instanceof Range && parts[1] instanceof CharSequence && parts[2] instanceof Range)) return parts; - final @NotNull Range originalPrev = (Range) parts[0]; - @NotNull CharSequence originalText = (CharSequence) parts[1]; - final @NotNull Range originalNext = (Range) parts[2]; + final Range originalPrev = (Range) parts[0]; + CharSequence originalText = (CharSequence) parts[1]; + final Range originalNext = (Range) parts[2]; // optimizer already applied final int textLength = originalText.length(); @@ -65,9 +64,9 @@ public Object[] apply(@NotNull CharSequence chars, Object[] parts) { final int charsLength = chars.length(); - @NotNull Range prevRange = originalPrev; - @NotNull CharSequence text = originalText; - @NotNull Range nextRange = originalNext; + Range prevRange = originalPrev; + CharSequence text = originalText; + Range nextRange = originalNext; prevEolPos = -1; diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/IBasedSegmentBuilder.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/IBasedSegmentBuilder.java index 714d8200a..2dc83c62f 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/IBasedSegmentBuilder.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/IBasedSegmentBuilder.java @@ -1,11 +1,10 @@ package com.vladsch.flexmark.util.sequence.builder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public interface IBasedSegmentBuilder> extends ISegmentBuilder { - @NotNull BasedSequence getBaseSequence(); - @NotNull String toStringWithRangesVisibleWhitespace(); - @NotNull String toStringWithRanges(); - @NotNull String toStringChars(); + BasedSequence getBaseSequence(); + String toStringWithRangesVisibleWhitespace(); + String toStringWithRanges(); + String toStringChars(); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/ISegmentBuilder.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/ISegmentBuilder.java index 9709b6763..896d5e58d 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/ISegmentBuilder.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/ISegmentBuilder.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.misc.BitFieldSet; import com.vladsch.flexmark.util.sequence.Range; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Iterator; @@ -54,7 +53,6 @@ enum Options { * * @return iterator over segment builder parts */ - @NotNull @Override Iterator iterator(); @@ -63,14 +61,13 @@ enum Options { * * @return iterator over segment builder segments */ - @NotNull Iterable getSegments(); - @NotNull S append(int startOffset, int endOffset); - @NotNull S append(CharSequence text); - @NotNull S appendAnchor(int offset); - @NotNull S append(@NotNull Range range); - @NotNull String toStringWithRangesVisibleWhitespace(@NotNull CharSequence chars); - @NotNull String toStringWithRanges(@NotNull CharSequence chars); - @NotNull String toString(@NotNull CharSequence chars); + S append(int startOffset, int endOffset); + S append(CharSequence text); + S appendAnchor(int offset); + S append(Range range); + String toStringWithRangesVisibleWhitespace(CharSequence chars); + String toStringWithRanges(CharSequence chars); + String toString(CharSequence chars); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/ISequenceBuilder.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/ISequenceBuilder.java index 674565474..88de48624 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/ISequenceBuilder.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/ISequenceBuilder.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.sequence.builder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface ISequenceBuilder, S extends CharSequence> extends Appendable { /** @@ -11,16 +10,14 @@ public interface ISequenceBuilder, S extends Ch */ @Nullable S getSingleBasedSequence(); - @NotNull T getBuilder(); + T getBuilder(); - @NotNull default T addAll(Iterable sequences) { return append(sequences); } char charAt(int index); - @NotNull default T append(Iterable sequences) { for (CharSequence chars : sequences) { append(chars, 0, chars.length()); @@ -29,12 +26,10 @@ default T append(Iterable sequences) { return (T) this; } - @NotNull default T add(@Nullable CharSequence chars) { return append(chars); } - @NotNull default T append(@Nullable CharSequence chars) { if (chars != null) { return append(chars, 0, chars.length()); @@ -43,7 +38,6 @@ default T append(@Nullable CharSequence chars) { return (T) this; } - @NotNull default T append(@Nullable CharSequence chars, int startIndex) { if (chars != null) { return append(chars, startIndex, chars.length()); @@ -52,13 +46,13 @@ default T append(@Nullable CharSequence chars, int startIndex) { return (T) this; } - @NotNull T append(@Nullable CharSequence chars, int startIndex, int endIndex); + T append(@Nullable CharSequence chars, int startIndex, int endIndex); - @NotNull T append(char c); + T append(char c); - @NotNull T append(char c, int count); + T append(char c, int count); - @NotNull S toSequence(); + S toSequence(); int length(); diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/PlainSegmentBuilder.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/PlainSegmentBuilder.java index b425708a5..88023c10f 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/PlainSegmentBuilder.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/PlainSegmentBuilder.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.sequence.builder; -import org.jetbrains.annotations.NotNull; public class PlainSegmentBuilder extends SegmentBuilderBase { public PlainSegmentBuilder() { @@ -10,12 +9,10 @@ public PlainSegmentBuilder(int options) { super(options); } - @NotNull public static PlainSegmentBuilder emptyBuilder() { return new PlainSegmentBuilder(); } - @NotNull public static PlainSegmentBuilder emptyBuilder(int options) { return new PlainSegmentBuilder(options); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/RichSequenceBuilder.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/RichSequenceBuilder.java index 6dec893eb..70d662931 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/RichSequenceBuilder.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/RichSequenceBuilder.java @@ -1,14 +1,12 @@ package com.vladsch.flexmark.util.sequence.builder; import com.vladsch.flexmark.util.sequence.RichSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A Builder for non based strings. Just a string builder wrapped in a sequence builder interface and wrapping result in RichSequence */ final public class RichSequenceBuilder implements ISequenceBuilder { - @NotNull public static RichSequenceBuilder emptyBuilder() { return new RichSequenceBuilder(); } @@ -23,7 +21,6 @@ public RichSequenceBuilder(int initialCapacity) { this.segments = new StringBuilder(initialCapacity); } - @NotNull public RichSequenceBuilder getBuilder() { return new RichSequenceBuilder(); } @@ -33,7 +30,6 @@ public char charAt(int index) { return segments.charAt(index); } - @NotNull @Override public RichSequenceBuilder append(@Nullable CharSequence chars, int startIndex, int endIndex) { if (chars != null && chars.length() > 0 && startIndex < endIndex) { @@ -42,27 +38,23 @@ public RichSequenceBuilder append(@Nullable CharSequence chars, int startIndex, return this; } - @NotNull @Override public RichSequenceBuilder append(char c) { segments.append(c); return this; } - @NotNull @Override public RichSequenceBuilder append(char c, int count) { while (count-- > 0) segments.append(c); return this; } - @NotNull @Override public RichSequence getSingleBasedSequence() { return toSequence(); } - @NotNull @Override public RichSequence toSequence() { return RichSequence.of(segments); diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/Seg.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/Seg.java index 7c5a8b2c9..7335bc3ef 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/Seg.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/Seg.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.sequence.builder; import com.vladsch.flexmark.util.sequence.Range; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.util.misc.Utils.escapeJavaString; @@ -95,7 +94,6 @@ public boolean isNull() { return !(isBase() || isText()); } - @NotNull public Range getRange() { assert isBase(); return Range.of(start, end); @@ -110,7 +108,7 @@ public int length() { return isBase() ? end - start : isText() ? (start & MAX_TEXT_OFFSET) - (end & MAX_TEXT_OFFSET) : 0; } - public String toString(@NotNull CharSequence allText) { + public String toString(CharSequence allText) { if (this.isNull()) { return "NULL"; } else if (isBase()) { @@ -154,7 +152,6 @@ public String toString() { } } - @NotNull public static Seg segOf(int startOffset, int endOffset) { return startOffset == 0 && endOffset == 0 ? ANCHOR_0 : new Seg(startOffset, endOffset); } @@ -169,7 +166,6 @@ public static int getTextEnd(int startOffset, boolean isRepeatedText) { return -(isRepeatedText ? startOffset | F_TEXT_OPTION : startOffset) - 1; } - @NotNull public static Seg textOf(int startOffset, int endOffset, boolean isFirst256, boolean isRepeatedText) { return new Seg(getTextStart(startOffset, isFirst256), getTextEnd(endOffset, isRepeatedText)); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentBuilderBase.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentBuilderBase.java index 0dcd0dc3b..bd24ca965 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentBuilderBase.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentBuilderBase.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.misc.DelimitedBuilder; import com.vladsch.flexmark.util.sequence.Range; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.Iterator; @@ -19,7 +18,7 @@ public class SegmentBuilderBase> implements ISeg final public static int[] EMPTY_PARTS = { }; - protected @NotNull int[] parts = EMPTY_PARTS; + protected int[] parts = EMPTY_PARTS; protected int partsSize = 0; protected int anchorsSize = 0; @@ -34,7 +33,7 @@ public class SegmentBuilderBase> implements ISeg final protected StringBuilder text = new StringBuilder(); // text segment ranges come from this CharSequence protected int immutableOffset = 0; // text offset for all committed text segments - private static int[] ensureCapacity(@NotNull int[] prev, int size) { + private static int[] ensureCapacity(int[] prev, int size) { assert size >= 0; int prevSize = prev.length / 2; @@ -175,7 +174,7 @@ public SegmentStats getStats() { // @formatter:on @Override - public @NotNull Iterator iterator() { + public Iterator iterator() { return new PartsIterator(this); } @@ -199,7 +198,7 @@ public Object next() { } @Override - public @NotNull Iterable getSegments() { + public Iterable getSegments() { return new SegIterable(this); } @@ -210,7 +209,6 @@ public SegIterable(SegmentBuilderBase builder) { this.builder = builder; } - @NotNull @Override public Iterator iterator() { return new SegIterator(builder); @@ -262,13 +260,11 @@ private Seg getSegOrNull(int index) { return i + 1 >= parts.length ? null : Seg.segOf(parts[i], parts[i + 1]); } - @NotNull private Seg getSeg(int index) { int i = index * 2; return i + 1 >= parts.length ? Seg.NULL : Seg.segOf(parts[i], parts[i + 1]); } - @NotNull public Object getPart(int index) { if (index == partsSize && haveDanglingText()) { // return dangling text @@ -280,7 +276,6 @@ public Object getPart(int index) { } } - @NotNull Seg getSegPart(int index) { if (index == partsSize && haveDanglingText()) { // return dangling text @@ -322,11 +317,11 @@ protected boolean haveDanglingText() { return text.length() > immutableOffset; } - protected Object[] optimizeText(@NotNull Object[] parts) { + protected Object[] optimizeText(Object[] parts) { return parts; } - protected Object[] handleOverlap(@NotNull Object[] parts) { + protected Object[] handleOverlap(Object[] parts) { // range overlaps with last segment in the list Range lastSeg = (Range) parts[0]; CharSequence text = (CharSequence) parts[1]; @@ -350,7 +345,7 @@ protected Object[] handleOverlap(@NotNull Object[] parts) { return parts; } - private void processParts(int segStart, int segEnd, boolean resolveOverlap, boolean nullNextRange, @NotNull Function transform) { + private void processParts(int segStart, int segEnd, boolean resolveOverlap, boolean nullNextRange, Function transform) { assert segStart >= 0 && segEnd >= 0 && segStart <= segEnd; CharSequence text = this.text.subSequence(immutableOffset, this.text.length()); @@ -482,7 +477,6 @@ private void addText(CharSequence optText) { * @param offset offset in original sequence * @return this */ - @NotNull public S appendAnchor(int offset) { return append(offset, offset); } @@ -494,8 +488,7 @@ public S appendAnchor(int offset) { * @param range range in original sequence * @return this */ - @NotNull - public S append(@NotNull Range range) { + public S append(Range range) { return append(range.getStart(), range.getEnd()); } @@ -507,7 +500,6 @@ public S append(@NotNull Range range) { * @param endOffset end offset in original sequence * @return this */ - @NotNull public S append(int startOffset, int endOffset) { if (endOffset < 0 || startOffset > endOffset) //noinspection unchecked @@ -564,8 +556,7 @@ public S append(int startOffset, int endOffset) { return (S) this; } - @NotNull - public S append(@NotNull CharSequence text) { + public S append(CharSequence text) { int length = text.length(); if (length != 0) { stats.addText(text); @@ -578,7 +569,6 @@ public S append(@NotNull CharSequence text) { return (S) this; } - @NotNull public S append(char c) { stats.addText(c); textStats.addText(c); @@ -590,7 +580,6 @@ public S append(char c) { return (S) this; } - @NotNull public S append(char c, int repeat) { if (repeat > 0) { stats.addText(c, repeat); @@ -603,8 +592,7 @@ public S append(char c, int repeat) { return (S) this; } - @NotNull - public String toString(@NotNull CharSequence chars, @NotNull CharSequence rangePrefix, @NotNull CharSequence rangeSuffix, @NotNull Function textMapper) { + public String toString(CharSequence chars, CharSequence rangePrefix, CharSequence rangeSuffix, Function textMapper) { if (endOffset > chars.length()) { throw new IllegalArgumentException("baseSequence length() must be at least " + endOffset + ", got: " + chars.length()); } @@ -633,18 +621,15 @@ public String toString(@NotNull CharSequence chars, @NotNull CharSequence rangeP return out.toString(); } - @NotNull - public String toStringWithRangesVisibleWhitespace(@NotNull CharSequence chars) { + public String toStringWithRangesVisibleWhitespace(CharSequence chars) { return toString(chars, "⟦", "⟧", SequenceUtils::toVisibleWhitespaceString); } - @NotNull - public String toStringWithRanges(@NotNull CharSequence chars) { + public String toStringWithRanges(CharSequence chars) { return toString(chars, "⟦", "⟧", Function.identity()); } - @NotNull - public String toString(@NotNull CharSequence chars) { + public String toString(CharSequence chars) { return toString(chars, "", "", Function.identity()); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentOptimizer.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentOptimizer.java index dc8d89875..1c3f5c1a1 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentOptimizer.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentOptimizer.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.sequence.builder; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.function.BiFunction; @@ -20,7 +19,7 @@ public interface SegmentOptimizer extends BiFunction entries) { StringBuilder out = new StringBuilder(); int iMax = entries.size(); @@ -124,7 +122,6 @@ public String getStatsText(List entries) { return out.toString(); } - @NotNull public String getAggregatedStatsText() { return getStatsText(getAggregatedStats()); } @@ -151,7 +148,6 @@ public String getAggregatedStatsText() { static final int MAX_BUCKETS = AGGR_STEPS.size(); - @NotNull public List getAggregatedStats() { if (aggregatedStats == null) { List entries = getStats(); @@ -195,7 +191,6 @@ public List getAggregatedStats() { return aggregatedStats; } - @NotNull public String getStatsText() { List entries = getStats(); return getStatsText(entries); @@ -205,7 +200,6 @@ public void clear() { stats.clear(); } - @NotNull public List getStats() { ArrayList entries = new ArrayList<>(stats.keySet()); @@ -213,7 +207,6 @@ public List getStats() { return entries; } - @NotNull public static SegmentedSequenceStats getInstance() { return new SegmentedSequenceStats(); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SequenceBuilder.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SequenceBuilder.java index 5e1827cd8..be20321bc 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SequenceBuilder.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SequenceBuilder.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.util.sequence.Range; import com.vladsch.flexmark.util.sequence.SegmentedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; @@ -15,9 +14,9 @@ */ public class SequenceBuilder implements ISequenceBuilder { final private BasedSegmentBuilder segments; - final private @NotNull BasedSequence baseSeq; - final private @NotNull BasedSequence altBase; // sequence used for creating the builder, needed for validation for alt sequence creation - final private @NotNull HashMap equivalentBases; + final private BasedSequence baseSeq; + final private BasedSequence altBase; // sequence used for creating the builder, needed for validation for alt sequence creation + final private HashMap equivalentBases; private @Nullable BasedSequence resultSeq; /** @@ -31,11 +30,11 @@ public class SequenceBuilder implements ISequenceBuilder()); } - private SequenceBuilder(@NotNull BasedSequence base, @Nullable SegmentOptimizer optimizer, @NotNull HashMap equivalentBases) { + private SequenceBuilder(BasedSequence base, @Nullable SegmentOptimizer optimizer, HashMap equivalentBases) { altBase = base; baseSeq = base.getBaseSequence(); this.equivalentBases = equivalentBases; @@ -58,7 +57,7 @@ private SequenceBuilder(@NotNull BasedSequence base, @Nullable SegmentOptimizer * @param options builder options * @param optimizer optimizer for based segment builder, or default {@link CharRecoveryOptimizer} */ - private SequenceBuilder(@NotNull BasedSequence base, int options, @Nullable SegmentOptimizer optimizer, @NotNull HashMap equivalentBases) { + private SequenceBuilder(BasedSequence base, int options, @Nullable SegmentOptimizer optimizer, HashMap equivalentBases) { altBase = base; baseSeq = base.getBaseSequence(); this.equivalentBases = equivalentBases; @@ -68,12 +67,10 @@ private SequenceBuilder(@NotNull BasedSequence base, int options, @Nullable Segm segments = optimizer == null ? BasedSegmentBuilder.emptyBuilder(baseSeq, options) : BasedSegmentBuilder.emptyBuilder(baseSeq, optimizer, options); } - @NotNull public BasedSequence getBaseSequence() { return baseSeq; } - @NotNull public BasedSegmentBuilder getSegmentBuilder() { return segments; } @@ -91,7 +88,6 @@ public BasedSequence getSingleBasedSequence() { return range == null ? null : baseSeq.subSequence(range.getStart(), range.getEnd()); } - @NotNull @Override public SequenceBuilder getBuilder() { return new SequenceBuilder(altBase, segments.options, segments.optimizer, equivalentBases); @@ -102,7 +98,7 @@ public char charAt(int index) { return toSequence().charAt(index); } - boolean isCommonBaseSequence(@NotNull BasedSequence chars) { + boolean isCommonBaseSequence(BasedSequence chars) { if (chars.isNull()) return false; BasedSequence charsBaseSequence = chars.getBaseSequence(); @@ -117,7 +113,6 @@ boolean isCommonBaseSequence(@NotNull BasedSequence chars) { return equivalent; } - @NotNull @Override public SequenceBuilder append(@Nullable CharSequence chars, int startIndex, int endIndex) { if (chars instanceof BasedSequence && isCommonBaseSequence((BasedSequence) chars)) { @@ -140,14 +135,12 @@ public SequenceBuilder append(@Nullable CharSequence chars, int startIndex, int return this; } - @NotNull public SequenceBuilder append(char c) { segments.append(c); resultSeq = null; return this; } - @NotNull public SequenceBuilder append(char c, int count) { if (count > 0) { segments.append(c, count); @@ -156,24 +149,20 @@ public SequenceBuilder append(char c, int count) { return this; } - @NotNull public SequenceBuilder append(int startOffset, int endOffset) { return addByOffsets(startOffset, endOffset); } - @NotNull - public SequenceBuilder append(@NotNull Range chars) { + public SequenceBuilder append(Range chars) { return addRange(chars); } - @NotNull - public SequenceBuilder addRange(@NotNull Range range) { + public SequenceBuilder addRange(Range range) { segments.append(range); resultSeq = null; return this; } - @NotNull public SequenceBuilder addByOffsets(int startOffset, int endOffset) { if (startOffset < 0 || startOffset > endOffset || endOffset > baseSeq.length()) { throw new IllegalArgumentException("addByOffsets start/end must be a valid range in [0, " + baseSeq.length() + "], got: [" + startOffset + ", " + endOffset + "]"); @@ -183,12 +172,10 @@ public SequenceBuilder addByOffsets(int startOffset, int endOffset) { return this; } - @NotNull public SequenceBuilder addByLength(int startOffset, int textLength) { return add(baseSeq.subSequence(startOffset, startOffset + textLength)); } - @NotNull @Override public BasedSequence toSequence() { if (resultSeq == null) { @@ -203,8 +190,7 @@ public BasedSequence toSequence() { * @param altSequence based sequence which is character identical to this builder's baseSeq * @return builder with offsets mapped to altSequence */ - @NotNull - public BasedSequence toSequence(@NotNull BasedSequence altSequence) { + public BasedSequence toSequence(BasedSequence altSequence) { return toSequence(altSequence, null, null); } @@ -216,8 +202,7 @@ public BasedSequence toSequence(@NotNull BasedSequence altSequence) { * @param ignoreCharDiff chars which should be treated as equivalent for verification purposes (Space, Tab, EOL, usually) * @return builder with offsets mapped to altSequence */ - @NotNull - public BasedSequence toSequence(@NotNull BasedSequence altSequence, @Nullable CharPredicate trimStart, @Nullable CharPredicate ignoreCharDiff) { + public BasedSequence toSequence(BasedSequence altSequence, @Nullable CharPredicate trimStart, @Nullable CharPredicate ignoreCharDiff) { if (altSequence == altBase) { return toSequence(); } @@ -266,8 +251,7 @@ public BasedSequence toSequence(@NotNull BasedSequence altSequence, @Nullable Ch * @param ignoreCharDiff chars which should be treated as equivalent for verification purposes (Space, Tab, EOL, usually) * @return builder with offsets mapped to altSequence */ - @NotNull - public BasedSequence toSequenceByIndex(@NotNull BasedSequence altSequence, @Nullable CharPredicate trimStart, @Nullable CharPredicate ignoreCharDiff) { + public BasedSequence toSequenceByIndex(BasedSequence altSequence, @Nullable CharPredicate trimStart, @Nullable CharPredicate ignoreCharDiff) { if (altSequence == altBase) { return toSequence(); } @@ -318,17 +302,14 @@ public int length() { return segments.length(); } - @NotNull public String toStringWithRanges() { return segments.toStringWithRangesVisibleWhitespace(baseSeq); } - @NotNull public String toStringWithRanges(boolean toVisibleWhiteSpace) { return toVisibleWhiteSpace ? segments.toStringWithRangesVisibleWhitespace(baseSeq) : segments.toStringWithRanges(baseSeq); } - @NotNull public String toString() { StringBuilder sb = new StringBuilder(); BasedSequence last = null; @@ -351,7 +332,6 @@ public String toString() { return sb.toString(); } - @NotNull public String toStringNoAddedSpaces() { StringBuilder sb = new StringBuilder(); for (Object part : segments) { @@ -366,23 +346,19 @@ public String toStringNoAddedSpaces() { return sb.toString(); } - @NotNull - public static SequenceBuilder emptyBuilder(@NotNull BasedSequence base) { + public static SequenceBuilder emptyBuilder(BasedSequence base) { return new SequenceBuilder(base, null); } - @NotNull - public static SequenceBuilder emptyBuilder(@NotNull BasedSequence base, @NotNull SegmentOptimizer optimizer) { + public static SequenceBuilder emptyBuilder(BasedSequence base, SegmentOptimizer optimizer) { return new SequenceBuilder(base, optimizer); } - @NotNull - public static SequenceBuilder emptyBuilder(@NotNull BasedSequence base, int options) { + public static SequenceBuilder emptyBuilder(BasedSequence base, int options) { return new SequenceBuilder(base, options, null, new HashMap<>()); } - @NotNull - public static SequenceBuilder emptyBuilder(@NotNull BasedSequence base, int options, @NotNull SegmentOptimizer optimizer) { + public static SequenceBuilder emptyBuilder(BasedSequence base, int options, SegmentOptimizer optimizer) { return new SequenceBuilder(base, options, optimizer, new HashMap<>()); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/StringSequenceBuilder.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/StringSequenceBuilder.java index c95d69145..fd7b739c7 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/StringSequenceBuilder.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/StringSequenceBuilder.java @@ -1,13 +1,11 @@ package com.vladsch.flexmark.util.sequence.builder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * A Builder for non based strings. Just a string builder wrapped in a sequence builder interface */ final public class StringSequenceBuilder implements ISequenceBuilder { - @NotNull public static StringSequenceBuilder emptyBuilder() { return new StringSequenceBuilder(); } @@ -22,7 +20,6 @@ public StringSequenceBuilder(int initialCapacity) { this.segments = new StringBuilder(initialCapacity); } - @NotNull public StringSequenceBuilder getBuilder() { return new StringSequenceBuilder(); } @@ -32,7 +29,6 @@ public char charAt(int index) { return segments.charAt(index); } - @NotNull @Override public StringSequenceBuilder append(@Nullable CharSequence chars, int startIndex, int endIndex) { if (chars != null && chars.length() > 0 && startIndex < endIndex) { @@ -41,27 +37,23 @@ public StringSequenceBuilder append(@Nullable CharSequence chars, int startIndex return this; } - @NotNull @Override public StringSequenceBuilder append(char c) { segments.append(c); return this; } - @NotNull @Override public StringSequenceBuilder append(char c, int count) { while (count-- > 0) segments.append(c); return this; } - @NotNull @Override public CharSequence getSingleBasedSequence() { return toSequence(); } - @NotNull @Override public CharSequence toSequence() { return segments; diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/package-info.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/package-info.java new file mode 100644 index 000000000..749f582b6 --- /dev/null +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package com.vladsch.flexmark.util.sequence.builder; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/BasedOffsetTracker.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/BasedOffsetTracker.java index 204d5277e..453330958 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/BasedOffsetTracker.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/BasedOffsetTracker.java @@ -1,20 +1,19 @@ package com.vladsch.flexmark.util.sequence.builder.tree; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public class BasedOffsetTracker { - protected final @NotNull BasedSequence sequence; // sequence on which this tracker is based, not the base sequence of original sequence - protected final @NotNull SegmentOffsetTree segmentOffsetTree; + protected final BasedSequence sequence; // sequence on which this tracker is based, not the base sequence of original sequence + protected final SegmentOffsetTree segmentOffsetTree; private @Nullable Segment lastSegment; - protected BasedOffsetTracker(@NotNull BasedSequence sequence, @NotNull SegmentTree segmentTree) { + protected BasedOffsetTracker(BasedSequence sequence, SegmentTree segmentTree) { this.sequence = sequence; this.segmentOffsetTree = segmentTree.getSegmentOffsetTree(sequence.getBaseSequence()); } - protected BasedOffsetTracker(@NotNull BasedSequence sequence, @NotNull SegmentOffsetTree segmentOffsetTree) { + protected BasedOffsetTracker(BasedSequence sequence, SegmentOffsetTree segmentOffsetTree) { this.sequence = sequence; this.segmentOffsetTree = segmentOffsetTree; } @@ -35,7 +34,6 @@ public int size() { * if false then offset represents the character at offset and the range [offset, offset+1) * @return information about the offset in this sequence */ - @NotNull public OffsetInfo getOffsetInfo(int offset, boolean isEndOffset) { // if is end offset then will not int offsetEnd = isEndOffset ? offset : offset + 1; @@ -114,12 +112,10 @@ public OffsetInfo getOffsetInfo(int offset, boolean isEndOffset) { return lastResult; } - @NotNull public BasedSequence getSequence() { return sequence; } - @NotNull public SegmentOffsetTree getSegmentOffsetTree() { return segmentOffsetTree; } @@ -137,8 +133,7 @@ public String toString() { * @param sequence sequence which to create offset tracker * @return based offset tracker */ - @NotNull - public static BasedOffsetTracker create(@NotNull BasedSequence sequence) { + public static BasedOffsetTracker create(BasedSequence sequence) { SegmentTree segmentTree = sequence.getSegmentTree(); return new BasedOffsetTracker(sequence, segmentTree); } @@ -150,8 +145,7 @@ public static BasedOffsetTracker create(@NotNull BasedSequence sequence) { * @param segmentOffsetTree segment offset tree for the sequence * @return based offset tracker */ - @NotNull - public static BasedOffsetTracker create(@NotNull BasedSequence sequence, @NotNull SegmentOffsetTree segmentOffsetTree) { + public static BasedOffsetTracker create(BasedSequence sequence, SegmentOffsetTree segmentOffsetTree) { return new BasedOffsetTracker(sequence, segmentOffsetTree); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/Segment.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/Segment.java index 34a267d5e..4016f421b 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/Segment.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/Segment.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.Seg; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.util.misc.Utils.escapeJavaString; @@ -204,9 +203,9 @@ public String toString() { static class Base extends Segment { protected final int startOffset; protected final int endOffset; - protected final @NotNull BasedSequence baseSeq; + protected final BasedSequence baseSeq; - public Base(int pos, byte[] bytes, int byteOffset, int indexOffset, @NotNull BasedSequence basedSequence) { + public Base(int pos, byte[] bytes, int byteOffset, int indexOffset, BasedSequence basedSequence) { super(pos, bytes, byteOffset, indexOffset); baseSeq = basedSequence; @@ -316,7 +315,6 @@ public CharSequence subSequence(int startIndex, int endIndex) { return create(startOffset + startIndex, endIndex - startIndex); } - @NotNull @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -396,7 +394,6 @@ public CharSequence subSequence(int startIndex, int endIndex) { return new TextRepeatedSequence(c, endIndex - startIndex); } - @NotNull @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -408,7 +405,7 @@ public String toString() { } static class Text extends Segment { - protected final @NotNull CharSequence chars; + protected final CharSequence chars; public Text(int pos, byte[] bytes, int byteOffset, int indexOffset) { super(pos, bytes, byteOffset, indexOffset); @@ -509,14 +506,13 @@ public int getEndOffset() { return -1; } - @NotNull @Override public CharSequence getCharSequence() { return chars; } } - public static Segment getSegment(byte[] bytes, int byteOffset, int pos, int indexOffset, @NotNull BasedSequence basedSequence) { + public static Segment getSegment(byte[] bytes, int byteOffset, int pos, int indexOffset, BasedSequence basedSequence) { int type = bytes[byteOffset] & TYPE_MASK; switch (type) { @@ -537,7 +533,7 @@ public static Segment getSegment(byte[] bytes, int byteOffset, int pos, int inde } } - public static SegType getSegType(@NotNull Seg seg, @NotNull CharSequence textChars) { + public static SegType getSegType(Seg seg, CharSequence textChars) { if (seg.isBase()) { return seg.isAnchor() ? SegType.ANCHOR : SegType.BASE; } else if (seg.isText()) { @@ -575,7 +571,7 @@ public static int getIntBytes(int length) { return length < 256 ? 1 : length < 65536 ? 2 : length < 65536 * 256 ? 3 : 4; } - public static int getSegByteLength(@NotNull Segment.SegType segType, int segStart, int segLength) { + public static int getSegByteLength(Segment.SegType segType, int segStart, int segLength) { int length = 1; if (segType.hasBoth()) { @@ -594,7 +590,7 @@ public static int getSegByteLength(@NotNull Segment.SegType segType, int segStar return length; } - public static int getSegByteLength(@NotNull Seg seg, @NotNull CharSequence textChars) { + public static int getSegByteLength(Seg seg, CharSequence textChars) { SegType segType = getSegType(seg, textChars); return getSegByteLength(segType, seg.getSegStart(), seg.length()); } @@ -641,7 +637,7 @@ public static char getChar(byte[] bytes, int offset) { return c; } - public static int addChars(byte[] bytes, int offset, @NotNull CharSequence chars, int start, int end) { + public static int addChars(byte[] bytes, int offset, CharSequence chars, int start, int end) { for (int i = start; i < end; i++) { char c = chars.charAt(i); bytes[offset++] = (byte) ((c & 0x0000ff00) >> 8); @@ -656,7 +652,7 @@ public static int addCharAscii(byte[] bytes, int offset, char c) { return offset; } - public static int addCharsAscii(byte[] bytes, int offset, @NotNull CharSequence chars, int start, int end) { + public static int addCharsAscii(byte[] bytes, int offset, CharSequence chars, int start, int end) { for (int i = start; i < end; i++) { char c = chars.charAt(i); assert c < 256; @@ -669,7 +665,7 @@ public static char getCharAscii(byte[] bytes, int offset) { return (char) (0x00ff & bytes[offset]); } - public static int addSegBytes(byte[] bytes, int offset, @NotNull Seg seg, @NotNull CharSequence textChars) { + public static int addSegBytes(byte[] bytes, int offset, Seg seg, CharSequence textChars) { SegType segType = getSegType(seg, textChars); int segLength = seg.length(); diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentOffsetTree.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentOffsetTree.java index 1e8d8d752..10b246563 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentOffsetTree.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentOffsetTree.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.util.sequence.builder.BasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.IBasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.Seg; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * Segment tree which uses offsets instead of aggregated length of segments @@ -18,28 +17,25 @@ * Their use will throw {@link IllegalStateException} if invoked. */ public class SegmentOffsetTree extends SegmentTree { - final protected @NotNull int[] startIndices; + final protected int[] startIndices; - protected SegmentOffsetTree(@NotNull int[] treeData, @NotNull byte[] segmentBytes, @NotNull int[] startIndices) { + protected SegmentOffsetTree(int[] treeData, byte[] segmentBytes, int[] startIndices) { super(treeData, segmentBytes); this.startIndices = startIndices; } - @NotNull - public static SegmentOffsetTree build(@NotNull Iterable segments, @NotNull CharSequence allText) { + public static SegmentOffsetTree build(Iterable segments, CharSequence allText) { SegmentTreeData segmentTreeData = buildTreeData(segments, allText, false); assert segmentTreeData.startIndices != null; return new SegmentOffsetTree(segmentTreeData.treeData, segmentTreeData.segmentBytes, segmentTreeData.startIndices); } - @NotNull - public static SegmentOffsetTree build(@NotNull BasedSegmentBuilder builder) { - @NotNull SegmentTreeData segmentTreeData = buildTreeData(builder.getSegments(), builder.getText(), true); + public static SegmentOffsetTree build(BasedSegmentBuilder builder) { + SegmentTreeData segmentTreeData = buildTreeData(builder.getSegments(), builder.getText(), true); return new SegmentTree(segmentTreeData.treeData, segmentTreeData.segmentBytes).getSegmentOffsetTree(builder.getBaseSequence()); } - @NotNull - public static SegmentOffsetTree build(@NotNull BasedSequence baseSeq) { + public static SegmentOffsetTree build(BasedSequence baseSeq) { return baseSeq.getSegmentTree().getSegmentOffsetTree(baseSeq); } @@ -51,8 +47,7 @@ public int getStartIndex(int pos) { return pos < 0 ? 0 : pos >= startIndices.length ? startIndices[startIndices.length - 1] : startIndices[pos]; } - @NotNull - public Segment getSegment(int pos, @NotNull BasedSequence baseSeq) { + public Segment getSegment(int pos, BasedSequence baseSeq) { return Segment.getSegment(segmentBytes, byteOffset(pos), pos, startIndices[pos], baseSeq); } @@ -61,7 +56,7 @@ public Segment getSegment(int pos, @NotNull BasedSequence baseSeq) { } @Nullable - public Segment getPreviousText(@NotNull Segment segment, @NotNull BasedSequence baseSeq) { + public Segment getPreviousText(Segment segment, BasedSequence baseSeq) { if (segment.getPos() == 0) { if (segment.getStartIndex() > 0) { Segment textSeg = getSegment(0, -1, 0, baseSeq); @@ -75,7 +70,7 @@ public Segment getPreviousText(@NotNull Segment segment, @NotNull BasedSequence } @Nullable - public Segment getNextText(@NotNull Segment segment, @NotNull BasedSequence baseSeq) { + public Segment getNextText(Segment segment, BasedSequence baseSeq) { if (segment.getByteOffset() + segment.getByteLength() < segmentBytes.length) { Segment textSeg = getSegment(segment.getByteOffset() + segment.getByteLength(), -1, segment.getEndIndex(), baseSeq); if (textSeg.isText()) return textSeg; @@ -83,7 +78,7 @@ public Segment getNextText(@NotNull Segment segment, @NotNull BasedSequence base return null; } - public @Nullable Segment findSegmentByOffset(int offset, @NotNull BasedSequence baseSeq, @Nullable Segment hint) { + public @Nullable Segment findSegmentByOffset(int offset, BasedSequence baseSeq, @Nullable Segment hint) { int startPos = 0; int endPos = size(); @@ -95,8 +90,7 @@ public Segment getNextText(@NotNull Segment segment, @NotNull BasedSequence base return null; } - @NotNull - public String toString(@NotNull BasedSequence baseSeq) { + public String toString(BasedSequence baseSeq) { DelimitedBuilder out = new DelimitedBuilder(", "); out.append(getClass().getSimpleName()).append("{aggr: {"); int iMax = size(); @@ -144,31 +138,31 @@ public int aggrLength(int pos) { @Deprecated @Override - public @Nullable Segment findSegment(int index, @NotNull BasedSequence baseSeq, @Nullable Segment hint) { + public @Nullable Segment findSegment(int index, BasedSequence baseSeq, @Nullable Segment hint) { throw new IllegalStateException("Method in SegmentOffsetTree should not be used"); } @Deprecated @Override - public @Nullable Segment findSegment(int index, int startPos, int endPos, @NotNull BasedSequence baseSeq, @Nullable Segment hint) { + public @Nullable Segment findSegment(int index, int startPos, int endPos, BasedSequence baseSeq, @Nullable Segment hint) { throw new IllegalStateException("Method in SegmentOffsetTree should not be used"); } @Deprecated @Override - public @NotNull SegmentTreeRange getSegmentRange(int startIndex, int endIndex, int startPos, int endPos, @NotNull BasedSequence baseSeq, @Nullable Segment hint) { + public SegmentTreeRange getSegmentRange(int startIndex, int endIndex, int startPos, int endPos, BasedSequence baseSeq, @Nullable Segment hint) { return super.getSegmentRange(startIndex, endIndex, startPos, endPos, baseSeq, hint); } @Deprecated @Override - public void addSegments(@NotNull IBasedSegmentBuilder builder, @NotNull SegmentTreeRange treeRange) { + public void addSegments(IBasedSegmentBuilder builder, SegmentTreeRange treeRange) { throw new IllegalStateException("Method in SegmentOffsetTree should not be used"); } @Deprecated @Override - public void addSegments(@NotNull IBasedSegmentBuilder builder, int startIndex, int endIndex, int startOffset, int endOffset, int startPos, int endPos) { + public void addSegments(IBasedSegmentBuilder builder, int startIndex, int endIndex, int startOffset, int endOffset, int startPos, int endPos) { throw new IllegalStateException("Method in SegmentOffsetTree should not be used"); } @@ -180,7 +174,7 @@ public void addSegments(@NotNull IBasedSegmentBuilder builder, int startIndex @Deprecated @Override - public @Nullable Segment getPrevAnchor(int pos, @NotNull BasedSequence baseSeq) { + public @Nullable Segment getPrevAnchor(int pos, BasedSequence baseSeq) { throw new IllegalStateException("Method in SegmentOffsetTree should not be used"); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTree.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTree.java index 41b5b3b47..76edd68f6 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTree.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTree.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.util.sequence.builder.BasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.IBasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.Seg; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; @@ -75,18 +74,17 @@ public SegmentTreePos findSegmentPos(int index) { return findSegmentPos(index, treeData, 0, size()); } - @NotNull - public Segment getSegment(int byteOffset, int pos, int startIndex, @NotNull BasedSequence baseSeq) { + public Segment getSegment(int byteOffset, int pos, int startIndex, BasedSequence baseSeq) { return Segment.getSegment(segmentBytes, byteOffset, pos, startIndex, baseSeq); } @Nullable - public Segment findSegment(int index, @NotNull BasedSequence baseSeq, @Nullable Segment hint) { + public Segment findSegment(int index, BasedSequence baseSeq, @Nullable Segment hint) { return findSegment(index, 0, size(), baseSeq, hint); } @Nullable - public Segment findSegment(int index, int startPos, int endPos, @NotNull BasedSequence baseSeq, @Nullable Segment hint) { + public Segment findSegment(int index, int startPos, int endPos, BasedSequence baseSeq, @Nullable Segment hint) { if (hint != null) { // NOTE: first try around cached segment for this index int startIndex = hint.getStartIndex(); @@ -161,8 +159,7 @@ public Segment findSegment(int index, int startPos, int endPos, @NotNull BasedSe return null; } - @NotNull - public SegmentTreeRange getSegmentRange(int startIndex, int endIndex, int startPos, int endPos, @NotNull BasedSequence baseSequence, @Nullable Segment hint) { + public SegmentTreeRange getSegmentRange(int startIndex, int endIndex, int startPos, int endPos, BasedSequence baseSequence, @Nullable Segment hint) { Segment startSegment; Segment endSegment; @@ -239,7 +236,7 @@ public SegmentTreeRange getSegmentRange(int startIndex, int endIndex, int startP ); } - public int getTextEndOffset(Segment segment, @NotNull BasedSequence baseSequence) { + public int getTextEndOffset(Segment segment, BasedSequence baseSequence) { assert segment.isText(); if (segment.pos + 1 < size()) { @@ -251,7 +248,7 @@ public int getTextEndOffset(Segment segment, @NotNull BasedSequence baseSequence return -1; } - public int getTextStartOffset(Segment segment, @NotNull BasedSequence baseSequence) { + public int getTextStartOffset(Segment segment, BasedSequence baseSequence) { assert segment.isText(); Segment prevSegment = getPrevAnchor(segment.pos, baseSequence); @@ -271,7 +268,7 @@ public int getTextStartOffset(Segment segment, @NotNull BasedSequence baseSequen * @param builder based segment builder * @param treeRange treeRange for which to add segments */ - public void addSegments(@NotNull IBasedSegmentBuilder builder, @NotNull SegmentTreeRange treeRange) { + public void addSegments(IBasedSegmentBuilder builder, SegmentTreeRange treeRange) { addSegments(builder, treeRange.startIndex, treeRange.endIndex, treeRange.startOffset, treeRange.endOffset, treeRange.startPos, treeRange.endPos); } @@ -286,7 +283,7 @@ public void addSegments(@NotNull IBasedSegmentBuilder builder, @NotNull Segme * @param startPos start pos of sub-sequence segments in tree * @param endPos end pos of sub-sequence segments in tree */ - public void addSegments(@NotNull IBasedSegmentBuilder builder, int startIndex, int endIndex, int startOffset, int endOffset, int startPos, int endPos) { + public void addSegments(IBasedSegmentBuilder builder, int startIndex, int endIndex, int startOffset, int endOffset, int startPos, int endPos) { // add our stuff to builder if (startOffset != -1) { builder.appendAnchor(startOffset); @@ -341,8 +338,7 @@ public void addSegments(@NotNull IBasedSegmentBuilder builder, int startIndex * @param endPos end pos of sub-sequence segments in tree * @return subsequence of segment corresponding to part of it which is in the sub-sequence of the tree */ - @NotNull - public static CharSequence getCharSequence(@NotNull Segment segment, int startIndex, int endIndex, int startPos, int endPos) { + public static CharSequence getCharSequence(Segment segment, int startIndex, int endIndex, int startPos, int endPos) { CharSequence charSequence; int pos = segment.pos; @@ -367,18 +363,16 @@ public SegmentTreePos findSegmentPos(int index, int startPos, int endPos) { return findSegmentPos(index, treeData, startPos, endPos); } - @NotNull - public Segment getSegment(int pos, @NotNull BasedSequence baseSeq) { + public Segment getSegment(int pos, BasedSequence baseSeq) { return Segment.getSegment(segmentBytes, byteOffset(pos), pos, aggrLength(pos - 1), baseSeq); } @Nullable - public Segment getPrevAnchor(int pos, @NotNull BasedSequence baseSeq) { + public Segment getPrevAnchor(int pos, BasedSequence baseSeq) { return getPrevAnchor(pos, treeData, segmentBytes, baseSeq); } - @NotNull - public String toString(@NotNull BasedSequence baseSeq) { + public String toString(BasedSequence baseSeq) { DelimitedBuilder out = new DelimitedBuilder(", "); out.append(getClass().getSimpleName()).append("{aggr: {"); int iMax = size(); @@ -401,7 +395,6 @@ public String toString(@NotNull BasedSequence baseSeq) { return out.toString(); } - @NotNull @Override public String toString() { return toString(BasedSequence.NULL); @@ -471,7 +464,7 @@ public static SegmentTreePos findSegmentPos(int index, int[] treeData, int start } @Nullable - public static Segment findSegment(int index, int[] treeData, int startPos, int endPos, byte[] segmentBytes, @NotNull BasedSequence baseSeq) { + public static Segment findSegment(int index, int[] treeData, int startPos, int endPos, byte[] segmentBytes, BasedSequence baseSeq) { SegmentTreePos treePos = findSegmentPos(index, treeData, startPos, endPos); if (treePos != null) { return Segment.getSegment(segmentBytes, byteOffset(treePos.pos, treeData), treePos.pos, treePos.startIndex, baseSeq); @@ -479,13 +472,12 @@ public static Segment findSegment(int index, int[] treeData, int startPos, int e return null; } - @NotNull - public static Segment getSegment(int pos, int[] treeData, byte[] segmentBytes, @NotNull BasedSequence baseSeq) { + public static Segment getSegment(int pos, int[] treeData, byte[] segmentBytes, BasedSequence baseSeq) { return Segment.getSegment(segmentBytes, byteOffset(pos, treeData), pos, aggrLength(pos, treeData), baseSeq); } @Nullable - public static Segment getPrevAnchor(int pos, int[] treeData, byte[] segmentBytes, @NotNull BasedSequence baseSeq) { + public static Segment getPrevAnchor(int pos, int[] treeData, byte[] segmentBytes, BasedSequence baseSeq) { int byteOffsetData = byteOffsetData(pos, treeData); int anchorOffset = getAnchorOffset(byteOffsetData); if (anchorOffset > 0) { @@ -499,26 +491,24 @@ public static Segment getPrevAnchor(int pos, int[] treeData, byte[] segmentBytes } protected static class SegmentTreeData { - final public @NotNull int[] treeData; // tuples of aggregated length, segment byte offset with flags for prev anchor offset of 1 to 7 - final public @NotNull byte[] segmentBytes; // bytes of serialized segments - final public @Nullable int[] startIndices; // start index for each segment within the string + final public int[] treeData; // tuples of aggregated length, segment byte offset with flags for prev anchor offset of 1 to 7 + final public byte[] segmentBytes; // bytes of serialized segments + final public int @Nullable [] startIndices; // start index for each segment within the string - public SegmentTreeData(@NotNull int[] treeData, @NotNull byte[] segmentBytes, @Nullable int[] startIndices) { + public SegmentTreeData(int[] treeData, byte[] segmentBytes, int @Nullable [] startIndices) { this.treeData = treeData; this.segmentBytes = segmentBytes; this.startIndices = startIndices; } } - @NotNull - public static SegmentTree build(@NotNull Iterable segments, @NotNull CharSequence allText) { - @NotNull SegmentTreeData segmentTreeData = buildTreeData(segments, allText, true); + public static SegmentTree build(Iterable segments, CharSequence allText) { + SegmentTreeData segmentTreeData = buildTreeData(segments, allText, true); return new SegmentTree(segmentTreeData.treeData, segmentTreeData.segmentBytes); } - @NotNull - public static SegmentTree build(@NotNull BasedSegmentBuilder builder) { - @NotNull SegmentTreeData segmentTreeData = buildTreeData(builder.getSegments(), builder.getText(), true); + public static SegmentTree build(BasedSegmentBuilder builder) { + SegmentTreeData segmentTreeData = buildTreeData(builder.getSegments(), builder.getText(), true); return new SegmentTree(segmentTreeData.treeData, segmentTreeData.segmentBytes); } @@ -536,8 +526,7 @@ public static SegmentTree build(@NotNull BasedSegmentBuilder builder) { * @param buildIndexData true to build index search data, false to build base offset tree data * @return segment tree instance with the data */ - @NotNull - public static SegmentTreeData buildTreeData(@NotNull Iterable segments, @NotNull CharSequence allText, boolean buildIndexData) { + public static SegmentTreeData buildTreeData(Iterable segments, CharSequence allText, boolean buildIndexData) { int byteLength = 0; int nonAnchors = 0; int lastEndOffset = 0; @@ -623,8 +612,7 @@ public static SegmentTreeData buildTreeData(@NotNull Iterable segments, @No * @param baseSeq base sequence for the sequence for this segment tree * @return SegmentOffsetTree for this segment tree */ - @NotNull - public SegmentOffsetTree getSegmentOffsetTree(@NotNull BasedSequence baseSeq) { + public SegmentOffsetTree getSegmentOffsetTree(BasedSequence baseSeq) { int nonAnchors = 0; int byteLength = segmentBytes.length; int segOffset = 0; diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/package-info.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/package-info.java new file mode 100644 index 000000000..fea9cdf82 --- /dev/null +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package com.vladsch.flexmark.util.sequence.builder.tree; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpaceMapper.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpaceMapper.java index 441cc26fd..c843c0192 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpaceMapper.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpaceMapper.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; public class SpaceMapper { final public static CharMapper toNonBreakSpace = new ToNonBreakSpace(); @@ -12,7 +11,7 @@ public static boolean areEquivalent(char c1, char c2) { return c1 == c2 || (c1 == ' ' && c2 == SequenceUtils.NBSP) || (c2 == ' ' && c1 == SequenceUtils.NBSP); } - public static @NotNull CharMapper toSpaces(@NotNull CharPredicate predicate) { + public static CharMapper toSpaces(CharPredicate predicate) { return new FromPredicate(predicate); } @@ -26,9 +25,9 @@ public char map(char c) { } private static class FromPredicate implements CharMapper { - final @NotNull CharPredicate myPredicate; + final CharPredicate myPredicate; - FromPredicate(@NotNull CharPredicate predicate) { + FromPredicate(CharPredicate predicate) { myPredicate = predicate; } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInCharsHandler.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInCharsHandler.java index 3eec34010..b2bb59f3c 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInCharsHandler.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInCharsHandler.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.Consumer; @@ -27,7 +26,7 @@ protected SpecialLeadInCharsHandler(CharPredicate predicate) { * @return true if sequence was a lead in for the handler */ @Override - public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer) { + public boolean escape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer) { if (sequence.length() == 1 && predicate.test(sequence.charAt(0))) { consumer.accept("\\"); consumer.accept(sequence); @@ -48,7 +47,7 @@ public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder opti * @return true if sequence was a lead in for the handler */ @Override - public boolean unEscape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer) { + public boolean unEscape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer) { if (sequence.length() == 2 && sequence.charAt(0) == '\\' && predicate.test(sequence.charAt(1))) { consumer.accept(sequence.subSequence(1)); return true; @@ -56,13 +55,11 @@ public boolean unEscape(@NotNull BasedSequence sequence, @Nullable DataHolder op return false; } - @NotNull public static SpecialLeadInCharsHandler create(char leadInChar) { return new SpecialLeadInCharsHandler(CharPredicate.anyOf(leadInChar)); } - @NotNull - public static SpecialLeadInCharsHandler create(@NotNull CharSequence leadInChar) { + public static SpecialLeadInCharsHandler create(CharSequence leadInChar) { return new SpecialLeadInCharsHandler(CharPredicate.anyOf(leadInChar)); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInHandler.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInHandler.java index fad6690f1..2e1794c50 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInHandler.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInHandler.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.Consumer; @@ -19,7 +18,7 @@ public interface SpecialLeadInHandler { * @param consumer consumer of char sequences to be called for the leadIn if it is changed by this handler * @return true if sequence was a lead in for the handler */ - boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer); + boolean escape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer); /** * UnEscape special lead-in characters which start a block element if first non-whitespace on the line @@ -32,5 +31,5 @@ public interface SpecialLeadInHandler { * @param consumer consumer of char sequences to be called for the leadIn if it is changed by this handler * @return true if sequence was a lead in for the handler */ - boolean unEscape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer); + boolean unEscape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer); } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInStartsWithCharsHandler.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInStartsWithCharsHandler.java index 6947ee923..27fce1b66 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInStartsWithCharsHandler.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInStartsWithCharsHandler.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.Consumer; @@ -27,7 +26,7 @@ protected SpecialLeadInStartsWithCharsHandler(CharPredicate predicate) { * @return true if sequence was a lead in for the handler */ @Override - public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer) { + public boolean escape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer) { if (sequence.length() >= 1 && predicate.test(sequence.charAt(0))) { consumer.accept("\\"); consumer.accept(sequence); @@ -48,7 +47,7 @@ public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder opti * @return true if sequence was a lead in for the handler */ @Override - public boolean unEscape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer) { + public boolean unEscape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer) { if (sequence.length() >= 2 && sequence.charAt(0) == '\\' && predicate.test(sequence.charAt(1))) { consumer.accept(sequence.subSequence(1)); return true; @@ -56,13 +55,11 @@ public boolean unEscape(@NotNull BasedSequence sequence, @Nullable DataHolder op return false; } - @NotNull public static SpecialLeadInStartsWithCharsHandler create(char leadInChar) { return new SpecialLeadInStartsWithCharsHandler(CharPredicate.anyOf(leadInChar)); } - @NotNull - public static SpecialLeadInStartsWithCharsHandler create(@NotNull CharSequence leadInChar) { + public static SpecialLeadInStartsWithCharsHandler create(CharSequence leadInChar) { return new SpecialLeadInStartsWithCharsHandler(CharPredicate.anyOf(leadInChar)); } } diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/package-info.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/package-info.java index 09d34f76f..8935f10a9 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/package-info.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.sequence.mappers; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/package-info.java b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/package-info.java index 1be99be6e..c42dd05d9 100644 --- a/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/package-info.java +++ b/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.sequence; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util-visitor/pom.xml b/flexmark-util-visitor/pom.xml index 7bbbeace1..6cc47a325 100644 --- a/flexmark-util-visitor/pom.xml +++ b/flexmark-util-visitor/pom.xml @@ -18,9 +18,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstActionHandler.java b/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstActionHandler.java index 3d3994468..519359b18 100644 --- a/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstActionHandler.java +++ b/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstActionHandler.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.visitor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; import java.util.Map; @@ -18,15 +17,15 @@ * @param handler to invoke the functionality during AST traversal for specific node */ public abstract class AstActionHandler, N, A extends AstAction, H extends AstHandler> { - final private @NotNull Map, H> customHandlersMap = new HashMap<>(); - final private @NotNull AstNode astAdapter; + final private Map, H> customHandlersMap = new HashMap<>(); + final private AstNode astAdapter; - public AstActionHandler(@NotNull AstNode astAdapter) { + public AstActionHandler(AstNode astAdapter) { this.astAdapter = astAdapter; } @SafeVarargs - final protected @NotNull C addActionHandlers(@NotNull H[]... handlers) { + final protected C addActionHandlers(H[]... handlers) { for (H[] moreHandlers : handlers) { for (H handler : moreHandlers) { customHandlersMap.put(handler.getNodeType(), handler); @@ -36,7 +35,7 @@ public AstActionHandler(@NotNull AstNode astAdapter) { return (C) this; } - protected @NotNull C addActionHandler(@NotNull H handler) { + protected C addActionHandler(H handler) { customHandlersMap.put(handler.getNodeType(), handler); //noinspection unchecked return (C) this; @@ -46,23 +45,23 @@ public AstActionHandler(@NotNull AstNode astAdapter) { return handler == null ? null : handler.getAdapter(); } - public @Nullable A getAction(@NotNull N node) { + public @Nullable A getAction(N node) { return getAction(customHandlersMap.get(node.getClass())); } - public @Nullable A getAction(@NotNull Class nodeClass) { + public @Nullable A getAction(Class nodeClass) { return getAction(customHandlersMap.get(nodeClass)); } - protected @Nullable H getHandler(@NotNull N node) { + protected @Nullable H getHandler(N node) { return customHandlersMap.get(node.getClass()); } - protected @Nullable H getHandler(@NotNull Class nodeClass) { + protected @Nullable H getHandler(Class nodeClass) { return customHandlersMap.get(nodeClass); } - public @NotNull Set> getNodeClasses() { + public Set> getNodeClasses() { return customHandlersMap.keySet(); } @@ -75,7 +74,7 @@ public AstActionHandler(@NotNull AstNode astAdapter) { * @param withChildren whether to process child nodes if there is no handler for the node type * @param processor processor to invoke to perform the processing, BiConsumer taking N node, and A action */ - protected void processNode(@NotNull N node, boolean withChildren, @NotNull BiConsumer processor) { + protected void processNode(N node, boolean withChildren, BiConsumer processor) { A action = getAction(node); if (action != null) { processor.accept(node, action); @@ -84,7 +83,7 @@ protected void processNode(@NotNull N node, boolean withChildren, @NotNull BiCon } } - protected final void processChildren(@NotNull N node, @NotNull BiConsumer processor) { + protected final void processChildren(N node, BiConsumer processor) { N child = astAdapter.getFirstChild(node); while (child != null) { // A subclass of this visitor might modify the node, resulting in getNext returning a different node or no @@ -104,7 +103,7 @@ protected final void processChildren(@NotNull N node, @NotNull BiConsumer * @param type of result returned by processor * @return result or defaultValue */ - final protected R processNodeOnly(@NotNull N node, R defaultValue, @NotNull BiFunction processor) { + final protected R processNodeOnly(N node, R defaultValue, BiFunction processor) { Object[] value = { defaultValue }; processNode(node, false, (n, h) -> value[0] = processor.apply(n, h)); //noinspection unchecked diff --git a/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstHandler.java b/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstHandler.java index bf2c42c73..736d3144d 100644 --- a/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstHandler.java +++ b/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstHandler.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.util.visitor; -import org.jetbrains.annotations.NotNull; /** * Base class for tracking generic node to specific node handler @@ -9,19 +8,19 @@ * @param node action */ abstract public class AstHandler> { - final private @NotNull Class aClass; - final private @NotNull A adapter; + final private Class aClass; + final private A adapter; - public AstHandler(@NotNull Class klass, @NotNull A adapter) { + public AstHandler(Class klass, A adapter) { aClass = klass; this.adapter = adapter; } - public @NotNull Class getNodeType() { + public Class getNodeType() { return aClass; } - public @NotNull A getAdapter() { + public A getAdapter() { return adapter; } diff --git a/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstNode.java b/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstNode.java index 88406062c..26463950d 100644 --- a/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstNode.java +++ b/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstNode.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.visitor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * Interface for converting to AstAccess @@ -9,6 +8,6 @@ * @param type of node */ public interface AstNode { - @Nullable N getFirstChild(@NotNull N node); - @Nullable N getNext(@NotNull N node); + @Nullable N getFirstChild(N node); + @Nullable N getNext(N node); } diff --git a/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/package-info.java b/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/package-info.java index ba29a8cd2..affd61308 100644 --- a/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/package-info.java +++ b/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.util.visitor; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-util/pom.xml b/flexmark-util/pom.xml index 3803b14a8..5b7c24a31 100644 --- a/flexmark-util/pom.xml +++ b/flexmark-util/pom.xml @@ -74,9 +74,9 @@ test - org.jetbrains - annotations - 24.0.1 + org.jspecify + jspecify + 1.0.0 diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/ExceptionMatcher.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/ExceptionMatcher.java index f8f71616e..30df359a3 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/ExceptionMatcher.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/ExceptionMatcher.java @@ -2,16 +2,15 @@ import org.hamcrest.BaseMatcher; import org.hamcrest.Description; -import org.jetbrains.annotations.NotNull; import java.util.regex.Pattern; public class ExceptionMatcher extends BaseMatcher { - final private @NotNull String prefix; - final private @NotNull Pattern pattern; - final private @NotNull String message; + final private String prefix; + final private Pattern pattern; + final private String message; - public ExceptionMatcher(@NotNull Class throwable, @NotNull Pattern pattern, @NotNull String message) { + public ExceptionMatcher(Class throwable, Pattern pattern, String message) { this.prefix = throwable.getName(); this.pattern = pattern; this.message = message; @@ -43,18 +42,15 @@ public void describeTo(Description description) { description.appendText(prefix + ": " + message); } - @NotNull - public static ExceptionMatcher match(@NotNull Class throwable, @NotNull String text) { + public static ExceptionMatcher match(Class throwable, String text) { return new ExceptionMatcher(throwable, Pattern.compile(Pattern.quote(text)), text); } - @NotNull - public static ExceptionMatcher matchPrefix(@NotNull Class throwable, @NotNull String text) { + public static ExceptionMatcher matchPrefix(Class throwable, String text) { return new ExceptionMatcher(throwable, Pattern.compile(Pattern.quote(text) + "(?s:.*)"), text); } - @NotNull - public static ExceptionMatcher matchRegEx(@NotNull Class throwable, @NotNull String regEx) { + public static ExceptionMatcher matchRegEx(Class throwable, String regEx) { return new ExceptionMatcher(throwable, Pattern.compile(regEx), regEx); } } diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/collection/CollectionHostValidator.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/collection/CollectionHostValidator.java index 413ed5642..a881e2985 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/collection/CollectionHostValidator.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/collection/CollectionHostValidator.java @@ -2,7 +2,7 @@ import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.misc.Paired; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Assert; import java.util.ArrayList; diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/BasedSequenceFullImplTest.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/BasedSequenceFullImplTest.java index b3e60ba4f..d6909e91a 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/BasedSequenceFullImplTest.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/BasedSequenceFullImplTest.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.sequence.builder.BasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.ArrayList; @@ -15,7 +14,7 @@ public class BasedSequenceFullImplTest { // TEST: need to complete tests here - static BasedSequence basedSequenceOf(@NotNull CharSequence chars) { + static BasedSequence basedSequenceOf(CharSequence chars) { return BasedSequence.of(BasedOptionsSequence.of(chars, BasedSequence.F_FULL_SEGMENTED_SEQUENCES)); } diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceTreeTest.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceTreeTest.java index a1b0ba8e1..7c3041020 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceTreeTest.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceTreeTest.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.sequence.builder.BasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; import com.vladsch.flexmark.util.sequence.mappers.SpaceMapper; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.ArrayList; @@ -16,7 +15,7 @@ public class SegmentedSequenceTreeTest { // TEST: need to complete tests here - static BasedSequence basedSequenceOf(@NotNull CharSequence chars) { + static BasedSequence basedSequenceOf(CharSequence chars) { return BasedSequence.of(BasedOptionsSequence.of(chars, BasedSequence.F_TREE_SEGMENTED_SEQUENCES)); } diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/BasedSegmentBuilderTest.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/BasedSegmentBuilderTest.java index ed8ef986e..e157b8b1d 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/BasedSegmentBuilderTest.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/BasedSegmentBuilderTest.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.PositionAnchor; import com.vladsch.flexmark.util.sequence.Range; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.List; @@ -1289,7 +1288,7 @@ public void test_optimizersCompoundNoAnchors1() { BasedSequence sequence = BasedSequence.of(input); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) segments.append(" "); @@ -1320,7 +1319,7 @@ public void test_optimizersCompoundNoAnchors2() { BasedSequence sequence = BasedSequence.of(input); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) segments.append(" "); @@ -1351,7 +1350,7 @@ public void test_optimizersCompoundNoAnchors3() { BasedSequence sequence = BasedSequence.of(input); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); // if (!trim.isEmpty()) segments.append(" "); @@ -1382,7 +1381,7 @@ public void test_optimizersCompoundAnchors1() { BasedSequence sequence = BasedSequence.of(input); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) segments.append(" "); @@ -1413,7 +1412,7 @@ public void test_optimizersCompoundAnchors2() { BasedSequence sequence = BasedSequence.of(input); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) segments.append(" "); @@ -1445,7 +1444,7 @@ public void test_optimizersCompound3Anchors() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, optimizer, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); // if (!trim.isEmpty()) segments.append(" "); diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/PlainSegmentBuilderTest.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/PlainSegmentBuilderTest.java index 8f248cc1e..7f82ebf07 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/PlainSegmentBuilderTest.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/PlainSegmentBuilderTest.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.PositionAnchor; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.List; @@ -457,16 +456,14 @@ public OptimizedSegmentBuilder2(CharSequence base, CharRecoveryOptimizer optimiz } @Override - protected Object[] optimizeText(@NotNull Object[] parts) { + protected Object[] optimizeText(Object[] parts) { return myOptimizer.apply(myBase, parts); } - @NotNull public static OptimizedSegmentBuilder2 emptyBuilder(CharSequence base, CharRecoveryOptimizer optimizer) { return new OptimizedSegmentBuilder2(base, optimizer); } - @NotNull public static OptimizedSegmentBuilder2 emptyBuilder(CharSequence base, CharRecoveryOptimizer optimizer, int options) { return new OptimizedSegmentBuilder2(base, optimizer, options); } @@ -874,7 +871,7 @@ public void test_optimizersCompoundNoAnchors1() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); OptimizedSegmentBuilder2 segments = OptimizedSegmentBuilder2.emptyBuilder(sequence, optimizer, F_TRACK_FIRST256); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) segments.append(" "); @@ -904,7 +901,7 @@ public void test_optimizersCompoundNoAnchors2() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); OptimizedSegmentBuilder2 segments = OptimizedSegmentBuilder2.emptyBuilder(sequence, optimizer, F_TRACK_FIRST256); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) segments.append(" "); @@ -936,7 +933,7 @@ public void test_optimizersCompoundNoAnchors3() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); OptimizedSegmentBuilder2 segments = OptimizedSegmentBuilder2.emptyBuilder(sequence, optimizer, F_TRACK_FIRST256); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); // if (!trim.isEmpty()) segments.append(" "); @@ -968,7 +965,7 @@ public void test_optimizersCompoundAnchors1() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); OptimizedSegmentBuilder2 segments = OptimizedSegmentBuilder2.emptyBuilder(sequence, optimizer, F_TRACK_FIRST256 | OptimizedSegmentBuilder2.F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) segments.append(" "); @@ -998,7 +995,7 @@ public void test_optimizersCompoundAnchors2() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); OptimizedSegmentBuilder2 segments = OptimizedSegmentBuilder2.emptyBuilder(sequence, optimizer, F_TRACK_FIRST256 | OptimizedSegmentBuilder2.F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) segments.append(" "); @@ -1030,7 +1027,7 @@ public void test_optimizersCompound3Anchors() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); OptimizedSegmentBuilder2 segments = OptimizedSegmentBuilder2.emptyBuilder(sequence, optimizer, F_TRACK_FIRST256 | OptimizedSegmentBuilder2.F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); // if (!trim.isEmpty()) segments.append(" "); diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/SequenceBuilderTest.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/SequenceBuilderTest.java index 5e9a065b5..9b67c7c3b 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/SequenceBuilderTest.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/SequenceBuilderTest.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.util.sequence.builder; import com.vladsch.flexmark.util.sequence.*; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.List; @@ -575,7 +574,7 @@ public void test_optimizersCompoundDefault1() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); SequenceBuilder builder = SequenceBuilder.emptyBuilder(sequence, optimizer); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) builder.append(" "); @@ -604,7 +603,7 @@ public void test_optimizersCompoundDefault2() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); SequenceBuilder builder = SequenceBuilder.emptyBuilder(sequence, optimizer); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) builder.append(" "); @@ -632,7 +631,7 @@ public void test_optimizersCompoundDefault3() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); SequenceBuilder builder = SequenceBuilder.emptyBuilder(sequence, optimizer); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); // if (!trim.isEmpty()) segments.append(" "); @@ -660,7 +659,7 @@ public void test_optimizersCompoundNoAnchors1() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); SequenceBuilder builder = SequenceBuilder.emptyBuilder(sequence, F_TRACK_FIRST256, optimizer); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) builder.append(" "); @@ -689,7 +688,7 @@ public void test_optimizersCompoundNoAnchors2() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); SequenceBuilder builder = SequenceBuilder.emptyBuilder(sequence, F_TRACK_FIRST256, optimizer); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) builder.append(" "); @@ -717,7 +716,7 @@ public void test_optimizersCompoundNoAnchors3() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); SequenceBuilder builder = SequenceBuilder.emptyBuilder(sequence, F_TRACK_FIRST256, optimizer); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); // if (!trim.isEmpty()) segments.append(" "); @@ -745,7 +744,7 @@ public void test_optimizersCompoundAnchors1() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); SequenceBuilder builder = SequenceBuilder.emptyBuilder(sequence, F_INCLUDE_ANCHORS | F_TRACK_FIRST256, optimizer); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) builder.append(" "); @@ -774,7 +773,7 @@ public void test_optimizersCompoundAnchors2() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); SequenceBuilder builder = SequenceBuilder.emptyBuilder(sequence, F_INCLUDE_ANCHORS | F_TRACK_FIRST256, optimizer); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); if (!trim.isEmpty()) builder.append(" "); @@ -802,7 +801,7 @@ public void test_optimizersCompoundAnchors3() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); SequenceBuilder builder = SequenceBuilder.emptyBuilder(sequence, F_INCLUDE_ANCHORS | F_TRACK_FIRST256, optimizer); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); // if (!trim.isEmpty()) segments.append(" "); diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/BasedOffsetTrackerTest.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/BasedOffsetTrackerTest.java index f14bfeec4..a1f7ea15b 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/BasedOffsetTrackerTest.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/BasedOffsetTrackerTest.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.misc.Pair; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.function.Function; @@ -63,7 +62,7 @@ String wrapText(String input, boolean isEndOffset, int margin) { return resolveOffset(sequence1, actual, info1.getSecond(), isEndOffset); } - String wrapText(String input, boolean isEndOffset, int margin, @NotNull Function postProcessor) { + String wrapText(String input, boolean isEndOffset, int margin, Function postProcessor) { BasedSequence actual = postProcessor.apply(wrapText(input, margin)); Pair info1 = getInput(input); BasedSequence sequence1 = BasedSequence.of(info1.getFirst()); diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentOffsetTreeTest.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentOffsetTreeTest.java index e501214cf..981b113d4 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentOffsetTreeTest.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentOffsetTreeTest.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.sequence.builder.CharRecoveryOptimizer; import com.vladsch.flexmark.util.sequence.builder.SegmentBuilderBase; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.List; @@ -70,7 +69,7 @@ static void loopEndShort(int startOffset, BiConsumer consumer) loop(startOffset + 65536, startOffset + 65536 * 8, 8, 3, consumer); } - void assertCharAt(@NotNull BasedSequence sequence, @NotNull SegmentBuilderBase segments, @NotNull SegmentTree segTree) { + void assertCharAt(BasedSequence sequence, SegmentBuilderBase segments, SegmentTree segTree) { BasedSequence sequenceFull = SegmentedSequenceFull.create(sequence, segments); SegmentOffsetTree segOffsetTree = segTree.getSegmentOffsetTree(sequence); @@ -200,7 +199,7 @@ public void test_buildSegments1() { BasedSequence sequence = BasedSequence.of(input); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); @@ -236,7 +235,7 @@ public void test_buildSegments2() { BasedSequence sequence = BasedSequence.of(input); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); @@ -282,7 +281,7 @@ public void test_optimizersCompound3Anchors() { CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, optimizer, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); // if (!trim.isEmpty()) segments.append(" "); diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTest.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTest.java index d71cbc10f..5199d19bf 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTest.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTest.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.Seg; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.Arrays; @@ -107,7 +106,6 @@ public CharSequence subSequence(int start, int end) { return new DummyCharSequence(myChar, end - start); } - @NotNull @Override public String toString() { StringBuilder sb = new StringBuilder(length()); diff --git a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTreeTest.java b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTreeTest.java index b7b275bac..6fed51c8f 100644 --- a/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTreeTest.java +++ b/flexmark-util/src/test/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTreeTest.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.sequence.builder.BasedSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.PlainSegmentBuilder; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.Arrays; @@ -211,7 +210,7 @@ public void test_getPrevAnchor() { // TEST: need test for this } - void assertCharAt(@NotNull BasedSequence sequence, @NotNull PlainSegmentBuilder segments, @NotNull SegmentTree segTree) { + void assertCharAt(BasedSequence sequence, PlainSegmentBuilder segments, SegmentTree segTree) { BasedSequence sequenceFull = SegmentedSequenceFull.create(sequence, segments); int iMax = sequenceFull.length(); System.out.println(segTree.toString(sequence)); @@ -341,7 +340,7 @@ public void test_buildSegments1() { BasedSequence sequence = BasedSequence.of(input); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); @@ -376,7 +375,7 @@ public void test_buildSegments2() { BasedSequence sequence = BasedSequence.of(input); BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); - @NotNull List lines = sequence.splitListEOL(false); + List lines = sequence.splitListEOL(false); for (BasedSequence line : lines) { BasedSequence trim = line.trim(); @@ -420,7 +419,7 @@ public void test_buildSegments2() { // BasedSequence sequence = BasedSequence.of(input); // BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); // -// @NotNull List lines = sequence.splitListEOL(false); +// List lines = sequence.splitListEOL(false); // for (BasedSequence line : lines) { // BasedSequence trim = line.trim(); // if (!trim.isEmpty()) segments.append(" "); @@ -452,7 +451,7 @@ public void test_buildSegments2() { // CharRecoveryOptimizer optimizer = new CharRecoveryOptimizer(PositionAnchor.CURRENT); // BasedSegmentBuilder segments = BasedSegmentBuilder.emptyBuilder(sequence, optimizer, F_TRACK_FIRST256 | F_INCLUDE_ANCHORS); // -// @NotNull List lines = sequence.splitListEOL(false); +// List lines = sequence.splitListEOL(false); // for (BasedSequence line : lines) { // BasedSequence trim = line.trim(); //// if (!trim.isEmpty()) segments.append(" "); diff --git a/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/YouTrackConverterExtension.java b/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/YouTrackConverterExtension.java index 5e715b5ac..188efe31c 100644 --- a/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/YouTrackConverterExtension.java +++ b/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/YouTrackConverterExtension.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.youtrack.converter.internal.YouTrackConverterNodeRenderer; -import org.jetbrains.annotations.NotNull; /** * Extension for youtrack_converters @@ -27,7 +26,7 @@ public void extend(Parser.Builder parserBuilder) { } @Override - public void rendererOptions(@NotNull MutableDataHolder options) { + public void rendererOptions(MutableDataHolder options) { String rendererType = HtmlRenderer.TYPE.get(options); if (rendererType.equals("HTML")) { // add youtrack equivalence @@ -44,7 +43,7 @@ public void parserOptions(MutableDataHolder options) { } @Override - public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { + public void extend(HtmlRenderer.Builder htmlRendererBuilder, String rendererType) { if (htmlRendererBuilder.isRendererType("YOUTRACK")) { htmlRendererBuilder.nodeRendererFactory(new YouTrackConverterNodeRenderer.Factory()); } else { diff --git a/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/internal/YouTrackConverterNodeRenderer.java b/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/internal/YouTrackConverterNodeRenderer.java index 961ab6b38..0306f4768 100644 --- a/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/internal/YouTrackConverterNodeRenderer.java +++ b/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/internal/YouTrackConverterNodeRenderer.java @@ -12,7 +12,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.Escaping; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -435,9 +434,8 @@ private void render(LinkRef node, NodeRendererContext context, HtmlWriter html) } public static class Factory implements NodeRendererFactory { - @NotNull @Override - public NodeRenderer apply(@NotNull DataHolder options) { + public NodeRenderer apply(DataHolder options) { return new YouTrackConverterNodeRenderer(options); } } diff --git a/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/internal/package-info.java b/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/internal/package-info.java index a4dcf4d97..7d37ef28c 100644 --- a/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/internal/package-info.java +++ b/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.youtrack.converter.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/package-info.java b/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/package-info.java index 1a548a5a5..7116b158f 100644 --- a/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/package-info.java +++ b/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.youtrack.converter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark-youtrack-converter/src/test/java/com/vladsch/flexmark/youtrack/converter/ComboYouTrackConverterSpecTest.java b/flexmark-youtrack-converter/src/test/java/com/vladsch/flexmark/youtrack/converter/ComboYouTrackConverterSpecTest.java index 98e400251..d8e7409b1 100644 --- a/flexmark-youtrack-converter/src/test/java/com/vladsch/flexmark/youtrack/converter/ComboYouTrackConverterSpecTest.java +++ b/flexmark-youtrack-converter/src/test/java/com/vladsch/flexmark/youtrack/converter/ComboYouTrackConverterSpecTest.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.test.util.spec.SpecExample; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; -import org.jetbrains.annotations.NotNull; import org.junit.runners.Parameterized; import java.util.Arrays; @@ -18,7 +17,7 @@ public class ComboYouTrackConverterSpecTest extends RendererSpecTest { final private static String SPEC_RESOURCE = "/youtrack_converter_ast_spec.md"; - final public static @NotNull ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); + final public static ResourceLocation RESOURCE_LOCATION = ResourceLocation.of(SPEC_RESOURCE); final private static DataHolder OPTIONS = new MutableDataSet() .set(Parser.EXTENSIONS, Arrays.asList(YouTrackConverterExtension.create(), StrikethroughExtension.create(), TablesExtension.create())); @@ -34,7 +33,7 @@ public class ComboYouTrackConverterSpecTest extends RendererSpecTest { optionsMap.put("keep-whitespace", new MutableDataSet().set(TablesExtension.TRIM_CELL_WHITESPACE, false)); } - public ComboYouTrackConverterSpecTest(@NotNull SpecExample example) { + public ComboYouTrackConverterSpecTest(SpecExample example) { super(example, optionsMap, OPTIONS); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/AutoLink.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/AutoLink.java index 70f72ba73..f9296a57f 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/AutoLink.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/AutoLink.java @@ -1,19 +1,16 @@ package com.vladsch.flexmark.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class AutoLink extends DelimitedLinkNode { public AutoLink() { } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, pageRef, anchorMarker, anchorRef, closingMarker }; } - @NotNull @Override public BasedSequence[] getSegmentsForChars() { return new BasedSequence[] { @@ -26,7 +23,7 @@ public BasedSequence[] getSegmentsForChars() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, openingMarker, "open"); segmentSpanChars(out, text, "text"); if (pageRef.isNotNull()) segmentSpanChars(out, pageRef, "pageRef"); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/BlockQuote.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/BlockQuote.java index cc1243a9b..858e2239f 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/BlockQuote.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/BlockQuote.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.ast.BlockQuoteLike; import com.vladsch.flexmark.util.ast.KeepTrailingBlankLineContainer; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -13,11 +12,10 @@ public class BlockQuote extends Block implements BlockQuoteLike, KeepTrailingBla private BasedSequence openingMarker = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, openingMarker, "marker"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker }; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/BulletList.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/BulletList.java index b6831c27c..dd226cc21 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/BulletList.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/BulletList.java @@ -2,14 +2,12 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; public class BulletList extends ListBlock { private char openingMarker; - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/Code.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/Code.java index 8f367c6aa..1baa95d56 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/Code.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/Code.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.ast.NodeVisitor; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; public class Code extends DelimitedNodeImpl implements DoNotLinkDecorate { public Code() { @@ -19,7 +18,7 @@ public Code(BasedSequence openingMarker, BasedSequence content, BasedSequence cl } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpan(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/CodeBlock.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/CodeBlock.java index a2e0a046e..d0fc58a74 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/CodeBlock.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/CodeBlock.java @@ -3,13 +3,11 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; public class CodeBlock extends Block { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/DelimitedLinkNode.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/DelimitedLinkNode.java index da67279d2..52890e857 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/DelimitedLinkNode.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/DelimitedLinkNode.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.BasedSequenceImpl; -import org.jetbrains.annotations.NotNull; public class DelimitedLinkNode extends LinkNode { @@ -17,14 +16,13 @@ public DelimitedLinkNode(BasedSequence chars) { protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/DelimitedNodeImpl.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/DelimitedNodeImpl.java index a425c1f28..66f36862b 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/DelimitedNodeImpl.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/DelimitedNodeImpl.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.DelimitedNode; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public abstract class DelimitedNodeImpl extends Node implements DelimitedNode { protected BasedSequence openingMarker = BasedSequence.NULL; @@ -11,11 +10,10 @@ public abstract class DelimitedNodeImpl extends Node implements DelimitedNode { protected BasedSequence closingMarker = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/FencedCodeBlock.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/FencedCodeBlock.java index a58e02b2a..174d0c082 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/FencedCodeBlock.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/FencedCodeBlock.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.ast.DoNotDecorate; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -16,7 +15,7 @@ public class FencedCodeBlock extends Block implements DoNotDecorate { private BasedSequence closingMarker = BasedSequence.NULL; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { BasedSequence content = getContentChars(); int lines = getContentLines().size(); segmentSpanChars(out, openingMarker, "open"); @@ -27,7 +26,6 @@ public void getAstExtra(@NotNull StringBuilder out) { segmentSpanChars(out, closingMarker, "close"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, info, attributes, getContentChars(), closingMarker }; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/HardLineBreak.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/HardLineBreak.java index b3d4dfa7b..239807530 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/HardLineBreak.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/HardLineBreak.java @@ -6,10 +6,8 @@ import com.vladsch.flexmark.util.ast.TextContainer; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; public class HardLineBreak extends Node implements DoNotTrim, TextContainer { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/Heading.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/Heading.java index fcec361ba..5ea9a9a7b 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/Heading.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/Heading.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.util.ast.TextCollectingVisitor; import com.vladsch.flexmark.util.ast.TextContainer; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -19,11 +18,10 @@ public class Heading extends Block implements AnchorRefTarget { protected boolean explicitAnchorRefId = false; @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker }; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlBlock.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlBlock.java index 61567a28b..9f4d254a5 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlBlock.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlBlock.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -12,7 +11,6 @@ * @see CommonMark Spec */ public class HtmlBlock extends HtmlBlockBase { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlBlockBase.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlBlockBase.java index b9e5a84ac..69a7f6a15 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlBlockBase.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlBlockBase.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -13,7 +12,6 @@ * @see CommonMark Spec */ public abstract class HtmlBlockBase extends Block { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlEntity.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlEntity.java index 11c3ed392..fcba80447 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlEntity.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlEntity.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.ReplacedTextMapper; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.util.misc.BitFieldSet.any; @@ -18,12 +17,11 @@ */ public class HtmlEntity extends Node implements TextContainer { @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { if (!getChars().isEmpty()) out.append(" \"").append(getChars()).append("\""); } // TODO: add opening and closing marker with intermediate text so that completions can be easily done - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInline.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInline.java index 2989417f2..38038a06a 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInline.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInline.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Inline HTML element. @@ -9,14 +8,13 @@ * @see CommonMark Spec */ public class HtmlInline extends HtmlInlineBase { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInlineBase.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInlineBase.java index 32db65a11..73ea99a12 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInlineBase.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInlineBase.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Inline HTML element. @@ -10,14 +9,13 @@ * @see CommonMark Spec */ public abstract class HtmlInlineBase extends Node { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInlineComment.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInlineComment.java index c8f227e25..b6298cad4 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInlineComment.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInlineComment.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Inline HTML comment element. @@ -9,14 +8,13 @@ * @see CommonMark Spec */ public class HtmlInlineComment extends HtmlInlineBase { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInnerBlock.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInnerBlock.java index a4d1037fc..962841234 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInnerBlock.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInnerBlock.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Inline HTML element. @@ -9,14 +8,13 @@ * @see CommonMark Spec */ public class HtmlInnerBlock extends HtmlBlockBase { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInnerBlockComment.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInnerBlockComment.java index 4467345d4..15088368a 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInnerBlockComment.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/HtmlInnerBlockComment.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Inline HTML element. @@ -9,14 +8,13 @@ * @see CommonMark Spec */ public class HtmlInnerBlockComment extends HtmlBlockBase { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { astExtraChars(out); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/Image.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/Image.java index 00776a513..00ab3fadf 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/Image.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/Image.java @@ -1,12 +1,10 @@ package com.vladsch.flexmark.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public class Image extends InlineLinkNode { private BasedSequence urlContent = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { @@ -30,7 +28,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, textOpeningMarker, text, textClosingMarker, "text"); segmentSpanChars(out, linkOpeningMarker, "linkOpen"); delimitedSegmentSpanChars(out, urlOpeningMarker, url, urlClosingMarker, "url"); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/IndentedCodeBlock.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/IndentedCodeBlock.java index 53ae2c7a8..7484ac57f 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/IndentedCodeBlock.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/IndentedCodeBlock.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.ReplacedTextMapper; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -16,7 +15,6 @@ public class IndentedCodeBlock extends Block implements TextContainer { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/InlineLinkNode.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/InlineLinkNode.java index 0b84c2499..23d54be3d 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/InlineLinkNode.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/InlineLinkNode.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.ast; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; public abstract class InlineLinkNode extends LinkNode { protected BasedSequence textOpeningMarker = BasedSequence.NULL; @@ -10,7 +9,6 @@ public abstract class InlineLinkNode extends LinkNode { protected BasedSequence linkOpeningMarker = BasedSequence.NULL; protected BasedSequence linkClosingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { @@ -31,7 +29,6 @@ public BasedSequence[] getSegments() { }; } - @NotNull @Override public BasedSequence[] getSegmentsForChars() { return new BasedSequence[] { @@ -52,7 +49,7 @@ public BasedSequence[] getSegmentsForChars() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, textOpeningMarker, text, textClosingMarker, "text"); segmentSpanChars(out, linkOpeningMarker, "linkOpen"); delimitedSegmentSpanChars(out, urlOpeningMarker, url, urlClosingMarker, "url"); @@ -162,7 +159,6 @@ public void setLinkClosingMarker(BasedSequence linkClosingMarker) { this.linkClosingMarker = linkClosingMarker; } - @NotNull @Override protected String toStringAttributes() { return "text=" + text + ", url=" + url + ", title=" + title; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/ListBlock.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/ListBlock.java index 7862cff65..0eddd03b8 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/ListBlock.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/ListBlock.java @@ -5,7 +5,6 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -50,7 +49,7 @@ public Node getLastBlankLineChild() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { super.getAstExtra(out); if (isTight()) out.append(" isTight"); else out.append(" isLoose"); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/ListItem.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/ListItem.java index 675590b9c..32a1d0186 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/ListItem.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/ListItem.java @@ -7,7 +7,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -51,7 +50,7 @@ public boolean isOrderedItem() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { segmentSpanChars(out, openingMarker, "open"); segmentSpanChars(out, markerSuffix, "openSuffix"); if (isTight()) out.append(" isTight"); @@ -60,7 +59,6 @@ public void getAstExtra(@NotNull StringBuilder out) { else if (isContainsBlankLine()) out.append(" hadBlankLine"); } - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, markerSuffix }; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/OrderedList.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/OrderedList.java index 012f796c9..ef1d94a12 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/OrderedList.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/OrderedList.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -10,7 +9,6 @@ public class OrderedList extends ListBlock { private int startNumber; private char delimiter; - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; @@ -32,7 +30,7 @@ public OrderedList(BlockContent blockContent) { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { super.getAstExtra(out); if (startNumber > 1) out.append(" start:").append(startNumber); out.append(" delimiter:'").append(delimiter).append("'"); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/Paragraph.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/Paragraph.java index aa2ebdc37..8524e8f90 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/Paragraph.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/Paragraph.java @@ -6,7 +6,6 @@ import com.vladsch.flexmark.util.ast.TextContainer; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; import java.util.List; @@ -16,14 +15,13 @@ public class Paragraph extends Block implements TextContainer { private boolean trailingBlankLine = false; private boolean hasTableSeparator; - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { super.getAstExtra(out); if (trailingBlankLine) out.append(" isTrailingBlankLine"); } @@ -65,7 +63,7 @@ protected void setLineIndents(List lineIndents) { @Override // FIX: add indent tracking then deprecate. ContentNode does not have indents // @Deprecated - public void setContent(@NotNull BasedSequence chars, @NotNull List lineSegments) { + public void setContent(BasedSequence chars, List lineSegments) { super.setContent(chars, lineSegments); } @@ -79,12 +77,12 @@ public void setContent(BasedSequence chars, List lineSegments, Li @Override // FIX: add indent tracking then deprecate. ContentNode does not have indents // @Deprecated - public void setContent(@NotNull List lineSegments) { + public void setContent(List lineSegments) { super.setContent(lineSegments); } @Override - public void setContent(@NotNull BlockContent blockContent) { + public void setContent(BlockContent blockContent) { super.setContent(blockContent); setLineIndents(blockContent.getLineIndents()); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/RefNode.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/RefNode.java index 9c22a947d..2cff097b3 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/RefNode.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/RefNode.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.ReplacedTextMapper; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; public abstract class RefNode extends Node implements LinkRefDerived, ReferencingNode, DoNotLinkDecorate, TextContainer { protected BasedSequence textOpeningMarker = BasedSequence.NULL; @@ -19,7 +18,6 @@ public abstract class RefNode extends Node implements LinkRefDerived, Referencin protected BasedSequence referenceClosingMarker = BasedSequence.NULL; protected boolean isDefined = false; - @NotNull @Override public BasedSequence[] getSegments() { if (isReferenceTextCombined()) { @@ -44,7 +42,7 @@ public BasedSequence[] getSegments() { } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { if (isReferenceTextCombined()) { delimitedSegmentSpanChars(out, referenceOpeningMarker, reference, referenceClosingMarker, "reference"); delimitedSegmentSpanChars(out, textOpeningMarker, text, textClosingMarker, "text"); @@ -145,7 +143,6 @@ public BasedSequence getText() { return text; } - @NotNull @Override public BasedSequence getReference() { return reference; @@ -267,7 +264,6 @@ public boolean collectText(ISequenceBuilder { protected BasedSequence openingMarker = BasedSequence.NULL; protected BasedSequence reference = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; - @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { @@ -33,7 +31,6 @@ public BasedSequence[] getSegments() { }; } - @NotNull @Override public BasedSequence[] getSegmentsForChars() { return new BasedSequence[] { @@ -59,12 +56,12 @@ public int compareTo(Reference other) { @Nullable @Override - public RefNode getReferencingNode(@NotNull Node node) { + public RefNode getReferencingNode(Node node) { return node instanceof RefNode ? (RefNode) node : null; } @Override - public void getAstExtra(@NotNull StringBuilder out) { + public void getAstExtra(StringBuilder out) { delimitedSegmentSpanChars(out, openingMarker, reference, closingMarker, "ref"); delimitedSegmentSpanChars(out, urlOpeningMarker, url, urlClosingMarker, "url"); delimitedSegmentSpanChars(out, titleOpeningMarker, title, titleClosingMarker, "title"); @@ -183,7 +180,6 @@ public void setTitle(BasedSequence title) { this.title = title; } - @NotNull @Override protected String toStringAttributes() { return "reference=" + reference + ", url=" + url; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/SoftLineBreak.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/SoftLineBreak.java index dcfab2013..114240e65 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/SoftLineBreak.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/SoftLineBreak.java @@ -3,10 +3,8 @@ import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; public class SoftLineBreak extends Node implements DoNotAttributeDecorate, DoNotTrim, TextContainer { - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; @@ -20,7 +18,7 @@ public SoftLineBreak(BasedSequence chars) { } @Override - public void setChars(@NotNull BasedSequence chars) { + public void setChars(BasedSequence chars) { super.setChars(chars); assert getChars().isNotEmpty(); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/Text.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/Text.java index fd9054dc1..df6eff098 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/Text.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/Text.java @@ -8,7 +8,6 @@ import com.vladsch.flexmark.util.sequence.PrefixedSubSequence; import com.vladsch.flexmark.util.sequence.ReplacedTextMapper; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; -import org.jetbrains.annotations.NotNull; import static com.vladsch.flexmark.util.misc.BitFieldSet.any; @@ -28,7 +27,6 @@ public Text(String chars, BasedSequence baseSeq) { super(PrefixedSubSequence.prefixOf(chars, baseSeq)); } - @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; @@ -47,14 +45,13 @@ public boolean collectText(ISequenceBuilder, Node> nodeClassifier = new ClassificationBag<>(NodeClassifier.INSTANCE); @@ -97,20 +96,20 @@ private void validateLinked(Node node) { } @Override - public void blockAdded(@NotNull Block node) { + public void blockAdded(Block node) { validateLinked(node); allBlockParsersMap.putValueKey(node, null); } @Override - public void blockAddedWithChildren(@NotNull Block node) { + public void blockAddedWithChildren(Block node) { validateLinked(node); allBlockParsersMap.putValueKey(node, null); addBlocks(node.getChildren()); } @Override - public void blockAddedWithDescendants(@NotNull Block node) { + public void blockAddedWithDescendants(Block node) { validateLinked(node); allBlockParsersMap.putValueKey(node, null); addBlocks(node.getDescendants()); @@ -131,20 +130,20 @@ private void validateUnlinked(Node node) { } @Override - public void blockRemoved(@NotNull Block node) { + public void blockRemoved(Block node) { validateUnlinked(node); allBlockParsersMap.removeValue(node); } @Override - public void blockRemovedWithChildren(@NotNull Block node) { + public void blockRemovedWithChildren(Block node) { validateUnlinked(node); allBlockParsersMap.removeValue(node); removeBlocks(node.getChildren()); } @Override - public void blockRemovedWithDescendants(@NotNull Block node) { + public void blockRemovedWithDescendants(Block node) { validateUnlinked(node); allBlockParsersMap.removeValue(node); removeBlocks(node.getDescendants()); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/util/Parsing.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/util/Parsing.java index c9478ee3a..15c03440b 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/util/Parsing.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/util/Parsing.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; import java.util.function.Function; @@ -333,7 +332,7 @@ public int hashCode() { final static HashMap> cachedPatterns = new HashMap<>(); - static Pattern getCachedPattern(@NotNull String patternName, @NotNull PatternTypeFlags cachedTypeFlags, @NotNull Function factory) { + static Pattern getCachedPattern(String patternName, PatternTypeFlags cachedTypeFlags, Function factory) { HashMap patternMap = cachedPatterns.computeIfAbsent(patternName, (key) -> new HashMap<>()); return patternMap.computeIfAbsent(cachedTypeFlags, factory); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/util/ReferenceRepository.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/util/ReferenceRepository.java index ea72e2409..5d786f913 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/util/ReferenceRepository.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/util/ReferenceRepository.java @@ -11,7 +11,6 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.DataKey; import com.vladsch.flexmark.util.sequence.Escaping; -import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; @@ -22,25 +21,21 @@ public ReferenceRepository(DataHolder options) { super(Parser.REFERENCES_KEEP.get(options)); } - @NotNull @Override public DataKey getDataKey() { return Parser.REFERENCES; } - @NotNull @Override public DataKey getKeepDataKey() { return Parser.REFERENCES_KEEP; } - @NotNull @Override - public String normalizeKey(@NotNull CharSequence key) { + public String normalizeKey(CharSequence key) { return Escaping.normalizeReference(key, true); } - @NotNull @Override public Set getReferencedElements(Node parent) { HashSet references = new HashSet<>(); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/util/TextCollectingVisitor.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/util/TextCollectingVisitor.java index 6a896e4b7..c39f1afe1 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/util/TextCollectingVisitor.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/util/TextCollectingVisitor.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.ast.*; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.HashSet; @@ -50,7 +49,7 @@ public TextCollectingVisitor(Class... lineBreakNodes) { ) { @Override - public void processNode(@NotNull Node node, boolean withChildren, @NotNull BiConsumer> processor) { + public void processNode(Node node, boolean withChildren, BiConsumer> processor) { Visitor visitor = getAction(node); if (visitor != null) { processor.accept(node, visitor); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/ast/util/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/ast/util/package-info.java index fc26a6c1e..4f981933f 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/ast/util/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/ast/util/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.ast.util; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/ExplicitAttributeIdProvider.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/ExplicitAttributeIdProvider.java index 882c29700..9a50402bb 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/ExplicitAttributeIdProvider.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/ExplicitAttributeIdProvider.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.formatter; import com.vladsch.flexmark.util.ast.Node; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface ExplicitAttributeIdProvider { /** @@ -13,5 +12,5 @@ public interface ExplicitAttributeIdProvider { * @param context context * @param markdown markdown writer */ - void addExplicitId(@NotNull Node node, @Nullable String id, @NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown); + void addExplicitId(Node node, @Nullable String id, NodeFormatterContext context, MarkdownWriter markdown); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/Formatter.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/Formatter.java index 5d59a4598..3689d4a71 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/Formatter.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/Formatter.java @@ -22,8 +22,7 @@ import com.vladsch.flexmark.util.sequence.SequenceUtils; import com.vladsch.flexmark.util.sequence.builder.ISequenceBuilder; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; import java.util.function.Function; @@ -200,7 +199,6 @@ public TranslationHandler getTranslationHandler() { return new TranslationHandlerImpl(options, idGeneratorFactory); } - @NotNull @Override public DataHolder getOptions() { return options; @@ -233,7 +231,7 @@ public static Builder builder(DataHolder options) { * @param node node to render * @param output appendable to use for the output */ - public void render(@NotNull Node node, @NotNull Appendable output) { + public void render(Node node, Appendable output) { render(node, output, MAX_TRAILING_BLANK_LINES.get(options)); } @@ -246,7 +244,7 @@ public void render(@NotNull Node node, @NotNull Appendable output) { * @param output appendable to which to render the resulting text * @param maxTrailingBlankLines max trailing blank lines in output, -1 means no last line EOL */ - public void render(@NotNull Node node, @NotNull Appendable output, int maxTrailingBlankLines) { + public void render(Node node, Appendable output, int maxTrailingBlankLines) { // NOTE: output to MarkdownWriter is only used to get builder if output is LineAppendable or ISequenceBuilder MarkdownWriter markdown = new MarkdownWriter(output, FORMAT_FLAGS.get(options)); MainNodeFormatter renderer = new MainNodeFormatter(options, markdown, node.getDocument(), null); @@ -269,8 +267,7 @@ public void render(@NotNull Node node, @NotNull Appendable output, int maxTraili * @param document the root node * @return the formatted markdown */ - @NotNull - public String render(@NotNull Node document) { + public String render(Node document) { StringBuilder sb = new StringBuilder(); render(document, sb); return sb.toString(); @@ -429,13 +426,12 @@ public Builder(DataHolder options) { /** * @return the configured {@link Formatter} */ - @NotNull public Formatter build() { return new Formatter(this); } @Override - protected void removeApiPoint(@NotNull Object apiPoint) { + protected void removeApiPoint(Object apiPoint) { if (apiPoint instanceof AttributeProviderFactory) this.attributeProviderFactories.remove(apiPoint); else if (apiPoint instanceof NodeFormatterFactory) this.nodeFormatterFactories.remove(apiPoint); else if (apiPoint instanceof LinkResolverFactory) this.linkResolverFactories.remove(apiPoint); @@ -446,7 +442,7 @@ protected void removeApiPoint(@NotNull Object apiPoint) { } @Override - protected void preloadExtension(@NotNull Extension extension) { + protected void preloadExtension(Extension extension) { if (extension instanceof FormatterExtension) { FormatterExtension formatterExtension = (FormatterExtension) extension; formatterExtension.rendererOptions(this); @@ -454,7 +450,7 @@ protected void preloadExtension(@NotNull Extension extension) { } @Override - protected boolean loadExtension(@NotNull Extension extension) { + protected boolean loadExtension(Extension extension) { if (extension instanceof FormatterExtension) { FormatterExtension formatterExtension = (FormatterExtension) extension; formatterExtension.extend(this); @@ -485,8 +481,7 @@ public Builder nodeFormatterFactory(NodeFormatterFactory nodeFormatterFactory) { * @param htmlIdGeneratorFactory the factory for generating header tag id attributes * @return {@code this} */ - @NotNull - public Builder htmlIdGeneratorFactory(@NotNull HeaderIdGeneratorFactory htmlIdGeneratorFactory) { + public Builder htmlIdGeneratorFactory(HeaderIdGeneratorFactory htmlIdGeneratorFactory) { //noinspection VariableNotUsedInsideIf if (this.htmlIdGeneratorFactory != null) { throw new IllegalStateException("custom header id factory is already set to " + htmlIdGeneratorFactory.getClass().getName()); @@ -506,7 +501,7 @@ public Builder htmlIdGeneratorFactory(@NotNull HeaderIdGeneratorFactory htmlIdGe * @param linkResolverFactory the factory for creating a node renderer * @return {@code this} */ - public @NotNull Builder linkResolverFactory(@NotNull LinkResolverFactory linkResolverFactory) { + public Builder linkResolverFactory(LinkResolverFactory linkResolverFactory) { this.linkResolverFactories.add(linkResolverFactory); addExtensionApiPoint(linkResolverFactory); return this; @@ -553,7 +548,7 @@ private class MainNodeFormatter extends NodeFormatterSubContext { final private List phasedFormatters; final private Set renderingPhases; final private DataHolder options; - private @NotNull final Boolean isFormatControlEnabled; + private final Boolean isFormatControlEnabled; private FormattingPhase phase; final TranslationHandler translationHandler; final private LinkResolver[] linkResolvers; @@ -676,15 +671,13 @@ private class MainNodeFormatter extends NodeFormatterSubContext { } } - @NotNull @Override - public String encodeUrl(@NotNull CharSequence url) { + public String encodeUrl(CharSequence url) { return String.valueOf(url); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Attributes attributes, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Attributes attributes, Boolean urlEncode) { return resolveLink(this, linkType, url, attributes); } @@ -712,13 +705,12 @@ ResolvedLink resolveLink(NodeFormatterSubContext context, LinkType linkType, Cha } @Override - public void addExplicitId(@NotNull Node node, @Nullable String id, @NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown) { + public void addExplicitId(Node node, @Nullable String id, NodeFormatterContext context, MarkdownWriter markdown) { if (id != null && explicitAttributeIdProvider != null) { explicitAttributeIdProvider.addExplicitId(node, id, context, markdown); } } - @NotNull @Override public RenderPurpose getRenderPurpose() { return translationHandler == null ? RenderPurpose.FORMAT : translationHandler.getRenderPurpose(); @@ -729,33 +721,29 @@ public boolean isTransformingText() { return translationHandler != null && translationHandler.isTransformingText(); } - @NotNull @Override - public CharSequence transformNonTranslating(CharSequence prefix, @NotNull CharSequence nonTranslatingText, CharSequence suffix, CharSequence suffix2) { + public CharSequence transformNonTranslating(CharSequence prefix, CharSequence nonTranslatingText, CharSequence suffix, CharSequence suffix2) { return translationHandler == null ? nonTranslatingText : translationHandler.transformNonTranslating(prefix, nonTranslatingText, suffix, suffix2); } - @NotNull @Override - public CharSequence transformTranslating(CharSequence prefix, @NotNull CharSequence translatingText, CharSequence suffix, CharSequence suffix2) { + public CharSequence transformTranslating(CharSequence prefix, CharSequence translatingText, CharSequence suffix, CharSequence suffix2) { return translationHandler == null ? translatingText : translationHandler.transformTranslating(prefix, translatingText, suffix, suffix2); } - @NotNull @Override - public CharSequence transformAnchorRef(@NotNull CharSequence pageRef, @NotNull CharSequence anchorRef) { + public CharSequence transformAnchorRef(CharSequence pageRef, CharSequence anchorRef) { return translationHandler == null ? anchorRef : translationHandler.transformAnchorRef(pageRef, anchorRef); } @Override - public void postProcessNonTranslating(@NotNull Function postProcessor, @NotNull Runnable scope) { + public void postProcessNonTranslating(Function postProcessor, Runnable scope) { if (translationHandler != null) translationHandler.postProcessNonTranslating(postProcessor, scope); else scope.run(); } - @NotNull @Override - public T postProcessNonTranslating(@NotNull Function postProcessor, @NotNull Supplier scope) { + public T postProcessNonTranslating(Function postProcessor, Supplier scope) { if (translationHandler != null) return translationHandler.postProcessNonTranslating(postProcessor, scope); else return scope.get(); } @@ -776,7 +764,7 @@ public HtmlIdGenerator getIdGenerator() { } @Override - public void translatingSpan(@NotNull TranslatingSpanRender render) { + public void translatingSpan(TranslatingSpanRender render) { if (translationHandler != null) { translationHandler.translatingSpan(render); } else { @@ -785,7 +773,7 @@ public void translatingSpan(@NotNull TranslatingSpanRender render) { } @Override - public void nonTranslatingSpan(@NotNull TranslatingSpanRender render) { + public void nonTranslatingSpan(TranslatingSpanRender render) { if (translationHandler != null) { translationHandler.nonTranslatingSpan(render); } else { @@ -794,7 +782,7 @@ public void nonTranslatingSpan(@NotNull TranslatingSpanRender render) { } @Override - public void translatingRefTargetSpan(@Nullable Node target, @NotNull TranslatingSpanRender render) { + public void translatingRefTargetSpan(@Nullable Node target, TranslatingSpanRender render) { if (translationHandler != null) { translationHandler.translatingRefTargetSpan(target, render); } else { @@ -802,7 +790,6 @@ public void translatingRefTargetSpan(@Nullable Node target, @NotNull Translating } } - @NotNull @Override public MutableDataHolder getTranslationStore() { if (translationHandler != null) { @@ -813,7 +800,7 @@ public MutableDataHolder getTranslationStore() { } @Override - public void customPlaceholderFormat(@NotNull TranslationPlaceholderGenerator generator, @NotNull TranslatingSpanRender render) { + public void customPlaceholderFormat(TranslationPlaceholderGenerator generator, TranslatingSpanRender render) { if (translationHandler != null) { translationHandler.customPlaceholderFormat(generator, render); } else { @@ -821,41 +808,38 @@ public void customPlaceholderFormat(@NotNull TranslationPlaceholderGenerator gen } } - @NotNull @Override public Node getCurrentNode() { return renderingNode; } @Override - public @NotNull DataHolder getOptions() { + public DataHolder getOptions() { return options; } - @NotNull @Override public FormatterOptions getFormatterOptions() { return formatterOptions; } - @NotNull @Override public Document getDocument() { return document; } @Override - public @NotNull CharPredicate getBlockQuoteLikePrefixPredicate() { + public CharPredicate getBlockQuoteLikePrefixPredicate() { return blockQuoteLikePredicate; } @Override - public @NotNull BasedSequence getBlockQuoteLikePrefixChars() { + public BasedSequence getBlockQuoteLikePrefixChars() { return blockQuoteLikeChars; } @Override - public @NotNull TrackedOffsetList getTrackedOffsets() { + public TrackedOffsetList getTrackedOffsets() { return trackedOffsets; } @@ -865,61 +849,56 @@ public boolean isRestoreTrackedSpaces() { } @Override - public @NotNull BasedSequence getTrackedSequence() { + public BasedSequence getTrackedSequence() { return trackedSequence; } - @NotNull @Override public FormattingPhase getFormattingPhase() { return phase; } @Override - public void render(@NotNull Node node) { + public void render(Node node) { renderNode(node, this); } - @NotNull @Override - final public Iterable nodesOfType(@NotNull Class[] classes) { + final public Iterable nodesOfType(Class[] classes) { return collectedNodes == null ? NULL_ITERABLE : collectedNodes.itemsOfType(Node.class, classes); } - @NotNull @Override - final public Iterable nodesOfType(@NotNull Collection> classes) { + final public Iterable nodesOfType(Collection> classes) { return collectedNodes == null ? NULL_ITERABLE : collectedNodes.itemsOfType(Node.class, classes); } - @NotNull @Override - final public Iterable reversedNodesOfType(@NotNull Class[] classes) { + final public Iterable reversedNodesOfType(Class[] classes) { return collectedNodes == null ? NULL_ITERABLE : collectedNodes.reversedItemsOfType(Node.class, classes); } - @NotNull @Override - final public Iterable reversedNodesOfType(@NotNull Collection> classes) { + final public Iterable reversedNodesOfType(Collection> classes) { return collectedNodes == null ? NULL_ITERABLE : collectedNodes.reversedItemsOfType(Node.class, classes); } @Override - public @NotNull NodeFormatterContext getSubContext() { + public NodeFormatterContext getSubContext() { return getSubContextRaw(null, markdown.getBuilder()); } @Override - public @NotNull NodeFormatterContext getSubContext(@Nullable DataHolder options) { + public NodeFormatterContext getSubContext(@Nullable DataHolder options) { return getSubContextRaw(options, markdown.getBuilder()); } @Override - public @NotNull NodeFormatterContext getSubContext(@Nullable DataHolder options, @NotNull ISequenceBuilder builder) { + public NodeFormatterContext getSubContext(@Nullable DataHolder options, ISequenceBuilder builder) { return getSubContextRaw(options, builder); } - NodeFormatterContext getSubContextRaw(@Nullable DataHolder options, @NotNull ISequenceBuilder builder) { + NodeFormatterContext getSubContextRaw(@Nullable DataHolder options, ISequenceBuilder builder) { MarkdownWriter writer = new MarkdownWriter(builder, getMarkdown().getOptions()); writer.setContext(this); //noinspection ReturnOfInnerClass @@ -1004,7 +983,7 @@ void renderNode(Node node, NodeFormatterSubContext subContext) { } } - public void renderChildren(@NotNull Node parent) { + public void renderChildren(Node parent) { renderChildrenNode(parent, this); } @@ -1076,53 +1055,44 @@ public SubNodeFormatter(MainNodeFormatter mainNodeRenderer, MarkdownWriter out, myFormatterOptions = new FormatterOptions(myOptions); } - @NotNull @Override public MutableDataHolder getTranslationStore() { return myMainNodeRenderer.getTranslationStore(); } - @NotNull @Override - final public Iterable nodesOfType(@NotNull Class[] classes) { + final public Iterable nodesOfType(Class[] classes) { return myMainNodeRenderer.nodesOfType(classes); } - @NotNull @Override - final public Iterable nodesOfType(@NotNull Collection> classes) { + final public Iterable nodesOfType(Collection> classes) { return myMainNodeRenderer.nodesOfType(classes); } - @NotNull @Override - final public Iterable reversedNodesOfType(@NotNull Class[] classes) { + final public Iterable reversedNodesOfType(Class[] classes) { return myMainNodeRenderer.reversedNodesOfType(classes); } - @NotNull @Override - final public Iterable reversedNodesOfType(@NotNull Collection> classes) { + final public Iterable reversedNodesOfType(Collection> classes) { return myMainNodeRenderer.reversedNodesOfType(classes); } @Override - public @NotNull DataHolder getOptions() {return myOptions;} + public DataHolder getOptions() {return myOptions;} - @NotNull @Override public FormatterOptions getFormatterOptions() {return myFormatterOptions;} - @NotNull @Override public Document getDocument() {return myMainNodeRenderer.getDocument();} @Override - @NotNull public CharPredicate getBlockQuoteLikePrefixPredicate() {return myMainNodeRenderer.getBlockQuoteLikePrefixPredicate();} @Override - @NotNull public BasedSequence getBlockQuoteLikePrefixChars() {return myMainNodeRenderer.getBlockQuoteLikePrefixChars();} /** @@ -1131,7 +1101,7 @@ final public Iterable reversedNodesOfType(@NotNull Collection builder) { + public NodeFormatterContext getSubContext(@Nullable DataHolder options, ISequenceBuilder builder) { MarkdownWriter htmlWriter = new MarkdownWriter(builder, this.markdown.getOptions()); htmlWriter.setContext(this); //noinspection ReturnOfInnerClass @@ -1184,15 +1152,13 @@ public void delegateRender() { } @Override - public void renderChildren(@NotNull Node parent) { + public void renderChildren(Node parent) { myMainNodeRenderer.renderChildrenNode(parent, this); } - @NotNull @Override public MarkdownWriter getMarkdown() { return markdown; } - @NotNull @Override public RenderPurpose getRenderPurpose() { return myMainNodeRenderer.getRenderPurpose(); @@ -1203,70 +1169,63 @@ public boolean isTransformingText() { return myMainNodeRenderer.isTransformingText(); } - @NotNull @Override - public CharSequence transformNonTranslating(CharSequence prefix, @NotNull CharSequence nonTranslatingText, CharSequence suffix, CharSequence suffix2) { + public CharSequence transformNonTranslating(CharSequence prefix, CharSequence nonTranslatingText, CharSequence suffix, CharSequence suffix2) { return myMainNodeRenderer.transformNonTranslating(prefix, nonTranslatingText, suffix, suffix2); } - @NotNull @Override - public CharSequence transformTranslating(CharSequence prefix, @NotNull CharSequence translatingText, CharSequence suffix, CharSequence suffix2) { + public CharSequence transformTranslating(CharSequence prefix, CharSequence translatingText, CharSequence suffix, CharSequence suffix2) { return myMainNodeRenderer.transformTranslating(prefix, translatingText, suffix, suffix2); } - @NotNull @Override - public CharSequence transformAnchorRef(@NotNull CharSequence pageRef, @NotNull CharSequence anchorRef) { + public CharSequence transformAnchorRef(CharSequence pageRef, CharSequence anchorRef) { return myMainNodeRenderer.transformAnchorRef(pageRef, anchorRef); } @Override - public void translatingSpan(@NotNull TranslatingSpanRender render) { + public void translatingSpan(TranslatingSpanRender render) { myMainNodeRenderer.translatingSpan(render); } @Override - public void nonTranslatingSpan(@NotNull TranslatingSpanRender render) { + public void nonTranslatingSpan(TranslatingSpanRender render) { myMainNodeRenderer.nonTranslatingSpan(render); } @Override - public void translatingRefTargetSpan(@Nullable Node target, @NotNull TranslatingSpanRender render) { + public void translatingRefTargetSpan(@Nullable Node target, TranslatingSpanRender render) { myMainNodeRenderer.translatingRefTargetSpan(target, render); } @Override - public void customPlaceholderFormat(@NotNull TranslationPlaceholderGenerator generator, @NotNull TranslatingSpanRender render) { + public void customPlaceholderFormat(TranslationPlaceholderGenerator generator, TranslatingSpanRender render) { myMainNodeRenderer.customPlaceholderFormat(generator, render); } - @NotNull @Override - public String encodeUrl(@NotNull CharSequence url) { + public String encodeUrl(CharSequence url) { return myMainNodeRenderer.encodeUrl(url); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Boolean urlEncode) { return myMainNodeRenderer.resolveLink(this, linkType, url, null); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Attributes attributes, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Attributes attributes, Boolean urlEncode) { return myMainNodeRenderer.resolveLink(this, linkType, url, attributes); } @Override - public void postProcessNonTranslating(@NotNull Function postProcessor, @NotNull Runnable scope) { + public void postProcessNonTranslating(Function postProcessor, Runnable scope) { myMainNodeRenderer.postProcessNonTranslating(postProcessor, scope); } - @NotNull @Override - public T postProcessNonTranslating(@NotNull Function postProcessor, @NotNull Supplier scope) { + public T postProcessNonTranslating(Function postProcessor, Supplier scope) { return myMainNodeRenderer.postProcessNonTranslating(postProcessor, scope); } @@ -1281,7 +1240,7 @@ public MergeContext getMergeContext() { } @Override - public void addExplicitId(@NotNull Node node, @Nullable String id, @NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown) { + public void addExplicitId(Node node, @Nullable String id, NodeFormatterContext context, MarkdownWriter markdown) { myMainNodeRenderer.addExplicitId(node, id, context, markdown); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/FormatterOptions.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/FormatterOptions.java index 150b86144..fba008829 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/FormatterOptions.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/FormatterOptions.java @@ -5,7 +5,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.format.CharWidthProvider; import com.vladsch.flexmark.util.format.options.*; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.regex.Pattern; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/FormatterUtils.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/FormatterUtils.java index 6d0a10811..6f48433d7 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/FormatterUtils.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/FormatterUtils.java @@ -21,8 +21,7 @@ import com.vladsch.flexmark.util.sequence.RepeatedSequence; import com.vladsch.flexmark.util.sequence.builder.SequenceBuilder; import com.vladsch.flexmark.util.sequence.mappers.SpaceMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -44,7 +43,7 @@ public class FormatterUtils { final public static DataKey>> LIST_ALIGN_NUMERIC = new DataKey<>("LIST_ITEM_NUMBER", NULL_PADDING); // function takes ordered marker and returns Pair LeftPad,RightPad final public static NullableDataKey LIST_ITEM_SPACING = new NullableDataKey<>("LIST_ITEM_SPACING"); - public static String getBlockLikePrefix(BlockQuoteLike node, NodeFormatterContext context, BlockQuoteMarker blockQuoteMarkers, @NotNull BasedSequence prefix) { + public static String getBlockLikePrefix(BlockQuoteLike node, NodeFormatterContext context, BlockQuoteMarker blockQuoteMarkers, BasedSequence prefix) { String prefixChars = node.getOpeningMarker().toString(); String usePrefix; boolean compactPrefix = false; @@ -103,7 +102,6 @@ public static CharSequence stripSoftLineBreak(CharSequence chars, CharSequence s return chars; } - @NotNull public static String getActualAdditionalPrefix(BasedSequence contentChars, MarkdownWriter markdown) { String prefix; int parentPrefix = markdown.getPrefix().length(); @@ -113,7 +111,6 @@ public static String getActualAdditionalPrefix(BasedSequence contentChars, Markd return prefix; } - @NotNull public static String getAdditionalPrefix(BasedSequence fromChars, BasedSequence toChars) { String prefix; int parentPrefix = fromChars.getStartOffset(); @@ -604,7 +601,7 @@ public static void renderTextBlockParagraphLines(Node node, NodeFormatterContext for (TrackedOffset trackedOffset : paragraphTrackedOffsets) { if (trackedOffset.isResolved()) { int offsetIndex = trackedOffset.getIndex(); - @NotNull Pair lineColumn = wrappedText.lineColumnAtIndex(offsetIndex); + Pair lineColumn = wrappedText.lineColumnAtIndex(offsetIndex); int trackedLine = lineColumn.getFirst(); LineInfo lineInfo = markdown.getLineInfo(startLine + trackedLine); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/MarkdownWriter.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/MarkdownWriter.java index ab2a90301..be4085e69 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/MarkdownWriter.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/MarkdownWriter.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.format.MarkdownWriterBase; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; @SuppressWarnings("UnusedReturnValue") public class MarkdownWriter extends MarkdownWriterBase { @@ -23,14 +22,13 @@ public MarkdownWriter(@Nullable Appendable appendable, int formatOptions) { super(appendable, formatOptions); } - @NotNull @Override public MarkdownWriter getEmptyAppendable() { return new MarkdownWriter(appendable, appendable.getOptions()); } @Override - public @NotNull BasedSequence lastBlockQuoteChildPrefix(BasedSequence prefix) { + public BasedSequence lastBlockQuoteChildPrefix(BasedSequence prefix) { Node node = context.getCurrentNode(); while (node != null && node.getNextAnyNot(BlankLine.class) == null) { Node parent = node.getParent(); @@ -48,19 +46,19 @@ public MarkdownWriter getEmptyAppendable() { return prefix; } - public @NotNull MarkdownWriter appendNonTranslating(@NotNull CharSequence csq) { + public MarkdownWriter appendNonTranslating(CharSequence csq) { return appendNonTranslating(null, csq, null, null); } - public @NotNull MarkdownWriter appendNonTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq) { + public MarkdownWriter appendNonTranslating(@Nullable CharSequence prefix, CharSequence csq) { return appendNonTranslating(prefix, csq, null, null); } - public @NotNull MarkdownWriter appendNonTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq, @Nullable CharSequence suffix) { + public MarkdownWriter appendNonTranslating(@Nullable CharSequence prefix, CharSequence csq, @Nullable CharSequence suffix) { return appendNonTranslating(prefix, csq, suffix, null); } - public @NotNull MarkdownWriter appendNonTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq, @Nullable CharSequence suffix, @Nullable CharSequence suffix2) { + public MarkdownWriter appendNonTranslating(@Nullable CharSequence prefix, CharSequence csq, @Nullable CharSequence suffix, @Nullable CharSequence suffix2) { if (context.isTransformingText()) { append(context.transformNonTranslating(prefix, csq, suffix, suffix2)); } else { @@ -69,19 +67,19 @@ public MarkdownWriter getEmptyAppendable() { return this; } - public @NotNull MarkdownWriter appendTranslating(@NotNull CharSequence csq) { + public MarkdownWriter appendTranslating(CharSequence csq) { return appendTranslating(null, csq, null, null); } - public @NotNull MarkdownWriter appendTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq) { + public MarkdownWriter appendTranslating(@Nullable CharSequence prefix, CharSequence csq) { return appendTranslating(prefix, csq, null, null); } - public @NotNull MarkdownWriter appendTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq, @Nullable CharSequence suffix) { + public MarkdownWriter appendTranslating(@Nullable CharSequence prefix, CharSequence csq, @Nullable CharSequence suffix) { return appendTranslating(prefix, csq, suffix, null); } - public @NotNull MarkdownWriter appendTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq, @Nullable CharSequence suffix, @Nullable CharSequence suffix2) { + public MarkdownWriter appendTranslating(@Nullable CharSequence prefix, CharSequence csq, @Nullable CharSequence suffix, @Nullable CharSequence suffix2) { if (context.isTransformingText()) { append(context.transformTranslating(prefix, csq, suffix, suffix2)); } else { diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/MergeContext.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/MergeContext.java index a78ea5ca8..134164043 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/MergeContext.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/MergeContext.java @@ -1,10 +1,9 @@ package com.vladsch.flexmark.formatter; import com.vladsch.flexmark.util.ast.Document; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public interface MergeContext { - @NotNull Document getDocument(@NotNull TranslationContext context); - void forEachPrecedingDocument(@Nullable Document document, @NotNull MergeContextConsumer consumer); + Document getDocument(TranslationContext context); + void forEachPrecedingDocument(@Nullable Document document, MergeContextConsumer consumer); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/MergeContextConsumer.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/MergeContextConsumer.java index 87d645c8a..5eb41f353 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/MergeContextConsumer.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/MergeContextConsumer.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.formatter; import com.vladsch.flexmark.util.ast.Document; -import org.jetbrains.annotations.NotNull; public interface MergeContextConsumer { - void accept(@NotNull TranslationContext docContext, @NotNull Document doc, int index); + void accept(TranslationContext docContext, Document doc, int index); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatter.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatter.java index 1006ba997..d6b904e4c 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatter.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatter.java @@ -1,7 +1,7 @@ package com.vladsch.flexmark.formatter; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterContext.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterContext.java index 7e987146e..87287c3d6 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterContext.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterContext.java @@ -10,7 +10,6 @@ import com.vladsch.flexmark.util.format.options.ElementPlacementSort; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -21,7 +20,7 @@ public interface NodeFormatterContext extends NodeContext nodesOfType(@NotNull Class[] classes); + Iterable nodesOfType(Class[] classes); - @NotNull Iterable nodesOfType(@NotNull Collection> classes); + Iterable nodesOfType(Collection> classes); /** * Get iterable of nodes of given types, in reverse order of their appearance in the document tree, depth first traversal. @@ -123,7 +121,7 @@ public interface NodeFormatterContext extends NodeContext reversedNodesOfType(@NotNull Class[] classes); + Iterable reversedNodesOfType(Class[] classes); - @NotNull Iterable reversedNodesOfType(@NotNull Collection> classes); + Iterable reversedNodesOfType(Collection> classes); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterFactory.java index 4ca6ae0a9..57869a63a 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterFactory.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.dependency.Dependent; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -18,7 +17,7 @@ public interface NodeFormatterFactory extends Dependent { * @param options the context for rendering (normally passed on to the node renderer) * @return a node renderer */ - @NotNull NodeFormatter create(@NotNull DataHolder options); + NodeFormatter create(DataHolder options); /** * @return null or a list of processors that must be executed before calling this one diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterSubContext.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterSubContext.java index 8e9e33c46..43c6f4e3d 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterSubContext.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormatterSubContext.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.formatter; import com.vladsch.flexmark.util.ast.Node; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.io.IOException; import java.util.List; @@ -13,7 +12,7 @@ public abstract class NodeFormatterSubContext implements NodeFormatterContext { List> rendererList = null; int rendererIndex = -1; - public NodeFormatterSubContext(@NotNull MarkdownWriter markdown) { + public NodeFormatterSubContext(MarkdownWriter markdown) { this.markdown = markdown; this.renderingNode = null; } @@ -27,15 +26,15 @@ public void setRenderingNode(@Nullable Node renderingNode) { } @Override - public @NotNull MarkdownWriter getMarkdown() { + public MarkdownWriter getMarkdown() { return markdown; } - public void flushTo(@NotNull Appendable out, int maxTrailingBlankLines) { + public void flushTo(Appendable out, int maxTrailingBlankLines) { flushTo(out, getFormatterOptions().maxBlankLines, maxTrailingBlankLines); } - public void flushTo(@NotNull Appendable out, int maxBlankLines, int maxTrailingBlankLines) { + public void flushTo(Appendable out, int maxBlankLines, int maxTrailingBlankLines) { markdown.line(); try { markdown.appendTo(out, maxBlankLines, maxTrailingBlankLines); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormattingHandler.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormattingHandler.java index a1a581d38..446362d1b 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormattingHandler.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeFormattingHandler.java @@ -3,19 +3,18 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.visitor.AstAction; import com.vladsch.flexmark.util.visitor.AstHandler; -import org.jetbrains.annotations.NotNull; public class NodeFormattingHandler extends AstHandler> { - public NodeFormattingHandler(@NotNull Class aClass, @NotNull CustomNodeFormatter adapter) { + public NodeFormattingHandler(Class aClass, CustomNodeFormatter adapter) { super(aClass, adapter); } - public void render(@NotNull Node node, @NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown) { + public void render(Node node, NodeFormatterContext context, MarkdownWriter markdown) { //noinspection unchecked getAdapter().render((N) node, context, markdown); } public static interface CustomNodeFormatter extends AstAction { - void render(@NotNull N node, @NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown); + void render(N node, NodeFormatterContext context, MarkdownWriter markdown); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeRepositoryFormatter.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeRepositoryFormatter.java index 60beb4d99..0ee2e849e 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeRepositoryFormatter.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/NodeRepositoryFormatter.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.util.data.DataSet; import com.vladsch.flexmark.util.format.options.ElementPlacement; import com.vladsch.flexmark.util.format.options.ElementPlacementSort; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -140,7 +139,7 @@ public Set getFormattingPhases() { } @Override - public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase) { + public void renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase) { // here non-rendered elements can be collected so that they are rendered in another part of the document if (context.isTransformingText() && myReferenceMapKey != null) { if (context.getRenderPurpose() == TRANSLATION_SPANS) { diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/PhasedNodeFormatter.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/PhasedNodeFormatter.java index 20aaa3116..b166762b6 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/PhasedNodeFormatter.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/PhasedNodeFormatter.java @@ -1,8 +1,7 @@ package com.vladsch.flexmark.formatter; import com.vladsch.flexmark.util.ast.Document; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -20,5 +19,5 @@ public interface PhasedNodeFormatter extends NodeFormatter { * @param document the document node to render * @param phase rendering phase for which to generate the output. Will be any of {@link FormattingPhase} except {@link FormattingPhase#DOCUMENT} because this phase is used for the non-phased node rendering */ - void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase); + void renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslatingSpanRender.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslatingSpanRender.java index 029c06419..b615e135e 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslatingSpanRender.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslatingSpanRender.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.formatter; -import org.jetbrains.annotations.NotNull; public interface TranslatingSpanRender { - void render(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown); + void render(NodeFormatterContext context, MarkdownWriter markdown); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationContext.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationContext.java index be7d58d11..88b85db3b 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationContext.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationContext.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.html.renderer.HtmlIdGenerator; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.MutableDataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.function.Function; import java.util.function.Supplier; @@ -16,13 +15,13 @@ public interface TranslationContext { * * @return RenderPurpose for current rendering */ - @NotNull RenderPurpose getRenderPurpose(); + RenderPurpose getRenderPurpose(); /** * Get MutableDataHolder for storing this translation run values across render purpose phases */ - @NotNull MutableDataHolder getTranslationStore(); + MutableDataHolder getTranslationStore(); /** * Returns false if special translation functions are no-ops @@ -59,19 +58,19 @@ public interface TranslationContext { * @param suffix2 suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing * @return text to be used in rendering for this phase */ - @NotNull CharSequence transformNonTranslating(@Nullable CharSequence prefix, @NotNull CharSequence nonTranslatingText, @Nullable CharSequence suffix, @Nullable CharSequence suffix2); + CharSequence transformNonTranslating(@Nullable CharSequence prefix, CharSequence nonTranslatingText, @Nullable CharSequence suffix, @Nullable CharSequence suffix2); /** * @param postProcessor id post processor for TRANSLATED purpose * @param scope code to which the post processor applies */ - void postProcessNonTranslating(@NotNull Function postProcessor, @NotNull Runnable scope); + void postProcessNonTranslating(Function postProcessor, Runnable scope); /** * @param postProcessor id post processor for TRANSLATED purpose * @param scope code to which the post processor applies */ - @NotNull T postProcessNonTranslating(@NotNull Function postProcessor, @NotNull Supplier scope); + T postProcessNonTranslating(Function postProcessor, Supplier scope); /** * @return true if non-translating post processor is set @@ -91,7 +90,7 @@ public interface TranslationContext { * @param suffix2 suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing * @return text to be used in rendering for this phase */ - @NotNull CharSequence transformTranslating(@Nullable CharSequence prefix, @NotNull CharSequence translatingText, @Nullable CharSequence suffix, @Nullable CharSequence suffix2); + CharSequence transformTranslating(@Nullable CharSequence prefix, CharSequence translatingText, @Nullable CharSequence suffix, @Nullable CharSequence suffix2); /** * During {@link RenderPurpose#TRANSLATION_SPANS} this converts anchorRef to ordinal placeholder id @@ -102,7 +101,7 @@ public interface TranslationContext { * @param anchorRef anchor ref * @return anchorRef for the phase to be used for rendering */ - @NotNull CharSequence transformAnchorRef(@NotNull CharSequence pageRef, @NotNull CharSequence anchorRef); + CharSequence transformAnchorRef(CharSequence pageRef, CharSequence anchorRef); /** * Separate translation span. Will generate a paragraph of text which should be translated as one piece @@ -111,7 +110,7 @@ public interface TranslationContext { * During {@link RenderPurpose#TRANSLATED_SPANS} output from renderer is suppressed, instead outputs corresponding translated span * During {@link RenderPurpose#TRANSLATED} calls render */ - void translatingSpan(@NotNull TranslatingSpanRender render); + void translatingSpan(TranslatingSpanRender render); /** * Separate non-translation span. Will generate a paragraph of text which will not be translated @@ -120,7 +119,7 @@ public interface TranslationContext { * During {@link RenderPurpose#TRANSLATED_SPANS} output from renderer is suppressed, instead outputs corresponding translated span * During {@link RenderPurpose#TRANSLATED} calls render */ - void nonTranslatingSpan(@NotNull TranslatingSpanRender render); + void nonTranslatingSpan(TranslatingSpanRender render); /** * Separate translation span which is also a ref target @@ -128,7 +127,7 @@ public interface TranslationContext { * @param target target node, * @param render */ - void translatingRefTargetSpan(@Nullable Node target, @NotNull TranslatingSpanRender render); + void translatingRefTargetSpan(@Nullable Node target, TranslatingSpanRender render); /** * Temporarily change the format for placeholders @@ -136,6 +135,6 @@ public interface TranslationContext { * @param generator placeholder generator * @param render render which will be used with the custom generator */ - void customPlaceholderFormat(@NotNull TranslationPlaceholderGenerator generator, @NotNull TranslatingSpanRender render); + void customPlaceholderFormat(TranslationPlaceholderGenerator generator, TranslatingSpanRender render); @Nullable MergeContext getMergeContext(); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationHandler.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationHandler.java index fbbb16b45..b0bbc16c5 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationHandler.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationHandler.java @@ -1,16 +1,15 @@ package com.vladsch.flexmark.formatter; import com.vladsch.flexmark.util.ast.Document; -import org.jetbrains.annotations.NotNull; import java.util.List; public interface TranslationHandler extends TranslationContext { - void beginRendering(@NotNull Document node, @NotNull NodeFormatterContext context, @NotNull MarkdownWriter out); + void beginRendering(Document node, NodeFormatterContext context, MarkdownWriter out); - @NotNull List getTranslatingTexts(); - void setTranslatedTexts(@NotNull List translatedTexts); - void setRenderPurpose(@NotNull RenderPurpose renderPurpose); + List getTranslatingTexts(); + void setTranslatedTexts(List translatedTexts); + void setRenderPurpose(RenderPurpose renderPurpose); - void setMergeContext(@NotNull MergeContext context); + void setMergeContext(MergeContext context); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationHandlerFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationHandlerFactory.java index 54c71eb8f..b0d9b0dc2 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationHandlerFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationHandlerFactory.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.html.renderer.HtmlIdGeneratorFactory; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; public interface TranslationHandlerFactory extends TranslationContext { - @NotNull TranslationHandler create(@NotNull DataHolder options, @NotNull HtmlIdGeneratorFactory idGeneratorFactory); + TranslationHandler create(DataHolder options, HtmlIdGeneratorFactory idGeneratorFactory); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationPlaceholderGenerator.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationPlaceholderGenerator.java index b0f33bd31..4b3f71bfa 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationPlaceholderGenerator.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/TranslationPlaceholderGenerator.java @@ -1,6 +1,5 @@ package com.vladsch.flexmark.formatter; -import org.jetbrains.annotations.NotNull; public interface TranslationPlaceholderGenerator { /** @@ -9,5 +8,5 @@ public interface TranslationPlaceholderGenerator { * @param index 1..N, make sure it is unique within this customizer, default format and within other customizers (huh?) * @return string for the placeholder */ - @NotNull String getPlaceholder(int index); + String getPlaceholder(int index); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/CoreNodeFormatter.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/CoreNodeFormatter.java index 4c56e9aa2..12a4146ac 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/CoreNodeFormatter.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/CoreNodeFormatter.java @@ -25,8 +25,7 @@ import com.vladsch.flexmark.util.sequence.RepeatedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; import com.vladsch.flexmark.util.sequence.mappers.SpaceMapper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -53,9 +52,8 @@ public class CoreNodeFormatter extends NodeRepositoryFormatter> ATTRIBUTE_UNIQUIFICATION_ID_MAP = Formatter.ATTRIBUTE_UNIQUIFICATION_ID_MAP; public static class Factory implements NodeFormatterFactory { - @NotNull @Override - public NodeFormatter create(@NotNull DataHolder options) { + public NodeFormatter create(DataHolder options) { return new CoreNodeFormatter(options); } } @@ -224,7 +222,7 @@ public void renderReferenceBlock(Reference node, NodeFormatterContext context, M } @Override - public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase) { + public void renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase) { super.renderDocument(context, markdown, document, phase); attributeUniquificationIdMap = Formatter.ATTRIBUTE_UNIQUIFICATION_ID_MAP.get(context.getTranslationStore()); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/FormatControlProcessor.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/FormatControlProcessor.java index d0e832e4c..d2abb66d3 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/FormatControlProcessor.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/FormatControlProcessor.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -29,7 +28,7 @@ public class FormatControlProcessor { private volatile Pattern formatterOffPattern; private volatile Pattern formatterOnPattern; - public FormatControlProcessor(@NotNull Document document, @Nullable DataHolder options) { + public FormatControlProcessor(Document document, @Nullable DataHolder options) { FormatterOptions formatterOptions = new FormatterOptions(options); this.formatterOnTag = formatterOptions.formatterOnTag; this.formatterOffTag = formatterOptions.formatterOffTag; @@ -60,7 +59,7 @@ public Pattern getFormatterOnPattern() { } @Nullable - private Pattern getPatternOrDisableRegexp(@NotNull String markerText) { + private Pattern getPatternOrDisableRegexp(String markerText) { try { return Pattern.compile(markerText); } catch (PatternSyntaxException var3) { @@ -120,11 +119,11 @@ private Boolean isFormatterOffTag(@Nullable CharSequence commentText) { return null; } - public void initializeFrom(@NotNull Node element) { + public void initializeFrom(Node element) { myFormatterOff = !isFormattingRegion(element.getStartOffset(), element, true); } - public void processFormatControl(@NotNull Node node) { + public void processFormatControl(Node node) { justTurnedOffFormatting = false; justTurnedOnFormatting = false; @@ -141,7 +140,7 @@ public void processFormatControl(@NotNull Node node) { } } - private boolean isFormattingRegion(int offset, @NotNull Node node, boolean checkParent) { + private boolean isFormattingRegion(int offset, Node node, boolean checkParent) { while (node != null) { if (node.getStartOffset() <= offset) { if (node instanceof Block && !(node instanceof Paragraph) && node.hasChildren()) { @@ -164,7 +163,7 @@ private boolean isFormattingRegion(int offset, @NotNull Node node, boolean check return true; } - public boolean isFormattingRegion(@NotNull Node node) { + public boolean isFormattingRegion(Node node) { // find the first HTML comment with a formatter directive if (!formatterTagsEnabled || node.getStartOffset() == 0) return true; return isFormattingRegion(node.getStartOffset(), node, true); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/MergeContextImpl.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/MergeContextImpl.java index 42160a66c..0c886f3ec 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/MergeContextImpl.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/MergeContextImpl.java @@ -5,8 +5,7 @@ import com.vladsch.flexmark.formatter.TranslationContext; import com.vladsch.flexmark.formatter.TranslationHandler; import com.vladsch.flexmark.util.ast.Document; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; @@ -49,14 +48,13 @@ public TranslationHandler[] getTranslationHandlers() { return myTranslationHandlers; } - @NotNull @Override - public Document getDocument(@NotNull TranslationContext context) { + public Document getDocument(TranslationContext context) { return myTranslationHandlerDocumentMap.get(context); } @Override - public void forEachPrecedingDocument(@Nullable Document document, @NotNull MergeContextConsumer consumer) { + public void forEachPrecedingDocument(@Nullable Document document, MergeContextConsumer consumer) { int iMax = myDocuments.length; for (int i = 0; i < iMax; i++) { if (myDocuments[i] == document) break; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/MergeLinkResolver.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/MergeLinkResolver.java index 40dcc0f0c..0e9142b79 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/MergeLinkResolver.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/MergeLinkResolver.java @@ -11,8 +11,7 @@ import com.vladsch.flexmark.html.renderer.ResolvedLink; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.misc.Utils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -33,9 +32,8 @@ public MergeLinkResolver(LinkResolverBasicContext context) { relativeParts = docRelativeURL.split("/"); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) { + public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) { if (node instanceof Image || node instanceof Link || node instanceof Reference) { String url = link.getUrl(); @@ -138,9 +136,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public LinkResolver apply(@NotNull LinkResolverBasicContext context) { + public LinkResolver apply(LinkResolverBasicContext context) { return new MergeLinkResolver(context); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/TranslationHandlerImpl.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/TranslationHandlerImpl.java index f420927e5..6b833c8ce 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/TranslationHandlerImpl.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/TranslationHandlerImpl.java @@ -9,8 +9,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.data.MutableDataSet; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.HashMap; @@ -79,11 +78,10 @@ public MergeContext getMergeContext() { } @Override - public void setMergeContext(@NotNull MergeContext context) { + public void setMergeContext(MergeContext context) { myMergeContext = context; } - @NotNull @Override public MutableDataSet getTranslationStore() { return myTranslationStore; @@ -95,7 +93,7 @@ public HtmlIdGenerator getIdGenerator() { } @Override - public void beginRendering(@NotNull Document node, @NotNull NodeFormatterContext context, @NotNull MarkdownWriter appendable) { + public void beginRendering(Document node, NodeFormatterContext context, MarkdownWriter appendable) { // collect anchor ref ids myWriter = appendable; myIdGenerator = myIdGeneratorFactory.create(); @@ -110,7 +108,6 @@ static boolean isNotBlank(CharSequence csq) { return false; } - @NotNull @Override public List getTranslatingTexts() { myTranslatingPlaceholders.clear(); @@ -141,7 +138,7 @@ public List getTranslatingTexts() { } @Override - public void setTranslatedTexts(@NotNull List translatedTexts) { + public void setTranslatedTexts(List translatedTexts) { myTranslatedTexts.clear(); myTranslatedTexts.putAll(myTranslatingTexts); myTranslatedSpans.clear(); @@ -182,7 +179,7 @@ public void setTranslatedTexts(@NotNull List translatedT } @Override - public void setRenderPurpose(@NotNull RenderPurpose renderPurpose) { + public void setRenderPurpose(RenderPurpose renderPurpose) { myAnchorId = 0; myTranslatingSpanId = 0; myPlaceholderId = 0; @@ -190,7 +187,6 @@ public void setRenderPurpose(@NotNull RenderPurpose renderPurpose) { myNonTranslatingSpanId = 0; } - @NotNull @Override public RenderPurpose getRenderPurpose() { return myRenderPurpose; @@ -201,9 +197,8 @@ public boolean isTransformingText() { return myRenderPurpose != RenderPurpose.FORMAT; } - @NotNull @Override - public CharSequence transformAnchorRef(@NotNull CharSequence pageRef, @NotNull CharSequence anchorRef) { + public CharSequence transformAnchorRef(CharSequence pageRef, CharSequence anchorRef) { switch (myRenderPurpose) { case TRANSLATION_SPANS: String replacedTextId = String.format(myFormatterOptions.translationIdFormat, ++myAnchorId); @@ -246,7 +241,7 @@ public CharSequence transformAnchorRef(@NotNull CharSequence pageRef, @NotNull C } @Override - public void customPlaceholderFormat(@NotNull TranslationPlaceholderGenerator generator, @NotNull TranslatingSpanRender render) { + public void customPlaceholderFormat(TranslationPlaceholderGenerator generator, TranslatingSpanRender render) { if (myRenderPurpose != TRANSLATED_SPANS) { TranslationPlaceholderGenerator savedGenerator = myPlaceholderGenerator; myPlaceholderGenerator = generator; @@ -256,7 +251,7 @@ public void customPlaceholderFormat(@NotNull TranslationPlaceholderGenerator gen } @Override - public void translatingSpan(@NotNull TranslatingSpanRender render) { + public void translatingSpan(TranslatingSpanRender render) { translatingRefTargetSpan(null, render); } @@ -280,7 +275,7 @@ private String renderInSubContext(TranslatingSpanRender render, boolean copyToMa } @Override - public void translatingRefTargetSpan(@Nullable Node target, @NotNull TranslatingSpanRender render) { + public void translatingRefTargetSpan(@Nullable Node target, TranslatingSpanRender render) { switch (myRenderPurpose) { case TRANSLATION_SPANS: { String spanText = renderInSubContext(render, true); @@ -338,7 +333,7 @@ public void translatingRefTargetSpan(@Nullable Node target, @NotNull Translating } } - public void nonTranslatingSpan(@NotNull TranslatingSpanRender render) { + public void nonTranslatingSpan(TranslatingSpanRender render) { switch (myRenderPurpose) { case TRANSLATION_SPANS: { String spanText = renderInSubContext(render, false); @@ -393,7 +388,7 @@ public static String addPrefixSuffix(CharSequence placeholderId, CharSequence pr } @Override - public void postProcessNonTranslating(@NotNull Function postProcessor, @NotNull Runnable scope) { + public void postProcessNonTranslating(Function postProcessor, Runnable scope) { Function savedValue = myNonTranslatingPostProcessor; try { myNonTranslatingPostProcessor = postProcessor; @@ -403,9 +398,8 @@ public void postProcessNonTranslating(@NotNull Function po } } - @NotNull @Override - public T postProcessNonTranslating(@NotNull Function postProcessor, @NotNull Supplier scope) { + public T postProcessNonTranslating(Function postProcessor, Supplier scope) { Function savedValue = myNonTranslatingPostProcessor; try { myNonTranslatingPostProcessor = postProcessor; @@ -420,9 +414,8 @@ public boolean isPostProcessingNonTranslating() { return myNonTranslatingPostProcessor != null; } - @NotNull @Override - public CharSequence transformNonTranslating(CharSequence prefix, @NotNull CharSequence nonTranslatingText, CharSequence suffix, CharSequence suffix2) { + public CharSequence transformNonTranslating(CharSequence prefix, CharSequence nonTranslatingText, CharSequence suffix, CharSequence suffix2) { // need to transfer trailing EOLs to id CharSequence trimmedEOL; if (suffix2 != null) { @@ -472,9 +465,8 @@ public CharSequence transformNonTranslating(CharSequence prefix, @NotNull CharSe } } - @NotNull @Override - public CharSequence transformTranslating(CharSequence prefix, @NotNull CharSequence translatingText, CharSequence suffix, CharSequence suffix2) { + public CharSequence transformTranslating(CharSequence prefix, CharSequence translatingText, CharSequence suffix, CharSequence suffix2) { switch (myRenderPurpose) { case TRANSLATION_SPANS: String replacedTextId = getPlaceholderId(myFormatterOptions.translationIdFormat, ++myPlaceholderId, prefix, suffix, suffix2); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/package-info.java index 3e94e8f4b..9be6fa353 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.formatter.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/formatter/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/formatter/package-info.java index 0c463cd51..ae1fe8b21 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/formatter/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/formatter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.formatter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/AttributeProvider.java b/flexmark/src/main/java/com/vladsch/flexmark/html/AttributeProvider.java index f9ab8f51b..4a218331d 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/AttributeProvider.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/AttributeProvider.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.html.Attributes; import com.vladsch.flexmark.util.html.MutableAttributes; -import org.jetbrains.annotations.NotNull; /** * Extension point for adding/changing attributes on the primary HTML tag for a node. @@ -32,5 +31,5 @@ public interface AttributeProvider { * AttributablePart.ID and generic AttributablePart.NODE, extensions are free to define more * @param attributes the attributes, with any default attributes already set in the map */ - void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @NotNull MutableAttributes attributes); + void setAttributes(Node node, AttributablePart part, MutableAttributes attributes); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/AttributeProviderFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/html/AttributeProviderFactory.java index 9b972f2eb..175cb436a 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/AttributeProviderFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/AttributeProviderFactory.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.html.renderer.LinkResolverContext; import com.vladsch.flexmark.util.dependency.Dependent; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.function.Function; @@ -19,5 +18,5 @@ public interface AttributeProviderFactory extends Function> equivalence = RENDERER_TYPE_EQUIVALENCE.get(options); @@ -284,7 +281,7 @@ public Builder(@Nullable DataHolder options) { } @Override - protected void removeApiPoint(@NotNull Object apiPoint) { + protected void removeApiPoint(Object apiPoint) { if (apiPoint instanceof AttributeProviderFactory) this.attributeProviderFactories.remove(apiPoint.getClass()); else if (apiPoint instanceof NodeRendererFactory) this.nodeRendererFactories.remove(apiPoint); else if (apiPoint instanceof LinkResolverFactory) this.linkResolverFactories.remove(apiPoint); @@ -295,7 +292,7 @@ protected void removeApiPoint(@NotNull Object apiPoint) { } @Override - protected void preloadExtension(@NotNull Extension extension) { + protected void preloadExtension(Extension extension) { if (extension instanceof HtmlRendererExtension) { HtmlRendererExtension htmlRendererExtension = (HtmlRendererExtension) extension; htmlRendererExtension.rendererOptions(this); @@ -306,7 +303,7 @@ protected void preloadExtension(@NotNull Extension extension) { } @Override - protected boolean loadExtension(@NotNull Extension extension) { + protected boolean loadExtension(Extension extension) { if (extension instanceof HtmlRendererExtension) { HtmlRendererExtension htmlRendererExtension = (HtmlRendererExtension) extension; htmlRendererExtension.extend(this, TYPE.get(this)); @@ -322,7 +319,6 @@ protected boolean loadExtension(@NotNull Extension extension) { /** * @return the configured {@link HtmlRenderer} */ - @NotNull public HtmlRenderer build() { return new HtmlRenderer(this); } @@ -338,7 +334,7 @@ public HtmlRenderer build() { * @param softBreak HTML for softbreak * @return {@code this} */ - public @NotNull Builder softBreak(@NotNull String softBreak) { + public Builder softBreak(String softBreak) { this.set(SOFT_BREAK, softBreak); return this; } @@ -349,7 +345,7 @@ public HtmlRenderer build() { * @param indentSize number of spaces per indent * @return {@code this} */ - public @NotNull Builder indentSize(int indentSize) { + public Builder indentSize(int indentSize) { this.set(INDENT_SIZE, indentSize); return this; } @@ -363,12 +359,12 @@ public HtmlRenderer build() { * @param escapeHtml true for escaping, false for preserving raw HTML * @return {@code this} */ - public @NotNull Builder escapeHtml(boolean escapeHtml) { + public Builder escapeHtml(boolean escapeHtml) { this.set(ESCAPE_HTML, escapeHtml); return this; } - public boolean isRendererType(@NotNull String supportedRendererType) { + public boolean isRendererType(String supportedRendererType) { String rendererType = HtmlRenderer.TYPE.get(this); return HtmlRenderer.isCompatibleRendererType(this, rendererType, supportedRendererType); } @@ -387,7 +383,7 @@ public boolean isRendererType(@NotNull String supportedRendererType) { * @param percentEncodeUrls true to percent-encode, false for leaving as-is * @return {@code this} */ - public @NotNull Builder percentEncodeUrls(boolean percentEncodeUrls) { + public Builder percentEncodeUrls(boolean percentEncodeUrls) { this.set(PERCENT_ENCODE_URLS, percentEncodeUrls); return this; } @@ -398,7 +394,7 @@ public boolean isRendererType(@NotNull String supportedRendererType) { * @param attributeProviderFactory the attribute provider factory to add * @return {@code this} */ - public @NotNull Builder attributeProviderFactory(@NotNull AttributeProviderFactory attributeProviderFactory) { + public Builder attributeProviderFactory(AttributeProviderFactory attributeProviderFactory) { this.attributeProviderFactories.put(attributeProviderFactory.getClass(), attributeProviderFactory); addExtensionApiPoint(attributeProviderFactory); return this; @@ -414,7 +410,7 @@ public boolean isRendererType(@NotNull String supportedRendererType) { * @param nodeRendererFactory the factory for creating a node renderer * @return {@code this} */ - public @NotNull Builder nodeRendererFactory(@NotNull NodeRendererFactory nodeRendererFactory) { + public Builder nodeRendererFactory(NodeRendererFactory nodeRendererFactory) { this.nodeRendererFactories.add(nodeRendererFactory); addExtensionApiPoint(nodeRendererFactory); return this; @@ -430,7 +426,7 @@ public boolean isRendererType(@NotNull String supportedRendererType) { * @param linkResolverFactory the factory for creating a node renderer * @return {@code this} */ - public @NotNull Builder linkResolverFactory(@NotNull LinkResolverFactory linkResolverFactory) { + public Builder linkResolverFactory(LinkResolverFactory linkResolverFactory) { this.linkResolverFactories.add(linkResolverFactory); addExtensionApiPoint(linkResolverFactory); return this; @@ -443,7 +439,7 @@ public boolean isRendererType(@NotNull String supportedRendererType) { * @return {@code this} */ @Override - public @NotNull Builder contentResolverFactory(@NotNull UriContentResolverFactory contentResolverFactory) { + public Builder contentResolverFactory(UriContentResolverFactory contentResolverFactory) { throw new IllegalStateException("Not implemented"); } @@ -453,8 +449,7 @@ public boolean isRendererType(@NotNull String supportedRendererType) { * @param htmlIdGeneratorFactory the factory for generating header tag id attributes * @return {@code this} */ - @NotNull - public Builder htmlIdGeneratorFactory(@NotNull HeaderIdGeneratorFactory htmlIdGeneratorFactory) { + public Builder htmlIdGeneratorFactory(HeaderIdGeneratorFactory htmlIdGeneratorFactory) { //noinspection VariableNotUsedInsideIf if (this.htmlIdGeneratorFactory != null) { throw new IllegalStateException("custom header id factory is already set to " + htmlIdGeneratorFactory.getClass().getName()); @@ -480,7 +475,7 @@ public interface HtmlRendererExtension extends Extension { * * @param options option set that will be used for the builder */ - void rendererOptions(@NotNull MutableDataHolder options); + void rendererOptions(MutableDataHolder options); /** * Called to give each extension to register extension points that it contains @@ -492,7 +487,7 @@ public interface HtmlRendererExtension extends Extension { * @see Builder#linkResolverFactory(LinkResolverFactory) * @see Builder#htmlIdGeneratorFactory(HeaderIdGeneratorFactory) */ - void extend(@NotNull Builder htmlRendererBuilder, @NotNull String rendererType); + void extend(Builder htmlRendererBuilder, String rendererType); } private class MainNodeRenderer extends NodeRendererSubContext implements NodeRendererContext, Disposable { @@ -576,15 +571,13 @@ public void dispose() { } } - @NotNull @Override public Node getCurrentNode() { return renderingNode; } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Attributes attributes, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Attributes attributes, Boolean urlEncode) { HashMap resolvedLinks = resolvedLinkMap.computeIfAbsent(linkType, k -> new HashMap<>()); String urlSeq = String.valueOf(url); @@ -612,7 +605,7 @@ public ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequenc } @Override - public String getNodeId(@NotNull Node node) { + public String getNodeId(Node node) { String id = htmlIdGenerator.getId(node); if (attributeProviderFactories.size() != 0) { MutableAttributes attributes = new MutableAttributes(); @@ -626,33 +619,28 @@ public String getNodeId(@NotNull Node node) { return id; } - @NotNull @Override public DataHolder getOptions() { return options; } - @NotNull @Override public HtmlRendererOptions getHtmlOptions() { return htmlOptions; } - @NotNull @Override public Document getDocument() { return document; } - @NotNull @Override public RenderingPhase getRenderingPhase() { return phase; } - @NotNull @Override - public String encodeUrl(@NotNull CharSequence url) { + public String encodeUrl(CharSequence url) { if (htmlOptions.percentEncodeUrls) { return Escaping.percentEncodeUrl(url); } else { @@ -661,7 +649,7 @@ public String encodeUrl(@NotNull CharSequence url) { } @Override - public @NotNull MutableAttributes extendRenderingNodeAttributes(@NotNull AttributablePart part, Attributes attributes) { + public MutableAttributes extendRenderingNodeAttributes(AttributablePart part, Attributes attributes) { MutableAttributes attr = attributes != null ? attributes.toMutable() : new MutableAttributes(); for (AttributeProvider attributeProvider : attributeProviders) { attributeProvider.setAttributes(this.renderingNode, part, attr); @@ -670,7 +658,7 @@ public String encodeUrl(@NotNull CharSequence url) { } @Override - public @NotNull MutableAttributes extendRenderingNodeAttributes(@NotNull Node node, @NotNull AttributablePart part, Attributes attributes) { + public MutableAttributes extendRenderingNodeAttributes(Node node, AttributablePart part, Attributes attributes) { MutableAttributes attr = attributes != null ? attributes.toMutable() : new MutableAttributes(); for (AttributeProvider attributeProvider : attributeProviders) { attributeProvider.setAttributes(node, part, attr); @@ -679,7 +667,7 @@ public String encodeUrl(@NotNull CharSequence url) { } @Override - public void render(@NotNull Node node) { + public void render(Node node) { renderNode(node, this); } @@ -709,7 +697,6 @@ void renderByPreviousHandler(NodeRendererSubContext subContext) { } } - @NotNull @Override public NodeRendererContext getSubContext(boolean inheritIndent) { HtmlWriter htmlWriter = new HtmlWriter(getHtmlWriter(), inheritIndent); @@ -718,7 +705,6 @@ public NodeRendererContext getSubContext(boolean inheritIndent) { return new SubNodeRenderer(this, htmlWriter, false); } - @NotNull @Override public NodeRendererContext getDelegatedSubContext(boolean inheritIndent) { HtmlWriter htmlWriter = new HtmlWriter(getHtmlWriter(), inheritIndent); @@ -786,7 +772,7 @@ void renderNode(Node node, NodeRendererSubContext subContext) { } } - public void renderChildren(@NotNull Node parent) { + public void renderChildren(Node parent) { renderChildrenNode(parent, this); } @@ -815,30 +801,25 @@ public SubNodeRenderer(MainNodeRenderer mainNodeRenderer, HtmlWriter htmlWriter, } @Override - public String getNodeId(@NotNull Node node) {return myMainNodeRenderer.getNodeId(node);} + public String getNodeId(Node node) {return myMainNodeRenderer.getNodeId(node);} - @NotNull @Override public DataHolder getOptions() {return myMainNodeRenderer.getOptions();} - @NotNull @Override public HtmlRendererOptions getHtmlOptions() {return myMainNodeRenderer.getHtmlOptions();} - @NotNull @Override public Document getDocument() {return myMainNodeRenderer.getDocument();} - @NotNull @Override public RenderingPhase getRenderingPhase() {return myMainNodeRenderer.getRenderingPhase();} - @NotNull @Override - public String encodeUrl(@NotNull CharSequence url) {return myMainNodeRenderer.encodeUrl(url);} + public String encodeUrl(CharSequence url) {return myMainNodeRenderer.encodeUrl(url);} @Override - public @NotNull MutableAttributes extendRenderingNodeAttributes(@NotNull AttributablePart part, Attributes attributes) { + public MutableAttributes extendRenderingNodeAttributes(AttributablePart part, Attributes attributes) { return myMainNodeRenderer.extendRenderingNodeAttributes( part, attributes @@ -846,7 +827,7 @@ public SubNodeRenderer(MainNodeRenderer mainNodeRenderer, HtmlWriter htmlWriter, } @Override - public @NotNull MutableAttributes extendRenderingNodeAttributes(@NotNull Node node, @NotNull AttributablePart part, Attributes attributes) { + public MutableAttributes extendRenderingNodeAttributes(Node node, AttributablePart part, Attributes attributes) { return myMainNodeRenderer.extendRenderingNodeAttributes( node, part, @@ -855,7 +836,7 @@ public SubNodeRenderer(MainNodeRenderer mainNodeRenderer, HtmlWriter htmlWriter, } @Override - public void render(@NotNull Node node) { + public void render(Node node) { myMainNodeRenderer.renderNode(node, this); } @@ -864,25 +845,21 @@ public void delegateRender() { myMainNodeRenderer.renderByPreviousHandler(this); } - @NotNull @Override public Node getCurrentNode() { return myMainNodeRenderer.getCurrentNode(); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Boolean urlEncode) { return myMainNodeRenderer.resolveLink(linkType, url, urlEncode); } - @NotNull @Override - public ResolvedLink resolveLink(@NotNull LinkType linkType, @NotNull CharSequence url, Attributes attributes, Boolean urlEncode) { + public ResolvedLink resolveLink(LinkType linkType, CharSequence url, Attributes attributes, Boolean urlEncode) { return myMainNodeRenderer.resolveLink(linkType, url, attributes, urlEncode); } - @NotNull @Override public NodeRendererContext getSubContext(boolean inheritIndent) { HtmlWriter htmlWriter = new HtmlWriter(this.htmlWriter, inheritIndent); @@ -891,7 +868,6 @@ public NodeRendererContext getSubContext(boolean inheritIndent) { return new SubNodeRenderer(myMainNodeRenderer, htmlWriter, false); } - @NotNull @Override public NodeRendererContext getDelegatedSubContext(boolean inheritIndent) { HtmlWriter htmlWriter = new HtmlWriter(this.htmlWriter, inheritIndent); @@ -901,11 +877,10 @@ public NodeRendererContext getDelegatedSubContext(boolean inheritIndent) { } @Override - public void renderChildren(@NotNull Node parent) { + public void renderChildren(Node parent) { myMainNodeRenderer.renderChildrenNode(parent, this); } - @NotNull @Override public HtmlWriter getHtmlWriter() { return htmlWriter; } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/HtmlRendererOptions.java b/flexmark/src/main/java/com/vladsch/flexmark/html/HtmlRendererOptions.java index 897e7a6a4..64e6097bf 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/HtmlRendererOptions.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/HtmlRendererOptions.java @@ -3,16 +3,15 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.misc.Utils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.HashMap; import java.util.regex.Pattern; public class HtmlRendererOptions { - final public @NotNull String softBreak; + final public String softBreak; final public boolean isSoftBreakAllSpaces; - final public @NotNull String hardBreak; + final public String hardBreak; final public @Nullable String strongEmphasisStyleHtmlOpen; final public @Nullable String strongEmphasisStyleHtmlClose; final public @Nullable String emphasisStyleHtmlOpen; @@ -32,12 +31,12 @@ public class HtmlRendererOptions { final public boolean doNotRenderLinksInDocument; final public boolean renderHeaderId; final public boolean generateHeaderIds; - final public @NotNull String languageClassPrefix; - final public @NotNull HashMap languageClassMap; - final public @NotNull String languageDelimiters; + final public String languageClassPrefix; + final public HashMap languageClassMap; + final public String languageDelimiters; final public CharPredicate languageDelimiterSet; - final public @NotNull String noLanguageClass; - final public @NotNull String sourcePositionAttribute; + final public String noLanguageClass; + final public String sourcePositionAttribute; final public @Nullable String inlineCodeSpliceClass; final public boolean sourcePositionParagraphLines; final public boolean sourceWrapHtmlBlocks; @@ -48,7 +47,7 @@ public class HtmlRendererOptions { final public boolean htmlBlockCloseTagEol; final public boolean unescapeHtmlEntities; final public boolean noPTagsUseBr; - final public @NotNull String autolinkWwwPrefix; + final public String autolinkWwwPrefix; final public @Nullable Pattern suppressedLinks; public HtmlRendererOptions(DataHolder options) { diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/HtmlWriter.java b/flexmark/src/main/java/com/vladsch/flexmark/html/HtmlWriter.java index 5f6d2081d..f886f5d8c 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/HtmlWriter.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/HtmlWriter.java @@ -9,8 +9,7 @@ import com.vladsch.flexmark.util.html.HtmlAppendableBase; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.TagRange; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; @@ -37,28 +36,28 @@ public HtmlWriter(@Nullable Appendable appendable, int indentSize, int formatOpt setSuppressCloseTagLine(suppressCloseTagLine); } - void setContext(@NotNull NodeRendererContext context) { + void setContext(NodeRendererContext context) { this.context = context; } - public @NotNull NodeRendererContext getContext() { + public NodeRendererContext getContext() { assert context != null; return context; } - public @NotNull HtmlWriter srcPos() { + public HtmlWriter srcPos() { return context == null ? this : srcPos(context.getCurrentNode().getChars()); } - public @NotNull HtmlWriter srcPosWithEOL() { + public HtmlWriter srcPosWithEOL() { return context == null ? this : srcPosWithEOL(context.getCurrentNode().getChars()); } - public @NotNull HtmlWriter srcPosWithTrailingEOL() { + public HtmlWriter srcPosWithTrailingEOL() { return context == null ? this : srcPosWithTrailingEOL(context.getCurrentNode().getChars()); } - public @NotNull HtmlWriter srcPos(@NotNull BasedSequence sourceText) { + public HtmlWriter srcPos(BasedSequence sourceText) { if (sourceText.isNotNull()) { BasedSequence trimmed = sourceText.trimEOL(); return srcPos(trimmed.getStartOffset(), trimmed.getEndOffset()); @@ -67,7 +66,7 @@ void setContext(@NotNull NodeRendererContext context) { } @SuppressWarnings("WeakerAccess") - public @NotNull HtmlWriter srcPosWithEOL(@NotNull BasedSequence sourceText) { + public HtmlWriter srcPosWithEOL(BasedSequence sourceText) { if (sourceText.isNotNull()) { return srcPos(sourceText.getStartOffset(), sourceText.getEndOffset()); } @@ -75,7 +74,7 @@ void setContext(@NotNull NodeRendererContext context) { } @SuppressWarnings("WeakerAccess") - public @NotNull HtmlWriter srcPosWithTrailingEOL(@NotNull BasedSequence sourceText) { + public HtmlWriter srcPosWithTrailingEOL(BasedSequence sourceText) { if (sourceText.isNotNull()) { int endOffset = sourceText.getEndOffset(); BasedSequence base = sourceText.getBaseSequence(); @@ -98,36 +97,34 @@ void setContext(@NotNull NodeRendererContext context) { return this; } - public @NotNull HtmlWriter srcPos(int startOffset, int endOffset) { + public HtmlWriter srcPos(int startOffset, int endOffset) { if (startOffset <= endOffset && context != null && !context.getHtmlOptions().sourcePositionAttribute.isEmpty()) { super.attr(context.getHtmlOptions().sourcePositionAttribute, startOffset + "-" + endOffset); } return this; } - @NotNull public HtmlWriter withAttr() { return withAttr(AttributablePart.NODE); } - public @NotNull HtmlWriter withAttr(@NotNull AttributablePart part) { + public HtmlWriter withAttr(AttributablePart part) { super.withAttr(); useAttributes = part; return this; } - public @NotNull HtmlWriter withAttr(@NotNull LinkStatus status) { + public HtmlWriter withAttr(LinkStatus status) { attr(Attribute.LINK_STATUS_ATTR, status.getName()); return withAttr(AttributablePart.LINK); } - public @NotNull HtmlWriter withAttr(@NotNull ResolvedLink resolvedLink) { + public HtmlWriter withAttr(ResolvedLink resolvedLink) { return withAttr(resolvedLink.getStatus()); } - @NotNull @Override - public HtmlWriter tag(@NotNull CharSequence tagName, boolean voidElement) { + public HtmlWriter tag(CharSequence tagName, boolean voidElement) { if (useAttributes != null) { String attributeValue; final Attributes attributes; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/IndependentAttributeProviderFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/html/IndependentAttributeProviderFactory.java index ff23e3b30..47c83de47 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/IndependentAttributeProviderFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/IndependentAttributeProviderFactory.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.html; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/IndependentLinkResolverFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/html/IndependentLinkResolverFactory.java index 84bfd11d4..c24fe92d8 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/IndependentLinkResolverFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/IndependentLinkResolverFactory.java @@ -1,6 +1,6 @@ package com.vladsch.flexmark.html; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/LinkResolver.java b/flexmark/src/main/java/com/vladsch/flexmark/html/LinkResolver.java index feb18a538..703ab4762 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/LinkResolver.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/LinkResolver.java @@ -3,10 +3,9 @@ import com.vladsch.flexmark.html.renderer.LinkResolverBasicContext; import com.vladsch.flexmark.html.renderer.ResolvedLink; import com.vladsch.flexmark.util.ast.Node; -import org.jetbrains.annotations.NotNull; public interface LinkResolver { - @NotNull ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link); + ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link); LinkResolver NULL = (node, context, link) -> link; } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/LinkResolverFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/html/LinkResolverFactory.java index a73d26a86..9992b472e 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/LinkResolverFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/LinkResolverFactory.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.html.renderer.LinkResolverBasicContext; import com.vladsch.flexmark.util.dependency.Dependent; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.function.Function; @@ -19,5 +18,5 @@ public interface LinkResolverFactory extends Function myRenderingHandler; + final public NodeRenderingHandler myRenderingHandler; final public @Nullable NodeRenderingHandlerWrapper myPreviousRenderingHandler; - public NodeRenderingHandlerWrapper(@NotNull NodeRenderingHandler renderingHandler, @Nullable NodeRenderingHandlerWrapper previousRenderingHandler) { + public NodeRenderingHandlerWrapper(NodeRenderingHandler renderingHandler, @Nullable NodeRenderingHandlerWrapper previousRenderingHandler) { myRenderingHandler = renderingHandler; myPreviousRenderingHandler = previousRenderingHandler; } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/RendererBuilder.java b/flexmark/src/main/java/com/vladsch/flexmark/html/RendererBuilder.java index 1519ad530..e5ae62467 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/RendererBuilder.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/RendererBuilder.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.html.renderer.HeaderIdGeneratorFactory; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; /** * Extension point for RenderingExtensions that only provide attributes, link resolvers or html id generators @@ -15,7 +14,7 @@ public interface RendererBuilder extends DataHolder { * @param attributeProviderFactory the attribute provider factory to add * @return {@code this} */ - @NotNull RendererBuilder attributeProviderFactory(@NotNull AttributeProviderFactory attributeProviderFactory); + RendererBuilder attributeProviderFactory(AttributeProviderFactory attributeProviderFactory); /** * Add a factory for resolving links in markdown to URI used in rendering @@ -23,7 +22,7 @@ public interface RendererBuilder extends DataHolder { * @param linkResolverFactory the factory for creating a node renderer * @return {@code this} */ - @NotNull RendererBuilder linkResolverFactory(@NotNull LinkResolverFactory linkResolverFactory); + RendererBuilder linkResolverFactory(LinkResolverFactory linkResolverFactory); /** * Add a factory for resolving URI to content @@ -31,7 +30,7 @@ public interface RendererBuilder extends DataHolder { * @param contentResolverFactory the factory for creating a node renderer * @return {@code this} */ - @NotNull RendererBuilder contentResolverFactory(@NotNull UriContentResolverFactory contentResolverFactory); + RendererBuilder contentResolverFactory(UriContentResolverFactory contentResolverFactory); /** * Add a factory for generating the header id attribute from the header's text @@ -39,5 +38,5 @@ public interface RendererBuilder extends DataHolder { * @param htmlIdGeneratorFactory the factory for generating header tag id attributes * @return {@code this} */ - @NotNull RendererBuilder htmlIdGeneratorFactory(@NotNull HeaderIdGeneratorFactory htmlIdGeneratorFactory); + RendererBuilder htmlIdGeneratorFactory(HeaderIdGeneratorFactory htmlIdGeneratorFactory); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/RendererExtension.java b/flexmark/src/main/java/com/vladsch/flexmark/html/RendererExtension.java index 0a302f9d3..b6426a488 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/RendererExtension.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/RendererExtension.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.html.renderer.HeaderIdGeneratorFactory; import com.vladsch.flexmark.util.data.MutableDataHolder; import com.vladsch.flexmark.util.misc.Extension; -import org.jetbrains.annotations.NotNull; public interface RendererExtension extends Extension { /** @@ -12,7 +11,7 @@ public interface RendererExtension extends Extension { * * @param options option set that will be used for the builder */ - void rendererOptions(@NotNull MutableDataHolder options); + void rendererOptions(MutableDataHolder options); /** * Called to give each extension to register extension points that it contains @@ -23,5 +22,5 @@ public interface RendererExtension extends Extension { * @see HtmlRenderer.Builder#linkResolverFactory(LinkResolverFactory) * @see HtmlRenderer.Builder#htmlIdGeneratorFactory(HeaderIdGeneratorFactory) */ - void extend(@NotNull RendererBuilder rendererBuilder, @NotNull String rendererType); + void extend(RendererBuilder rendererBuilder, String rendererType); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/UriContentResolver.java b/flexmark/src/main/java/com/vladsch/flexmark/html/UriContentResolver.java index 3c8a17f3a..55c909da4 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/UriContentResolver.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/UriContentResolver.java @@ -3,10 +3,9 @@ import com.vladsch.flexmark.html.renderer.LinkResolverBasicContext; import com.vladsch.flexmark.html.renderer.ResolvedContent; import com.vladsch.flexmark.util.ast.Node; -import org.jetbrains.annotations.NotNull; public interface UriContentResolver { - @NotNull ResolvedContent resolveContent(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedContent content); + ResolvedContent resolveContent(Node node, LinkResolverBasicContext context, ResolvedContent content); UriContentResolver NULL = (node, context, content) -> content; } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/UriContentResolverFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/html/UriContentResolverFactory.java index ac0de0c17..6ec16b01c 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/UriContentResolverFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/UriContentResolverFactory.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.html.renderer.LinkResolverBasicContext; import com.vladsch.flexmark.util.dependency.Dependent; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; import java.util.function.Function; @@ -19,5 +18,5 @@ public interface UriContentResolverFactory extends Function * @param options the context for rendering (normally passed on to the node renderer) * @return a node renderer */ - @NotNull NodeRenderer apply(@NotNull DataHolder options); + NodeRenderer apply(DataHolder options); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/NodeRenderingHandler.java b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/NodeRenderingHandler.java index 7e0d38a35..c7e5dd686 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/NodeRenderingHandler.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/NodeRenderingHandler.java @@ -4,19 +4,18 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.visitor.AstAction; import com.vladsch.flexmark.util.visitor.AstHandler; -import org.jetbrains.annotations.NotNull; public class NodeRenderingHandler extends AstHandler> { - public NodeRenderingHandler(@NotNull Class aClass, @NotNull CustomNodeRenderer adapter) { + public NodeRenderingHandler(Class aClass, CustomNodeRenderer adapter) { super(aClass, adapter); } - public void render(@NotNull Node node, @NotNull NodeRendererContext context, @NotNull HtmlWriter html) { + public void render(Node node, NodeRendererContext context, HtmlWriter html) { //noinspection unchecked getAdapter().render((N) node, context, html); } public interface CustomNodeRenderer extends AstAction { - void render(@NotNull N node, @NotNull NodeRendererContext context, @NotNull HtmlWriter html); + void render(N node, NodeRendererContext context, HtmlWriter html); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/PhasedNodeRenderer.java b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/PhasedNodeRenderer.java index b7d3a6d3b..2cfbb9ecf 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/PhasedNodeRenderer.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/PhasedNodeRenderer.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.html.HtmlWriter; import com.vladsch.flexmark.util.ast.Document; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; @@ -26,5 +25,5 @@ public interface PhasedNodeRenderer extends NodeRenderer { * the node renderer calls are made so it is a good place to reset internal structures for * start of each phase. */ - void renderDocument(@NotNull NodeRendererContext context, @NotNull HtmlWriter html, @NotNull Document document, @NotNull RenderingPhase phase); + void renderDocument(NodeRendererContext context, HtmlWriter html, Document document, RenderingPhase phase); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/ResolvedContent.java b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/ResolvedContent.java index f19338609..3a467caec 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/ResolvedContent.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/ResolvedContent.java @@ -1,16 +1,15 @@ package com.vladsch.flexmark.html.renderer; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; public class ResolvedContent { - final private @NotNull ResolvedLink resolvedLink; - final private @NotNull LinkStatus status; - final private @Nullable byte[] content; + final private ResolvedLink resolvedLink; + final private LinkStatus status; + final private byte @Nullable [] content; - public ResolvedContent(@NotNull ResolvedLink resolvedLink, @NotNull LinkStatus status, @Nullable byte[] content) { + public ResolvedContent(ResolvedLink resolvedLink, LinkStatus status, byte @Nullable [] content) { this.resolvedLink = resolvedLink; this.status = status; this.content = content; @@ -18,19 +17,19 @@ public ResolvedContent(@NotNull ResolvedLink resolvedLink, @NotNull LinkStatus s // @formatter:off - public ResolvedContent withStatus(@NotNull LinkStatus status) { return status == this.status ? this : new ResolvedContent(resolvedLink, status, content); } - public ResolvedContent withContent(@Nullable byte[] content) { return Arrays.equals(this.content, content) ? this : new ResolvedContent(resolvedLink, status, content); } + public ResolvedContent withStatus(LinkStatus status) { return status == this.status ? this : new ResolvedContent(resolvedLink, status, content); } + public ResolvedContent withContent(byte @Nullable [] content) { return Arrays.equals(this.content, content) ? this : new ResolvedContent(resolvedLink, status, content); } // @formatter:on - public @NotNull ResolvedLink getResolvedLink() { + public ResolvedLink getResolvedLink() { return resolvedLink; } - public @NotNull LinkStatus getStatus() { + public LinkStatus getStatus() { return status; } - public @Nullable byte[] getContent() { + public byte @Nullable [] getContent() { return content; } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/ResolvedLink.java b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/ResolvedLink.java index f584923c7..fe3b68573 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/ResolvedLink.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/ResolvedLink.java @@ -4,20 +4,19 @@ import com.vladsch.flexmark.util.html.Attributes; import com.vladsch.flexmark.util.html.MutableAttribute; import com.vladsch.flexmark.util.html.MutableAttributes; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; public class ResolvedLink { - final private @NotNull LinkType myLinkType; - final private @NotNull String myUrl; - final private @NotNull LinkStatus myStatus; + final private LinkType myLinkType; + final private String myUrl; + final private LinkStatus myStatus; private @Nullable MutableAttributes myAttributes; - public ResolvedLink(@NotNull LinkType linkType, @NotNull CharSequence url) { + public ResolvedLink(LinkType linkType, CharSequence url) { this(linkType, url, null, LinkStatus.UNKNOWN); } - public ResolvedLink(@NotNull LinkType linkType, @NotNull CharSequence url, @Nullable Attributes attributes) { + public ResolvedLink(LinkType linkType, CharSequence url, @Nullable Attributes attributes) { this(linkType, url, attributes, LinkStatus.UNKNOWN); } @@ -26,21 +25,21 @@ public Attributes getAttributes() { return myAttributes == null ? null : myAttributes.toImmutable(); } - public @NotNull Attributes getNonNullAttributes() { + public Attributes getNonNullAttributes() { if (myAttributes == null) { myAttributes = new MutableAttributes(); } return myAttributes.toImmutable(); } - public @NotNull MutableAttributes getMutableAttributes() { + public MutableAttributes getMutableAttributes() { if (myAttributes == null) { myAttributes = new MutableAttributes(); } return myAttributes; } - public ResolvedLink(@NotNull LinkType linkType, CharSequence url, @Nullable Attributes attributes, @NotNull LinkStatus status) { + public ResolvedLink(LinkType linkType, CharSequence url, @Nullable Attributes attributes, LinkStatus status) { myLinkType = linkType; myUrl = String.valueOf(url); myStatus = status; @@ -50,31 +49,28 @@ public ResolvedLink(@NotNull LinkType linkType, CharSequence url, @Nullable Attr } // @formatter:off - public ResolvedLink withLinkType(@NotNull LinkType linkType) { return linkType == this.myLinkType ? this : new ResolvedLink(linkType, myUrl, myAttributes, myStatus); } - public ResolvedLink withStatus(@NotNull LinkStatus status) { return status == this.myStatus ? this : new ResolvedLink(myLinkType, myUrl, myAttributes, status); } + public ResolvedLink withLinkType(LinkType linkType) { return linkType == this.myLinkType ? this : new ResolvedLink(linkType, myUrl, myAttributes, myStatus); } + public ResolvedLink withStatus(LinkStatus status) { return status == this.myStatus ? this : new ResolvedLink(myLinkType, myUrl, myAttributes, status); } // @formatter:on - @NotNull public LinkType getLinkType() { return myLinkType; } - @NotNull public LinkStatus getStatus() { return myStatus; } - public @NotNull ResolvedLink withUrl(@NotNull CharSequence url) { + public ResolvedLink withUrl(CharSequence url) { String useUrl = String.valueOf(url); return this.myUrl.equals(useUrl) ? this : new ResolvedLink(myLinkType, useUrl, myAttributes, myStatus); } - @NotNull public String getUrl() { return myUrl; } - public @NotNull String getPageRef() { + public String getPageRef() { // parse out the anchor marker and ref int pos = myUrl.indexOf('#'); if (pos < 0) { @@ -94,7 +90,7 @@ public String getUrl() { } } - public @NotNull ResolvedLink withTitle(@Nullable CharSequence title) { + public ResolvedLink withTitle(@Nullable CharSequence title) { String haveTitle = myAttributes == null ? null : myAttributes.getValue(Attribute.TITLE_ATTR); if (title == haveTitle || haveTitle != null && title != null && haveTitle.contentEquals(title)) return this; @@ -112,7 +108,7 @@ public String getUrl() { return myAttributes == null ? null : myAttributes.getValue(Attribute.TITLE_ATTR); } - public @NotNull ResolvedLink withTarget(@Nullable CharSequence target) { + public ResolvedLink withTarget(@Nullable CharSequence target) { String haveTarget = myAttributes == null ? null : myAttributes.getValue(Attribute.TARGET_ATTR); if (target == haveTarget || haveTarget != null && target != null && haveTarget.contentEquals(target)) return this; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/package-info.java index 2f5e09d97..ac98236db 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/html/renderer/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.html.renderer; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/package-info.java index 8d48ba563..627f18de2 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/package-info.java @@ -6,5 +6,8 @@ *
  • {@link com.vladsch.flexmark.html} for HTML rendering
  • * */ +@NullMarked package com.vladsch.flexmark; +import org.jspecify.annotations.NullMarked; + diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParser.java index fe4605fee..f485c5d6c 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParser.java @@ -7,8 +7,7 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.BitSet; import java.util.List; @@ -20,18 +19,18 @@ */ public interface InlineParser extends LightInlineParser { - void initializeDocument(@NotNull Document document); - void finalizeDocument(@NotNull Document document); + void initializeDocument(Document document); + void finalizeDocument(Document document); /** * @param input the content to parse as inline * @param node the node to append resulting nodes to (as children) */ - void parse(@NotNull BasedSequence input, @NotNull Node node); + void parse(BasedSequence input, Node node); @Nullable Delimiter getLastDelimiter(); @Nullable Bracket getLastBracket(); - @Nullable List parseCustom(@NotNull BasedSequence input, @NotNull Node node, @NotNull BitSet customCharacters, @NotNull Map nodeFactoryMap); + @Nullable List parseCustom(BasedSequence input, Node node, BitSet customCharacters, Map nodeFactoryMap); void mergeTextNodes(@Nullable Node fromNode, @Nullable Node toNode); void mergeIfNeeded(@Nullable Text first, @Nullable Text last); @Nullable BasedSequence toEOL(); @@ -43,8 +42,8 @@ public interface InlineParser extends LightInlineParser { boolean parseHtmlInline(); boolean parseEntity(); void processDelimiters(@Nullable Delimiter stackBottom); - void removeDelimitersBetween(@NotNull Delimiter opener, @NotNull Delimiter closer); - void removeDelimiterAndNode(@NotNull Delimiter delim); - void removeDelimiterKeepNode(@NotNull Delimiter delim); - void removeDelimiter(@NotNull Delimiter delim); + void removeDelimitersBetween(Delimiter opener, Delimiter closer); + void removeDelimiterAndNode(Delimiter delim); + void removeDelimiterKeepNode(Delimiter delim); + void removeDelimiter(Delimiter delim); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParserExtension.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParserExtension.java index b39e7bb9b..ce9f0b895 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParserExtension.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParserExtension.java @@ -1,10 +1,9 @@ package com.vladsch.flexmark.parser; -import org.jetbrains.annotations.NotNull; public interface InlineParserExtension { - void finalizeDocument(@NotNull InlineParser inlineParser); - void finalizeBlock(@NotNull InlineParser inlineParser); + void finalizeDocument(InlineParser inlineParser); + void finalizeBlock(InlineParser inlineParser); /** * Parse input @@ -12,5 +11,5 @@ public interface InlineParserExtension { * @param inlineParser * @return true if character input was processed */ - boolean parse(@NotNull LightInlineParser inlineParser); + boolean parse(LightInlineParser inlineParser); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParserExtensionFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParserExtensionFactory.java index c6c484d76..f14024525 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParserExtensionFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/InlineParserExtensionFactory.java @@ -1,7 +1,6 @@ package com.vladsch.flexmark.parser; import com.vladsch.flexmark.util.dependency.Dependent; -import org.jetbrains.annotations.NotNull; import java.util.function.Function; @@ -11,7 +10,7 @@ public interface InlineParserExtensionFactory extends Function delimiterProcessors, - @NotNull LinkRefProcessorData linkRefProcessors, - @NotNull List inlineParserExtensions + LinkRefProcessorData linkRefProcessors, + List inlineParserExtensions ); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/LightInlineParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/LightInlineParser.java index 45489acdf..be2fec592 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/LightInlineParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/LightInlineParser.java @@ -5,38 +5,37 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; public interface LightInlineParser { - @NotNull ArrayList getCurrentText(); - @NotNull BasedSequence getInput(); + ArrayList getCurrentText(); + BasedSequence getInput(); void setInput(BasedSequence input); int getIndex(); void setIndex(int index); - @NotNull Node getBlock(); + Node getBlock(); @Nullable BasedSequence match(Pattern re); - @Nullable BasedSequence[] matchWithGroups(Pattern re); + BasedSequence @Nullable [] matchWithGroups(Pattern re); @Nullable Matcher matcher(Pattern re); char peek(); char peek(int ahead); boolean flushTextNode(); - @NotNull Document getDocument(); - void setDocument(@NotNull Document document); - @NotNull InlineParserOptions getOptions(); - @NotNull Parsing getParsing(); - void appendText(@NotNull BasedSequence text); - void appendText(@NotNull BasedSequence text, int beginIndex, int endIndex); - void appendNode(@NotNull Node node); + Document getDocument(); + void setDocument(Document document); + InlineParserOptions getOptions(); + Parsing getParsing(); + void appendText(BasedSequence text); + void appendText(BasedSequence text, int beginIndex, int endIndex); + void appendNode(Node node); // In some cases, we don't want the text to be appended to an existing node, we need it separate - @NotNull Text appendSeparateText(@NotNull BasedSequence text); - void setBlock(@NotNull Node block); - void moveNodes(@NotNull Node fromNode, @NotNull Node toNode); + Text appendSeparateText(BasedSequence text); + void setBlock(Node block); + void moveNodes(Node fromNode, Node toNode); boolean spnl(); boolean nonIndentSp(); boolean sp(); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/LightInlineParserImpl.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/LightInlineParserImpl.java index 9e939b9ec..c3df2afdb 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/LightInlineParserImpl.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/LightInlineParserImpl.java @@ -8,8 +8,7 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SegmentedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.ArrayList; import java.util.regex.MatchResult; @@ -31,7 +30,6 @@ public LightInlineParserImpl(DataHolder dataOptions) { this.myParsing = new Parsing(dataOptions); } - @NotNull @Override public ArrayList getCurrentText() { if (currentText == null) { @@ -41,7 +39,6 @@ public ArrayList getCurrentText() { return currentText; } - @NotNull @Override public BasedSequence getInput() { return input; @@ -62,42 +59,38 @@ public void setIndex(int index) { this.index = index; } - @NotNull @Override public Document getDocument() { return document; } @Override - public void setDocument(@NotNull Document document) { + public void setDocument(Document document) { this.document = document; } - @NotNull @Override public InlineParserOptions getOptions() { return options; } - @NotNull @Override public Parsing getParsing() { return myParsing; } - @NotNull @Override public Node getBlock() { return block; } @Override - public void setBlock(@NotNull Node block) { + public void setBlock(Node block) { this.block = block; } @Override - public void moveNodes(@NotNull Node fromNode, @NotNull Node toNode) { + public void moveNodes(Node fromNode, Node toNode) { if (fromNode != toNode) { Node next = fromNode.getNext(); while (next != null) { @@ -113,25 +106,24 @@ public void moveNodes(@NotNull Node fromNode, @NotNull Node toNode) { } @Override - public void appendText(@NotNull BasedSequence text) { + public void appendText(BasedSequence text) { getCurrentText().add(text); } @Override - public void appendText(@NotNull BasedSequence text, int beginIndex, int endIndex) { + public void appendText(BasedSequence text, int beginIndex, int endIndex) { getCurrentText().add(text.subSequence(beginIndex, endIndex)); } @Override - public void appendNode(@NotNull Node node) { + public void appendNode(Node node) { flushTextNode(); block.appendChild(node); } // In some cases, we don't want the text to be appended to an existing node, we need it separate - @NotNull @Override - public Text appendSeparateText(@NotNull BasedSequence text) { + public Text appendSeparateText(BasedSequence text) { Text node = new Text(text); appendNode(node); return node; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/LinkRefProcessor.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/LinkRefProcessor.java index 5dbc9ac8c..95efbe5b1 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/LinkRefProcessor.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/LinkRefProcessor.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; /** * Processing of elements which are based on a link ref: [] or ![] @@ -36,7 +35,7 @@ public interface LinkRefProcessor { * @param nodeChars text to match, including [] or ![] * @return true if it is a match */ - boolean isMatch(@NotNull BasedSequence nodeChars); + boolean isMatch(BasedSequence nodeChars); /** * Create the desired element that was previously matched with isMatch @@ -44,7 +43,7 @@ public interface LinkRefProcessor { * @param nodeChars char sequence from which to create the node * @return Node element to be inserted into the tree */ - @NotNull Node createNode(@NotNull BasedSequence nodeChars); + Node createNode(BasedSequence nodeChars); /** * Adjust child nodes' text as needed when some of the link ref text was used in the opening or closing sequence of the node @@ -54,7 +53,7 @@ public interface LinkRefProcessor { * @param node node whose inline text is to be adjusted to reflect some of the text having been used as part of the opener and/or closer sequence. * @return adjusted sequence to use for this node's child text */ - @NotNull BasedSequence adjustInlineText(@NotNull Document document, @NotNull Node node); + BasedSequence adjustInlineText(Document document, Node node); /** * Allows the delimiter processor to allow/disallow other delimiters in its inline text @@ -63,7 +62,7 @@ public interface LinkRefProcessor { * @param document document, can be used to get options * @param node delimited node created by this processor @return true if delimiters are allowed in this part of the node's text */ - boolean allowDelimiters(@NotNull BasedSequence chars, @NotNull Document document, @NotNull Node node); + boolean allowDelimiters(BasedSequence chars, Document document, Node node); /** * Allows the processor to adjust nodes' elements after all delimiters have been processed inside the inlined text @@ -71,5 +70,5 @@ public interface LinkRefProcessor { * @param document document, can be used to get parsing options * @param node node whose elements can be adjusted */ - void updateNodeElements(@NotNull Document document, @NotNull Node node); + void updateNodeElements(Document document, Node node); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/LinkRefProcessorFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/LinkRefProcessorFactory.java index 98d4b824a..ac2253321 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/LinkRefProcessorFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/LinkRefProcessorFactory.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.function.Function; @@ -17,7 +16,7 @@ public interface LinkRefProcessorFactory extends Function0} for nesting */ - int getBracketNestingLevel(@NotNull DataHolder options); + int getBracketNestingLevel(DataHolder options); /** * Create a link ref processor for the document @@ -38,5 +37,5 @@ public interface LinkRefProcessorFactory extends Function inlineParserExtensionFactories; final private InlineParserFactory inlineParserFactory; - final private @NotNull DataHolder options; + final private DataHolder options; Parser(Builder builder) { DataSet options = builder.toImmutable(); @@ -353,7 +352,7 @@ public static Builder builder(DataHolder options) { * @param input the text to parse * @return the root node */ - public @NotNull Document parse(@NotNull BasedSequence input) { + public Document parse(BasedSequence input) { // NOTE: parser can only handle contiguous sequences with no out of base characters if (input instanceof ReplacedBasedSequence) { throw new IllegalArgumentException("" + @@ -379,7 +378,7 @@ public static Builder builder(DataHolder options) { * @param input the text to parse * @return the root node */ - public @NotNull Document parse(@NotNull String input) { + public Document parse(String input) { DocumentParser documentParser = new DocumentParser(options , blockParserFactories , paragraphPreProcessorFactories @@ -398,7 +397,7 @@ public static Builder builder(DataHolder options) { * @return the root node * @throws IOException when reading throws an exception */ - public @NotNull Document parseReader(@NotNull Reader input) throws IOException { + public Document parseReader(Reader input) throws IOException { DocumentParser documentParser = new DocumentParser(options , blockParserFactories , paragraphPreProcessorFactories @@ -414,12 +413,12 @@ private Document postProcess(Document document) { } @Override - public @NotNull DataHolder getOptions() { + public DataHolder getOptions() { return options; } @Override - public boolean transferReferences(@NotNull Document document, @NotNull Document included, Boolean onlyIfUndefined) { + public boolean transferReferences(Document document, Document included, Boolean onlyIfUndefined) { // transfer references from included to document boolean transferred = false; @@ -477,13 +476,12 @@ public Builder() { /** * @return the configured {@link Parser} */ - @NotNull public Parser build() { return new Parser(this); } @Override - protected void removeApiPoint(@NotNull Object apiPoint) { + protected void removeApiPoint(Object apiPoint) { if (apiPoint instanceof CustomBlockParserFactory) { this.blockParserFactories.remove(apiPoint); } else if (apiPoint instanceof DelimiterProcessor) { @@ -508,7 +506,7 @@ protected void removeApiPoint(@NotNull Object apiPoint) { } @Override - protected void preloadExtension(@NotNull Extension extension) { + protected void preloadExtension(Extension extension) { if (extension instanceof ParserExtension) { ParserExtension parserExtension = (ParserExtension) extension; parserExtension.parserOptions(this); @@ -516,7 +514,7 @@ protected void preloadExtension(@NotNull Extension extension) { } @Override - protected boolean loadExtension(@NotNull Extension extension) { + protected boolean loadExtension(Extension extension) { if (extension instanceof ParserExtension) { ParserExtension parserExtension = (ParserExtension) extension; parserExtension.extend(this); diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/ParserEmulationProfile.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/ParserEmulationProfile.java index 502762045..c13399ed1 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/ParserEmulationProfile.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/ParserEmulationProfile.java @@ -3,7 +3,6 @@ import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.util.ast.KeepType; import com.vladsch.flexmark.util.data.*; -import org.jetbrains.annotations.NotNull; public enum ParserEmulationProfile implements MutableDataSetter { COMMONMARK(null), @@ -305,9 +304,8 @@ else if (this == COMMONMARK_0_28) { return new MutableListOptions((DataHolder) null); } - @NotNull @Override - public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { + public MutableDataHolder setIn(MutableDataHolder dataHolder) { if (this == FIXED_INDENT) { getOptions(dataHolder).setIn(dataHolder) .set(Parser.STRONG_WRAPS_EMPHASIS, true) diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/PostProcessor.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/PostProcessor.java index 04f7c1d5d..7d27c6fa2 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/PostProcessor.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/PostProcessor.java @@ -3,18 +3,17 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NodeTracker; -import org.jetbrains.annotations.NotNull; public interface PostProcessor { /** * @param document the node to post-process * @return the result of post-processing, may be a modified {@code document} argument */ - @NotNull Document processDocument(@NotNull Document document); + Document processDocument(Document document); /** * @param state node tracker used for optimizing node processing * @param node the node to post-process */ - void process(@NotNull NodeTracker state, @NotNull Node node); + void process(NodeTracker state, Node node); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/PostProcessorFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/PostProcessorFactory.java index 6782502fa..609ec28f7 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/PostProcessorFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/PostProcessorFactory.java @@ -2,8 +2,7 @@ import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.dependency.Dependent; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Map; import java.util.Set; @@ -23,5 +22,5 @@ public interface PostProcessorFactory extends Function, * @return post processor for the document */ @Override - @NotNull PostProcessor apply(@NotNull Document document); + PostProcessor apply(Document document); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/BlockPreProcessorFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/BlockPreProcessorFactory.java index f4212cac8..e856d3f34 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/BlockPreProcessorFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/BlockPreProcessorFactory.java @@ -2,7 +2,6 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.dependency.Dependent; -import org.jetbrains.annotations.NotNull; import java.util.Set; import java.util.function.Function; @@ -13,7 +12,6 @@ public interface BlockPreProcessorFactory extends Function> getBlockTypes(); /** @@ -22,6 +20,5 @@ public interface BlockPreProcessorFactory extends Function, Dependent { @Override - @NotNull BlockParserFactory apply(@NotNull DataHolder options); + BlockParserFactory apply(DataHolder options); /** * @param options options for this parser session * @return special lead in character handler for the block parser elements */ - default @Nullable SpecialLeadInHandler getLeadInHandler(@NotNull DataHolder options) { + default @Nullable SpecialLeadInHandler getLeadInHandler(DataHolder options) { return null; } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/DocumentPostProcessor.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/DocumentPostProcessor.java index abdbcb9fe..1db920044 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/DocumentPostProcessor.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/DocumentPostProcessor.java @@ -3,14 +3,13 @@ import com.vladsch.flexmark.parser.PostProcessor; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NodeTracker; -import org.jetbrains.annotations.NotNull; public abstract class DocumentPostProcessor implements PostProcessor { /** * @param state node tracker used for optimizing node processing * @param node the node to post-process */ - final public void process(@NotNull NodeTracker state, @NotNull Node node) { + final public void process(NodeTracker state, Node node) { } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/DocumentPostProcessorFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/DocumentPostProcessorFactory.java index 1a32d9139..cc1703018 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/DocumentPostProcessorFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/DocumentPostProcessorFactory.java @@ -1,7 +1,7 @@ package com.vladsch.flexmark.parser.block; import com.vladsch.flexmark.parser.PostProcessorFactory; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Map; import java.util.Set; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/NodePostProcessor.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/NodePostProcessor.java index 47d71b87f..8e979bf66 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/NodePostProcessor.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/NodePostProcessor.java @@ -2,16 +2,14 @@ import com.vladsch.flexmark.parser.PostProcessor; import com.vladsch.flexmark.util.ast.Document; -import org.jetbrains.annotations.NotNull; public abstract class NodePostProcessor implements PostProcessor { /** * @param document the node to post-process * @return the result of post-processing, may be a modified {@code document} argument */ - @NotNull @Override - final public Document processDocument(@NotNull Document document) { + final public Document processDocument(Document document) { return document; } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/NodePostProcessorFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/NodePostProcessorFactory.java index 70cb66753..765476463 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/NodePostProcessorFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/NodePostProcessorFactory.java @@ -3,8 +3,7 @@ import com.vladsch.flexmark.parser.PostProcessorFactory; import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.ast.Node; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -52,7 +51,6 @@ final public Map, Set>> getNodeTypes() { return NODE_MAP; } - @NotNull @Override - abstract public NodePostProcessor apply(@NotNull Document document); + abstract public NodePostProcessor apply(Document document); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/package-info.java index 7bb36a1a2..3e570ed5c 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/block/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/block/package-info.java @@ -1,4 +1,7 @@ /** * Types for extending block parsing */ +@NullMarked package com.vladsch.flexmark.parser.block; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/BlockQuoteParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/BlockQuoteParser.java index 033d9dc8f..d73df901a 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/BlockQuoteParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/BlockQuoteParser.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInHandler; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInStartsWithCharsHandler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.Collections; @@ -140,7 +139,7 @@ public Set> getBeforeDependents() { } @Override - public @Nullable SpecialLeadInHandler getLeadInHandler(@NotNull DataHolder options) { + public @Nullable SpecialLeadInHandler getLeadInHandler(DataHolder options) { return BlockQuoteLeadInHandler.HANDLER; } @@ -149,9 +148,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/FencedCodeBlockParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/FencedCodeBlockParser.java index eb1640fe5..23eb8ae25 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/FencedCodeBlockParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/FencedCodeBlockParser.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.SegmentedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -169,9 +168,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/HeadingParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/HeadingParser.java index 4b61c4327..c39a81397 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/HeadingParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/HeadingParser.java @@ -13,8 +13,7 @@ import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInCharsHandler; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInHandler; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInStartsWithCharsHandler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -105,14 +104,13 @@ public boolean affectsGlobalScope() { } @Override - public @Nullable SpecialLeadInHandler getLeadInHandler(@NotNull DataHolder options) { + public @Nullable SpecialLeadInHandler getLeadInHandler(DataHolder options) { boolean noAtxSpace = Parser.ESCAPE_HEADING_NO_ATX_SPACE.get(options) || Parser.HEADING_NO_ATX_SPACE.get(options); return noAtxSpace ? HeadingLeadInHandler.HANDLER_NO_SPACE : HeadingLeadInHandler.HANDLER_SPACE; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/HtmlBlockParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/HtmlBlockParser.java index 4cedbfbcd..fa1cd1e84 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/HtmlBlockParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/HtmlBlockParser.java @@ -9,8 +9,7 @@ import com.vladsch.flexmark.util.ast.BlockContent; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -272,9 +271,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/IndentedCodeBlockParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/IndentedCodeBlockParser.java index e3dc8a068..b305987e1 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/IndentedCodeBlockParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/IndentedCodeBlockParser.java @@ -10,8 +10,7 @@ import com.vladsch.flexmark.util.collection.iteration.Reverse; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; @@ -107,9 +106,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ListBlockParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ListBlockParser.java index 32dc553e0..4accfc14d 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ListBlockParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ListBlockParser.java @@ -19,8 +19,7 @@ import com.vladsch.flexmark.util.sequence.SequenceUtils; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInCharsHandler; import com.vladsch.flexmark.util.sequence.mappers.SpecialLeadInHandler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -430,14 +429,13 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } @Override - public @Nullable SpecialLeadInHandler getLeadInHandler(@NotNull DataHolder options) { + public @Nullable SpecialLeadInHandler getLeadInHandler(DataHolder options) { return ListItemLeadInHandler.create(Parser.LISTS_ITEM_PREFIX_CHARS.get(options), Parser.LISTS_ORDERED_ITEM_DOT_ONLY.get(options)); } } @@ -448,8 +446,7 @@ static class ListItemLeadInHandler extends SpecialLeadInCharsHandler { final static SpecialLeadInHandler ORDERED_DELIM_DOT_HANDLER = new ListItemLeadInHandler(Parser.LISTS_ITEM_PREFIX_CHARS.getDefaultValue(), true); final static SpecialLeadInHandler ORDERED_DELIM_DOT_PARENS_HANDLER = new ListItemLeadInHandler(Parser.LISTS_ITEM_PREFIX_CHARS.getDefaultValue(), false); - @NotNull - static SpecialLeadInHandler create(@NotNull CharSequence listItemDelims, boolean dotOnly) { + static SpecialLeadInHandler create(CharSequence listItemDelims, boolean dotOnly) { return SequenceUtils.equals(Parser.LISTS_ITEM_PREFIX_CHARS.getDefaultValue(), listItemDelims) ? dotOnly ? ORDERED_DELIM_DOT_HANDLER : ORDERED_DELIM_DOT_PARENS_HANDLER : new ListItemLeadInHandler(listItemDelims, dotOnly); @@ -463,7 +460,7 @@ public ListItemLeadInHandler(CharSequence listItemDelims, boolean dotOnly) { } @Override - public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer) { + public boolean escape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer) { if (super.escape(sequence, options, consumer)) return true; if (ESCAPE_NUMBERED_LEAD_IN.get(options)) { int nonDigit = sequence.indexOfAnyNot(CharPredicate.DECIMAL_DIGITS); @@ -478,7 +475,7 @@ public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder opti } @Override - public boolean unEscape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer consumer) { + public boolean unEscape(BasedSequence sequence, @Nullable DataHolder options, Consumer consumer) { if (super.unEscape(sequence, options, consumer)) return true; int nonDigit = sequence.indexOfAnyNot(CharPredicate.DECIMAL_DIGITS); if (nonDigit > 0 && nonDigit + 2 == sequence.length() && sequence.charAt(nonDigit) == '\\' && orderedDelims.test(sequence.charAt(nonDigit + 1))) { diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ReferencePreProcessorFactory.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ReferencePreProcessorFactory.java index a1eeb703b..44ee199a0 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ReferencePreProcessorFactory.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ReferencePreProcessorFactory.java @@ -4,7 +4,7 @@ import com.vladsch.flexmark.parser.block.ParagraphPreProcessorFactory; import com.vladsch.flexmark.parser.block.ParserState; import com.vladsch.flexmark.parser.internal.InlineParserImpl; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Set; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ThematicBreakParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ThematicBreakParser.java index 88075bf75..e20923bdf 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ThematicBreakParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/ThematicBreakParser.java @@ -6,8 +6,7 @@ import com.vladsch.flexmark.util.ast.Block; import com.vladsch.flexmark.util.data.DataHolder; import com.vladsch.flexmark.util.sequence.BasedSequence; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.Arrays; import java.util.HashSet; @@ -74,9 +73,8 @@ public boolean affectsGlobalScope() { return false; } - @NotNull @Override - public BlockParserFactory apply(@NotNull DataHolder options) { + public BlockParserFactory apply(DataHolder options) { return new BlockFactory(options); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/delimiter/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/delimiter/package-info.java index fa57a4b81..420ee260f 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/delimiter/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/delimiter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.parser.core.delimiter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/package-info.java index 19efc4817..42bde8bb1 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/core/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/core/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.parser.core; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/delimiter/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/delimiter/package-info.java index f88161e07..a0a4a2921 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/delimiter/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/delimiter/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.parser.delimiter; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/CommonmarkInlineParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/CommonmarkInlineParser.java index d149a3eaf..05ae8f2f0 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/CommonmarkInlineParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/CommonmarkInlineParser.java @@ -4,7 +4,6 @@ import com.vladsch.flexmark.parser.delimiter.DelimiterProcessor; import com.vladsch.flexmark.util.ast.Document; import com.vladsch.flexmark.util.data.DataHolder; -import org.jetbrains.annotations.NotNull; import java.util.BitSet; import java.util.List; @@ -19,7 +18,7 @@ public CommonmarkInlineParser( } @Override - public void initializeDocument(@NotNull Document document) { + public void initializeDocument(Document document) { super.initializeDocument(document); } } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/DocumentParser.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/DocumentParser.java index c4a539ecf..474db3266 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/DocumentParser.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/DocumentParser.java @@ -18,7 +18,6 @@ import com.vladsch.flexmark.util.misc.CharPredicate; import com.vladsch.flexmark.util.sequence.BasedSequence; import com.vladsch.flexmark.util.sequence.PrefixedSubSequence; -import org.jetbrains.annotations.NotNull; import java.io.BufferedReader; import java.io.IOException; @@ -132,27 +131,27 @@ public void blockParserRemoved(BlockParser blockParser) { blockTracker.blockParserRemoved(blockParser); } - public void blockAdded(@NotNull Block node) { + public void blockAdded(Block node) { blockTracker.blockAdded(node); } - public void blockAddedWithChildren(@NotNull Block node) { + public void blockAddedWithChildren(Block node) { blockTracker.blockAddedWithChildren(node); } - public void blockAddedWithDescendants(@NotNull Block node) { + public void blockAddedWithDescendants(Block node) { blockTracker.blockAddedWithDescendants(node); } - public void blockRemoved(@NotNull Block node) { + public void blockRemoved(Block node) { blockTracker.blockRemoved(node); } - public void blockRemovedWithChildren(@NotNull Block node) { + public void blockRemovedWithChildren(Block node) { blockTracker.blockRemovedWithChildren(node); } - public void blockRemovedWithDescendants(@NotNull Block node) { + public void blockRemovedWithDescendants(Block node) { blockTracker.blockRemovedWithDescendants(node); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/InlineParserImpl.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/InlineParserImpl.java index 888a98c93..fb87afda7 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/InlineParserImpl.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/InlineParserImpl.java @@ -20,8 +20,7 @@ import com.vladsch.flexmark.util.sequence.Escaping; import com.vladsch.flexmark.util.sequence.SegmentedSequence; import com.vladsch.flexmark.util.sequence.SequenceUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; import java.util.*; import java.util.function.Function; @@ -81,7 +80,7 @@ public InlineParserImpl( } @Override - public void initializeDocument(@NotNull Document document) { + public void initializeDocument(Document document) { this.document = document; this.referenceRepository = Parser.REFERENCES.get(document); @@ -115,7 +114,7 @@ public void initializeDocument(@NotNull Document document) { } @Override - public void finalizeDocument(@NotNull Document document) { + public void finalizeDocument(Document document) { assert this.referenceRepository == Parser.REFERENCES.get(document); if (inlineParserExtensions != null) { @@ -139,7 +138,7 @@ public Bracket getLastBracket() { @Nullable @Override - public List parseCustom(@NotNull BasedSequence input, @NotNull Node node, @NotNull BitSet customCharacters, @NotNull Map nodeFactoryMap) { + public List parseCustom(BasedSequence input, Node node, BitSet customCharacters, Map nodeFactoryMap) { this.customCharacters = customCharacters; this.specialCharacters.or(customCharacters); this.customSpecialCharacterFactoryMap = nodeFactoryMap; @@ -155,7 +154,7 @@ public List parseCustom(@NotNull BasedSequence input, @NotNull Node node, * Parse content in block into inline children, using reference map to resolve references. */ @Override - public void parse(@NotNull BasedSequence content, @NotNull Node block) { + public void parse(BasedSequence content, Node block) { this.block = block; this.input = content.trim(); this.index = 0; @@ -1519,7 +1518,7 @@ public void processDelimiters(Delimiter stackBottom) { } @Override - public void removeDelimitersBetween(@NotNull Delimiter opener, @NotNull Delimiter closer) { + public void removeDelimitersBetween(Delimiter opener, Delimiter closer) { Delimiter delimiter = closer.getPrevious(); while (delimiter != null && delimiter != opener) { Delimiter previousDelimiter = delimiter.getPrevious(); @@ -1534,7 +1533,7 @@ public void removeDelimitersBetween(@NotNull Delimiter opener, @NotNull Delimite * @param delim delimiter to remove */ @Override - public void removeDelimiterAndNode(@NotNull Delimiter delim) { + public void removeDelimiterAndNode(Delimiter delim) { Text node = delim.getNode(); Text previousText = delim.getPreviousNonDelimiterTextNode(); Text nextText = delim.getNextNonDelimiterTextNode(); @@ -1554,7 +1553,7 @@ public void removeDelimiterAndNode(@NotNull Delimiter delim) { * @param delim delimiter being processed */ @Override - public void removeDelimiterKeepNode(@NotNull Delimiter delim) { + public void removeDelimiterKeepNode(Delimiter delim) { Node node; DelimiterProcessor delimiterProcessor = delimiterProcessors.get(delim.getDelimiterChar()); node = delimiterProcessor != null ? delimiterProcessor.unmatchedDelimiterNode(this, delim) : null; @@ -1589,7 +1588,7 @@ public void removeDelimiterKeepNode(@NotNull Delimiter delim) { } @Override - public void removeDelimiter(@NotNull Delimiter delim) { + public void removeDelimiter(Delimiter delim) { if (delim.getPrevious() != null) { delim.getPrevious().setNext(delim.getNext()); } diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/package-info.java index d924695e6..fa675d979 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/internal/package-info.java @@ -1 +1,4 @@ +@NullMarked package com.vladsch.flexmark.parser.internal; + +import org.jspecify.annotations.NullMarked; diff --git a/flexmark/src/main/java/com/vladsch/flexmark/parser/package-info.java b/flexmark/src/main/java/com/vladsch/flexmark/parser/package-info.java index 05957c131..deaa5709d 100644 --- a/flexmark/src/main/java/com/vladsch/flexmark/parser/package-info.java +++ b/flexmark/src/main/java/com/vladsch/flexmark/parser/package-info.java @@ -1,4 +1,7 @@ /** * Parse input text to AST nodes see {@link com.vladsch.flexmark.parser.Parser} */ +@NullMarked package com.vladsch.flexmark.parser; + +import org.jspecify.annotations.NullMarked;