proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocExtension.java
SimTocExtension
extend
class SimTocExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension, Formatter.FormatterExtension { // duplicated here for convenience final public static AttributablePart TOC_CONTENT = TocUtils.TOC_CONTENT; // div element wrapping TOC list final public static AttributablePart TOC_LIST = TocUtils.TOC_LIST; // ul/ol element of TOC list final public static DataKey<Integer> LEVELS = TocExtension.LEVELS; final public static DataKey<Boolean> IS_TEXT_ONLY = TocExtension.IS_TEXT_ONLY; final public static DataKey<Boolean> IS_NUMBERED = TocExtension.IS_NUMBERED; final public static DataKey<TocOptions.ListType> LIST_TYPE = TocExtension.LIST_TYPE; final public static DataKey<Boolean> IS_HTML = TocExtension.IS_HTML; final public static DataKey<Integer> TITLE_LEVEL = TocExtension.TITLE_LEVEL; final public static NullableDataKey<String> TITLE = TocExtension.TITLE; final public static DataKey<Boolean> AST_INCLUDE_OPTIONS = TocExtension.AST_INCLUDE_OPTIONS; final public static DataKey<Boolean> BLANK_LINE_SPACER = TocExtension.BLANK_LINE_SPACER; final public static DataKey<String> DIV_CLASS = TocExtension.DIV_CLASS; final public static DataKey<String> LIST_CLASS = TocExtension.LIST_CLASS; final public static DataKey<Boolean> CASE_SENSITIVE_TOC_TAG = TocExtension.CASE_SENSITIVE_TOC_TAG; // format options final public static DataKey<SimTocGenerateOnFormat> FORMAT_UPDATE_ON_FORMAT = TocExtension.FORMAT_UPDATE_ON_FORMAT; final public static DataKey<TocOptions> FORMAT_OPTIONS = TocExtension.FORMAT_OPTIONS; private SimTocExtension() { } public static SimTocExtension create() { return new SimTocExtension(); } @Override public void rendererOptions(@NotNull MutableDataHolder options) { // set header id options if not already set if (!options.contains(HtmlRenderer.GENERATE_HEADER_ID)) { options.set(HtmlRenderer.GENERATE_HEADER_ID, true); } if (!options.contains(Formatter.GENERATE_HEADER_ID)) { options.set(Formatter.GENERATE_HEADER_ID, true); } if (!options.contains(HtmlRenderer.RENDER_HEADER_ID)) { options.set(HtmlRenderer.RENDER_HEADER_ID, true); } } @Override public void parserOptions(MutableDataHolder options) { } @Override public void extend(Formatter.Builder formatterBuilder) { formatterBuilder.nodeFormatterFactory(new SimTocNodeFormatter.Factory()); } @Override public void extend(Parser.Builder parserBuilder) { parserBuilder.customBlockParserFactory(new SimTocBlockParser.Factory()); } @Override public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) {<FILL_FUNCTION_BODY>} }
if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new SimTocNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { }
866
59
925
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/SimTocVisitorExt.java
SimTocVisitorExt
VISIT_HANDLERS
class SimTocVisitorExt { public static <V extends SimTocVisitor> VisitHandler<?>[] VISIT_HANDLERS(V visitor) {<FILL_FUNCTION_BODY>} }
return new VisitHandler<?>[] { new VisitHandler<>(SimTocBlock.class, visitor::visit), new VisitHandler<>(SimTocOptionList.class, visitor::visit), new VisitHandler<>(SimTocOption.class, visitor::visit), new VisitHandler<>(SimTocContent.class, visitor::visit) };
55
94
149
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlock.java
TocBlock
getAstExtra
class TocBlock extends TocBlockBase { protected BasedSequence openingMarker = BasedSequence.NULL; protected BasedSequence tocKeyword = BasedSequence.NULL; protected BasedSequence style = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; @Override public void getAstExtra(@NotNull StringBuilder out) {<FILL_FUNCTION_BODY>} @NotNull @Override public BasedSequence[] getSegments() { BasedSequence[] nodeSegments = new BasedSequence[] { openingMarker, tocKeyword, style, closingMarker }; if (lineSegments.size() == 0) return nodeSegments; BasedSequence[] allSegments = new BasedSequence[lineSegments.size() + nodeSegments.length]; lineSegments.toArray(allSegments); System.arraycopy(allSegments, 0, allSegments, nodeSegments.length, lineSegments.size()); return allSegments; } public TocBlock(BasedSequence chars) { this(chars, false); } public TocBlock(BasedSequence chars, boolean closingSimToc) { this(chars, null, closingSimToc); } public TocBlock(BasedSequence chars, BasedSequence styleChars) { this(chars, styleChars, false); } public TocBlock(BasedSequence chars, BasedSequence styleChars, boolean closingSimToc) { super(chars); openingMarker = chars.subSequence(0, 1); tocKeyword = chars.subSequence(1, 4); if (styleChars != null) { style = styleChars; } int closingPos = chars.indexOf(']', 4); if (closingSimToc && !(closingPos != -1 && closingPos + 1 < chars.length() && chars.charAt(closingPos + 1) == ':')) { throw new IllegalStateException("Invalid TOC block sequence"); } closingMarker = chars.subSequence(closingPos, closingPos + (closingSimToc ? 2 : 1)); } public BasedSequence getOpeningMarker() { return openingMarker; } public BasedSequence getTocKeyword() { return tocKeyword; } public BasedSequence getStyle() { return style; } public BasedSequence getClosingMarker() { return closingMarker; } }
segmentSpan(out, openingMarker, "openingMarker"); segmentSpan(out, tocKeyword, "tocKeyword"); segmentSpan(out, style, "style"); segmentSpan(out, closingMarker, "closingMarker");
628
62
690
<methods>public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence, boolean) ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence) ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, boolean) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.sequence.BasedSequence getClosingMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getOpeningMarker() ,public @NotNull BasedSequence [] getSegments() ,public com.vladsch.flexmark.util.sequence.BasedSequence getStyle() ,public com.vladsch.flexmark.util.sequence.BasedSequence getTocKeyword() <variables>protected com.vladsch.flexmark.util.sequence.BasedSequence closingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence openingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence style,protected com.vladsch.flexmark.util.sequence.BasedSequence tocKeyword
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocBlockBase.java
TocBlockBase
getSegments
class TocBlockBase extends Block { protected BasedSequence openingMarker = BasedSequence.NULL; protected BasedSequence tocKeyword = BasedSequence.NULL; protected BasedSequence style = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; @Override public void getAstExtra(@NotNull StringBuilder out) { segmentSpan(out, openingMarker, "openingMarker"); segmentSpan(out, tocKeyword, "tocKeyword"); segmentSpan(out, style, "style"); segmentSpan(out, closingMarker, "closingMarker"); } @NotNull @Override public BasedSequence[] getSegments() {<FILL_FUNCTION_BODY>} public TocBlockBase(BasedSequence chars) { this(chars, false); } public TocBlockBase(BasedSequence chars, boolean closingSimToc) { this(chars, null, closingSimToc); } public TocBlockBase(BasedSequence chars, BasedSequence styleChars) { this(chars, styleChars, false); } public TocBlockBase(BasedSequence chars, BasedSequence styleChars, boolean closingSimToc) { super(chars); openingMarker = chars.subSequence(0, 1); tocKeyword = chars.subSequence(1, 4); if (styleChars != null) { style = styleChars; } int closingPos = chars.indexOf(']', 4); if (closingSimToc && !(closingPos != -1 && closingPos + 1 < chars.length() && chars.charAt(closingPos + 1) == ':')) { throw new IllegalStateException("Invalid TOC block sequence"); } closingMarker = chars.subSequence(closingPos, closingPos + (closingSimToc ? 2 : 1)); } public BasedSequence getOpeningMarker() { return openingMarker; } public BasedSequence getTocKeyword() { return tocKeyword; } public BasedSequence getStyle() { return style; } public BasedSequence getClosingMarker() { return closingMarker; } }
BasedSequence[] nodeSegments = new BasedSequence[] { openingMarker, tocKeyword, style, closingMarker }; if (lineSegments.size() == 0) return nodeSegments; BasedSequence[] allSegments = new BasedSequence[lineSegments.size() + nodeSegments.length]; lineSegments.toArray(allSegments); System.arraycopy(allSegments, 0, allSegments, nodeSegments.length, lineSegments.size()); return allSegments;
568
124
692
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void <init>(@NotNull BasedSequence, @NotNull List<BasedSequence>) ,public void <init>(@NotNull List<BasedSequence>) ,public void <init>(com.vladsch.flexmark.util.ast.BlockContent) ,public @Nullable Block getParent() <variables>
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/TocExtension.java
TocExtension
rendererOptions
class TocExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension { // duplicated here for convenience final public static AttributablePart TOC_CONTENT = TocUtils.TOC_CONTENT; // div element wrapping TOC list final public static AttributablePart TOC_LIST = TocUtils.TOC_LIST; // ul/ol element of TOC list final public static DataKey<Integer> LEVELS = new DataKey<>("LEVELS", TocOptions.DEFAULT_LEVELS); final public static DataKey<Boolean> IS_TEXT_ONLY = new DataKey<>("IS_TEXT_ONLY", false); final public static DataKey<Boolean> IS_NUMBERED = new DataKey<>("IS_NUMBERED", false); final public static DataKey<TocOptions.ListType> LIST_TYPE = new DataKey<>("LIST_TYPE", TocOptions.ListType.HIERARCHY); final public static DataKey<Boolean> IS_HTML = new DataKey<>("IS_HTML", false); final public static DataKey<Integer> TITLE_LEVEL = new DataKey<>("TITLE_LEVEL", TocOptions.DEFAULT_TITLE_LEVEL); final public static NullableDataKey<String> TITLE = new NullableDataKey<>("TITLE"); final public static DataKey<Boolean> AST_INCLUDE_OPTIONS = new DataKey<>("AST_INCLUDE_OPTIONS", false); final public static DataKey<Boolean> BLANK_LINE_SPACER = new DataKey<>("BLANK_LINE_SPACER", false); final public static DataKey<String> DIV_CLASS = new DataKey<>("DIV_CLASS", ""); final public static DataKey<String> LIST_CLASS = new DataKey<>("LIST_CLASS", ""); final public static DataKey<Boolean> CASE_SENSITIVE_TOC_TAG = new DataKey<>("CASE_SENSITIVE_TOC_TAG", true); // format options final public static DataKey<SimTocGenerateOnFormat> FORMAT_UPDATE_ON_FORMAT = new DataKey<>("FORMAT_UPDATE_ON_FORMAT", SimTocGenerateOnFormat.UPDATE); final public static DataKey<TocOptions> FORMAT_OPTIONS = new DataKey<>("FORMAT_OPTIONS", new TocOptions(null, false), options -> new TocOptions(options, false)); private TocExtension() { } public static TocExtension create() { return new TocExtension(); } @Override public void rendererOptions(@NotNull MutableDataHolder options) {<FILL_FUNCTION_BODY>} @Override public void parserOptions(MutableDataHolder options) { } @Override public void extend(Parser.Builder parserBuilder) { parserBuilder.customBlockParserFactory(new TocBlockParser.Factory()); } @Override public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new TocNodeRenderer.Factory()); } } }
// set header id options if not already set if (!options.contains(HtmlRenderer.RENDER_HEADER_ID)) { options.set(HtmlRenderer.RENDER_HEADER_ID, true); options.set(HtmlRenderer.GENERATE_HEADER_ID, true); } else if (!options.contains(HtmlRenderer.GENERATE_HEADER_ID)) { options.set(HtmlRenderer.GENERATE_HEADER_ID, true); }
799
121
920
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocBlockParser.java
TocParsing
canContain
class TocParsing extends Parsing { final Pattern TOC_BLOCK_START; //private static Pattern TOC_BLOCK_CONTINUE = Pattern.compile("^.+$"); public TocParsing(DataHolder options) { super(options); if (CASE_SENSITIVE_TOC_TAG.get(options)) { this.TOC_BLOCK_START = Pattern.compile("^\\[TOC(?:\\s+([^\\]]+))?]:\\s*#(?:\\s+(" + super.LINK_TITLE_STRING + "))?\\s*$"); } else { this.TOC_BLOCK_START = Pattern.compile("^\\[(?i:TOC)(?:\\s+([^\\]]+))?]:\\s*#(?:\\s+(" + super.LINK_TITLE_STRING + "))?\\s*$"); } } } static int HAVE_HTML = 1; static int HAVE_HEADING = 2; static int HAVE_LIST = 4; static int HAVE_BLANK_LINE = 8; final private SimTocBlock block; final private TocOptions options; private int haveChildren = 0; private BasedSequence blankLineSpacer = BasedSequence.NULL; SimTocBlockParser(DataHolder options, BasedSequence tocChars, BasedSequence styleChars, BasedSequence titleChars) { this.options = new TocOptions(options, true); block = new SimTocBlock(tocChars, styleChars, titleChars); } @Override public Block getBlock() { return block; } @Override public BlockContinue tryContinue(ParserState state) { // we stop on a blank line if blank line spacer is not enabled or we already had one if ((!options.isBlankLineSpacer || haveChildren != 0) && state.isBlank()) { return BlockContinue.none(); } else { if (state.isBlank()) { haveChildren |= HAVE_BLANK_LINE; blankLineSpacer = state.getLine(); } return BlockContinue.atIndex(state.getIndex()); } } @Override public boolean canContain(ParserState state, BlockParser blockParser, Block block) {<FILL_FUNCTION_BODY>
if (block instanceof HtmlBlock) { if ((haveChildren & ~HAVE_BLANK_LINE) == 0) { haveChildren |= HAVE_HTML; return true; } } else if (block instanceof Heading) { if ((haveChildren & ~HAVE_BLANK_LINE) == 0) { haveChildren |= HAVE_HEADING; return true; } } else if (block instanceof ListBlock) { if ((haveChildren & (HAVE_HTML | HAVE_LIST)) == 0) { haveChildren |= HAVE_LIST; return true; } } return false;
611
165
776
<methods>public non-sealed void <init>() ,public void addLine(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.util.sequence.BasedSequence) ,public boolean breakOutOnDoubleBlankLine() ,public boolean canContain(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.parser.block.BlockParser, com.vladsch.flexmark.util.ast.Block) ,public boolean canInterruptBy(com.vladsch.flexmark.parser.block.BlockParserFactory) ,public final void finalizeClosedBlock() ,public com.vladsch.flexmark.util.ast.BlockContent getBlockContent() ,public com.vladsch.flexmark.util.data.MutableDataHolder getDataHolder() ,public boolean isClosed() ,public boolean isContainer() ,public boolean isInterruptible() ,public boolean isParagraphParser() ,public boolean isPropagatingLastBlankLine(com.vladsch.flexmark.parser.block.BlockParser) ,public boolean isRawText() ,public void parseInlines(com.vladsch.flexmark.parser.InlineParser) ,public void removeBlankLines() <variables>private boolean isClosed,private com.vladsch.flexmark.util.data.MutableDataSet mutableData
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeFormatter.java
SimTocNodeFormatter
renderTocHeaders
class SimTocNodeFormatter implements NodeFormatter { final private TocOptions options; final private TocFormatOptions formatOptions; private MarkdownTable myTable; public SimTocNodeFormatter(DataHolder options) { this.options = new TocOptions(options, true); this.formatOptions = new TocFormatOptions(options); } @Nullable @Override public Set<Class<?>> getNodeClasses() { return null; } @Nullable @Override public Set<NodeFormattingHandler<?>> getNodeFormattingHandlers() { return new HashSet<>(Arrays.asList( new NodeFormattingHandler<>(SimTocBlock.class, SimTocNodeFormatter.this::render), new NodeFormattingHandler<>(SimTocContent.class, SimTocNodeFormatter.this::render) )); } private void render(SimTocBlock node, NodeFormatterContext context, MarkdownWriter markdown) { switch (formatOptions.updateOnFormat) { case REMOVE: { String simTocPrefix = TocUtils.getSimTocPrefix(options, this.options); markdown.append(simTocPrefix); if (options.isBlankLineSpacer) markdown.blankLine(); break; } case UPDATE: { HeadingCollectingVisitor visitor = new HeadingCollectingVisitor(); List<Heading> headings = visitor.collectAndGetHeadings(context.getDocument()); if (headings != null) { SimTocOptionsParser optionsParser = new SimTocOptionsParser(); TocOptions options = optionsParser.parseOption(node.getStyle(), this.options, null).getFirst(); if (node.getTitle().isNotNull()) { options = options.withTitle(node.getTitle().unescape()); } String simTocPrefix = TocUtils.getSimTocPrefix(options, this.options); markdown.append(simTocPrefix); if (options.isBlankLineSpacer) markdown.blankLine(); renderTocHeaders(markdown, headings, options); } break; } case AS_IS: markdown.openPreFormatted(false).append(node.getChars()).closePreFormatted(); break; default: throw new IllegalStateException(formatOptions.updateOnFormat.toString() + " is not implemented"); } } private void renderTocHeaders(MarkdownWriter markdown, List<Heading> headings, TocOptions options) {<FILL_FUNCTION_BODY>} private void render(SimTocContent node, NodeFormatterContext context, MarkdownWriter markdown) { } public static class Factory implements NodeFormatterFactory { @NotNull @Override public NodeFormatter create(@NotNull DataHolder options) { return new SimTocNodeFormatter(options); } } }
List<Heading> filteredHeadings = TocUtils.filteredHeadings(headings, options); Paired<List<Heading>, List<String>> paired = TocUtils.markdownHeaderTexts(filteredHeadings, options); TocUtils.renderTocContent(markdown, options, this.options, paired.getFirst(), paired.getSecond());
753
92
845
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/SimTocNodeRenderer.java
SimTocNodeRenderer
getNodeRenderingHandlers
class SimTocNodeRenderer implements NodeRenderer { final private TocOptions options; public SimTocNodeRenderer(DataHolder options) { this.options = new TocOptions(options, true); } @Override public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {<FILL_FUNCTION_BODY>} private void render(SimTocContent node, NodeRendererContext context, HtmlWriter html) { // we don't render this or its children } private void render(SimTocOptionList node, NodeRendererContext context, HtmlWriter html) { // we don't render this or its children } private void render(SimTocOption node, NodeRendererContext context, HtmlWriter html) { // we don't render this or its children } private void render(SimTocBlock node, NodeRendererContext context, HtmlWriter html) { HeadingCollectingVisitor visitor = new HeadingCollectingVisitor(); List<Heading> headings = visitor.collectAndGetHeadings(context.getDocument()); if (headings != null) { SimTocOptionsParser optionsParser = new SimTocOptionsParser(); TocOptions options = optionsParser.parseOption(node.getStyle(), this.options, null).getFirst(); if (node.getTitle().isNotNull()) { options = options.withTitle(node.getTitle().unescape()); } renderTocHeaders(context, html, node, headings, options); } } private void renderTocHeaders(NodeRendererContext context, HtmlWriter html, Node node, List<Heading> headings, TocOptions options) { List<Heading> filteredHeadings = TocUtils.filteredHeadings(headings, options); Paired<List<Heading>, List<String>> paired = TocUtils.htmlHeadingTexts(context, filteredHeadings, options); List<Integer> headingLevels = paired.getFirst().stream().map(Heading::getLevel).collect(Collectors.toList()); List<String> headingRefIds = paired.getFirst().stream().map(Heading::getAnchorRefId).collect(Collectors.toList()); TocUtils.renderHtmlToc(html, context.getHtmlOptions().sourcePositionAttribute.isEmpty() ? BasedSequence.NULL : node.getChars(), headingLevels, paired.getSecond(), headingRefIds, options); } public static class Factory implements NodeRendererFactory { @NotNull @Override public NodeRenderer apply(@NotNull DataHolder options) { return new SimTocNodeRenderer(options); } } }
return new HashSet<>(Arrays.asList( new NodeRenderingHandler<>(SimTocBlock.class, this::render), new NodeRenderingHandler<>(SimTocContent.class, this::render), new NodeRenderingHandler<>(SimTocOptionList.class, this::render), new NodeRenderingHandler<>(SimTocOption.class, this::render) ));
660
102
762
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocBlockParser.java
BlockFactory
tryStart
class BlockFactory extends AbstractBlockParserFactory { final private TocParsing myParsing; BlockFactory(DataHolder options) { super(options); this.myParsing = new TocParsing(options); } @Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) {<FILL_FUNCTION_BODY>} }
if (state.getIndent() >= 4) { return BlockStart.none(); } BasedSequence line = state.getLine(); int nextNonSpace = state.getNextNonSpaceIndex(); BasedSequence trySequence = line.subSequence(nextNonSpace, line.length()); Matcher matcher = myParsing.TOC_BLOCK_START.matcher(line); if (matcher.matches()) { BasedSequence tocChars = state.getLineWithEOL(); BasedSequence styleChars = null; if (matcher.start(1) != -1) { int styleStart = matcher.start(1); int styleEnd = matcher.end(1); styleChars = trySequence.subSequence(styleStart, styleEnd); } TocBlockParser tocBlockParser = new TocBlockParser(state.getProperties(), tocChars, styleChars); return BlockStart.of(tocBlockParser) .atIndex(state.getIndex()) //.replaceActiveBlockParser() ; } return none();
103
276
379
<methods>public non-sealed void <init>() ,public void addLine(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.util.sequence.BasedSequence) ,public boolean breakOutOnDoubleBlankLine() ,public boolean canContain(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.parser.block.BlockParser, com.vladsch.flexmark.util.ast.Block) ,public boolean canInterruptBy(com.vladsch.flexmark.parser.block.BlockParserFactory) ,public final void finalizeClosedBlock() ,public com.vladsch.flexmark.util.ast.BlockContent getBlockContent() ,public com.vladsch.flexmark.util.data.MutableDataHolder getDataHolder() ,public boolean isClosed() ,public boolean isContainer() ,public boolean isInterruptible() ,public boolean isParagraphParser() ,public boolean isPropagatingLastBlankLine(com.vladsch.flexmark.parser.block.BlockParser) ,public boolean isRawText() ,public void parseInlines(com.vladsch.flexmark.parser.InlineParser) ,public void removeBlankLines() <variables>private boolean isClosed,private com.vladsch.flexmark.util.data.MutableDataSet mutableData
vsch_flexmark-java
flexmark-java/flexmark-ext-toc/src/main/java/com/vladsch/flexmark/ext/toc/internal/TocNodeRenderer.java
TocNodeRenderer
render
class TocNodeRenderer implements NodeRenderer { final private TocOptions options; final private boolean haveTitle; public TocNodeRenderer(DataHolder options) { this.haveTitle = options != null && options.contains(TocExtension.TITLE); this.options = new TocOptions(options, false); } @Override public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() { HashSet<NodeRenderingHandler<?>> set = new HashSet<>(); set.add(new NodeRenderingHandler<>(TocBlock.class, this::render)); return set; } private void render(TocBlock node, NodeRendererContext context, HtmlWriter html) {<FILL_FUNCTION_BODY>} private void renderTocHeaders(NodeRendererContext context, HtmlWriter html, Node node, List<Heading> headings, TocOptions options) { List<Heading> filteredHeadings = TocUtils.filteredHeadings(headings, options); final Paired<List<Heading>, List<String>> paired = TocUtils.htmlHeadingTexts(context, filteredHeadings, options); List<Integer> headingLevels = paired.getFirst().stream().map(Heading::getLevel).collect(Collectors.toList()); List<String> headingRefIds = paired.getFirst().stream().map(Heading::getAnchorRefId).collect(Collectors.toList()); TocUtils.renderHtmlToc(html, context.getHtmlOptions().sourcePositionAttribute.isEmpty() ? BasedSequence.NULL : node.getChars(), headingLevels, paired.getSecond(), headingRefIds, options); } public static class Factory implements NodeRendererFactory { @NotNull @Override public NodeRenderer apply(@NotNull DataHolder options) { return new TocNodeRenderer(options); } } }
HeadingCollectingVisitor visitor = new HeadingCollectingVisitor(); List<Heading> headings = visitor.collectAndGetHeadings(context.getDocument()); if (headings != null) { TocOptionsParser optionsParser = new TocOptionsParser(); TocOptions titleOptions = haveTitle ? this.options : this.options.withTitle(""); TocOptions options = optionsParser.parseOption(node.getStyle(), titleOptions, null).getFirst(); renderTocHeaders(context, html, node, headings, options); }
467
140
607
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicExtension.java
TypographicExtension
extend
class TypographicExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension { final public static DataKey<Boolean> ENABLE_QUOTES = new DataKey<>("ENABLE_QUOTES", true); final public static DataKey<Boolean> ENABLE_SMARTS = new DataKey<>("ENABLE_SMARTS", true); final public static DataKey<String> ANGLE_QUOTE_CLOSE = new DataKey<>("ANGLE_QUOTE_CLOSE", "&raquo;"); final public static DataKey<String> ANGLE_QUOTE_OPEN = new DataKey<>("ANGLE_QUOTE_OPEN", "&laquo;"); final public static NullableDataKey<String> ANGLE_QUOTE_UNMATCHED = new NullableDataKey<>("ANGLE_QUOTE_UNMATCHED"); final public static DataKey<String> DOUBLE_QUOTE_CLOSE = new DataKey<>("DOUBLE_QUOTE_CLOSE", "&rdquo;"); final public static DataKey<String> DOUBLE_QUOTE_OPEN = new DataKey<>("DOUBLE_QUOTE_OPEN", "&ldquo;"); final public static NullableDataKey<String> DOUBLE_QUOTE_UNMATCHED = new NullableDataKey<>("DOUBLE_QUOTE_UNMATCHED"); final public static DataKey<String> ELLIPSIS = new DataKey<>("ELLIPSIS", "&hellip;"); final public static DataKey<String> ELLIPSIS_SPACED = new DataKey<>("ELLIPSIS_SPACED", "&hellip;"); final public static DataKey<String> EM_DASH = new DataKey<>("EM_DASH", "&mdash;"); final public static DataKey<String> EN_DASH = new DataKey<>("EN_DASH", "&ndash;"); final public static DataKey<String> SINGLE_QUOTE_CLOSE = new DataKey<>("SINGLE_QUOTE_CLOSE", "&rsquo;"); final public static DataKey<String> SINGLE_QUOTE_OPEN = new DataKey<>("SINGLE_QUOTE_OPEN", "&lsquo;"); final public static DataKey<String> SINGLE_QUOTE_UNMATCHED = new DataKey<>("SINGLE_QUOTE_UNMATCHED", "&rsquo;"); private TypographicExtension() { } public static TypographicExtension create() { return new TypographicExtension(); } @Override public void rendererOptions(@NotNull MutableDataHolder options) { } @Override public void parserOptions(MutableDataHolder options) { } @Override public void extend(Parser.Builder parserBuilder) {<FILL_FUNCTION_BODY>} @Override public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) { if (htmlRendererBuilder.isRendererType("HTML") || htmlRendererBuilder.isRendererType("JIRA")) { htmlRendererBuilder.nodeRendererFactory(new TypographicNodeRenderer.Factory()); } } }
if (ENABLE_QUOTES.get(parserBuilder)) { TypographicOptions options = new TypographicOptions(parserBuilder); parserBuilder.customDelimiterProcessor(new AngleQuoteDelimiterProcessor(options)); parserBuilder.customDelimiterProcessor(new SingleQuoteDelimiterProcessor(options)); parserBuilder.customDelimiterProcessor(new DoubleQuoteDelimiterProcessor(options)); } if (ENABLE_SMARTS.get(parserBuilder)) { parserBuilder.customInlineParserExtensionFactory(new SmartsInlineParser.Factory()); }
805
144
949
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicQuotes.java
TypographicQuotes
getAstExtra
class TypographicQuotes extends Node implements DelimitedNode, DoNotAttributeDecorate, TypographicText { protected BasedSequence openingMarker = BasedSequence.NULL; protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; protected String typographicOpening; protected String typographicClosing; @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; return new BasedSequence[] { openingMarker, text, closingMarker }; } @Override public void getAstExtra(@NotNull StringBuilder out) {<FILL_FUNCTION_BODY>} public TypographicQuotes() { } public TypographicQuotes(BasedSequence chars) { super(chars); } public TypographicQuotes(BasedSequence openingMarker, BasedSequence text, BasedSequence closingMarker) { super(openingMarker.baseSubSequence(openingMarker.getStartOffset(), closingMarker.getEndOffset())); this.openingMarker = openingMarker; this.text = text; this.closingMarker = closingMarker; } public BasedSequence getOpeningMarker() { return openingMarker; } public void setOpeningMarker(BasedSequence openingMarker) { this.openingMarker = openingMarker; } public BasedSequence getText() { return text; } public void setText(BasedSequence text) { this.text = text; } public BasedSequence getClosingMarker() { return closingMarker; } public void setClosingMarker(BasedSequence closingMarker) { this.closingMarker = closingMarker; } public String getTypographicOpening() { return typographicOpening; } public void setTypographicOpening(String typographicOpening) { this.typographicOpening = typographicOpening; } public String getTypographicClosing() { return typographicClosing; } public void setTypographicClosing(String typographicClosing) { this.typographicClosing = typographicClosing; } }
if (openingMarker.isNotNull()) out.append(" typographicOpening: ").append(typographicOpening).append(" "); if (closingMarker.isNotNull()) out.append(" typographicClosing: ").append(typographicClosing).append(" "); delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text");
548
90
638
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void appendChain(@NotNull Node) ,public void appendChild(com.vladsch.flexmark.util.ast.Node) ,public static void astChars(@NotNull StringBuilder, @NotNull CharSequence, @NotNull String) ,public void astExtraChars(@NotNull StringBuilder) ,public void astString(@NotNull StringBuilder, boolean) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int, int) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int) ,public transient int countAncestorsOfType(@NotNull Class<?> []) ,public transient int countDirectAncestorsOfType(@Nullable Class<?>, @NotNull Class<?> []) ,public static void delimitedSegmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public static void delimitedSegmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public int endOfLine(int) ,public void extractChainTo(@NotNull Node) ,public void extractToFirstInChain(@NotNull Node) ,public transient @Nullable Node getAncestorOfType(@NotNull Class<?> []) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.sequence.BasedSequence getBaseSequence() ,public @NotNull Node getBlankLineSibling() ,public @NotNull BasedSequence getChars() ,public @NotNull BasedSequence getCharsFromSegments() ,public com.vladsch.flexmark.util.sequence.BasedSequence getChildChars() ,public @NotNull ReversiblePeekingIterator<Node> getChildIterator() ,public transient @Nullable Node getChildOfType(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterable<Node> getChildren() ,public @NotNull ReversiblePeekingIterable<Node> getDescendants() ,public @NotNull Document getDocument() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptyPrefix() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptySuffix() ,public int getEndLineNumber() ,public int getEndOfLine() ,public int getEndOffset() ,public com.vladsch.flexmark.util.sequence.BasedSequence getExactChildChars() ,public @Nullable Node getFirstChild() ,public transient @Nullable Node getFirstChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getFirstChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getFirstInChain() ,public @Nullable Node getGrandParent() ,public @Nullable Node getLastBlankLineChild() ,public @Nullable Node getLastChild() ,public transient @Nullable Node getLastChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getLastChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getLastInChain() ,public static @NotNull BasedSequence getLeadSegment(@NotNull BasedSequence []) ,public Pair<java.lang.Integer,java.lang.Integer> getLineColumnAtEnd() ,public int getLineNumber() ,public @Nullable Node getNext() ,public transient @Nullable Node getNextAny(@NotNull Class<?> []) ,public transient @Nullable Node getNextAnyNot(@NotNull Class<?> []) ,public @NotNull String getNodeName() ,public static transient int getNodeOfTypeIndex(@NotNull Node, @NotNull Class<?> []) ,public transient int getNodeOfTypeIndex(@NotNull Class<?> []) ,public @Nullable Node getOldestAncestorOfTypeAfter(@NotNull Class<?>, @NotNull Class<?>) ,public @Nullable Node getParent() ,public @Nullable Node getPrevious() ,public transient @Nullable Node getPreviousAny(@NotNull Class<?> []) ,public transient @Nullable Node getPreviousAnyNot(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterator<Node> getReversedChildIterator() ,public @NotNull ReversiblePeekingIterable<Node> getReversedChildren() ,public @NotNull ReversiblePeekingIterable<Node> getReversedDescendants() ,public abstract @NotNull BasedSequence [] getSegments() ,public @NotNull BasedSequence [] getSegmentsForChars() ,public com.vladsch.flexmark.util.sequence.Range getSourceRange() ,public int getStartLineNumber() ,public int getStartOfLine() ,public int getStartOffset() ,public int getTextLength() ,public static @NotNull BasedSequence getTrailSegment(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public boolean hasChildren() ,public boolean hasOrMoreChildren(int) ,public void insertAfter(@NotNull Node) ,public void insertBefore(com.vladsch.flexmark.util.ast.Node) ,public void insertChainAfter(@NotNull Node) ,public void insertChainBefore(@NotNull Node) ,public transient boolean isOrDescendantOfType(@NotNull Class<?> []) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtIndex(int) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtStart() ,public void moveTrailingBlankLines() ,public void prependChild(@NotNull Node) ,public void removeChildren() ,public static void segmentSpan(@NotNull StringBuilder, int, int, @Nullable String) ,public static void segmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @Nullable String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String, @NotNull String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public static void segmentSpanCharsToVisible(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public void setChars(@NotNull BasedSequence) ,public void setCharsFromContent() ,public void setCharsFromContentOnly() ,public void setCharsFromSegments() ,public static transient @NotNull BasedSequence spanningChars(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public int startOfLine(int) ,public void takeChildren(@NotNull Node) ,public @NotNull String toAstString(boolean) ,public static @NotNull String toSegmentSpan(@NotNull BasedSequence, @Nullable String) ,public java.lang.String toString() ,public void unlink() <variables>public static final AstNode<com.vladsch.flexmark.util.ast.Node> AST_ADAPTER,public static final com.vladsch.flexmark.util.sequence.BasedSequence[] EMPTY_SEGMENTS,public static final java.lang.String SPLICE,private @NotNull BasedSequence chars,@Nullable Node firstChild,private @Nullable Node lastChild,@Nullable Node next,private @Nullable Node parent,private @Nullable Node prev
vsch_flexmark-java
flexmark-java/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicSmarts.java
TypographicSmarts
collectText
class TypographicSmarts extends Node implements DoNotAttributeDecorate, TypographicText { private String typographicText; public TypographicSmarts() { } public TypographicSmarts(BasedSequence chars) { super(chars); } public TypographicSmarts(String typographicText) { this.typographicText = typographicText; } public TypographicSmarts(BasedSequence chars, String typographicText) { super(chars); this.typographicText = typographicText; } @Override public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?, BasedSequence>, BasedSequence> out, int flags, NodeVisitor nodeVisitor) {<FILL_FUNCTION_BODY>} @Override public void getAstExtra(@NotNull StringBuilder out) { out.append(" typographic: ").append(typographicText).append(" "); } public String getTypographicText() { return typographicText; } public void setTypographicText(String typographicText) { this.typographicText = typographicText; } @NotNull @Override public BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } @NotNull @Override protected String toStringAttributes() { return "text=" + getChars(); } }
if (any(flags, F_NODE_TEXT)) { out.append(getChars()); } else { ReplacedTextMapper textMapper = new ReplacedTextMapper(getChars()); BasedSequence unescaped = Escaping.unescape(getChars(), textMapper); out.append(unescaped); } return false;
357
91
448
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void appendChain(@NotNull Node) ,public void appendChild(com.vladsch.flexmark.util.ast.Node) ,public static void astChars(@NotNull StringBuilder, @NotNull CharSequence, @NotNull String) ,public void astExtraChars(@NotNull StringBuilder) ,public void astString(@NotNull StringBuilder, boolean) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int, int) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int) ,public transient int countAncestorsOfType(@NotNull Class<?> []) ,public transient int countDirectAncestorsOfType(@Nullable Class<?>, @NotNull Class<?> []) ,public static void delimitedSegmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public static void delimitedSegmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public int endOfLine(int) ,public void extractChainTo(@NotNull Node) ,public void extractToFirstInChain(@NotNull Node) ,public transient @Nullable Node getAncestorOfType(@NotNull Class<?> []) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.sequence.BasedSequence getBaseSequence() ,public @NotNull Node getBlankLineSibling() ,public @NotNull BasedSequence getChars() ,public @NotNull BasedSequence getCharsFromSegments() ,public com.vladsch.flexmark.util.sequence.BasedSequence getChildChars() ,public @NotNull ReversiblePeekingIterator<Node> getChildIterator() ,public transient @Nullable Node getChildOfType(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterable<Node> getChildren() ,public @NotNull ReversiblePeekingIterable<Node> getDescendants() ,public @NotNull Document getDocument() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptyPrefix() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptySuffix() ,public int getEndLineNumber() ,public int getEndOfLine() ,public int getEndOffset() ,public com.vladsch.flexmark.util.sequence.BasedSequence getExactChildChars() ,public @Nullable Node getFirstChild() ,public transient @Nullable Node getFirstChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getFirstChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getFirstInChain() ,public @Nullable Node getGrandParent() ,public @Nullable Node getLastBlankLineChild() ,public @Nullable Node getLastChild() ,public transient @Nullable Node getLastChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getLastChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getLastInChain() ,public static @NotNull BasedSequence getLeadSegment(@NotNull BasedSequence []) ,public Pair<java.lang.Integer,java.lang.Integer> getLineColumnAtEnd() ,public int getLineNumber() ,public @Nullable Node getNext() ,public transient @Nullable Node getNextAny(@NotNull Class<?> []) ,public transient @Nullable Node getNextAnyNot(@NotNull Class<?> []) ,public @NotNull String getNodeName() ,public static transient int getNodeOfTypeIndex(@NotNull Node, @NotNull Class<?> []) ,public transient int getNodeOfTypeIndex(@NotNull Class<?> []) ,public @Nullable Node getOldestAncestorOfTypeAfter(@NotNull Class<?>, @NotNull Class<?>) ,public @Nullable Node getParent() ,public @Nullable Node getPrevious() ,public transient @Nullable Node getPreviousAny(@NotNull Class<?> []) ,public transient @Nullable Node getPreviousAnyNot(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterator<Node> getReversedChildIterator() ,public @NotNull ReversiblePeekingIterable<Node> getReversedChildren() ,public @NotNull ReversiblePeekingIterable<Node> getReversedDescendants() ,public abstract @NotNull BasedSequence [] getSegments() ,public @NotNull BasedSequence [] getSegmentsForChars() ,public com.vladsch.flexmark.util.sequence.Range getSourceRange() ,public int getStartLineNumber() ,public int getStartOfLine() ,public int getStartOffset() ,public int getTextLength() ,public static @NotNull BasedSequence getTrailSegment(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public boolean hasChildren() ,public boolean hasOrMoreChildren(int) ,public void insertAfter(@NotNull Node) ,public void insertBefore(com.vladsch.flexmark.util.ast.Node) ,public void insertChainAfter(@NotNull Node) ,public void insertChainBefore(@NotNull Node) ,public transient boolean isOrDescendantOfType(@NotNull Class<?> []) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtIndex(int) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtStart() ,public void moveTrailingBlankLines() ,public void prependChild(@NotNull Node) ,public void removeChildren() ,public static void segmentSpan(@NotNull StringBuilder, int, int, @Nullable String) ,public static void segmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @Nullable String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String, @NotNull String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public static void segmentSpanCharsToVisible(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public void setChars(@NotNull BasedSequence) ,public void setCharsFromContent() ,public void setCharsFromContentOnly() ,public void setCharsFromSegments() ,public static transient @NotNull BasedSequence spanningChars(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public int startOfLine(int) ,public void takeChildren(@NotNull Node) ,public @NotNull String toAstString(boolean) ,public static @NotNull String toSegmentSpan(@NotNull BasedSequence, @Nullable String) ,public java.lang.String toString() ,public void unlink() <variables>public static final AstNode<com.vladsch.flexmark.util.ast.Node> AST_ADAPTER,public static final com.vladsch.flexmark.util.sequence.BasedSequence[] EMPTY_SEGMENTS,public static final java.lang.String SPLICE,private @NotNull BasedSequence chars,@Nullable Node firstChild,private @Nullable Node lastChild,@Nullable Node next,private @Nullable Node parent,private @Nullable Node prev
vsch_flexmark-java
flexmark-java/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/TypographicVisitorExt.java
TypographicVisitorExt
VISIT_HANDLERS
class TypographicVisitorExt { public static <V extends TypographicVisitor> VisitHandler<?>[] VISIT_HANDLERS(V visitor) {<FILL_FUNCTION_BODY>} }
return new VisitHandler<?>[] { new VisitHandler<>(TypographicSmarts.class, visitor::visit), new VisitHandler<>(TypographicQuotes.class, visitor::visit), };
53
55
108
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/QuoteDelimiterProcessorBase.java
QuoteDelimiterProcessorBase
haveNextCloser
class QuoteDelimiterProcessorBase implements DelimiterProcessor { protected final TypographicOptions myOptions; protected final char myOpenDelimiter; protected final char myCloseDelimiter; protected final String myOpener; protected final String myCloser; protected final String myUnmatched; public QuoteDelimiterProcessorBase(TypographicOptions options, char openDelimiter, char closeDelimiter, String opener, String closer, String unmatched) { myOptions = options; myOpenDelimiter = openDelimiter; myCloseDelimiter = closeDelimiter; myOpener = opener; myCloser = closer; myUnmatched = unmatched; } @Override final public char getOpeningCharacter() { return myOpenDelimiter; } @Override final public char getClosingCharacter() { return myCloseDelimiter; } @Override public int getMinLength() { return 1; } @Override public boolean canBeOpener(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace) { return leftFlanking; } @Override public boolean canBeCloser(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace) { return rightFlanking; } @Override public boolean skipNonOpenerCloser() { return false; } protected boolean havePreviousOpener(DelimiterRun opener) { DelimiterRun previous = opener.getPrevious(); int minLength = getMinLength(); while (previous != null) { if (previous.getDelimiterChar() == myOpenDelimiter) { return canOpen(previous, minLength); } previous = previous.getPrevious(); } return false; } protected boolean haveNextCloser(DelimiterRun closer) {<FILL_FUNCTION_BODY>} protected boolean canClose(DelimiterRun closer, int minLength) { if (closer.canClose()) { BasedSequence closerChars = closer.getNode().getChars(); if (closer.getNext() != null && closerChars.isContinuationOf(closer.getNext().getNode().getChars()) || closerChars.getEndOffset() >= closerChars.getBaseSequence().length() || isAllowed(closerChars.getBaseSequence(), closerChars.getEndOffset() + minLength - 1)) { return true; } } return false; } protected boolean canOpen(DelimiterRun opener, int minLength) { if (opener.canOpen()) { BasedSequence openerChars = opener.getNode().getChars(); if (opener.getPrevious() != null && opener.getPrevious().getNode().getChars().isContinuationOf(openerChars) || openerChars.getStartOffset() == 0 || isAllowed(openerChars.getBaseSequence(), openerChars.getStartOffset() - minLength)) { return true; } } return false; } @SuppressWarnings("WeakerAccess") protected boolean isAllowed(char c) { return !Character.isLetterOrDigit(c); } @SuppressWarnings("WeakerAccess") protected boolean isAllowed(CharSequence seq, int index) { return index < 0 || index >= seq.length() || !Character.isLetterOrDigit(seq.charAt(index)); } @Override public int getDelimiterUse(DelimiterRun opener, DelimiterRun closer) { //if (haveNextCloser(closer)) { // // have one that is enclosed // return 0; //} //if (havePreviousOpener(opener)) { // // have one that is enclosed // return 0; //} int minLength = getMinLength(); if (opener.length() >= minLength && closer.length() >= minLength) { if (canOpen(opener, minLength) && canClose(closer, minLength)) return minLength; } return 0; } @Override public Node unmatchedDelimiterNode(InlineParser inlineParser, DelimiterRun delimiter) { if (myUnmatched != null && myOptions.typographicSmarts) { BasedSequence chars = delimiter.getNode().getChars(); if (chars.length() == 1) { return new TypographicSmarts(chars, myUnmatched); } } return null; } @Override public void process(Delimiter opener, Delimiter closer, int delimitersUsed) { // Normal case, wrap nodes between delimiters in strikethrough. TypographicQuotes node = new TypographicQuotes(opener.getTailChars(delimitersUsed), BasedSequence.NULL, closer.getLeadChars(delimitersUsed)); node.setTypographicOpening(myOpener); node.setTypographicClosing(myCloser); opener.moveNodesBetweenDelimitersTo(node, closer); } }
DelimiterRun next = closer.getNext(); int minLength = getMinLength(); while (next != null) { if (next.getDelimiterChar() == myCloseDelimiter) { return canClose(next, minLength); } next = next.getNext(); } return false;
1,413
87
1,500
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/SmartsInlineParser.java
SmartsInlineParser
parse
class SmartsInlineParser implements InlineParserExtension { final private SmartsParsing parsing; public SmartsInlineParser(LightInlineParser inlineParser) { this.parsing = new SmartsParsing(inlineParser.getParsing()); } @Override public void finalizeDocument(@NotNull InlineParser inlineParser) { } @Override public void finalizeBlock(@NotNull InlineParser inlineParser) { } @Override public boolean parse(@NotNull LightInlineParser inlineParser) {<FILL_FUNCTION_BODY>} public static class Factory implements InlineParserExtensionFactory { @Nullable @Override public Set<Class<?>> getAfterDependents() { return null; } @NotNull @Override public CharSequence getCharacters() { return ".-"; } @Nullable @Override public Set<Class<?>> getBeforeDependents() { return null; } @NotNull @Override public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { return new SmartsInlineParser(lightInlineParser); } @Override public boolean affectsGlobalScope() { return false; } } }
// hard coding implementation because pattern matching can be very slow for large files BasedSequence input = inlineParser.getInput(); String typographicSmarts = null; BasedSequence match = null; int i = inlineParser.getIndex(); char c = input.charAt(i); if (c == '.') { if (input.matchChars(parsing.ELIPSIS, i)) { match = input.subSequence(i, i + parsing.ELIPSIS.length()); typographicSmarts = "&hellip;"; } else if (input.matchChars(parsing.ELIPSIS_SPACED, i)) { match = input.subSequence(i, i + parsing.ELIPSIS_SPACED.length()); typographicSmarts = "&hellip;"; } } else if (c == '-') { if (input.matchChars(parsing.EM_DASH, i)) { match = input.subSequence(i, i + parsing.EM_DASH.length()); typographicSmarts = "&mdash;"; } else if (input.matchChars(parsing.EN_DASH, i)) { match = input.subSequence(i, i + parsing.EN_DASH.length()); typographicSmarts = "&ndash;"; } } if (match != null) { inlineParser.flushTextNode(); inlineParser.setIndex(i + match.length()); TypographicSmarts smarts = new TypographicSmarts(match, typographicSmarts); inlineParser.getBlock().appendChild(smarts); return true; } return false;
329
422
751
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-typographic/src/main/java/com/vladsch/flexmark/ext/typographic/internal/TypographicNodeRenderer.java
TypographicNodeRenderer
render
class TypographicNodeRenderer implements NodeRenderer { public TypographicNodeRenderer(DataHolder options) { } @Override public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() { HashSet<NodeRenderingHandler<?>> set = new HashSet<>(); set.add(new NodeRenderingHandler<>(TypographicSmarts.class, this::render)); set.add(new NodeRenderingHandler<>(TypographicQuotes.class, this::render)); return set; } private void render(TypographicQuotes node, NodeRendererContext context, HtmlWriter html) {<FILL_FUNCTION_BODY>} private void render(TypographicSmarts node, NodeRendererContext context, HtmlWriter html) { html.raw(node.getTypographicText()); } public static class Factory implements NodeRendererFactory { @NotNull @Override public NodeRenderer apply(@NotNull DataHolder options) { return new TypographicNodeRenderer(options); } } }
if (node.getTypographicOpening() != null && !node.getTypographicOpening().isEmpty()) html.raw(node.getTypographicOpening()); context.renderChildren(node); if (node.getTypographicClosing() != null && !node.getTypographicClosing().isEmpty()) html.raw(node.getTypographicClosing());
255
90
345
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/WikiLinkExtension.java
WikiLinkExtension
extend
class WikiLinkExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension, Formatter.FormatterExtension { final public static DataKey<Boolean> ALLOW_INLINES = new DataKey<>("ALLOW_INLINES", false); final public static DataKey<Boolean> ALLOW_ANCHORS = new DataKey<>("ALLOW_ANCHORS", false); final public static DataKey<Boolean> ALLOW_ANCHOR_ESCAPE = new DataKey<>("ALLOW_ANCHOR_ESCAPE", false); final public static DataKey<Boolean> ALLOW_PIPE_ESCAPE = new DataKey<>("ALLOW_PIPE_ESCAPE", false); final public static DataKey<Boolean> DISABLE_RENDERING = new DataKey<>("DISABLE_RENDERING", false); final public static DataKey<Boolean> LINK_FIRST_SYNTAX = new DataKey<>("LINK_FIRST_SYNTAX", false); final public static DataKey<String> LINK_PREFIX = new DataKey<>("LINK_PREFIX", ""); /** * Link prefix to use for absolute wiki links starting with the <code>'/'</code> character. * <p> * <p> * Will get its value from option {@link #LINK_PREFIX} until its own value is set. * </p> */ final public static DataKey<String> LINK_PREFIX_ABSOLUTE = new DataKey<>("LINK_PREFIX_ABSOLUTE", LINK_PREFIX); final public static DataKey<String> IMAGE_PREFIX = new DataKey<>("IMAGE_PREFIX", ""); /** * Image prefix to use for absolute wiki image sources starting with the <code>'/'</code> character. * <p> * <p> * Will get its value from option {@link #IMAGE_PREFIX} until its own value is set. * </p> */ final public static DataKey<String> IMAGE_PREFIX_ABSOLUTE = new DataKey<>("IMAGE_PREFIX_ABSOLUTE", IMAGE_PREFIX); final public static DataKey<Boolean> IMAGE_LINKS = new DataKey<>("IMAGE_LINKS", false); final public static DataKey<String> LINK_FILE_EXTENSION = new DataKey<>("LINK_FILE_EXTENSION", ""); final public static DataKey<String> IMAGE_FILE_EXTENSION = new DataKey<>("IMAGE_FILE_EXTENSION", ""); /** * Characters to escape in wiki links. * <p> * <p> * Each character in the configuration string is replaced with a character * at the corresponding index in the string given by the configuration * option {@link #LINK_REPLACE_CHARS}. * </p> */ final public static DataKey<String> LINK_ESCAPE_CHARS = new DataKey<>("LINK_ESCAPE_CHARS", " +/<>"); /** * Characters to replace {@link #LINK_ESCAPE_CHARS} with. * * @see #LINK_ESCAPE_CHARS */ final public static DataKey<String> LINK_REPLACE_CHARS = new DataKey<>("LINK_REPLACE_CHARS", "-----"); final public static LinkType WIKI_LINK = new LinkType("WIKI"); private WikiLinkExtension() { } public static WikiLinkExtension create() { return new WikiLinkExtension(); } @Override public void rendererOptions(@NotNull MutableDataHolder options) { } @Override public void parserOptions(MutableDataHolder options) { } @Override public void extend(Formatter.Builder formatterBuilder) { formatterBuilder.nodeFormatterFactory(new WikiLinkNodeFormatter.Factory()); // formatterBuilder.linkResolverFactory(new WikiLinkLinkResolver.Factory()); } @Override public void extend(Parser.Builder parserBuilder) { parserBuilder.linkRefProcessorFactory(new WikiLinkLinkRefProcessor.Factory()); } @Override public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) {<FILL_FUNCTION_BODY>} }
if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new WikiLinkNodeRenderer.Factory()); htmlRendererBuilder.linkResolverFactory(new WikiLinkLinkResolver.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { htmlRendererBuilder.nodeRendererFactory(new WikiLinkJiraRenderer.Factory()); htmlRendererBuilder.linkResolverFactory(new WikiLinkLinkResolver.Factory()); }
1,107
117
1,224
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkJiraRenderer.java
WikiLinkJiraRenderer
getNodeRenderingHandlers
class WikiLinkJiraRenderer implements NodeRenderer { final private WikiLinkOptions options; public WikiLinkJiraRenderer(DataHolder options) { this.options = new WikiLinkOptions(options); } @Override public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {<FILL_FUNCTION_BODY>} private void render(WikiLink node, NodeRendererContext context, HtmlWriter html) { if (options.disableRendering) { html.text(node.getChars().unescape()); } else { ResolvedLink resolvedLink = context.resolveLink(WikiLinkExtension.WIKI_LINK, node.getLink().toString(), null); html.raw("["); html.raw(node.getText().isNotNull() ? node.getText().toString() : node.getPageRef().toString()); html.raw("|"); html.raw(resolvedLink.getUrl()); html.raw("]"); } } public static class Factory implements NodeRendererFactory { @NotNull @Override public NodeRenderer apply(@NotNull DataHolder options) { return new WikiLinkJiraRenderer(options); } } }
HashSet<NodeRenderingHandler<?>> set = new HashSet<>(); set.add(new NodeRenderingHandler<>(WikiLink.class, this::render)); return set;
306
50
356
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkRefProcessor.java
WikiLinkLinkRefProcessor
updateNodeElements
class WikiLinkLinkRefProcessor implements LinkRefProcessor { static final int BRACKET_NESTING_LEVEL = 1; final private WikiLinkOptions options; public WikiLinkLinkRefProcessor(Document document) { this.options = new WikiLinkOptions(document); } @Override public boolean getWantExclamationPrefix() { return options.imageLinks; } @Override public int getBracketNestingLevel() { return BRACKET_NESTING_LEVEL; } @Override public boolean isMatch(@NotNull BasedSequence nodeChars) { int length = nodeChars.length(); if (options.imageLinks) { if (length >= 5 && nodeChars.charAt(0) == '!') { return nodeChars.charAt(1) == '[' && nodeChars.charAt(2) == '[' && nodeChars.endCharAt(1) == ']' && nodeChars.endCharAt(2) == ']'; } else if (length >= 4) { return nodeChars.charAt(0) == '[' && nodeChars.charAt(1) == '[' && nodeChars.endCharAt(1) == ']' && nodeChars.endCharAt(2) == ']'; } } else if (length >= 4) { return nodeChars.charAt(0) == '[' && nodeChars.charAt(1) == '[' && nodeChars.endCharAt(1) == ']' && nodeChars.endCharAt(2) == ']'; } return false; } @NotNull @Override public BasedSequence adjustInlineText(@NotNull Document document, @NotNull 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; return wikiNode.getText().ifNull(wikiNode.getLink()); } @Override public boolean allowDelimiters(@NotNull BasedSequence chars, @NotNull Document document, @NotNull 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) {<FILL_FUNCTION_BODY>} @NotNull @Override public Node createNode(@NotNull 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) { return new WikiLinkLinkRefProcessor(document); } @Override public boolean getWantExclamationPrefix(@NotNull DataHolder options) { return WikiLinkExtension.IMAGE_LINKS.get(options); } @Override public int getBracketNestingLevel(@NotNull DataHolder options) { return BRACKET_NESTING_LEVEL; } } }
assert (node instanceof WikiNode); WikiNode wikiNode = (WikiNode) node; if (node instanceof WikiLink && WikiLinkExtension.ALLOW_INLINES.get(document)) { // need to update link and pageRef with plain text versions if (wikiNode.getText().isNull()) { BasedSequence link = new TextCollectingVisitor().collectAndGetSequence(node, TextContainer.F_NODE_TEXT); wikiNode.setLink(link, WikiLinkExtension.ALLOW_ANCHORS.get(document), WikiLinkExtension.ALLOW_ANCHOR_ESCAPE.get(document)); } }
888
163
1,051
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkLinkResolver.java
WikiLinkLinkResolver
resolveLink
class WikiLinkLinkResolver implements LinkResolver { final private WikiLinkOptions options; public WikiLinkLinkResolver(LinkResolverBasicContext context) { this.options = new WikiLinkOptions(context.getOptions()); } @NotNull @Override public ResolvedLink resolveLink(@NotNull Node node, @NotNull LinkResolverBasicContext context, @NotNull ResolvedLink link) {<FILL_FUNCTION_BODY>} public static class Factory implements LinkResolverFactory { @Nullable @Override public Set<Class<?>> getAfterDependents() { return null; } @Nullable @Override public Set<Class<?>> getBeforeDependents() { return null; } @Override public boolean affectsGlobalScope() { return false; } @NotNull @Override public LinkResolver apply(@NotNull LinkResolverBasicContext context) { return new WikiLinkLinkResolver(context); } } }
if (link.getLinkType() == WIKI_LINK) { StringBuilder sb = new StringBuilder(); final boolean isWikiImage = node instanceof WikiImage; String wikiLink = link.getUrl(); int iMax = wikiLink.length(); boolean absolute = iMax > 0 && wikiLink.charAt(0) == '/'; sb.append(isWikiImage ? options.getImagePrefix(absolute) : options.getLinkPrefix(absolute)); boolean hadAnchorRef = false; boolean isEscaped = false; String linkEscapeChars = options.linkEscapeChars; String linkReplaceChars = options.linkReplaceChars; for (int i = absolute ? 1 : 0; i < iMax; i++) { char c = wikiLink.charAt(i); if (c == '#' && !hadAnchorRef && options.allowAnchors && !(isEscaped && options.allowAnchorEscape)) { sb.append(isWikiImage ? options.imageFileExtension : options.linkFileExtension); sb.append(c); hadAnchorRef = true; isEscaped = false; continue; } if (c == '\\') { if (isEscaped) { // need to URL encode \ sb.append("%5C"); } isEscaped = !isEscaped; } else { isEscaped = false; if (c == '#' && !hadAnchorRef) { // need to URL encode the # sb.append("%23"); } else { int pos = linkEscapeChars.indexOf(c); if (pos < 0) { sb.append(c); } else { sb.append(linkReplaceChars.charAt(pos)); } } } } if (isEscaped) { // need to add dangling URL encoded \ sb.append("%5C"); } if (!hadAnchorRef) { sb.append(isWikiImage ? options.imageFileExtension : options.linkFileExtension); } if (isWikiImage) { return new ResolvedLink(LinkType.IMAGE, sb.toString(), null, LinkStatus.UNCHECKED); } else { return new ResolvedLink(LinkType.LINK, sb.toString(), null, LinkStatus.UNCHECKED); } } return link;
251
630
881
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-wikilink/src/main/java/com/vladsch/flexmark/ext/wikilink/internal/WikiLinkNodeRenderer.java
WikiLinkNodeRenderer
render
class WikiLinkNodeRenderer implements NodeRenderer { final private WikiLinkOptions options; public WikiLinkNodeRenderer(DataHolder options) { this.options = new WikiLinkOptions(options); } @Override public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() { HashSet<NodeRenderingHandler<?>> set = new HashSet<>(); set.add(new NodeRenderingHandler<>(WikiLink.class, this::render)); set.add(new NodeRenderingHandler<>(WikiImage.class, this::render)); return set; } private void render(WikiLink node, NodeRendererContext context, HtmlWriter html) { if (!context.isDoNotRenderLinks()) { if (options.disableRendering) { html.text(node.getChars().unescape()); } else { ResolvedLink resolvedLink = context.resolveLink(WikiLinkExtension.WIKI_LINK, node.getLink(), null); html.attr("href", resolvedLink.getUrl()); html.srcPos(node.getChars()).withAttr(resolvedLink).tag("a"); context.renderChildren(node);//html.text(node.getText().isNotNull() ? node.getText().toString() : node.getPageRef().toString()); html.tag("/a"); } } } private void render(WikiImage node, NodeRendererContext context, HtmlWriter html) {<FILL_FUNCTION_BODY>} public static class Factory implements NodeRendererFactory { @NotNull @Override public NodeRenderer apply(@NotNull DataHolder options) { return new WikiLinkNodeRenderer(options); } } }
if (!context.isDoNotRenderLinks()) { if (options.disableRendering) { html.text(node.getChars().unescape()); } else { String altText = node.getText().isNotNull() ? node.getText().toString() : node.getLink().unescape(); ResolvedLink resolvedLink = context.resolveLink(WikiLinkExtension.WIKI_LINK, node.getLink(), null); String url = resolvedLink.getUrl(); html.attr("src", url); html.attr("alt", altText); html.srcPos(node.getChars()).withAttr(resolvedLink).tagVoid("img"); } }
431
175
606
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/Macro.java
Macro
getAttributes
class Macro extends Node { protected BasedSequence openingMarker = BasedSequence.NULL; protected BasedSequence name = BasedSequence.NULL; protected BasedSequence attributeText = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; @NotNull @Override public BasedSequence[] getSegments() { //return EMPTY_SEGMENTS; return new BasedSequence[] { openingMarker, name, attributeText, closingMarker }; } @Override public void getAstExtra(@NotNull StringBuilder out) { segmentSpanChars(out, openingMarker, "open"); segmentSpanChars(out, name, "name"); segmentSpanChars(out, attributeText, "attributes"); segmentSpanChars(out, closingMarker, "close"); if (isClosedTag()) out.append(" isClosed"); if (isBlockMacro()) out.append(" isBlockMacro"); segmentSpanChars(out, getMacroContentChars(), "macroContent"); } public Macro() { } public Macro(BasedSequence chars) { super(chars); } public Macro(BasedSequence openingMarker, BasedSequence name, BasedSequence closingMarker) { super(openingMarker.baseSubSequence(openingMarker.getStartOffset(), closingMarker.getEndOffset())); this.openingMarker = openingMarker; this.name = name; this.closingMarker = closingMarker; } public BasedSequence getOpeningMarker() { return openingMarker; } public void setOpeningMarker(BasedSequence openingMarker) { this.openingMarker = openingMarker; } public BasedSequence getName() { return name; } public void setName(BasedSequence name) { this.name = name; } public BasedSequence getClosingMarker() { return closingMarker; } public void setClosingMarker(BasedSequence closingMarker) { this.closingMarker = closingMarker; } public BasedSequence getAttributeText() { return attributeText; } public void setAttributeText(BasedSequence attributeText) { this.attributeText = attributeText; } public boolean isBlockMacro() { Node parent = getParent(); return parent instanceof MacroBlock && parent.getFirstChild() == this; } public Map<String, String> getAttributes() {<FILL_FUNCTION_BODY>} public BasedSequence getMacroContentChars() { Node lastChild = getLastChild(); int startOffset = getClosingMarker().getEndOffset(); int endOffset = lastChild == null || lastChild instanceof MacroAttribute ? getEndOffset() : lastChild.getStartOffset(); return isClosedTag() ? BasedSequence.NULL : getChars().baseSubSequence(startOffset, endOffset); } public boolean isClosedTag() { return getClosingMarker().length() > 2; } }
Map<String, String> attributes = new LinkedHashMap<>(); Node child = getFirstChild(); while (child != null) { if (child instanceof MacroAttribute) { MacroAttribute attribute = (MacroAttribute) child; attributes.put(attribute.getAttribute().toString(), attribute.getValue().toString()); } child = child.getNext(); } return attributes;
753
102
855
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void appendChain(@NotNull Node) ,public void appendChild(com.vladsch.flexmark.util.ast.Node) ,public static void astChars(@NotNull StringBuilder, @NotNull CharSequence, @NotNull String) ,public void astExtraChars(@NotNull StringBuilder) ,public void astString(@NotNull StringBuilder, boolean) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int, int) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int) ,public transient int countAncestorsOfType(@NotNull Class<?> []) ,public transient int countDirectAncestorsOfType(@Nullable Class<?>, @NotNull Class<?> []) ,public static void delimitedSegmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public static void delimitedSegmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public int endOfLine(int) ,public void extractChainTo(@NotNull Node) ,public void extractToFirstInChain(@NotNull Node) ,public transient @Nullable Node getAncestorOfType(@NotNull Class<?> []) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.sequence.BasedSequence getBaseSequence() ,public @NotNull Node getBlankLineSibling() ,public @NotNull BasedSequence getChars() ,public @NotNull BasedSequence getCharsFromSegments() ,public com.vladsch.flexmark.util.sequence.BasedSequence getChildChars() ,public @NotNull ReversiblePeekingIterator<Node> getChildIterator() ,public transient @Nullable Node getChildOfType(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterable<Node> getChildren() ,public @NotNull ReversiblePeekingIterable<Node> getDescendants() ,public @NotNull Document getDocument() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptyPrefix() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptySuffix() ,public int getEndLineNumber() ,public int getEndOfLine() ,public int getEndOffset() ,public com.vladsch.flexmark.util.sequence.BasedSequence getExactChildChars() ,public @Nullable Node getFirstChild() ,public transient @Nullable Node getFirstChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getFirstChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getFirstInChain() ,public @Nullable Node getGrandParent() ,public @Nullable Node getLastBlankLineChild() ,public @Nullable Node getLastChild() ,public transient @Nullable Node getLastChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getLastChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getLastInChain() ,public static @NotNull BasedSequence getLeadSegment(@NotNull BasedSequence []) ,public Pair<java.lang.Integer,java.lang.Integer> getLineColumnAtEnd() ,public int getLineNumber() ,public @Nullable Node getNext() ,public transient @Nullable Node getNextAny(@NotNull Class<?> []) ,public transient @Nullable Node getNextAnyNot(@NotNull Class<?> []) ,public @NotNull String getNodeName() ,public static transient int getNodeOfTypeIndex(@NotNull Node, @NotNull Class<?> []) ,public transient int getNodeOfTypeIndex(@NotNull Class<?> []) ,public @Nullable Node getOldestAncestorOfTypeAfter(@NotNull Class<?>, @NotNull Class<?>) ,public @Nullable Node getParent() ,public @Nullable Node getPrevious() ,public transient @Nullable Node getPreviousAny(@NotNull Class<?> []) ,public transient @Nullable Node getPreviousAnyNot(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterator<Node> getReversedChildIterator() ,public @NotNull ReversiblePeekingIterable<Node> getReversedChildren() ,public @NotNull ReversiblePeekingIterable<Node> getReversedDescendants() ,public abstract @NotNull BasedSequence [] getSegments() ,public @NotNull BasedSequence [] getSegmentsForChars() ,public com.vladsch.flexmark.util.sequence.Range getSourceRange() ,public int getStartLineNumber() ,public int getStartOfLine() ,public int getStartOffset() ,public int getTextLength() ,public static @NotNull BasedSequence getTrailSegment(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public boolean hasChildren() ,public boolean hasOrMoreChildren(int) ,public void insertAfter(@NotNull Node) ,public void insertBefore(com.vladsch.flexmark.util.ast.Node) ,public void insertChainAfter(@NotNull Node) ,public void insertChainBefore(@NotNull Node) ,public transient boolean isOrDescendantOfType(@NotNull Class<?> []) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtIndex(int) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtStart() ,public void moveTrailingBlankLines() ,public void prependChild(@NotNull Node) ,public void removeChildren() ,public static void segmentSpan(@NotNull StringBuilder, int, int, @Nullable String) ,public static void segmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @Nullable String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String, @NotNull String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public static void segmentSpanCharsToVisible(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public void setChars(@NotNull BasedSequence) ,public void setCharsFromContent() ,public void setCharsFromContentOnly() ,public void setCharsFromSegments() ,public static transient @NotNull BasedSequence spanningChars(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public int startOfLine(int) ,public void takeChildren(@NotNull Node) ,public @NotNull String toAstString(boolean) ,public static @NotNull String toSegmentSpan(@NotNull BasedSequence, @Nullable String) ,public java.lang.String toString() ,public void unlink() <variables>public static final AstNode<com.vladsch.flexmark.util.ast.Node> AST_ADAPTER,public static final com.vladsch.flexmark.util.sequence.BasedSequence[] EMPTY_SEGMENTS,public static final java.lang.String SPLICE,private @NotNull BasedSequence chars,@Nullable Node firstChild,private @Nullable Node lastChild,@Nullable Node next,private @Nullable Node parent,private @Nullable Node prev
vsch_flexmark-java
flexmark-java/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroBlock.java
MacroBlock
getMacroContentChars
class MacroBlock extends Block { @Override public void getAstExtra(@NotNull StringBuilder out) { if (isClosedTag()) out.append(" isClosed"); segmentSpanChars(out, getMacroContentChars(), "macroContent"); } @NotNull @Override public BasedSequence[] getSegments() { return Node.EMPTY_SEGMENTS; } public MacroBlock() { } public MacroBlock(BasedSequence chars) { super(chars); } public MacroBlock(Node node) { super(); appendChild(node); this.setCharsFromContent(); } public Map<String, String> getAttributes() { return getMacroNode().getAttributes(); } public Macro getMacroNode() { Node firstChild = getFirstChild(); assert firstChild instanceof Macro; return (Macro) firstChild; } public boolean isClosedTag() { return getMacroNode().isClosedTag(); } public BasedSequence getMacroContentChars() {<FILL_FUNCTION_BODY>} }
Node firstChild = getFirstChild(); Node lastChild = getLastChild(); Node firstContentNode = firstChild.getNext(); Node lastContentNode = lastChild instanceof MacroClose ? lastChild.getPrevious() : lastChild; //noinspection UnnecessaryLocalVariable BasedSequence contentChars = Node.spanningChars(firstContentNode == null || firstContentNode instanceof MacroClose ? BasedSequence.NULL : firstContentNode.getChars(), lastContentNode == null || lastContentNode == firstChild ? BasedSequence.NULL : lastContentNode.getChars()); return contentChars;
304
149
453
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void <init>(@NotNull BasedSequence, @NotNull List<BasedSequence>) ,public void <init>(@NotNull List<BasedSequence>) ,public void <init>(com.vladsch.flexmark.util.ast.BlockContent) ,public @Nullable Block getParent() <variables>
vsch_flexmark-java
flexmark-java/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/MacroVisitorExt.java
MacroVisitorExt
VISIT_HANDLERS
class MacroVisitorExt { public static <V extends MacroVisitor> VisitHandler<?>[] VISIT_HANDLERS(V visitor) {<FILL_FUNCTION_BODY>} }
return new VisitHandler<?>[] { new VisitHandler<>(Macro.class, visitor::visit), new VisitHandler<>(MacroClose.class, visitor::visit), new VisitHandler<>(MacroBlock.class, visitor::visit), };
53
70
123
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroBlockParser.java
BlockFactory
tryStart
class BlockFactory extends AbstractBlockParserFactory { final private MacroParsing parsing; BlockFactory(DataHolder options) { super(options); this.parsing = new MacroParsing(new Parsing(options)); } @Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) {<FILL_FUNCTION_BODY>} }
BasedSequence line = state.getLine(); int currentIndent = state.getIndent(); if (currentIndent == 0 && !(matchedBlockParser.getBlockParser().getBlock() instanceof Paragraph)) { final BasedSequence tryLine = line.subSequence(state.getIndex()); Matcher matcher = parsing.MACRO_OPEN.matcher(tryLine); if (matcher.find()) { // see if it closes on the same line, then we create a block and close it BasedSequence macroName = line.subSequence(matcher.start(1), matcher.end(1)); BasedSequence macroOpen = tryLine.subSequence(0, matcher.end()); final BasedSequence afterOpen = tryLine.subSequence(matcher.end()); boolean oneLine = false; boolean isClosedTag = false; MacroClose macroClose = null; if (macroOpen.endsWith("/}}")) { // closed tag, if the end is blank then it is a block if (afterOpen.isBlank()) { // this is an open/close tag oneLine = true; isClosedTag = true; } else { return BlockStart.none(); } } else { // see if close or blank if (!afterOpen.isBlank()) { Matcher closeMatcher = parsing.MACRO_CLOSE_END.matcher(afterOpen); if (closeMatcher.find()) { if (macroName.equals(closeMatcher.group(1)) && (closeMatcher.groupCount() < 2 || closeMatcher.start(2) == -1 || (closeMatcher.group(2).length() & 1) == 1)) { // same name and not escaped oneLine = true; macroClose = new MacroClose(afterOpen.subSequence(closeMatcher.start(), closeMatcher.start() + 3), afterOpen.subSequence(closeMatcher.start(1), closeMatcher.end(1)), afterOpen.subSequence(closeMatcher.end() - 2, closeMatcher.end())); macroClose.setCharsFromContent(); } } if (!oneLine) { return BlockStart.none(); } } } Macro macro = new Macro(macroOpen.subSequence(0, 2), macroName, macroOpen.endSequence(isClosedTag ? 3 : 2)); macro.setCharsFromContent(); BasedSequence attributeText = macroOpen.baseSubSequence(macroName.getEndOffset(), macro.getClosingMarker().getStartOffset()).trim(); if (!attributeText.isEmpty()) { // have some attribute text macro.setAttributeText(attributeText); // parse attributes Matcher attributeMatcher = parsing.MACRO_ATTRIBUTE.matcher(attributeText); while (attributeMatcher.find()) { BasedSequence attributeName = attributeText.subSequence(attributeMatcher.start(1), attributeMatcher.end(1)); BasedSequence attributeSeparator = attributeMatcher.groupCount() == 1 || attributeMatcher.start(2) == -1 ? BasedSequence.NULL : attributeText.subSequence(attributeMatcher.end(1), attributeMatcher.start(2)).trim(); BasedSequence attributeValue = attributeMatcher.groupCount() == 1 || attributeMatcher.start(2) == -1 ? BasedSequence.NULL : attributeText.subSequence(attributeMatcher.start(2), attributeMatcher.end(2)); boolean isQuoted = attributeValue.length() >= 2 && (attributeValue.charAt(0) == '"' && attributeValue.endCharAt(1) == '"' || attributeValue.charAt(0) == '\'' && attributeValue.endCharAt(1) == '\''); BasedSequence attributeOpen = !isQuoted ? BasedSequence.NULL : attributeValue.subSequence(0, 1); BasedSequence attributeClose = !isQuoted ? BasedSequence.NULL : attributeValue.endSequence(1, 0); if (isQuoted) { attributeValue = attributeValue.midSequence(1, -1); } MacroAttribute attribute = new MacroAttribute(attributeName, attributeSeparator, attributeOpen, attributeValue, attributeClose); macro.appendChild(attribute); } } final MacroBlockParser parser = new MacroBlockParser(state.getProperties(), parsing, macroName, oneLine); if (oneLine) { parser.hadClose = true; } parser.block.appendChild(macro); if (macroClose != null) parser.block.appendChild(macroClose); return BlockStart.of(parser) .atIndex(state.getLineEndIndex()) ; } } return BlockStart.none();
104
1,189
1,293
<methods>public non-sealed void <init>() ,public void addLine(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.util.sequence.BasedSequence) ,public boolean breakOutOnDoubleBlankLine() ,public boolean canContain(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.parser.block.BlockParser, com.vladsch.flexmark.util.ast.Block) ,public boolean canInterruptBy(com.vladsch.flexmark.parser.block.BlockParserFactory) ,public final void finalizeClosedBlock() ,public com.vladsch.flexmark.util.ast.BlockContent getBlockContent() ,public com.vladsch.flexmark.util.data.MutableDataHolder getDataHolder() ,public boolean isClosed() ,public boolean isContainer() ,public boolean isInterruptible() ,public boolean isParagraphParser() ,public boolean isPropagatingLastBlankLine(com.vladsch.flexmark.parser.block.BlockParser) ,public boolean isRawText() ,public void parseInlines(com.vladsch.flexmark.parser.InlineParser) ,public void removeBlankLines() <variables>private boolean isClosed,private com.vladsch.flexmark.util.data.MutableDataSet mutableData
vsch_flexmark-java
flexmark-java/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroInlineParser.java
MacroInlineParser
parse
class MacroInlineParser implements InlineParserExtension { final private MacroParsing parsing; private List<Macro> openMacros; public MacroInlineParser(LightInlineParser inlineParser) { this.parsing = new MacroParsing(inlineParser.getParsing()); this.openMacros = new ArrayList<>(); } @Override public void finalizeDocument(@NotNull InlineParser inlineParser) { } @Override public void finalizeBlock(@NotNull InlineParser inlineParser) { for (int j = openMacros.size(); j-- > 0; ) { inlineParser.moveNodes(openMacros.get(j), inlineParser.getBlock().getLastChild()); } openMacros.clear(); } @Override public boolean parse(@NotNull LightInlineParser inlineParser) {<FILL_FUNCTION_BODY>} public static class Factory implements InlineParserExtensionFactory { @Nullable @Override public Set<Class<?>> getAfterDependents() { return null; } @NotNull @Override public CharSequence getCharacters() { return "{"; } @Nullable @Override public Set<Class<?>> getBeforeDependents() { return null; } @NotNull @Override public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { return new MacroInlineParser(lightInlineParser); } @Override public boolean affectsGlobalScope() { return false; } } }
if (inlineParser.peek(1) == '{') { BasedSequence input = inlineParser.getInput(); int index = inlineParser.getIndex(); Matcher matcher = inlineParser.matcher(parsing.MACRO_TAG); if (matcher != null) { BasedSequence macroOpen = input.subSequence(matcher.start(), matcher.end()); // see what we have if (macroOpen.charAt(2) == '/') { // close BasedSequence macroName = input.subSequence(matcher.start(2), matcher.end(2)); for (int i = openMacros.size(); i-- > 0; ) { if (openMacros.get(i).getName().equals(macroName)) { // this one is now closed, we close all intervening ones too inlineParser.flushTextNode(); for (int j = openMacros.size(); j-- > i; ) { inlineParser.moveNodes(openMacros.get(j), inlineParser.getBlock().getLastChild()); } MacroClose macroClose = new MacroClose(macroOpen.subSequence(0, 3), macroName, macroOpen.endSequence(2)); inlineParser.getBlock().appendChild(macroClose); inlineParser.moveNodes(openMacros.get(i), macroClose); if (i == 0) { openMacros.clear(); } else { openMacros = openMacros.subList(0, i); } return true; } } } else { // open, see if open/close BasedSequence macroName = input.subSequence(matcher.start(1), matcher.end(1)); boolean isClosedTag = macroOpen.endCharAt(3) == '/'; Macro macro = new Macro(macroOpen.subSequence(0, 2), macroName, macroOpen.endSequence(isClosedTag ? 3 : 2)); macro.setCharsFromContent(); inlineParser.flushTextNode(); inlineParser.getBlock().appendChild(macro); if (!isClosedTag) { openMacros.add(macro); } BasedSequence attributeText = macroOpen.baseSubSequence(macroName.getEndOffset(), macro.getClosingMarker().getStartOffset()).trim(); if (!attributeText.isEmpty()) { // have some attribute text macro.setAttributeText(attributeText); // parse attributes Matcher attributeMatcher = parsing.MACRO_ATTRIBUTE.matcher(attributeText); while (attributeMatcher.find()) { BasedSequence attributeName = attributeText.subSequence(attributeMatcher.start(1), attributeMatcher.end(1)); BasedSequence attributeSeparator = attributeMatcher.groupCount() == 1 || attributeMatcher.start(2) == -1 ? BasedSequence.NULL : attributeText.subSequence(attributeMatcher.end(1), attributeMatcher.start(2)).trim(); BasedSequence attributeValue = attributeMatcher.groupCount() == 1 || attributeMatcher.start(2) == -1 ? BasedSequence.NULL : attributeText.subSequence(attributeMatcher.start(2), attributeMatcher.end(2)); boolean isQuoted = attributeValue.length() >= 2 && (attributeValue.charAt(0) == '"' && attributeValue.endCharAt(1) == '"' || attributeValue.charAt(0) == '\'' && attributeValue.endCharAt(1) == '\''); BasedSequence attributeOpen = !isQuoted ? BasedSequence.NULL : attributeValue.subSequence(0, 1); BasedSequence attributeClose = !isQuoted ? BasedSequence.NULL : attributeValue.endSequence(1, 0); if (isQuoted) { attributeValue = attributeValue.midSequence(1, -1); } MacroAttribute attribute = new MacroAttribute(attributeName, attributeSeparator, attributeOpen, attributeValue, attributeClose); macro.appendChild(attribute); } } return true; } // did not process, reset to where we started inlineParser.setIndex(index); } } return false;
410
1,043
1,453
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-xwiki-macros/src/main/java/com/vladsch/flexmark/ext/xwiki/macros/internal/MacroNodeRenderer.java
MacroNodeRenderer
getNodeRenderingHandlers
class MacroNodeRenderer implements NodeRenderer { final private MacroOptions options; public MacroNodeRenderer(DataHolder options) { this.options = new MacroOptions(options); } @Override public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {<FILL_FUNCTION_BODY>} private void render(Macro node, NodeRendererContext context, HtmlWriter html) { if (options.enableRendering) { html.text(Node.spanningChars(node.getOpeningMarker(), node.getClosingMarker())); context.renderChildren(node); } } private void render(MacroAttribute node, NodeRendererContext context, HtmlWriter html) { } private void render(MacroClose node, NodeRendererContext context, HtmlWriter html) { if (options.enableRendering) html.text(Node.spanningChars(node.getOpeningMarker(), node.getClosingMarker())); } private void render(MacroBlock node, NodeRendererContext context, HtmlWriter html) { if (options.enableRendering) context.renderChildren(node); } public static class Factory implements NodeRendererFactory { @NotNull @Override public NodeRenderer apply(@NotNull DataHolder options) { return new MacroNodeRenderer(options); } } }
HashSet<NodeRenderingHandler<?>> set = new HashSet<>(); set.add(new NodeRenderingHandler<>(Macro.class, this::render)); set.add(new NodeRenderingHandler<>(MacroAttribute.class, this::render)); set.add(new NodeRenderingHandler<>(MacroClose.class, this::render)); set.add(new NodeRenderingHandler<>(MacroBlock.class, this::render)); return set;
344
118
462
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterNode.java
YamlFrontMatterNode
getValuesSequences
class YamlFrontMatterNode extends Node { private BasedSequence key; //private List<BasedSequence> values; @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { key }; } public YamlFrontMatterNode(BasedSequence key, List<BasedSequence> values) { this.key = key; //this.values = values; for (BasedSequence value : values) { appendChild(new YamlFrontMatterValue(value)); } } public String getKey() { return key.toString(); } public BasedSequence getKeySequence() { return key; } public void setKey(BasedSequence key) { this.key = key; } public List<String> getValues() { ArrayList<String> list = new ArrayList<>(); Node child = getFirstChild(); while (child != null) { list.add(child.getChars().toString()); child = child.getNext(); } return list; } public List<BasedSequence> getValuesSequences() {<FILL_FUNCTION_BODY>} }
ArrayList<BasedSequence> list = new ArrayList<>(); Node child = getFirstChild(); while (child != null) { list.add(child.getChars()); child = child.getNext(); } return list;
306
64
370
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void appendChain(@NotNull Node) ,public void appendChild(com.vladsch.flexmark.util.ast.Node) ,public static void astChars(@NotNull StringBuilder, @NotNull CharSequence, @NotNull String) ,public void astExtraChars(@NotNull StringBuilder) ,public void astString(@NotNull StringBuilder, boolean) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int, int) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int) ,public transient int countAncestorsOfType(@NotNull Class<?> []) ,public transient int countDirectAncestorsOfType(@Nullable Class<?>, @NotNull Class<?> []) ,public static void delimitedSegmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public static void delimitedSegmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public int endOfLine(int) ,public void extractChainTo(@NotNull Node) ,public void extractToFirstInChain(@NotNull Node) ,public transient @Nullable Node getAncestorOfType(@NotNull Class<?> []) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.sequence.BasedSequence getBaseSequence() ,public @NotNull Node getBlankLineSibling() ,public @NotNull BasedSequence getChars() ,public @NotNull BasedSequence getCharsFromSegments() ,public com.vladsch.flexmark.util.sequence.BasedSequence getChildChars() ,public @NotNull ReversiblePeekingIterator<Node> getChildIterator() ,public transient @Nullable Node getChildOfType(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterable<Node> getChildren() ,public @NotNull ReversiblePeekingIterable<Node> getDescendants() ,public @NotNull Document getDocument() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptyPrefix() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptySuffix() ,public int getEndLineNumber() ,public int getEndOfLine() ,public int getEndOffset() ,public com.vladsch.flexmark.util.sequence.BasedSequence getExactChildChars() ,public @Nullable Node getFirstChild() ,public transient @Nullable Node getFirstChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getFirstChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getFirstInChain() ,public @Nullable Node getGrandParent() ,public @Nullable Node getLastBlankLineChild() ,public @Nullable Node getLastChild() ,public transient @Nullable Node getLastChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getLastChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getLastInChain() ,public static @NotNull BasedSequence getLeadSegment(@NotNull BasedSequence []) ,public Pair<java.lang.Integer,java.lang.Integer> getLineColumnAtEnd() ,public int getLineNumber() ,public @Nullable Node getNext() ,public transient @Nullable Node getNextAny(@NotNull Class<?> []) ,public transient @Nullable Node getNextAnyNot(@NotNull Class<?> []) ,public @NotNull String getNodeName() ,public static transient int getNodeOfTypeIndex(@NotNull Node, @NotNull Class<?> []) ,public transient int getNodeOfTypeIndex(@NotNull Class<?> []) ,public @Nullable Node getOldestAncestorOfTypeAfter(@NotNull Class<?>, @NotNull Class<?>) ,public @Nullable Node getParent() ,public @Nullable Node getPrevious() ,public transient @Nullable Node getPreviousAny(@NotNull Class<?> []) ,public transient @Nullable Node getPreviousAnyNot(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterator<Node> getReversedChildIterator() ,public @NotNull ReversiblePeekingIterable<Node> getReversedChildren() ,public @NotNull ReversiblePeekingIterable<Node> getReversedDescendants() ,public abstract @NotNull BasedSequence [] getSegments() ,public @NotNull BasedSequence [] getSegmentsForChars() ,public com.vladsch.flexmark.util.sequence.Range getSourceRange() ,public int getStartLineNumber() ,public int getStartOfLine() ,public int getStartOffset() ,public int getTextLength() ,public static @NotNull BasedSequence getTrailSegment(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public boolean hasChildren() ,public boolean hasOrMoreChildren(int) ,public void insertAfter(@NotNull Node) ,public void insertBefore(com.vladsch.flexmark.util.ast.Node) ,public void insertChainAfter(@NotNull Node) ,public void insertChainBefore(@NotNull Node) ,public transient boolean isOrDescendantOfType(@NotNull Class<?> []) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtIndex(int) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtStart() ,public void moveTrailingBlankLines() ,public void prependChild(@NotNull Node) ,public void removeChildren() ,public static void segmentSpan(@NotNull StringBuilder, int, int, @Nullable String) ,public static void segmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @Nullable String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String, @NotNull String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public static void segmentSpanCharsToVisible(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public void setChars(@NotNull BasedSequence) ,public void setCharsFromContent() ,public void setCharsFromContentOnly() ,public void setCharsFromSegments() ,public static transient @NotNull BasedSequence spanningChars(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public int startOfLine(int) ,public void takeChildren(@NotNull Node) ,public @NotNull String toAstString(boolean) ,public static @NotNull String toSegmentSpan(@NotNull BasedSequence, @Nullable String) ,public java.lang.String toString() ,public void unlink() <variables>public static final AstNode<com.vladsch.flexmark.util.ast.Node> AST_ADAPTER,public static final com.vladsch.flexmark.util.sequence.BasedSequence[] EMPTY_SEGMENTS,public static final java.lang.String SPLICE,private @NotNull BasedSequence chars,@Nullable Node firstChild,private @Nullable Node lastChild,@Nullable Node next,private @Nullable Node parent,private @Nullable Node prev
vsch_flexmark-java
flexmark-java/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/YamlFrontMatterVisitorExt.java
YamlFrontMatterVisitorExt
VISIT_HANDLERS
class YamlFrontMatterVisitorExt { public static <V extends YamlFrontMatterVisitor> VisitHandler<?>[] VISIT_HANDLERS(V visitor) {<FILL_FUNCTION_BODY>} }
return new VisitHandler<?>[] { new VisitHandler<>(YamlFrontMatterNode.class, visitor::visit), new VisitHandler<>(YamlFrontMatterBlock.class, visitor::visit), };
61
61
122
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterBlockParser.java
YamlFrontMatterBlockParser
tryContinue
class YamlFrontMatterBlockParser extends AbstractBlockParser { final private static Pattern REGEX_METADATA = Pattern.compile("^[ ]{0,3}([A-Za-z0-9_\\-.]+):\\s*(.*)"); final private static Pattern REGEX_METADATA_LIST = Pattern.compile("^[ ]+-\\s*(.*)"); final private static Pattern REGEX_METADATA_LITERAL = Pattern.compile("^\\s*(.*)"); final private static Pattern REGEX_BEGIN = Pattern.compile("^-{3}(\\s.*)?"); final private static Pattern REGEX_END = Pattern.compile("^(-{3}|\\.{3})(\\s.*)?"); private boolean inYAMLBlock; private boolean inLiteral; private BasedSequence currentKey; private List<BasedSequence> currentValues; private YamlFrontMatterBlock block; private BlockContent content; public YamlFrontMatterBlockParser() { inYAMLBlock = true; inLiteral = false; currentKey = null; currentValues = new ArrayList<>(); block = new YamlFrontMatterBlock(); content = new BlockContent(); } @Override public Block getBlock() { return block; } @Override public boolean isContainer() { return false; } @Override public void addLine(ParserState state, BasedSequence line) { content.add(line, state.getIndent()); } @Override public void closeBlock(ParserState state) { block.setContent(content.getLines().subList(0, content.getLineCount())); block.setCharsFromContent(); content = null; } @Override public BlockContinue tryContinue(ParserState state) {<FILL_FUNCTION_BODY>} @Override public void parseInlines(InlineParser inlineParser) { } public static class Factory implements CustomBlockParserFactory { @Nullable @Override public Set<Class<?>> getAfterDependents() { return null; } @Nullable @Override public Set<Class<?>> getBeforeDependents() { return null; } @Override public boolean affectsGlobalScope() { return false; } @NotNull @Override public BlockParserFactory apply(@NotNull DataHolder options) { return new BlockFactory(options); } } private static class BlockFactory extends AbstractBlockParserFactory { private BlockFactory(DataHolder options) { super(options); } @Override public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) { CharSequence line = state.getLine(); BlockParser parentParser = matchedBlockParser.getBlockParser(); // check whether this line is the first line of whole document or not if (parentParser instanceof DocumentBlockParser && parentParser.getBlock().getFirstChild() == null && REGEX_BEGIN.matcher(line).matches()) { return BlockStart.of(new YamlFrontMatterBlockParser()).atIndex(state.getNextNonSpaceIndex()); } return BlockStart.none(); } } }
final BasedSequence line = state.getLine(); if (inYAMLBlock) { if (REGEX_END.matcher(line).matches()) { if (currentKey != null) { YamlFrontMatterNode child = new YamlFrontMatterNode(currentKey, currentValues); child.setCharsFromContent(); block.appendChild(child); } // add the last line addLine(state, line); return BlockContinue.finished(); } Matcher matcher = REGEX_METADATA.matcher(line); if (matcher.matches()) { if (currentKey != null) { YamlFrontMatterNode child = new YamlFrontMatterNode(currentKey, currentValues); child.setCharsFromContent(); block.appendChild(child); } inLiteral = false; currentKey = line.subSequence(matcher.start(1), matcher.end(1)); currentValues = new ArrayList<>(); if ("|".equals(matcher.group(2))) { inLiteral = true; } else if (!"".equals(matcher.group(2))) { currentValues.add(line.subSequence(matcher.start(2), matcher.end(2))); } return BlockContinue.atIndex(state.getIndex()); } else { if (inLiteral) { matcher = REGEX_METADATA_LITERAL.matcher(line); if (matcher.matches()) { if (currentValues.size() == 1) { BasedSequence combined = SegmentedSequence.create(currentValues.get(0), PrefixedSubSequence.prefixOf("\n", line.subSequence(matcher.start(1), matcher.end(1)).trim())); currentValues.set(0, combined); } else { currentValues.add(line.subSequence(matcher.start(1), matcher.end(1)).trim()); } } } else { matcher = REGEX_METADATA_LIST.matcher(line); if (matcher.matches()) { currentValues.add(line.subSequence(matcher.start(1), matcher.end(1))); } } return BlockContinue.atIndex(state.getIndex()); } } else if (REGEX_BEGIN.matcher(line).matches()) { inYAMLBlock = true; return BlockContinue.atIndex(state.getIndex()); } return BlockContinue.none();
846
658
1,504
<methods>public non-sealed void <init>() ,public void addLine(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.util.sequence.BasedSequence) ,public boolean breakOutOnDoubleBlankLine() ,public boolean canContain(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.parser.block.BlockParser, com.vladsch.flexmark.util.ast.Block) ,public boolean canInterruptBy(com.vladsch.flexmark.parser.block.BlockParserFactory) ,public final void finalizeClosedBlock() ,public com.vladsch.flexmark.util.ast.BlockContent getBlockContent() ,public com.vladsch.flexmark.util.data.MutableDataHolder getDataHolder() ,public boolean isClosed() ,public boolean isContainer() ,public boolean isInterruptible() ,public boolean isParagraphParser() ,public boolean isPropagatingLastBlankLine(com.vladsch.flexmark.parser.block.BlockParser) ,public boolean isRawText() ,public void parseInlines(com.vladsch.flexmark.parser.InlineParser) ,public void removeBlankLines() <variables>private boolean isClosed,private com.vladsch.flexmark.util.data.MutableDataSet mutableData
vsch_flexmark-java
flexmark-java/flexmark-ext-yaml-front-matter/src/main/java/com/vladsch/flexmark/ext/yaml/front/matter/internal/YamlFrontMatterNodeFormatter.java
YamlFrontMatterNodeFormatter
renderDocument
class YamlFrontMatterNodeFormatter implements PhasedNodeFormatter { public YamlFrontMatterNodeFormatter(DataHolder options) { } @Nullable @Override public Set<FormattingPhase> getFormattingPhases() { return new HashSet<>(Collections.singleton(FormattingPhase.DOCUMENT_FIRST)); } @Nullable @Override public Set<Class<?>> getNodeClasses() { return null; } @Override public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase) {<FILL_FUNCTION_BODY>} @Nullable @Override public Set<NodeFormattingHandler<?>> getNodeFormattingHandlers() { return new HashSet<>(Collections.singletonList( new NodeFormattingHandler<>(YamlFrontMatterBlock.class, YamlFrontMatterNodeFormatter.this::render) )); } private void render(YamlFrontMatterBlock node, NodeFormatterContext context, MarkdownWriter markdown) { } public static class Factory implements NodeFormatterFactory { @NotNull @Override public NodeFormatter create(@NotNull DataHolder options) { return new YamlFrontMatterNodeFormatter(options); } } }
if (phase == FormattingPhase.DOCUMENT_FIRST) { Node node = document.getFirstChild(); if (node instanceof YamlFrontMatterBlock) { markdown.openPreFormatted(false); markdown.append(node.getChars()).blankLine(); markdown.closePreFormatted(); } }
353
93
446
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/YouTubeLink.java
YouTubeLink
setTextChars
class YouTubeLink extends InlineLinkNode { public YouTubeLink() { } public YouTubeLink(Link other) { super(other.baseSubSequence(other.getStartOffset() - 1, other.getEndOffset()), other.baseSubSequence(other.getStartOffset() - 1, other.getTextOpeningMarker().getEndOffset()), other.getText(), other.getTextClosingMarker(), other.getLinkOpeningMarker(), other.getUrl(), other.getTitleOpeningMarker(), other.getTitle(), other.getTitleClosingMarker(), other.getLinkClosingMarker() ); } @Override public void setTextChars(BasedSequence textChars) {<FILL_FUNCTION_BODY>} }
int textCharsLength = textChars.length(); this.textOpeningMarker = textChars.subSequence(0, 1); this.text = textChars.subSequence(1, textCharsLength - 1).trim(); this.textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength);
196
92
288
<methods>public void <init>() ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence) ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence) ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence) ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.sequence.BasedSequence getLinkClosingMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getLinkOpeningMarker() ,public @NotNull BasedSequence [] getSegments() ,public @NotNull BasedSequence [] getSegmentsForChars() ,public com.vladsch.flexmark.util.sequence.BasedSequence getText() ,public com.vladsch.flexmark.util.sequence.BasedSequence getTextClosingMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getTextOpeningMarker() ,public void setLinkClosingMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setLinkOpeningMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setText(com.vladsch.flexmark.util.sequence.BasedSequence) ,public abstract void setTextChars(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTextClosingMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTextOpeningMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setUrl(com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence, com.vladsch.flexmark.util.sequence.BasedSequence) <variables>protected com.vladsch.flexmark.util.sequence.BasedSequence linkClosingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence linkOpeningMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence text,protected com.vladsch.flexmark.util.sequence.BasedSequence textClosingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence textOpeningMarker
vsch_flexmark-java
flexmark-java/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/YouTubeLinkExtension.java
YouTubeLinkExtension
extend
class YouTubeLinkExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension { private YouTubeLinkExtension() { } public static YouTubeLinkExtension create() { return new YouTubeLinkExtension(); } @Override public void extend(Parser.Builder parserBuilder) { parserBuilder.postProcessorFactory(new YouTubeLinkNodePostProcessor.Factory(parserBuilder)); } @Override public void rendererOptions(@NotNull MutableDataHolder options) { } @Override public void parserOptions(MutableDataHolder options) { } @Override public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) {<FILL_FUNCTION_BODY>} }
if (htmlRendererBuilder.isRendererType("HTML")) { htmlRendererBuilder.nodeRendererFactory(new YouTubeLinkNodeRenderer.Factory()); } else if (htmlRendererBuilder.isRendererType("JIRA")) { }
186
58
244
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodePostProcessor.java
YouTubeLinkNodePostProcessor
process
class YouTubeLinkNodePostProcessor extends NodePostProcessor { public YouTubeLinkNodePostProcessor(DataHolder options) { } @Override public void process(@NotNull NodeTracker state, @NotNull Node node) {<FILL_FUNCTION_BODY>} public static class Factory extends NodePostProcessorFactory { public Factory(DataHolder options) { super(false); addNodes(Link.class); } @NotNull @Override public NodePostProcessor apply(@NotNull Document document) { return new YouTubeLinkNodePostProcessor(document); } } }
if (node instanceof Link) { Node previous = node.getPrevious(); if (previous instanceof Text) { BasedSequence chars = previous.getChars(); if (chars.endsWith("@") && chars.isContinuedBy(node.getChars())) { int prevBackslash = chars.subSequence(0, chars.length() - 1).countTrailing(CharPredicate.BACKSLASH); if ((prevBackslash & 1) == 0) { // trim previous chars to remove '@' previous.setChars(chars.subSequence(0, chars.length() - 1)); YouTubeLink youTubeLink = new YouTubeLink((Link) node); youTubeLink.takeChildren(node); node.unlink(); previous.insertAfter(youTubeLink); state.nodeRemoved(node); state.nodeAddedWithChildren(youTubeLink); } } } }
149
243
392
<methods>public non-sealed void <init>() ,public final @NotNull Document processDocument(@NotNull Document) <variables>
vsch_flexmark-java
flexmark-java/flexmark-ext-youtube-embedded/src/main/java/com/vladsch/flexmark/ext/youtube/embedded/internal/YouTubeLinkNodeRenderer.java
YouTubeLinkNodeRenderer
render
class YouTubeLinkNodeRenderer implements NodeRenderer { public YouTubeLinkNodeRenderer(DataHolder options) { } @Override public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() { HashSet<NodeRenderingHandler<?>> set = new HashSet<>(); set.add(new NodeRenderingHandler<>(YouTubeLink.class, this::render)); return set; } private void render(YouTubeLink node, NodeRendererContext context, HtmlWriter html) {<FILL_FUNCTION_BODY>} public static class Factory implements NodeRendererFactory { @NotNull @Override public NodeRenderer apply(@NotNull DataHolder options) { return new YouTubeLinkNodeRenderer(options); } } }
if (context.isDoNotRenderLinks()) { context.renderChildren(node); } else { // standard Link Rendering ResolvedLink resolvedLink = context.resolveLink(LinkType.LINK, node.getUrl().unescape(), null); URL url = null; try { url = new URL(resolvedLink.getUrl()); } catch (MalformedURLException e) { } if (url != null && "youtu.be".equalsIgnoreCase(url.getHost())) { html.attr("src", "https://www.youtube-nocookie.com/embed" + url.getFile().replace("?t=", "?start=")); html.attr("width", "560"); html.attr("height", "315"); html.attr("class", "youtube-embedded"); html.attr("allowfullscreen", "true"); html.attr("frameborder", "0"); html.attr("allow", "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"); html.srcPos(node.getChars()).withAttr(resolvedLink).tag("iframe"); html.tag("/iframe"); } else if (resolvedLink.getUrl().contains("www.youtube.com/watch")) { html.attr("src", resolvedLink.getUrl().replace("watch?v=".toLowerCase(), "embed/")); html.attr("width", "420"); html.attr("height", "315"); html.attr("class", "youtube-embedded"); html.attr("allowfullscreen", "true"); html.attr("frameborder", "0"); html.srcPos(node.getChars()).withAttr(resolvedLink).tag("iframe"); //context.renderChildren(node); html.tag("/iframe"); } else { html.attr("href", resolvedLink.getUrl()); if (node.getTitle().isNotNull()) { html.attr("title", node.getTitle().unescape()); } html.srcPos(node.getChars()).withAttr(resolvedLink).tag("a"); context.renderChildren(node); html.tag("/a"); } }
189
569
758
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzBlock.java
ZzzzzzBlock
getAstExtra
class ZzzzzzBlock extends Block { protected BasedSequence openingMarker = BasedSequence.NULL; protected BasedSequence text = BasedSequence.NULL; protected BasedSequence closingMarker = BasedSequence.NULL; protected BasedSequence zzzzzz = BasedSequence.NULL; private int zzzzzzOrdinal = 0; private int firstReferenceOffset = Integer.MAX_VALUE; public int getFirstReferenceOffset() { return firstReferenceOffset; } public void setFirstReferenceOffset(int firstReferenceOffset) { this.firstReferenceOffset = firstReferenceOffset; } public void addFirstReferenceOffset(int firstReferenceOffset) { if (this.firstReferenceOffset < firstReferenceOffset) this.firstReferenceOffset = firstReferenceOffset; } public boolean isReferenced() { return this.firstReferenceOffset < Integer.MAX_VALUE; } public int getZzzzzzOrdinal() { return zzzzzzOrdinal; } public void setZzzzzzOrdinal(int zzzzzzOrdinal) { this.zzzzzzOrdinal = zzzzzzOrdinal; } @Override public void getAstExtra(@NotNull StringBuilder out) {<FILL_FUNCTION_BODY>} @NotNull @Override public BasedSequence[] getSegments() { return new BasedSequence[] { openingMarker, text, closingMarker, zzzzzz }; } public ZzzzzzBlock() { } public ZzzzzzBlock(BasedSequence chars) { super(chars); } public ZzzzzzBlock(Node node) { super(); appendChild(node); this.setCharsFromContent(); } public BasedSequence getOpeningMarker() { return openingMarker; } public void setOpeningMarker(BasedSequence openingMarker) { this.openingMarker = openingMarker; } public BasedSequence getText() { return text; } public void setText(BasedSequence text) { this.text = text; } public BasedSequence getClosingMarker() { return closingMarker; } public void setClosingMarker(BasedSequence closingMarker) { this.closingMarker = closingMarker; } public BasedSequence getZzzzzz() { return zzzzzz; } public void setZzzzzz(BasedSequence zzzzzz) { this.zzzzzz = zzzzzz; } }
out.append(" ordinal: ").append(zzzzzzOrdinal).append(" "); segmentSpan(out, openingMarker, "open"); segmentSpan(out, text, "text"); segmentSpan(out, closingMarker, "close"); segmentSpan(out, zzzzzz, "zzzzzz");
648
81
729
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void <init>(@NotNull BasedSequence, @NotNull List<BasedSequence>) ,public void <init>(@NotNull List<BasedSequence>) ,public void <init>(com.vladsch.flexmark.util.ast.BlockContent) ,public @Nullable Block getParent() <variables>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzExtension.java
ZzzzzzExtension
extend
class ZzzzzzExtension implements Parser.ParserExtension , HtmlRenderer.HtmlRendererExtension // zzzoptionszzz(NODE_RENDERER, PHASED_NODE_RENDERER) , Parser.ReferenceHoldingExtension //zzzoptionszzz(CUSTOM_NODE_REPOSITORY) { final public static DataKey<KeepType> ZZZZZZS_KEEP = new DataKey<>("ZZZZZZS_KEEP", KeepType.FIRST); //zzzoptionszzz(CUSTOM_NODE_REPOSITORY) standard option to allow control over how to handle duplicates final public static DataKey<ZzzzzzRepository> ZZZZZZS = new DataKey<>("ZZZZZZS", new ZzzzzzRepository(null), ZzzzzzRepository::new); //zzzoptionszzz(CUSTOM_NODE_REPOSITORY) final public static DataKey<Boolean> ZZZZZZ_OPTION1 = new DataKey<>("ZZZZZZ_OPTION1", false); //zzzoptionszzz(CUSTOM_PROPERTIES) final public static DataKey<String> ZZZZZZ_OPTION2 = new DataKey<>("ZZZZZZ_OPTION2", "default"); //zzzoptionszzz(CUSTOM_PROPERTIES) final public static DataKey<Integer> ZZZZZZ_OPTION3 = new DataKey<>("ZZZZZZ_OPTION3", Integer.MAX_VALUE); //zzzoptionszzz(CUSTOM_PROPERTIES) final public static DataKey<String> LOCAL_ONLY_TARGET_CLASS = new DataKey<>("LOCAL_ONLY_TARGET_CLASS", "local-only");//zzzoptionszzz(LINK_RESOLVER, ATTRIBUTE_PROVIDER) final public static DataKey<String> MISSING_TARGET_CLASS = new DataKey<>("MISSING_TARGET_CLASS", "absent");//zzzoptionszzz(LINK_RESOLVER, ATTRIBUTE_PROVIDER) final public static LinkStatus LOCAL_ONLY = new LinkStatus("LOCAL_ONLY"); private ZzzzzzExtension() { } public static ZzzzzzExtension create() { return new ZzzzzzExtension(); } @Override public void rendererOptions(@NotNull MutableDataHolder options) { } @Override public void parserOptions(MutableDataHolder options) { } @Override public boolean transferReferences(MutableDataHolder document, DataHolder included) { if (document.contains(ZZZZZZS) && included.contains(ZZZZZZS)) { return Parser.transferReferences(ZZZZZZS.get(document), ZZZZZZS.get(included), ZZZZZZS_KEEP.get(document) == KeepType.FIRST); } return false; } @Override public void extend(Parser.Builder parserBuilder) {<FILL_FUNCTION_BODY>} @Override public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull 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) htmlRendererBuilder.attributeProviderFactory(new ZzzzzzAttributeProvider.Factory());// zzzoptionszzz(ATTRIBUTE_PROVIDER, NODE_RENDERER, PHASED_NODE_RENDERER) } else if (htmlRendererBuilder.isRendererType("JIRA")) { htmlRendererBuilder.nodeRendererFactory(new ZzzzzzJiraRenderer.Factory());// zzzoptionszzz(NODE_RENDERER, PHASED_NODE_RENDERER) htmlRendererBuilder.linkResolverFactory(new ZzzzzzLinkResolver.Factory());// zzzoptionszzz(LINK_RESOLVER, NODE_RENDERER, PHASED_NODE_RENDERER) htmlRendererBuilder.attributeProviderFactory(new ZzzzzzAttributeProvider.Factory());// zzzoptionszzz(ATTRIBUTE_PROVIDER, NODE_RENDERER, PHASED_NODE_RENDERER) } } }
// zzzoptionszzz(REMOVE, BLOCK_PARSER) // zzzoptionszzz(BLOCK_PRE_PROCESSOR) // zzzoptionszzz(REMOVE, DELIMITER_PROCESSOR) // zzzoptionszzz(REMOVE, LINK_REF_PROCESSOR) // zzzoptionszzz(NODE_RENDERER) // zzzoptionszzz(LINK_RESOLVER) // zzzoptionszzz(CUSTOM_PROPERTIES) // zzzoptionszzz(PARAGRAPH_PRE_PROCESSOR) // zzzoptionszzz(DOCUMENT_POST_PROCESSOR) // zzzoptionszzz(NODE_POST_PROCESSOR) // zzzoptionszzz(CUSTOM_NODE_REPOSITORY) // zzzoptionszzz(CUSTOM_NODE) // zzzoptionszzz(CUSTOM_BLOCK_NODE) parserBuilder.customBlockParserFactory(new ZzzzzzBlockParser.Factory());//zzzoptionszzz(REMOVE, BLOCK_PARSER) parserBuilder.paragraphPreProcessorFactory(ZzzzzzParagraphPreProcessor.Factory());//zzzoptionszzz(REMOVE, PARAGRAPH_PRE_PROCESSOR) parserBuilder.blockPreProcessorFactory(new ZzzzzzBlockPreProcessor.Factory());//zzzoptionszzz(REMOVE, BLOCK_PRE_PROCESSOR) parserBuilder.customDelimiterProcessor(new ZzzzzzDelimiterProcessor());//zzzoptionszzz(REMOVE, DELIMITER_PROCESSOR) parserBuilder.linkRefProcessorFactory(new ZzzzzzLinkRefProcessor.Factory());//zzzoptionszzz(REMOVE, LINK_REF_PROCESSOR) parserBuilder.postProcessorFactory(new ZzzzzzNodePostProcessor.Factory());//zzzoptionszzz(REMOVE, NODE_POST_PROCESSOR) parserBuilder.postProcessorFactory(new ZzzzzzDocumentPostProcessor.Factory());//zzzoptionszzz(REMOVE, DOCUMENT_POST_PROCESSOR) parserBuilder.customInlineParserExtensionFactory(new ZzzzzzInlineParserExtension.Factory());//zzzoptionszzz(REMOVE, INLINE_PARSER_EXTENSION)
1,123
577
1,700
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/ZzzzzzVisitorExt.java
ZzzzzzVisitorExt
VISIT_HANDLERS
class ZzzzzzVisitorExt { public static <V extends ZzzzzzVisitor> VisitHandler<?>[] VISIT_HANDLERS(V visitor) {<FILL_FUNCTION_BODY>} }
return new VisitHandler<?>[] { new VisitHandler<>(Zzzzzz.class, visitor::visit),// zzzoptionszzz(CUSTOM_NODE) new VisitHandler<>(ZzzzzzBlock.class, visitor::visit),// zzzoptionszzz(CUSTOM_BLOCK_NODE) };
57
85
142
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzAttributeProvider.java
ZzzzzzAttributeProvider
setLinkAttributes
class ZzzzzzAttributeProvider implements AttributeProvider { final private String missingTargetClass; final private String localOnlyTargetClass; final private AttributeProviderAdapter nodeAdapter; public ZzzzzzAttributeProvider(LinkResolverContext context) { DataHolder options = context.getOptions(); this.localOnlyTargetClass = ZzzzzzExtension.LOCAL_ONLY_TARGET_CLASS.get(options); this.missingTargetClass = ZzzzzzExtension.MISSING_TARGET_CLASS.get(options); this.nodeAdapter = new AttributeProviderAdapter( new AttributeProvidingHandler<>(Image.class, this::setLinkAttributes), new AttributeProvidingHandler<>(ImageRef.class, this::setLinkAttributes), new AttributeProvidingHandler<>(LinkRef.class, this::setLinkAttributes), new AttributeProvidingHandler<>(Link.class, this::setLinkAttributes) ); } @Override public void setAttributes(@NotNull Node node, @NotNull AttributablePart part, @NotNull MutableAttributes attributes) { nodeAdapter.setAttributes(node, part, attributes); } private void setLinkAttributes(LinkNode node, AttributablePart part, MutableAttributes attributes) { setLinkAttributes(part, attributes); } private void setLinkAttributes(RefNode node, AttributablePart part, MutableAttributes attributes) { setLinkAttributes(part, attributes); } private void setLinkAttributes(AttributablePart part, MutableAttributes attributes) {<FILL_FUNCTION_BODY>} public static class Factory extends IndependentAttributeProviderFactory { //@Override //public Set<Class<?>> getAfterDependents() { // return null; //} // //@Override //public Set<Class<?>> getBeforeDependents() { // return null; //} // //@Override //public boolean affectsGlobalScope() { // return false; //} @NotNull @Override public AttributeProvider apply(@NotNull LinkResolverContext context) { return new ZzzzzzAttributeProvider(context); } } }
if (part == LINK) { String linkStatus = attributes.getValue(LINK_STATUS_ATTR); if (LinkStatus.NOT_FOUND.isStatus(linkStatus)) { attributes.addValue("class", missingTargetClass); } else if (ZzzzzzExtension.LOCAL_ONLY.isStatus(linkStatus)) { attributes.addValue("class", localOnlyTargetClass); } }
545
108
653
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockParser.java
Factory
getAfterDependents
class Factory implements CustomBlockParserFactory { @Nullable @Override public Set<Class<?>> getAfterDependents() {<FILL_FUNCTION_BODY>} @Nullable @Override public Set<Class<?>> getBeforeDependents() { return null; //return new HashSet<>(Arrays.asList( // BlockQuoteParser.Factory.class, // HeadingParser.Factory.class, // FencedCodeBlockParser.Factory.class, // HtmlBlockParser.Factory.class, // ThematicBreakParser.Factory.class, // ListBlockParser.Factory.class, // IndentedCodeBlockParser.Factory.class //)); } @Override public boolean affectsGlobalScope() { return false; } @NotNull @Override public BlockParserFactory apply(@NotNull DataHolder options) { return new BlockFactory(options); } }
return null; //return new HashSet<>(Arrays.asList( // BlockQuoteParser.Factory.class, // HeadingParser.Factory.class, // FencedCodeBlockParser.Factory.class, // HtmlBlockParser.Factory.class, // ThematicBreakParser.Factory.class, // ListBlockParser.Factory.class, // IndentedCodeBlockParser.Factory.class //));
245
117
362
<methods>public non-sealed void <init>() ,public void addLine(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.util.sequence.BasedSequence) ,public boolean breakOutOnDoubleBlankLine() ,public boolean canContain(com.vladsch.flexmark.parser.block.ParserState, com.vladsch.flexmark.parser.block.BlockParser, com.vladsch.flexmark.util.ast.Block) ,public boolean canInterruptBy(com.vladsch.flexmark.parser.block.BlockParserFactory) ,public final void finalizeClosedBlock() ,public com.vladsch.flexmark.util.ast.BlockContent getBlockContent() ,public com.vladsch.flexmark.util.data.MutableDataHolder getDataHolder() ,public boolean isClosed() ,public boolean isContainer() ,public boolean isInterruptible() ,public boolean isParagraphParser() ,public boolean isPropagatingLastBlankLine(com.vladsch.flexmark.parser.block.BlockParser) ,public boolean isRawText() ,public void parseInlines(com.vladsch.flexmark.parser.InlineParser) ,public void removeBlankLines() <variables>private boolean isClosed,private com.vladsch.flexmark.util.data.MutableDataSet mutableData
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzBlockPreProcessor.java
Factory
getBlockTypes
class Factory implements BlockPreProcessorFactory { @NotNull @Override public Set<Class<? extends Block>> getBlockTypes() {<FILL_FUNCTION_BODY>} @Nullable @Override public Set<Class<?>> getAfterDependents() { return null; } @Nullable @Override public Set<Class<?>> getBeforeDependents() { return null; } @Override public boolean affectsGlobalScope() { return true; } @NotNull @Override public BlockPreProcessor apply(@NotNull ParserState state) { return new ZzzzzzBlockPreProcessor(state.getProperties()); } }
HashSet<Class<? extends Block>> set = new HashSet<>(); set.add(Heading.class); return set;
178
37
215
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzDelimiterProcessor.java
ZzzzzzDelimiterProcessor
getDelimiterUse
class ZzzzzzDelimiterProcessor implements DelimiterProcessor { @Override public char getOpeningCharacter() { return ':'; } @Override public char getClosingCharacter() { return ':'; } @Override public int getMinLength() { return 1; } @Override public boolean canBeOpener(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace) { return leftFlanking; } @Override public boolean canBeCloser(String before, String after, boolean leftFlanking, boolean rightFlanking, boolean beforeIsPunctuation, boolean afterIsPunctuation, boolean beforeIsWhitespace, boolean afterIsWhiteSpace) { return rightFlanking; } @Override public boolean skipNonOpenerCloser() { return false; } @Override public int getDelimiterUse(DelimiterRun opener, DelimiterRun closer) {<FILL_FUNCTION_BODY>} @Override public Node unmatchedDelimiterNode(InlineParser inlineParser, DelimiterRun delimiter) { return null; } @Override public void process(Delimiter opener, Delimiter closer, int delimitersUsed) { // Normal case, wrap nodes between delimiters in strikethrough. Zzzzzz zzzzzz = new Zzzzzz(opener.getTailChars(delimitersUsed), BasedSequence.NULL, closer.getLeadChars(delimitersUsed)); opener.moveNodesBetweenDelimitersTo(zzzzzz, closer); } }
if (opener.length() >= 1 && closer.length() >= 1) { return 1; } else { return 0; }
455
43
498
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzDocumentPostProcessor.java
ZzzzzzDocumentPostProcessor
visit
class ZzzzzzDocumentPostProcessor extends DocumentPostProcessor { final private NodeVisitor myVisitor; public ZzzzzzDocumentPostProcessor(Document document) { myVisitor = new NodeVisitor( new VisitHandler<>(Text.class, this::visit) ); } @NotNull @Override public Document processDocument(@NotNull Document document) { myVisitor.visit(document); return document; } private void visit(Text node) {<FILL_FUNCTION_BODY>} public static class Factory extends DocumentPostProcessorFactory { @NotNull @Override public DocumentPostProcessor apply(@NotNull Document document) { return new ZzzzzzDocumentPostProcessor(document); } } }
if (!node.isOrDescendantOfType(DoNotDecorate.class)) { // do some processing BasedSequence original = node.getChars(); boolean wrapInTextBase = !(node.getParent() instanceof TextBase); TextBase textBase = null; while (wrapInTextBase) { if (wrapInTextBase) { wrapInTextBase = false; textBase = new TextBase(original); node.insertBefore(textBase); textBase.appendChild(node); } } }
193
142
335
<methods>public non-sealed void <init>() ,public final void process(@NotNull NodeTracker, @NotNull Node) <variables>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzInlineParserExtension.java
ZzzzzzInlineParserExtension
finalizeBlock
class ZzzzzzInlineParserExtension implements InlineParserExtension { private List<Zzzzzz> openZzzzzzs; public ZzzzzzInlineParserExtension(LightInlineParser inlineParser) { this.openZzzzzzs = new ArrayList<>(); } @Override public void finalizeDocument(@NotNull InlineParser inlineParser) { } @Override public void finalizeBlock(@NotNull InlineParser inlineParser) {<FILL_FUNCTION_BODY>} @Override public boolean parse(@NotNull LightInlineParser inlineParser) { return false; } public static class Factory implements InlineParserExtensionFactory { @Nullable @Override public Set<Class<?>> getAfterDependents() { return null; } @NotNull @Override public CharSequence getCharacters() { return ""; } @Nullable @Override public Set<Class<?>> getBeforeDependents() { return null; } @NotNull @Override public InlineParserExtension apply(@NotNull LightInlineParser lightInlineParser) { return new ZzzzzzInlineParserExtension(lightInlineParser); } @Override public boolean affectsGlobalScope() { return false; } } }
for (int j = openZzzzzzs.size(); j-- > 0; ) { inlineParser.moveNodes(openZzzzzzs.get(j), inlineParser.getBlock().getLastChild()); } openZzzzzzs.clear();
338
70
408
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzJiraRenderer.java
ZzzzzzJiraRenderer
getNodeRenderingHandlers
class ZzzzzzJiraRenderer implements NodeRenderer { public ZzzzzzJiraRenderer(DataHolder options) { } @Override public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {<FILL_FUNCTION_BODY>} private void render(Zzzzzz node, NodeRendererContext context, HtmlWriter html) { html.raw(""); } private void render(ZzzzzzBlock node, NodeRendererContext context, HtmlWriter html) { html.raw("{}"); html.raw(node.getText().unescape()); html.raw("{}"); } public static class Factory implements NodeRendererFactory { @NotNull @Override public NodeRenderer apply(@NotNull DataHolder options) { return new ZzzzzzJiraRenderer(options); } } }
return new HashSet<>(Arrays.asList( new NodeRenderingHandler<>(Zzzzzz.class, this::render),// zzzoptionszzz(CUSTOM_NODE) new NodeRenderingHandler<>(ZzzzzzBlock.class, this::render)// zzzoptionszzz(CUSTOM_BLOCK_NODE) ));
216
91
307
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzLinkRefProcessor.java
ZzzzzzLinkRefProcessor
adjustInlineText
class ZzzzzzLinkRefProcessor implements LinkRefProcessor { static final boolean WANT_EXCLAMATION_PREFIX = false; static final int BRACKET_NESTING_LEVEL = 1; final private ZzzzzzOptions options; public ZzzzzzLinkRefProcessor(Document document) { this.options = new ZzzzzzOptions(document); } @Override public boolean getWantExclamationPrefix() { return WANT_EXCLAMATION_PREFIX; } @Override public int getBracketNestingLevel() { return BRACKET_NESTING_LEVEL; } @Override public boolean isMatch(@NotNull 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) {<FILL_FUNCTION_BODY>} @Override public boolean allowDelimiters(@NotNull BasedSequence chars, @NotNull Document document, @NotNull Node node) { return true; } @Override public void updateNodeElements(@NotNull Document document, @NotNull Node node) { } @NotNull @Override public Node createNode(@NotNull BasedSequence nodeChars) { return new Zzzzzz(nodeChars, options.zzzzzzOption2); } public static class Factory implements LinkRefProcessorFactory { @NotNull @Override public LinkRefProcessor apply(@NotNull Document document) { return new ZzzzzzLinkRefProcessor(document); } @Override public boolean getWantExclamationPrefix(@NotNull DataHolder options) { return WANT_EXCLAMATION_PREFIX; } @Override public int getBracketNestingLevel(@NotNull DataHolder options) { return BRACKET_NESTING_LEVEL; } } }
// nothing to do, our prefixes are stripped out of a link ref return node.getChars();
545
30
575
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodePostProcessor.java
ZzzzzzNodePostProcessor
processText
class ZzzzzzNodePostProcessor extends NodePostProcessor { public ZzzzzzNodePostProcessor(Document document) { } @Override public void process(@NotNull NodeTracker state, @NotNull Node node) { } private void processText(NodeTracker state, Text node) {<FILL_FUNCTION_BODY>} public static class Factory extends NodePostProcessorFactory { public Factory() { super(false); addNodeWithExclusions(Text.class, DoNotDecorate.class/*, Heading.class*/); //addNodes(HtmlBlock.class, HtmlCommentBlock.class); } @NotNull @Override public NodePostProcessor apply(@NotNull Document document) { return new ZzzzzzNodePostProcessor(document); } } }
BasedSequence original = node.getChars(); boolean wrapInTextBase = !(node.getParent() instanceof TextBase); TextBase textBase = null; while (wrapInTextBase) { if (wrapInTextBase) { wrapInTextBase = false; textBase = new TextBase(original); node.insertBefore(textBase); textBase.appendChild(node); state.nodeAdded(textBase); } }
206
120
326
<methods>public non-sealed void <init>() ,public final @NotNull Document processDocument(@NotNull Document) <variables>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzNodeRenderer.java
ZzzzzzNodeRenderer
getNodeRenderingHandlers
class ZzzzzzNodeRenderer implements NodeRenderer , PhasedNodeRenderer // zzzoptionszzz(PHASED_NODE_RENDERER) { private static String fromChars = " +/<>"; private static String toChars = "-----"; final private ZzzzzzOptions options;// zzzoptionszzz(CUSTOM_PROPERTIES) public ZzzzzzNodeRenderer(DataHolder options) { this.options = new ZzzzzzOptions(options);// zzzoptionszzz(CUSTOM_PROPERTIES) } @Override public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {<FILL_FUNCTION_BODY>} @Override//zzzoptionszzz(REMOVE, PHASED_NODE_RENDERER) public Set<RenderingPhase> getRenderingPhases() {//zzzoptionszzz(REMOVE, PHASED_NODE_RENDERER) return new HashSet<>(Collections.singletonList(RenderingPhase.BODY_BOTTOM));//zzzoptionszzz(REMOVE, PHASED_NODE_RENDERER) }//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) }//zzzoptionszzz(REMOVE, PHASED_NODE_RENDERER) private void render(Zzzzzz node, NodeRendererContext context, HtmlWriter html) { if (options.zzzzzzOption1) html.attr("href", context.encodeUrl(options.zzzzzzOption2)); html.withAttr().tag("a"); html.text(node.getText().unescape()); html.tag("/a"); } private void render(ZzzzzzBlock node, NodeRendererContext context, HtmlWriter html) { if (options.zzzzzzOption1) html.attr("href", context.encodeUrl(options.zzzzzzOption2)); html.withAttr().tag("a"); html.text(node.getText().unescape()); html.tag("/a"); } public static class Factory implements NodeRendererFactory { @NotNull @Override public NodeRenderer apply(@NotNull DataHolder options) { return new ZzzzzzNodeRenderer(options); } } }
Set<NodeRenderingHandler<?>> set = new HashSet<>(); // @formatter:off set.add(new NodeRenderingHandler<>(Zzzzzz.class, ZzzzzzNodeRenderer.this::render));// zzzoptionszzz(CUSTOM_NODE) set.add(new NodeRenderingHandler<>(ZzzzzzBlock.class, ZzzzzzNodeRenderer.this::render));// zzzoptionszzz(CUSTOM_BLOCK_NODE),// zzzoptionszzz(CUSTOM_NODE) // @formatter:on return set;
663
147
810
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzParagraphPreProcessor.java
ZzzzzzParagraphPreProcessor
skipNext
class ZzzzzzParagraphPreProcessor implements ParagraphPreProcessor { private static String COL = "(?:" + "\\s*-{3,}\\s*|\\s*:-{2,}\\s*|\\s*-{2,}:\\s*|\\s*:-+:\\s*" + ")"; private static Pattern TABLE_HEADER_SEPARATOR = Pattern.compile( // For single column, require at least one pipe, otherwise it's ambiguous with setext headers "\\|" + COL + "\\|?\\s*" + "|" + COL + "\\|\\s*" + "|" + "\\|?" + "(?:" + COL + "\\|)+" + COL + "\\|?\\s*"); private static BitSet pipeCharacters = new BitSet(1); static { pipeCharacters.set('|'); } private static HashMap<Character, CharacterNodeFactory> pipeNodeMap = new HashMap<>(); static { pipeNodeMap.put('|', new CharacterNodeFactory() { @Override public boolean skipNext(char c) {<FILL_FUNCTION_BODY>} @Override public boolean skipPrev(char c) { return c == ' ' || c == '\t'; //return false; } @Override public boolean wantSkippedWhitespace() { return true; } @Override public Node get() { return new ZzzzzzBlock(); } }); } final private ZzzzzzOptions options; ZzzzzzParagraphPreProcessor(DataHolder options) { this.options = new ZzzzzzOptions(options); } private ZzzzzzParagraphPreProcessor(ZzzzzzOptions options) { this.options = options; } @Override public int preProcessBlock(Paragraph block, ParserState state) { //InlineParser inlineParser = state.getInlineParser(); return 0; } public static ParagraphPreProcessorFactory Factory() { return new ParagraphPreProcessorFactory() { @Override public boolean affectsGlobalScope() { return false; } @Nullable @Override public Set<Class<?>> getAfterDependents() { HashSet<Class<?>> set = new HashSet<>(); set.add(ReferencePreProcessorFactory.class); return set; } @Nullable @Override public Set<Class<?>> getBeforeDependents() { return null; } @Override public ParagraphPreProcessor apply(ParserState state) { return new ZzzzzzParagraphPreProcessor(state.getProperties()); } }; } }
return c == ' ' || c == '\t'; //return false;
695
22
717
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-ext-zzzzzz/src/main/java/com/vladsch/flexmark/ext/zzzzzz/internal/ZzzzzzRepository.java
ZzzzzzRepository
resolveZzzzzzOrdinals
class ZzzzzzRepository extends NodeRepository<ZzzzzzBlock> { private ArrayList<ZzzzzzBlock> referencedZzzzzzBlocks = new ArrayList<>(); public ZzzzzzRepository(DataHolder options) { super(ZzzzzzExtension.ZZZZZZS_KEEP.get(options)); } public void addZzzzzzReference(ZzzzzzBlock zzzzzzBlock, Zzzzzz zzzzzz) { if (!zzzzzzBlock.isReferenced()) { referencedZzzzzzBlocks.add(zzzzzzBlock); } zzzzzzBlock.setFirstReferenceOffset(zzzzzz.getStartOffset()); } public void resolveZzzzzzOrdinals() {<FILL_FUNCTION_BODY>} public List<ZzzzzzBlock> getReferencedZzzzzzBlocks() { return referencedZzzzzzBlocks; } @NotNull @Override public DataKey<ZzzzzzRepository> getDataKey() { return ZzzzzzExtension.ZZZZZZS; } @NotNull @Override public DataKey<KeepType> getKeepDataKey() { return ZzzzzzExtension.ZZZZZZS_KEEP; } @NotNull @Override public Set<ZzzzzzBlock> getReferencedElements(Node parent) { HashSet<ZzzzzzBlock> references = new HashSet<>(); //visitNodes(parent, new ValueRunnable<Node>() { // @Override // public void run(Node value) { // if (value instanceof Zzzzzz) { // //Reference reference = ((RefNode) value).getReferenceNode(ZzzzzzRepository.this); // //if (reference != null) { // // references.add(reference); // //} // } // } //}, Zzzzzz.class); return references; } }
// need to sort by first referenced offset then set each to its ordinal position in the array+1 referencedZzzzzzBlocks.sort((f1, f2) -> f1.getFirstReferenceOffset() - f2.getFirstReferenceOffset()); int ordinal = 0; for (ZzzzzzBlock zzzzzzBlock : referencedZzzzzzBlocks) { zzzzzzBlock.setZzzzzzOrdinal(++ordinal); }
515
119
634
<methods>public void <init>(@Nullable KeepType) ,public void clear() ,public boolean containsKey(@NotNull Object) ,public boolean containsValue(java.lang.Object) ,public @NotNull Set<Map.Entry<String,ZzzzzzBlock>> entrySet() ,public boolean equals(java.lang.Object) ,public @Nullable ZzzzzzBlock get(@NotNull Object) ,public abstract @NotNull DataKey<? extends NodeRepository<ZzzzzzBlock>> getDataKey() ,public @Nullable ZzzzzzBlock getFromRaw(@NotNull CharSequence) ,public abstract @NotNull DataKey<KeepType> getKeepDataKey() ,public abstract @NotNull Set<ZzzzzzBlock> getReferencedElements(com.vladsch.flexmark.util.ast.Node) ,public @NotNull Collection<ZzzzzzBlock> getValues() ,public int hashCode() ,public boolean isEmpty() ,public @NotNull Set<String> keySet() ,public @NotNull String normalizeKey(@NotNull CharSequence) ,public @Nullable ZzzzzzBlock put(@NotNull String, @NotNull ZzzzzzBlock) ,public void putAll(@NotNull Map<? extends String,? extends ZzzzzzBlock>) ,public @Nullable ZzzzzzBlock putRawKey(@NotNull CharSequence, @NotNull ZzzzzzBlock) ,public @Nullable ZzzzzzBlock remove(@NotNull Object) ,public int size() ,public static boolean transferReferences(@NotNull NodeRepository<T>, @NotNull NodeRepository<T>, boolean, @Nullable Map<String,String>) ,public @NotNull List<ZzzzzzBlock> values() <variables>protected final non-sealed com.vladsch.flexmark.util.ast.KeepType keepType,protected final ArrayList<com.vladsch.flexmark.ext.zzzzzz.ZzzzzzBlock> nodeList,protected final Map<java.lang.String,com.vladsch.flexmark.ext.zzzzzz.ZzzzzzBlock> nodeMap
vsch_flexmark-java
flexmark-java/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/DelegatingNodeRendererFactoryWrapper.java
DelegatingNodeRendererFactoryWrapper
getBeforeDependents
class DelegatingNodeRendererFactoryWrapper implements Function<DataHolder, HtmlNodeRenderer>, Dependent, DelegatingNodeRendererFactory { final private HtmlNodeRendererFactory nodeRendererFactory; private List<DelegatingNodeRendererFactoryWrapper> nodeRenderers; private Set<Class<?>> myDelegates = null; public DelegatingNodeRendererFactoryWrapper(List<DelegatingNodeRendererFactoryWrapper> nodeRenderers, HtmlNodeRendererFactory nodeRendererFactory) { this.nodeRendererFactory = nodeRendererFactory; this.nodeRenderers = nodeRenderers; } @Override public HtmlNodeRenderer apply(DataHolder options) { return nodeRendererFactory.apply(options); } public HtmlNodeRendererFactory getFactory() { return nodeRendererFactory; } @Override public Set<Class<?>> getDelegates() { return nodeRendererFactory instanceof DelegatingNodeRendererFactory ? ((DelegatingNodeRendererFactory) nodeRendererFactory).getDelegates() : null; } @Nullable @Override final public Set<Class<?>> getAfterDependents() { return null; } @Nullable @Override public Set<Class<?>> getBeforeDependents() {<FILL_FUNCTION_BODY>} @Override final public boolean affectsGlobalScope() { return false; } }
if (myDelegates == null && nodeRenderers != null) { Set<Class<?>> delegates = getDelegates(); if (delegates != null) { myDelegates = new HashSet<>(); for (DelegatingNodeRendererFactoryWrapper factory : nodeRenderers) { if (delegates.contains(factory.getFactory().getClass())) { myDelegates.add(factory.getFactory().getClass()); } } } // release reference nodeRenderers = null; } return myDelegates;
351
153
504
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlConverterState.java
HtmlConverterState
toString
class HtmlConverterState { final @NotNull Node myParent; final List<Node> myElements; int myIndex; final @NotNull MutableAttributes myAttributes; private @Nullable LinkedList<Runnable> myPrePopActions; HtmlConverterState(@NotNull Node parent) { myParent = parent; myElements = parent.childNodes(); myIndex = 0; myAttributes = new MutableAttributes(); myPrePopActions = null; } public Node getParent() { return myParent; } public List<Node> getElements() { return myElements; } public int getIndex() { return myIndex; } public Attributes getAttributes() { return myAttributes; } public LinkedList<Runnable> getPrePopActions() { return myPrePopActions; } public void addPrePopAction(Runnable action) { if (myPrePopActions == null) { myPrePopActions = new LinkedList<>(); } myPrePopActions.add(action); } public void runPrePopActions() { if (myPrePopActions != null) { int iMax = myPrePopActions.size(); for (int i = iMax; i-- > 0; ) { myPrePopActions.get(i).run(); } } } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return "State{" + "myParent=" + myParent + ", myElements=" + myElements + ", myIndex=" + myIndex + ", myAttributes=" + myAttributes + '}';
383
59
442
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlMarkdownWriter.java
HtmlMarkdownWriter
lastBlockQuoteChildPrefix
class HtmlMarkdownWriter extends MarkdownWriterBase<HtmlMarkdownWriter, Node, HtmlNodeConverterContext> { public HtmlMarkdownWriter() { this(null, 0); } public HtmlMarkdownWriter(int formatOptions) { this(null, formatOptions); } 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) {<FILL_FUNCTION_BODY>} }
Node node = context.getCurrentNode(); if (node instanceof Element) { Element element = (Element) node; while (element.nextElementSibling() == null) { Element parent = element.parent(); if (parent == null) break; if (parent.nodeName().toLowerCase().equals(FlexmarkHtmlConverter.BLOCKQUOTE_NODE)) { int pos = prefix.lastIndexOf('>'); if (pos >= 0) { prefix = prefix.getBuilder().append(prefix.subSequence(0, pos)).append(' ').append(prefix.subSequence(pos + 1)).toSequence(); // } else { // // NOTE: occurs if continuation block prefix is remove } } element = parent; } } return prefix;
192
204
396
<methods>public void <init>() ,public void <init>(int) ,public void <init>(@Nullable Appendable, int) ,public @NotNull HtmlMarkdownWriter addIndentOnFirstEOL(@NotNull Runnable) ,public @NotNull HtmlMarkdownWriter addPrefix(@NotNull CharSequence) ,public @NotNull HtmlMarkdownWriter addPrefix(@NotNull CharSequence, boolean) ,public @NotNull HtmlMarkdownWriter append(char) ,public @NotNull HtmlMarkdownWriter append(@NotNull CharSequence) ,public @NotNull HtmlMarkdownWriter append(@NotNull CharSequence, int, int) ,public @NotNull HtmlMarkdownWriter append(@NotNull LineAppendable, int, int, boolean) ,public @NotNull HtmlMarkdownWriter append(char, int) ,public T appendTo(@NotNull T, boolean, int, int, int, int) throws java.io.IOException,public @NotNull HtmlMarkdownWriter blankLine() ,public @NotNull HtmlMarkdownWriter blankLine(int) ,public @NotNull HtmlMarkdownWriter blankLineIf(boolean) ,public @NotNull HtmlMarkdownWriter changeOptions(int, int) ,public @NotNull HtmlMarkdownWriter closePreFormatted() ,public int column() ,public boolean endsWithEOL() ,public int getAfterEolPrefixDelta() ,public @NotNull BasedSequence getBeforeEolPrefix() ,public @NotNull ISequenceBuilder<?,?> getBuilder() ,public com.vladsch.flexmark.html2md.converter.HtmlNodeConverterContext getContext() ,public @NotNull BasedSequence getIndentPrefix() ,public @NotNull BasedSequence getLine(int) ,public int getLineCount() ,public int getLineCountWithPending() ,public @NotNull LineInfo getLineInfo(int) ,public @NotNull Iterable<BasedSequence> getLines(int, int, int, boolean) ,public @NotNull Iterable<LineInfo> getLinesInfo(int, int, int) ,public @NotNull BitFieldSet<LineAppendable.Options> getOptionSet() ,public int getOptions() ,public int getPendingEOL() ,public int getPendingSpace() ,public @NotNull BasedSequence getPrefix() ,public int getTrailingBlankLines(int) ,public @NotNull HtmlMarkdownWriter indent() ,public void insertLine(int, @NotNull CharSequence, @NotNull CharSequence) ,public boolean isPendingSpace() ,public boolean isPreFormatted() ,public @NotNull Iterator<LineInfo> iterator() ,public abstract @NotNull BasedSequence lastBlockQuoteChildPrefix(com.vladsch.flexmark.util.sequence.BasedSequence) ,public @NotNull HtmlMarkdownWriter line() ,public @NotNull HtmlMarkdownWriter lineIf(boolean) ,public @NotNull HtmlMarkdownWriter lineOnFirstText(boolean) ,public @NotNull HtmlMarkdownWriter lineWithTrailingSpaces(int) ,public int offset() ,public int offsetWithPending() ,public @NotNull HtmlMarkdownWriter openPreFormatted(boolean) ,public @NotNull HtmlMarkdownWriter popOptions() ,public @NotNull HtmlMarkdownWriter popPrefix() ,public @NotNull HtmlMarkdownWriter popPrefix(boolean) ,public @NotNull HtmlMarkdownWriter pushOptions() ,public @NotNull HtmlMarkdownWriter pushPrefix() ,public @NotNull HtmlMarkdownWriter removeExtraBlankLines(int, int, int, int) ,public @NotNull HtmlMarkdownWriter removeIndentOnFirstEOL(@NotNull Runnable) ,public @NotNull HtmlMarkdownWriter removeLines(int, int) ,public void setContext(com.vladsch.flexmark.html2md.converter.HtmlNodeConverterContext) ,public @NotNull HtmlMarkdownWriter setIndentPrefix(@Nullable CharSequence) ,public void setLine(int, @NotNull CharSequence, @NotNull CharSequence) ,public @NotNull HtmlMarkdownWriter setOptions(int) ,public @NotNull HtmlMarkdownWriter setPrefix(@NotNull CharSequence) ,public @NotNull HtmlMarkdownWriter setPrefix(@Nullable CharSequence, boolean) ,public void setPrefixLength(int, int) ,public @NotNull HtmlMarkdownWriter tailBlankLine() ,public @NotNull HtmlMarkdownWriter tailBlankLine(int) ,public @NotNull CharSequence toSequence(int, int, boolean) ,public java.lang.String toString() ,public @NotNull String toString(int, int, boolean) ,public @NotNull HtmlMarkdownWriter unIndent() ,public @NotNull HtmlMarkdownWriter unIndentNoEol() <variables>protected final non-sealed com.vladsch.flexmark.util.sequence.LineAppendableImpl appendable,protected com.vladsch.flexmark.html2md.converter.HtmlNodeConverterContext context
vsch_flexmark-java
flexmark-java/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlNodeConverterSubContext.java
HtmlNodeConverterSubContext
flushTo
class HtmlNodeConverterSubContext implements HtmlNodeConverterContext { final protected HtmlMarkdownWriter markdown; NodeRenderingHandlerWrapper<?> renderingHandlerWrapper; @Nullable Node myRenderingNode; public HtmlNodeConverterSubContext(@NotNull HtmlMarkdownWriter markdown) { this.markdown = markdown; this.myRenderingNode = null; this.markdown.setContext(this); } public @Nullable Node getRenderingNode() { return myRenderingNode; } public void setRenderingNode(@Nullable Node renderingNode) { this.myRenderingNode = renderingNode; } public @NotNull HtmlMarkdownWriter getMarkdown() { return markdown; } public void flushTo(@NotNull Appendable out, int maxTrailingBlankLines) { flushTo(out, getHtmlConverterOptions().maxBlankLines, maxTrailingBlankLines); } public void flushTo(@NotNull Appendable out, int maxBlankLines, int maxTrailingBlankLines) {<FILL_FUNCTION_BODY>} }
markdown.line(); try { markdown.appendTo(out, maxBlankLines, maxTrailingBlankLines); } catch (IOException e) { e.printStackTrace(); }
286
58
344
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/HtmlNodeRendererHandler.java
HtmlNodeRendererHandler
equals
class HtmlNodeRendererHandler<N extends Node> implements CustomHtmlNodeRenderer<N> { protected final String myTagName; protected final Class<? extends N> myClass; protected final CustomHtmlNodeRenderer<N> myAdapter; public HtmlNodeRendererHandler(String tagName, Class<? extends N> aClass, CustomHtmlNodeRenderer<N> adapter) { myTagName = tagName; myClass = aClass; myAdapter = adapter; } @Override public void render(Node node, HtmlNodeConverterContext context, HtmlMarkdownWriter markdown) { //noinspection unchecked myAdapter.render((N) node, context, markdown); } public Class<? extends N> getNodeType() { return myClass; } public String getTagName() { return myTagName; } public CustomHtmlNodeRenderer<N> getNodeAdapter() { return myAdapter; } @Override public boolean equals(Object o) {<FILL_FUNCTION_BODY>} @Override public int hashCode() { int result = myClass.hashCode(); result = 31 * result + myAdapter.hashCode(); return result; } }
if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; HtmlNodeRendererHandler<?> other = (HtmlNodeRendererHandler<?>) o; if (myClass != other.myClass) return false; return myAdapter == other.myAdapter;
319
87
406
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-html2md-converter/src/main/java/com/vladsch/flexmark/html2md/converter/ListState.java
ListState
getItemPrefix
class ListState { final public boolean isNumbered; public int itemCount; public ListState(boolean isNumbered) { this.isNumbered = isNumbered; itemCount = 0; } public String getItemPrefix(HtmlConverterOptions options) {<FILL_FUNCTION_BODY>} }
if (isNumbered) { return String.format(Locale.US, "%d%c ", itemCount, options.orderedListDelimiter); } else { return String.format("%c ", options.unorderedListDelimiter); }
85
66
151
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-jira-converter/src/main/java/com/vladsch/flexmark/jira/converter/JiraConverterExtension.java
JiraConverterExtension
extend
class JiraConverterExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension { private JiraConverterExtension() { } public static JiraConverterExtension create() { return new JiraConverterExtension(); } @Override public void extend(Parser.Builder parserBuilder) { } @Override public void rendererOptions(@NotNull MutableDataHolder options) { String rendererType = HtmlRenderer.TYPE.get(options); if (rendererType.equals("HTML")) { options.set(HtmlRenderer.TYPE, "JIRA"); } else if (!rendererType.equals("JIRA")) { throw new IllegalStateException("Non HTML Renderer is already set to " + rendererType); } } @Override public void parserOptions(MutableDataHolder options) { } @Override public void extend(@NotNull HtmlRenderer.Builder htmlRendererBuilder, @NotNull String rendererType) {<FILL_FUNCTION_BODY>} }
if (htmlRendererBuilder.isRendererType("JIRA")) { htmlRendererBuilder.nodeRendererFactory(new JiraConverterNodeRenderer.Factory()); } else { throw new IllegalStateException("Jira Converter Extension used with non Jira Renderer " + rendererType); }
259
74
333
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-pdf-converter/src/main/java/com/vladsch/flexmark/pdf/converter/PdfConverterExtension.java
PdfConverterExtension
exportToPdf
class PdfConverterExtension { final public static NullableDataKey<PdfRendererBuilder.TextDirection> DEFAULT_TEXT_DIRECTION = new NullableDataKey<>("DEFAULT_TEXT_DIRECTION"); final public static NullableDataKey<ProtectionPolicy> PROTECTION_POLICY = new NullableDataKey<>("PROTECTION_POLICY"); final public static String DEFAULT_CSS_RESOURCE_PATH = "/default.css"; final public static String DEFAULT_TOC_LIST_CLASS = "toc"; final public static DataKey<String> DEFAULT_CSS = new DataKey<>("DEFAULT_CSS", () -> Utils.getResourceAsString(PdfConverterExtension.class, DEFAULT_CSS_RESOURCE_PATH)); public static String embedCss(String html, String css) { if (css != null && !css.isEmpty()) { int pos = html.indexOf("</head>"); String prefix = "<style>\n"; String suffix = "\n</style>"; String tail = ""; if (pos == -1) { pos = html.indexOf("<html>"); if (pos != -1) { pos += 6; prefix = "<head>" + prefix; suffix = suffix + "</head>"; } else { pos = html.indexOf("<body>"); if (pos != -1) { prefix = "<html><head>" + prefix; suffix = suffix + "</head>"; tail = "</html>\n"; } else { pos = 0; prefix = "<html><head>" + prefix; suffix = suffix + "</head><body>\n"; tail = "</body></html>\n"; } } } return html.subSequence(0, pos) + prefix + css + suffix + html.subSequence(pos, html.length()) + tail; } return html; } public static void exportToPdf(String out, String html, String url, DataHolder options) { String css = DEFAULT_CSS.get(options); html = embedCss(html, css); exportToPdf(out, html, url, DEFAULT_TEXT_DIRECTION.get(options), PROTECTION_POLICY.get(options)); } public static void exportToPdf(String out, String html, String url, PdfRendererBuilder.TextDirection defaultTextDirection) { exportToPdf(out, html, url, defaultTextDirection, null); } public static void exportToPdf(String out, String html, String url, PdfRendererBuilder.TextDirection defaultTextDirection, ProtectionPolicy protectionPolicy) { try { OutputStream os = new FileOutputStream(out); exportToPdf(os, html, url, defaultTextDirection, protectionPolicy); } catch (FileNotFoundException e) { e.printStackTrace(); } } public static void exportToPdf(OutputStream os, String html, String url, DataHolder options) { exportToPdf(os, html, url, DEFAULT_TEXT_DIRECTION.get(options), PROTECTION_POLICY.get(options)); } public static void exportToPdf(OutputStream os, String html, String url, PdfRendererBuilder.TextDirection defaultTextDirection) { exportToPdf(os, html, url, defaultTextDirection, null); } public static void exportToPdf(OutputStream os, String html, String url, PdfRendererBuilder.TextDirection defaultTextDirection, ProtectionPolicy protectionPolicy) {<FILL_FUNCTION_BODY>} private static void handleW3cDocument(String html, String url, PdfRendererBuilder builder) { org.jsoup.nodes.Document doc; doc = Jsoup.parse(html); Document dom = new W3CDom().fromJsoup(doc); builder.withW3cDocument(dom, url); } private static void handleTextDirection(BaseRendererBuilder.TextDirection defaultTextDirection, PdfRendererBuilder builder) { if (defaultTextDirection != null) { builder.useUnicodeBidiSplitter(new ICUBidiSplitter.ICUBidiSplitterFactory()); builder.useUnicodeBidiReorderer(new ICUBidiReorderer()); builder.defaultTextDirection(defaultTextDirection); // OR RTL } } }
PdfBoxRenderer renderer = null; try { // There are more options on the builder than shown below. PdfRendererBuilder builder = new PdfRendererBuilder(); handleTextDirection(defaultTextDirection, builder); handleW3cDocument(html, url, builder); builder.toStream(os); renderer = builder.buildPdfRenderer(); PDDocument document = renderer.getPdfDocument(); if (protectionPolicy != null) document.protect(protectionPolicy); renderer.layout(); renderer.createPDF(); } catch (Exception e) { e.printStackTrace(); // LOG exception } finally { try { if (renderer != null) { renderer.close(); } os.close(); } catch (IOException e) { // swallow } }
1,111
228
1,339
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/FixedIterationConditions.java
FixedIterationConditions
mapTtoB
class FixedIterationConditions<N> implements IterationConditions<N> { final private @NotNull Function<? super N, N> initializer; final private @NotNull Function<? super N, N> iterator; final private @NotNull Function<? super N, N> reverseInitializer; final private @NotNull Function<? super N, N> reverseIterator; public FixedIterationConditions(@NotNull Function<? super N, N> initializer, @NotNull Function<? super N, N> iterator, @NotNull Function<? super N, N> reverseInitializer, @NotNull Function<? super N, N> reverseIterator) { this.initializer = initializer; this.iterator = iterator; this.reverseInitializer = reverseInitializer; this.reverseIterator = reverseIterator; } @Override @NotNull public Function<? super N, N> getInitializer() { return initializer; } @Override @NotNull public Function<? super N, N> getIterator() { return iterator; } @NotNull @Override public IterationConditions<N> getReversed() { return new FixedIterationConditions<>(reverseInitializer, reverseIterator, initializer, iterator); } public static <B, T> Function<? super B, B> getAdapter(Function<? super T, T> function, Function<? super B, T> adaptBtoT, Function<? super T, B> adaptTtoB) { return adaptBtoT.andThen(function).andThen(adaptTtoB); } public static <B, T> FixedIterationConditions<B> mapTtoB(IterationConditions<T> constraints, Function<? super B, T> adaptBtoT, Function<? super T, B> adaptTtoB) {<FILL_FUNCTION_BODY>} }
return new FixedIterationConditions<>( getAdapter(constraints.getInitializer(), adaptBtoT, adaptTtoB), getAdapter(constraints.getIterator(), adaptBtoT, adaptTtoB), getAdapter(constraints.getReversed().getInitializer(), adaptBtoT, adaptTtoB), getAdapter(constraints.getReversed().getIterator(), adaptBtoT, adaptTtoB) );
472
113
585
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-tree-iteration/src/main/java/com/vladsch/flexmark/tree/iteration/ValueIterationAdapterImpl.java
ChainedConsumerAdapter
of
class ChainedConsumerAdapter<P, T, V> implements ValueIterationConsumerAdapter<P, V> { final private ValueIterationConsumerAdapter<? super P, T> myBeforeAdapter; final private ValueIterationConsumerAdapter<? super T, V> myAfterAdapter; public ChainedConsumerAdapter(ValueIterationConsumerAdapter<? super P, T> beforeAdapter, ValueIterationConsumerAdapter<? super T, V> afterAdapter) { myBeforeAdapter = beforeAdapter; myAfterAdapter = afterAdapter; } @NotNull @Override public <R> ValueIterationConsumer<? super P, R> getConsumer(ValueIterationConsumer<? super V, R> valueConsumer) { return myBeforeAdapter.getConsumer(myAfterAdapter.getConsumer(valueConsumer)); } @NotNull @Override public <R> ValueIterationConsumer<? super P, R> getConsumer(VoidIterationConsumer<? super V> voidConsumer) { return myBeforeAdapter.getConsumer(myAfterAdapter.getConsumer(voidConsumer)); } } public ValueIterationAdapterImpl(@NotNull Function<? super N, T> function) { this(function, null); } public ValueIterationAdapterImpl(@NotNull Function<? super N, T> function, @Nullable ValueIterationFilter<? super T> filter) { this(new ConsumerAdapter<>(function, filter)); } public ValueIterationAdapterImpl(@NotNull ValueIterationConsumerAdapter<N, T> consumerAdapter) { myConsumerAdapter = consumerAdapter; } @NotNull @Override public ValueIterationConsumerAdapter<N, T> getConsumerAdapter() { return myConsumerAdapter; } @NotNull @Override public <V> ValueIterationAdapter<N, V> andThen(ValueIterationAdapter<? super T, V> after) { return new ValueIterationAdapterImpl<>(new ChainedConsumerAdapter<>(myConsumerAdapter, after.getConsumerAdapter())); } @NotNull @Override public ValueIterationAdapter<N, T> compose(ValueIterationAdapter<? super N, N> before) { return new ValueIterationAdapterImpl<>(new ChainedConsumerAdapter<>(before.getConsumerAdapter(), myConsumerAdapter)); } public static <N> ValueIterationAdapter<N, N> of() { return new ValueIterationAdapterImpl<>(Function.identity()); } public static <N> ValueIterationAdapter<N, N> of(ValueIterationFilter<? super N> filter) { return new ValueIterationAdapterImpl<>(Function.identity(), filter); } public static <N, T> ValueIterationAdapter<N, T> of(Function<? super N, T> function) { return new ValueIterationAdapterImpl<>(function); } public static <N, T> ValueIterationAdapter<N, T> of(Class<? extends T> clazz) { return new ValueIterationAdapterImpl<>(it -> clazz.isInstance(it) ? clazz.cast(it) : null); } public static <N, T> ValueIterationAdapter<N, T> of(Iterable<Class<? extends T>> clazzes) {<FILL_FUNCTION_BODY>
return new ValueIterationAdapterImpl<>(it -> { for (Class<? extends T> clazz : clazzes) { if (clazz.isInstance(it)) return clazz.cast(it); } return null; });
812
67
879
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/AllNodesVisitor.java
AllNodesVisitor
visitChildren
class AllNodesVisitor { protected abstract void process(@NotNull Node node); public void visit(@NotNull Node node) { visitChildren(node); } private void visitChildren(@NotNull Node parent) {<FILL_FUNCTION_BODY>} }
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 // node after visiting it. So get the next node before visiting. Node next = node.getNext(); process(node); visit(node); node = next; }
67
95
162
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Block.java
Block
setParent
class Block extends ContentNode { public Block() { } public Block(@NotNull BasedSequence chars) { super(chars); } public Block(@NotNull BasedSequence chars, @NotNull List<BasedSequence> lineSegments) { super(chars, lineSegments); } public Block(@NotNull List<BasedSequence> lineSegments) { super(lineSegments); } public Block(BlockContent blockContent) { super(blockContent); } @Nullable public Block getParent() { return (Block) super.getParent(); } @Override protected void setParent(@Nullable Node parent) {<FILL_FUNCTION_BODY>} }
if (parent != null && !(parent instanceof Block)) { throw new IllegalArgumentException("Parent of block must also be block (can not be inline)"); } super.setParent(parent);
185
52
237
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void <init>(@NotNull BasedSequence, @NotNull List<BasedSequence>) ,public void <init>(@NotNull List<BasedSequence>) ,public void <init>(@NotNull BlockContent) ,public @NotNull BasedSequence getContentChars() ,public @NotNull BasedSequence getContentChars(int, int) ,public @NotNull List<BasedSequence> getContentLines() ,public @NotNull List<BasedSequence> getContentLines(int, int) ,public @NotNull BasedSequence getLineChars(int) ,public int getLineCount() ,public @NotNull BasedSequence getSpanningChars() ,public void setContent(@NotNull BasedSequence, @NotNull List<BasedSequence>) ,public void setContent(@NotNull List<BasedSequence>) ,public void setContent(@NotNull BlockContent) ,public void setContentLine(int, @NotNull BasedSequence) ,public void setContentLines(@NotNull List<BasedSequence>) <variables>protected List<com.vladsch.flexmark.util.sequence.BasedSequence> lineSegments
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockContent.java
BlockContent
getContents
class BlockContent { // list of line text final private ArrayList<BasedSequence> lines = new ArrayList<>(); final private ArrayList<Integer> lineIndents = new ArrayList<>(); public @NotNull BasedSequence getLine(int line) { return lines.get(line); } public @NotNull 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<BasedSequence> getLines() { return lines; } public @NotNull List<Integer> getLineIndents() { return lineIndents; } public int getLineCount() { return lines.size(); } public BlockContent() { } public BlockContent(@NotNull 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"; if (other.lines.size() > 0 && startLine < lineIndent) { lines.addAll(other.lines.subList(startLine, lineIndent)); lineIndents.addAll(other.lineIndents.subList(startLine, lineIndent)); } } public int getStartOffset() { return lines.size() > 0 ? lines.get(0).getStartOffset() : -1; } public int getEndOffset() { return lines.size() > 0 ? lines.get(lines.size() - 1).getEndOffset() : -1; } public int getLineIndent() { return lines.size() > 0 ? lineIndents.get(0) : 0; } 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) { lines.add(lineWithEOL); lineIndents.add(lineIndent); } public void addAll(@NotNull List<BasedSequence> lines, List<Integer> lineIndents) { assert lines.size() == lineIndents.size() : "lines and lineIndents should be of the same size"; this.lines.addAll(lines); this.lineIndents.addAll(lineIndents); } public boolean hasSingleLine() { return lines.size() == 1; } public @NotNull BasedSequence getContents() { if (lines.size() == 0) return BasedSequence.NULL; return getContents(0, lines.size()); } public @NotNull BlockContent subContents(int startLine, int endLine) { return new BlockContent(this, startLine, endLine); } public @NotNull BasedSequence getContents(int startLine, int endLine) {<FILL_FUNCTION_BODY>} public @NotNull String getString() { if (lines.size() == 0) return ""; StringBuilder sb = new StringBuilder(); for (BasedSequence line : lines) { sb.append(line.trimEOL()); sb.append('\n'); } return sb.toString(); } }
if (lines.size() == 0) return BasedSequence.NULL; if (startLine < 0) { throw new IndexOutOfBoundsException("startLine must be at least 0"); } if (endLine < 0) { throw new IndexOutOfBoundsException("endLine must be at least 0"); } if (endLine < startLine) { throw new IndexOutOfBoundsException("endLine must not be less than startLine"); } if (endLine > lines.size()) { throw new IndexOutOfBoundsException("endLine must not be greater than line cardinality"); } return SegmentedSequence.create(lines.get(0), lines.subList(startLine, endLine));
875
183
1,058
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/BlockNodeVisitor.java
BlockNodeVisitor
processNode
class BlockNodeVisitor extends NodeVisitor { public BlockNodeVisitor() { } public BlockNodeVisitor(@NotNull VisitHandler... handlers) { super(handlers); } public BlockNodeVisitor(@NotNull VisitHandler[]... handlers) { super(handlers); } public BlockNodeVisitor(@NotNull Collection<VisitHandler> handlers) { super(handlers); } @Override public void processNode(@NotNull Node node, boolean withChildren, @NotNull BiConsumer<Node, Visitor<Node>> processor) {<FILL_FUNCTION_BODY>} }
if (node instanceof Block) { super.processNode(node, withChildren, processor); }
156
29
185
<methods>public void <init>() ,public transient void <init>(@NotNull VisitHandler#RAW []) ,public transient void <init>(@NotNull VisitHandler#RAW [] []) ,public void <init>(@NotNull Collection<VisitHandler#RAW>) ,public @NotNull NodeVisitor addHandler(@NotNull VisitHandler#RAW) ,public @NotNull NodeVisitor addHandlers(@NotNull Collection<VisitHandler#RAW>) ,public @NotNull NodeVisitor addHandlers(@NotNull VisitHandler#RAW []) ,public transient @NotNull NodeVisitor addHandlers(@NotNull VisitHandler#RAW [] []) ,public @NotNull NodeVisitor addTypedHandlers(@NotNull Collection<VisitHandler<?>>) ,public final void visit(@NotNull Node) ,public final void visitChildren(@NotNull Node) ,public final void visitNodeOnly(@NotNull Node) <variables>protected static final VisitHandler#RAW[] EMPTY_HANDLERS
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ClassifyingNodeTracker.java
ClassifyingNodeTracker
validateLinked
class ClassifyingNodeTracker implements NodeTracker { protected final @NotNull ClassificationBag<Class<?>, Node> nodeClassifier; final private @Nullable NodeTracker host; final private @NotNull OrderedMap<Class<?>, Set<Class<?>>> exclusionMap; final private @NotNull OrderedSet<Class<?>> exclusionSet; final private @NotNull HashMap<Integer, BitSet> nodeAncestryMap; public ClassifyingNodeTracker(@Nullable NodeTracker host, @NotNull Map<Class<? extends Node>, Set<Class<?>>> exclusionMap) { this.host = host; nodeClassifier = new ClassificationBag<>(NodeClassifier.INSTANCE); this.exclusionMap = new OrderedMap<>(exclusionMap.size()); this.exclusionMap.putAll(exclusionMap); // this maps the exclusion class to bits in the bit set exclusionSet = new OrderedSet<>(); ReversibleIterator<Set<Class<?>>> iterator = this.exclusionMap.valueIterable().iterator(); while (iterator.hasNext()) { exclusionSet.addAll(iterator.next()); } nodeAncestryMap = new HashMap<>(); } @NotNull public OrderedMap<Class<?>, Set<Class<?>>> getExclusionMap() { return exclusionMap; } @NotNull public HashMap<Integer, BitSet> getNodeAncestryMap() { return nodeAncestryMap; } @NotNull public OrderedSet<Class<?>> getExclusionSet() { return exclusionSet; } @NotNull public ClassificationBag<Class<?>, Node> getNodeClassifier() { return nodeClassifier; } private void validateLinked(Node node) {<FILL_FUNCTION_BODY>} @Override public void nodeAdded(@NotNull Node node) { validateLinked(node); nodeClassifier.add(node); if (host != null) host.nodeAdded(node); } @Override public void nodeAddedWithChildren(@NotNull Node node) { validateLinked(node); nodeClassifier.add(node); addNodes(node.getChildren()); if (host != null) host.nodeAddedWithChildren(node); } @Override public void nodeAddedWithDescendants(@NotNull Node node) { validateLinked(node); nodeClassifier.add(node); addNodes(node.getDescendants()); if (host != null) host.nodeAddedWithDescendants(node); } private void addNodes(@NotNull ReversiblePeekingIterable<Node> nodes) { for (Node child : nodes) { nodeClassifier.add(child); } } private void validateUnlinked(@NotNull 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) { nodeRemovedWithDescendants(node); } @Override public void nodeRemovedWithChildren(@NotNull Node node) { nodeRemovedWithDescendants(node); } @Override public void nodeRemovedWithDescendants(@NotNull Node node) { validateUnlinked(node); nodeClassifier.add(node); removeNodes(node.getDescendants()); if (host != null) host.nodeRemovedWithDescendants(node); } private void removeNodes(@NotNull ReversiblePeekingIterable<Node> nodes) { for (Node child : nodes) { nodeClassifier.add(child); } } public @NotNull OrderedSet<Node> getItems() { return nodeClassifier.getItems(); } public <X> @NotNull ReversibleIterable<X> getCategoryItems(@NotNull Class<? extends X> nodeClass, @NotNull Set<Class<?>> classes) { return nodeClassifier.getCategoryItems(nodeClass, classes); } }
if (node.getNext() == null && node.getParent() == null) { throw new IllegalStateException("Added block " + node + " is not linked into the AST"); }
1,076
50
1,126
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/ContentNode.java
ContentNode
setContentLine
class ContentNode extends Node implements Content { protected List<BasedSequence> lineSegments = BasedSequence.EMPTY_LIST; public ContentNode() { } public ContentNode(@NotNull BasedSequence chars) { super(chars); } public ContentNode(@NotNull BasedSequence chars, @NotNull List<BasedSequence> lineSegments) { super(chars); this.lineSegments = lineSegments; } public ContentNode(@NotNull List<BasedSequence> lineSegments) { this(getSpanningChars(lineSegments), lineSegments); } public ContentNode(@NotNull BlockContent blockContent) { this(blockContent.getSpanningChars(), blockContent.getLines()); } public void setContent(@NotNull BasedSequence chars, @NotNull List<BasedSequence> lineSegments) { setChars(chars); this.lineSegments = lineSegments; } public void setContent(@NotNull List<BasedSequence> lineSegments) { this.lineSegments = lineSegments; setChars(getSpanningChars()); } public void setContent(@NotNull BlockContent blockContent) { setChars(blockContent.getSpanningChars()); this.lineSegments = blockContent.getLines(); } @Override public @NotNull BasedSequence getSpanningChars() { return getSpanningChars(lineSegments); } private static @NotNull BasedSequence getSpanningChars(@NotNull List<BasedSequence> lineSegments) { return lineSegments.isEmpty() ? BasedSequence.NULL : lineSegments.get(0).baseSubSequence(lineSegments.get(0).getStartOffset(), lineSegments.get(lineSegments.size() - 1).getEndOffset()); } @Override public int getLineCount() { return lineSegments.size(); } @NotNull @Override public BasedSequence getLineChars(int index) { return lineSegments.get(index); } @NotNull @Override public List<BasedSequence> getContentLines() { return lineSegments; } @NotNull @Override public List<BasedSequence> 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<BasedSequence> contentLines) { this.lineSegments = contentLines; } public void setContentLine(int lineIndex, @NotNull BasedSequence contentLine) {<FILL_FUNCTION_BODY>} }
ArrayList<BasedSequence> lines = new ArrayList<>(lineSegments); lines.set(lineIndex, contentLine); this.lineSegments = lines; setCharsFromContent();
802
50
852
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void appendChain(@NotNull Node) ,public void appendChild(com.vladsch.flexmark.util.ast.Node) ,public static void astChars(@NotNull StringBuilder, @NotNull CharSequence, @NotNull String) ,public void astExtraChars(@NotNull StringBuilder) ,public void astString(@NotNull StringBuilder, boolean) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int, int) ,public com.vladsch.flexmark.util.sequence.BasedSequence baseSubSequence(int) ,public transient int countAncestorsOfType(@NotNull Class<?> []) ,public transient int countDirectAncestorsOfType(@Nullable Class<?>, @NotNull Class<?> []) ,public static void delimitedSegmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public static void delimitedSegmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull BasedSequence, @NotNull String) ,public int endOfLine(int) ,public void extractChainTo(@NotNull Node) ,public void extractToFirstInChain(@NotNull Node) ,public transient @Nullable Node getAncestorOfType(@NotNull Class<?> []) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.sequence.BasedSequence getBaseSequence() ,public @NotNull Node getBlankLineSibling() ,public @NotNull BasedSequence getChars() ,public @NotNull BasedSequence getCharsFromSegments() ,public com.vladsch.flexmark.util.sequence.BasedSequence getChildChars() ,public @NotNull ReversiblePeekingIterator<Node> getChildIterator() ,public transient @Nullable Node getChildOfType(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterable<Node> getChildren() ,public @NotNull ReversiblePeekingIterable<Node> getDescendants() ,public @NotNull Document getDocument() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptyPrefix() ,public com.vladsch.flexmark.util.sequence.BasedSequence getEmptySuffix() ,public int getEndLineNumber() ,public int getEndOfLine() ,public int getEndOffset() ,public com.vladsch.flexmark.util.sequence.BasedSequence getExactChildChars() ,public @Nullable Node getFirstChild() ,public transient @Nullable Node getFirstChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getFirstChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getFirstInChain() ,public @Nullable Node getGrandParent() ,public @Nullable Node getLastBlankLineChild() ,public @Nullable Node getLastChild() ,public transient @Nullable Node getLastChildAny(@NotNull Class<?> []) ,public transient @Nullable Node getLastChildAnyNot(@NotNull Class<?> []) ,public @NotNull Node getLastInChain() ,public static @NotNull BasedSequence getLeadSegment(@NotNull BasedSequence []) ,public Pair<java.lang.Integer,java.lang.Integer> getLineColumnAtEnd() ,public int getLineNumber() ,public @Nullable Node getNext() ,public transient @Nullable Node getNextAny(@NotNull Class<?> []) ,public transient @Nullable Node getNextAnyNot(@NotNull Class<?> []) ,public @NotNull String getNodeName() ,public static transient int getNodeOfTypeIndex(@NotNull Node, @NotNull Class<?> []) ,public transient int getNodeOfTypeIndex(@NotNull Class<?> []) ,public @Nullable Node getOldestAncestorOfTypeAfter(@NotNull Class<?>, @NotNull Class<?>) ,public @Nullable Node getParent() ,public @Nullable Node getPrevious() ,public transient @Nullable Node getPreviousAny(@NotNull Class<?> []) ,public transient @Nullable Node getPreviousAnyNot(@NotNull Class<?> []) ,public @NotNull ReversiblePeekingIterator<Node> getReversedChildIterator() ,public @NotNull ReversiblePeekingIterable<Node> getReversedChildren() ,public @NotNull ReversiblePeekingIterable<Node> getReversedDescendants() ,public abstract @NotNull BasedSequence [] getSegments() ,public @NotNull BasedSequence [] getSegmentsForChars() ,public com.vladsch.flexmark.util.sequence.Range getSourceRange() ,public int getStartLineNumber() ,public int getStartOfLine() ,public int getStartOffset() ,public int getTextLength() ,public static @NotNull BasedSequence getTrailSegment(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public boolean hasChildren() ,public boolean hasOrMoreChildren(int) ,public void insertAfter(@NotNull Node) ,public void insertBefore(com.vladsch.flexmark.util.ast.Node) ,public void insertChainAfter(@NotNull Node) ,public void insertChainBefore(@NotNull Node) ,public transient boolean isOrDescendantOfType(@NotNull Class<?> []) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtIndex(int) ,public Pair<java.lang.Integer,java.lang.Integer> lineColumnAtStart() ,public void moveTrailingBlankLines() ,public void prependChild(@NotNull Node) ,public void removeChildren() ,public static void segmentSpan(@NotNull StringBuilder, int, int, @Nullable String) ,public static void segmentSpan(@NotNull StringBuilder, @NotNull BasedSequence, @Nullable String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, int, int, @Nullable String, @NotNull String, @NotNull String, @NotNull String) ,public static void segmentSpanChars(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public static void segmentSpanCharsToVisible(@NotNull StringBuilder, @NotNull BasedSequence, @NotNull String) ,public void setChars(@NotNull BasedSequence) ,public void setCharsFromContent() ,public void setCharsFromContentOnly() ,public void setCharsFromSegments() ,public static transient @NotNull BasedSequence spanningChars(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public int startOfLine(int) ,public void takeChildren(@NotNull Node) ,public @NotNull String toAstString(boolean) ,public static @NotNull String toSegmentSpan(@NotNull BasedSequence, @Nullable String) ,public java.lang.String toString() ,public void unlink() <variables>public static final AstNode<com.vladsch.flexmark.util.ast.Node> AST_ADAPTER,public static final com.vladsch.flexmark.util.sequence.BasedSequence[] EMPTY_SEGMENTS,public static final java.lang.String SPLICE,private @NotNull BasedSequence chars,@Nullable Node firstChild,private @Nullable Node lastChild,@Nullable Node next,private @Nullable Node parent,private @Nullable Node prev
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/DescendantNodeIterator.java
DescendantNodeIterator
next
class DescendantNodeIterator implements ReversiblePeekingIterator<Node> { final private boolean isReversed; private @NotNull ReversiblePeekingIterator<Node> iterator; private @Nullable Stack<ReversiblePeekingIterator<Node>> iteratorStack; private Node result; /** * iterate nodes, with descendants, depth first until all are done * * @param iterator iterator to use for iterating nodes and their descendants */ public DescendantNodeIterator(@NotNull ReversiblePeekingIterator<Node> iterator) { this.isReversed = iterator.isReversed(); this.iterator = iterator instanceof DescendantNodeIterator ? ((DescendantNodeIterator) iterator).iterator : iterator; this.iteratorStack = null; this.result = null; } @Override public boolean isReversed() { return isReversed; } @Override public boolean hasNext() { return iterator.hasNext(); } @Override public @NotNull Node next() {<FILL_FUNCTION_BODY>} @Nullable public Node peek() { return iterator.peek(); } @Override public void remove() { if (result == null) { throw new IllegalStateException("Either next() was not called yet or the node was removed"); } result.unlink(); result = null; } public void forEachRemaining(@NotNull Consumer<? super Node> consumer) { while (hasNext()) { consumer.accept(next()); } } }
result = iterator.next(); if (result.getFirstChild() != null) { // push the current iterator on to the stack and make the node's children the iterator if (iterator.hasNext()) { if (iteratorStack == null) iteratorStack = new Stack<>(); iteratorStack.push(iterator); } iterator = isReversed ? result.getReversedChildIterator() : result.getChildIterator(); } else { // see if need to pop an iterator if (iteratorStack != null && !iteratorStack.isEmpty() && !iterator.hasNext()) { // pop a new iterator off the stack iterator = iteratorStack.pop(); } } return result;
416
191
607
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/Document.java
Document
getLineNumber
class Document extends Block implements MutableDataHolder { final public static Document NULL = new Document(null, BasedSequence.NULL); final private MutableDataSet dataSet; @Override public @NotNull BasedSequence[] getSegments() { return EMPTY_SEGMENTS; } public Document(DataHolder options, BasedSequence chars) { super(chars); dataSet = new MutableDataSet(options); } @Override public @NotNull MutableDataHolder clear() { throw new UnsupportedOperationException(); } @NotNull @Override public <T> MutableDataHolder set(@NotNull DataKey<T> key, @NotNull T value) {return dataSet.set(key, value);} @NotNull @Override public <T> MutableDataHolder set(@NotNull NullableDataKey<T> key, @Nullable T value) {return dataSet.set(key, value);} @NotNull @Override public MutableDataSet setFrom(@NotNull MutableDataSetter dataSetter) {return dataSet.setFrom(dataSetter);} @NotNull @Override public MutableDataSet setAll(@NotNull 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);} @NotNull @Override public MutableDataSet remove(@NotNull DataKeyBase<?> key) {return dataSet.remove(key);} @Override @Nullable public Object getOrCompute(@NotNull DataKeyBase<?> key, @NotNull 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);} @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<? extends DataKeyBase<?>, Object> getAll() {return dataSet.getAll();} @Override @NotNull public Collection<? extends DataKeyBase<?>> getKeys() {return dataSet.getKeys();} @Override public boolean contains(@NotNull DataKeyBase<?> key) {return dataSet.contains(key);} @Override public int getLineCount() { if (lineSegments == EMPTY_LIST) { char c = getChars().lastChar(); return (c == '\n' || c == '\r' ? 0 : 1) + getLineNumber(getChars().length()); } else { return lineSegments.size(); } } /** * Get line number at offset * <p> * Next line starts after the EOL sequence. * offsets between \r and \n are considered part of the same line as offset before \r. * * @param offset offset in document text * @return line number at offset */ public int getLineNumber(int offset) {<FILL_FUNCTION_BODY>} }
if (lineSegments == EMPTY_LIST) { BasedSequence preText = getChars().baseSubSequence(0, Utils.maxLimit(offset + 1, getChars().length())); if (preText.isEmpty()) return 0; int lineNumber = 0; int nextLineEnd = preText.endOfLineAnyEOL(0); int length = preText.length(); while (nextLineEnd < length) { int eolLength = preText.eolStartLength(nextLineEnd); int lengthWithEOL = nextLineEnd + eolLength; if (offset >= lengthWithEOL) lineNumber++; // do not treat offset between \r and \n as complete line int oldNextLineEnd = nextLineEnd; nextLineEnd = preText.endOfLineAnyEOL(lengthWithEOL); assert nextLineEnd > oldNextLineEnd; } return lineNumber; } else { int iMax = lineSegments.size(); for (int i = 0; i < iMax; i++) { if (offset < lineSegments.get(i).getEndOffset()) { return i; } } return iMax; }
967
306
1,273
<methods>public void <init>() ,public void <init>(@NotNull BasedSequence) ,public void <init>(@NotNull BasedSequence, @NotNull List<BasedSequence>) ,public void <init>(@NotNull List<BasedSequence>) ,public void <init>(com.vladsch.flexmark.util.ast.BlockContent) ,public @Nullable Block getParent() <variables>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeClassifierVisitor.java
NodeClassifierVisitor
updateNodeAncestry
class NodeClassifierVisitor extends NodeVisitorBase implements NodeTracker { final private OrderedMap<Class<?>, Set<Class<?>>> exclusionMap; final private OrderedSet<Class<?>> exclusionSet; final private HashMap<Integer, BitSet> nodeAncestryMap; final private Stack<BitSet> nodeAncestryBitSetStack = new Stack<>(); final private CopyOnWriteRef<BitSet> nodeAncestryBitSet = new CopyOnWriteRef<>(new BitSet(), value -> value != null ? (BitSet) value.clone() : new BitSet()); final private static BitSet EMPTY_SET = new BitSet(); private boolean isClassificationDone = false; final private ClassifyingNodeTracker classifyingNodeTracker; public NodeClassifierVisitor(Map<Class<? extends Node>, Set<Class<?>>> exclusionMap) { classifyingNodeTracker = new ClassifyingNodeTracker(this, exclusionMap); this.exclusionMap = classifyingNodeTracker.getExclusionMap(); nodeAncestryMap = classifyingNodeTracker.getNodeAncestryMap(); exclusionSet = classifyingNodeTracker.getExclusionSet(); } public @NotNull ClassifyingNodeTracker classify(@NotNull Node node) { // no double dipping assert !isClassificationDone; visit(node); isClassificationDone = true; return classifyingNodeTracker; } @Override public void visit(@NotNull 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); } // @formatter:on @Override public void nodeAdded(@NotNull Node node) { if (isClassificationDone) { if (node.getParent() == null) { throw new IllegalStateException("Node must be inserted into the document before calling node tracker nodeAdded functions"); } if (!(node.getParent() instanceof Document)) { int parentIndex = classifyingNodeTracker.getItems().indexOf(node.getParent()); if (parentIndex == -1) { throw new IllegalStateException("Parent node: " + node.getParent() + " of " + node + " is not tracked, some post processor forgot to call tracker.nodeAdded()."); } BitSet ancestorBitSet = nodeAncestryMap.get(parentIndex); nodeAncestryBitSet.setValue(ancestorBitSet); } // let'er rip to update the descendants nodeAncestryBitSetStack.clear(); visit(node); } } void pushNodeAncestry() { if (!exclusionMap.isEmpty()) { nodeAncestryBitSetStack.push(nodeAncestryBitSet.getImmutable()); } } void popNodeAncestry() { nodeAncestryBitSet.setValue(nodeAncestryBitSetStack.pop()); } boolean updateNodeAncestry(Node node, CopyOnWriteRef<BitSet> nodeAncestryBitSet) {<FILL_FUNCTION_BODY>} /** * Visit the child nodes. * * @param parent the parent node whose children should be visited */ @Override public void visitChildren(@NotNull Node parent) { if (!isClassificationDone) { // initial collection phase if (!(parent instanceof Document)) { classifyingNodeTracker.nodeAdded(parent); } } if (parent.getFirstChild() != null) { pushNodeAncestry(); if (updateNodeAncestry(parent, nodeAncestryBitSet)) { super.visitChildren(parent); } popNodeAncestry(); } else { updateNodeAncestry(parent, nodeAncestryBitSet); } } }
if (!exclusionMap.isEmpty() && !(node instanceof Document)) { // add flags if needed BitSet bitSet = nodeAncestryBitSet.getPeek(); assert bitSet != null; int index = classifyingNodeTracker.getItems().indexOf(node); if (index == -1) { throw new IllegalStateException("Node: " + node + " is not tracked, some post processor forgot to call tracker.nodeAdded()."); } if (exclusionSet != null && !exclusionSet.isEmpty()) { Iterator<Class<?>> iterator = ((Set<Class<?>>) exclusionSet).iterator(); while (iterator.hasNext()) { Class<?> nodeType = iterator.next(); if (nodeType.isInstance(node)) { // get the index of this exclusion int i = exclusionSet.indexOf(nodeType); assert i != -1; if (!bitSet.get(i)) { bitSet = nodeAncestryBitSet.getMutable(); assert bitSet != null; bitSet.set(i); } } } } if (isClassificationDone && nodeAncestryBitSetStack.size() > 1) { // see if we can stop // now store the stuff for the node index BitSet oldBitSet = nodeAncestryMap.get(index); if (oldBitSet != null && oldBitSet.equals(bitSet)) { // no need to process descendants of this node return false; } } if (!bitSet.isEmpty()) { nodeAncestryMap.put(index, nodeAncestryBitSet.getImmutable()); } } return true;
1,086
453
1,539
<methods>public non-sealed void <init>() ,public void visitChildren(@NotNull Node) <variables>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeCollectingVisitor.java
NodeCollectingVisitor
visitChildren
class NodeCollectingVisitor { final public static Function<Node, Class<?>> NODE_CLASSIFIER = Node::getClass; final private static Class<?>[] EMPTY_CLASSES = new Class<?>[0]; final private @NotNull HashMap<Class<?>, List<Class<?>>> subClassMap; final private @NotNull HashSet<Class<?>> included; final private @NotNull HashSet<Class<?>> excluded; final private @NotNull ClassificationBag<Class<?>, Node> nodes; final private @NotNull Class<?>[] classes; public NodeCollectingVisitor(@NotNull Set<Class<?>> classes) { this.classes = classes.toArray(EMPTY_CLASSES); subClassMap = new HashMap<>(); included = new HashSet<>(); included.addAll(classes); for (Class<?> clazz : classes) { ArrayList<Class<?>> classList = new ArrayList<>(1); classList.add(clazz); subClassMap.put(clazz, classList); } excluded = new HashSet<>(); nodes = new ClassificationBag<>(NODE_CLASSIFIER); } public void collect(@NotNull Node node) { visit(node); } public SubClassingBag<Node> getSubClassingBag() { return new SubClassingBag<>(nodes, subClassMap); } private void visit(@NotNull Node node) { Class<?> nodeClass = node.getClass(); if (included.contains(nodeClass)) { nodes.add(node); } else if (!excluded.contains(nodeClass)) { // see if implements one of the original classes passed in for (Class<?> clazz : classes) { if (clazz.isInstance(node)) { // this class is included included.add(nodeClass); List<Class<?>> classList = subClassMap.get(clazz); if (classList == null) { classList = new ArrayList<>(2); classList.add(clazz); classList.add(nodeClass); subClassMap.put(clazz, classList); } else { classList.add(nodeClass); } nodes.add(node); visitChildren(node); return; } } // not of interest, exclude for next occurrence excluded.add(nodeClass); } visitChildren(node); } private void visitChildren(@NotNull Node parent) {<FILL_FUNCTION_BODY>} }
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 // node after visiting it. So get the next node before visiting. Node next = node.getNext(); visit(node); node = next; }
666
89
755
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterable.java
NodeIterable
forEach
class NodeIterable implements ReversiblePeekingIterable<Node> { final Node firstNode; final Node lastNode; final boolean reversed; public NodeIterable(Node firstNode, Node lastNode, boolean reversed) { this.firstNode = firstNode; this.lastNode = lastNode; this.reversed = reversed; } @NotNull @Override public ReversiblePeekingIterator<Node> iterator() { return new NodeIterator(firstNode, lastNode, reversed); } public void forEach(Consumer<? super Node> consumer) {<FILL_FUNCTION_BODY>} @NotNull @Override public ReversiblePeekingIterable<Node> reversed() { return new NodeIterable(firstNode, lastNode, !reversed); } @Override public boolean isReversed() { return reversed; } @NotNull @Override public ReversiblePeekingIterator<Node> reversedIterator() { return new NodeIterator(firstNode, lastNode, !reversed); } final public static ReversiblePeekingIterable<Node> EMPTY = new ReversiblePeekingIterable<Node>() { @NotNull @Override public ReversiblePeekingIterator<Node> iterator() { return NodeIterator.EMPTY; } @NotNull @Override public ReversiblePeekingIterable<Node> reversed() { return this; } public void forEach(Consumer<? super Node> consumer) { } @Override public boolean isReversed() { return false; } @NotNull @Override public ReversiblePeekingIterator<Node> reversedIterator() { return NodeIterator.EMPTY; } }; }
ReversibleIterator<Node> iterator = iterator(); while (iterator.hasNext()) { consumer.accept(iterator.next()); }
486
41
527
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeIterator.java
NodeIterator
next
class NodeIterator implements ReversiblePeekingIterator<Node> { final Node firstNode; final Node lastNode; final boolean reversed; Node node; Node result; /** * @param firstNode node from which to start the iteration and continue until all sibling nodes have been traversed */ public NodeIterator(Node firstNode) { this(firstNode, null, false); } /** * @param firstNode node from which to start the iteration and continue until all sibling nodes have been traversed * @param reversed true/false if the nodes are to be traversed in reverse order. If true the nodes previous sibling will be used instead of next sibling */ public NodeIterator(Node firstNode, boolean reversed) { this(firstNode, null, reversed); } /** * @param firstNode node from which to start the iteration and continue until all sibling nodes have been traversed or lastNode has been traversed * @param lastNode the last node to be traversed */ public NodeIterator(Node firstNode, Node lastNode) { this(firstNode, lastNode, false); } /** * iterate nodes until null or last node is iterated over * * @param firstNode node from which to start the iteration and continue until all sibling nodes have been traversed or lastNode has been traversed * @param lastNode the last node to be traversed * @param reversed true/false if the nodes are to be traversed in reverse order. If true the nodes previous sibling will be used instead of next sibling */ public NodeIterator(Node firstNode, Node lastNode, boolean reversed) { if (firstNode == null) throw new NullPointerException(); this.firstNode = firstNode; this.lastNode = lastNode; this.reversed = reversed; this.node = reversed ? lastNode : firstNode; } /** * @return true if the iterator is a reversed iterator */ @Override public boolean isReversed() { return reversed; } /** * @return true if there is a next node */ @Override public boolean hasNext() { return node != null; } /** * @return the next node for the iterator. If the iterator is not reversed then the previous node's next sibling is returned. If it is reversed the the previous node's previous sibling is returned. */ @Override public Node next() {<FILL_FUNCTION_BODY>} /** * @return the node which would be returned by a call to {@link #next()} or null if there is no next node. */ @Nullable public Node peek() { if (node != null) { return node; } return null; } /** * Remove the last node returned by {@link #next()} */ @Override public void remove() { if (result == null) { throw new IllegalStateException("Either next() was not called yet or the node was removed"); } result.unlink(); result = null; } public void forEachRemaining(Consumer<? super Node> consumer) { if (consumer == null) throw new NullPointerException(); while (hasNext()) { consumer.accept(next()); } } final public static ReversiblePeekingIterator<Node> EMPTY = new ReversiblePeekingIterator<Node>() { @Override public void remove() { } @Override public boolean isReversed() { return false; } @Override public boolean hasNext() { return false; } @Override public Node next() { throw new NoSuchElementException(); } @Nullable @Override public Node peek() { return null; } }; }
result = null; if (node == null) { throw new NoSuchElementException(); } result = node; node = reversed ? node.getPrevious() : node.getNext(); if (node == null || result == (reversed ? firstNode : lastNode)) node = null; return result;
1,025
86
1,111
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeRepository.java
NodeRepository
transferReferences
class NodeRepository<T> implements Map<String, T> { protected final ArrayList<T> nodeList = new ArrayList<>(); protected final Map<String, T> nodeMap = new HashMap<>(); protected final KeepType keepType; public abstract @NotNull DataKey<? extends NodeRepository<T>> getDataKey(); public abstract @NotNull DataKey<KeepType> getKeepDataKey(); // function implementing extraction of referenced elements by given node or its children public abstract @NotNull Set<T> getReferencedElements(Node parent); @SafeVarargs protected final void visitNodes(@NotNull Node parent, @NotNull Consumer<Node> runnable, @NotNull Class<? extends Node>... classes) { NodeVisitor visitor = new NodeVisitor(); for (Class<? extends Node> clazz : classes) { visitor.addHandler(new VisitHandler<>(clazz, runnable::accept)); } visitor.visit(parent); } public NodeRepository(@Nullable KeepType keepType) { this.keepType = keepType == null ? KeepType.LOCKED : keepType; } public @NotNull String normalizeKey(@NotNull CharSequence key) { return key.toString(); } public @Nullable T getFromRaw(@NotNull CharSequence rawKey) { return nodeMap.get(normalizeKey(rawKey)); } public @Nullable T putRawKey(@NotNull CharSequence key, @NotNull T t) { return put(normalizeKey(key), t); } public @NotNull Collection<T> getValues() { return nodeMap.values(); } public static <T> boolean transferReferences(@NotNull NodeRepository<T> destination, @NotNull NodeRepository<T> included, boolean onlyIfUndefined, @Nullable Map<String, String> referenceIdMap) {<FILL_FUNCTION_BODY>} @Override public @Nullable T put(@NotNull String s, @NotNull T t) { nodeList.add(t); if (keepType == KeepType.LOCKED) throw new IllegalStateException("Not allowed to modify LOCKED repository"); if (keepType != KeepType.LAST) { T another = nodeMap.get(s); if (another != null) { if (keepType == KeepType.FAIL) throw new IllegalStateException("Duplicate key " + s); return another; } } return nodeMap.put(s, t); } @Override public void putAll(@NotNull Map<? extends String, ? extends T> map) { if (keepType == KeepType.LOCKED) throw new IllegalStateException("Not allowed to modify LOCKED repository"); if (keepType != KeepType.LAST) { for (String key : map.keySet()) { nodeMap.put(key, map.get(key)); } } else { nodeMap.putAll(map); } } @Override public @Nullable T remove(@NotNull Object o) { if (keepType == KeepType.LOCKED) throw new IllegalStateException("Not allowed to modify LOCKED repository"); return nodeMap.remove(o); } @Override public void clear() { if (keepType == KeepType.LOCKED) throw new IllegalStateException("Not allowed to modify LOCKED repository"); nodeMap.clear(); } @Override public int size() {return nodeMap.size();} @Override public boolean isEmpty() {return nodeMap.isEmpty();} @Override public boolean containsKey(@NotNull 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);} @NotNull @Override public Set<String> keySet() {return nodeMap.keySet();} @NotNull @Override public List<T> values() {return nodeList;} @NotNull @Override public Set<Entry<String, T>> entrySet() {return nodeMap.entrySet();} @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object o) { return nodeMap.equals(o); } @Override public int hashCode() {return nodeMap.hashCode();} }
// copy references but only if they are not defined in the original document boolean transferred = false; for (Map.Entry<String, T> entry : included.entrySet()) { String key = entry.getKey(); // map as requested if (referenceIdMap != null) referenceIdMap.getOrDefault(key, key); if (!onlyIfUndefined || !destination.containsKey(key)) { destination.put(key, entry.getValue()); transferred = true; } } return transferred;
1,108
136
1,244
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/NodeVisitorBase.java
NodeVisitorBase
visitChildren
class NodeVisitorBase { protected abstract void visit(@NotNull Node node); public void visitChildren(@NotNull Node parent) {<FILL_FUNCTION_BODY>} }
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 // node after visiting it. So get the next node before visiting. Node next = node.getNext(); visit(node); node = next; }
45
89
134
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-ast/src/main/java/com/vladsch/flexmark/util/ast/TextCollectingVisitor.java
TextCollectingVisitor
processNode
class TextCollectingVisitor { final private NodeVisitor myVisitor; SpaceInsertingSequenceBuilder out; int flags; // flags defined by TextContainer public TextCollectingVisitor() { myVisitor = new NodeVisitor() { @Override public void processNode(@NotNull Node node, boolean withChildren, @NotNull BiConsumer<Node, Visitor<Node>> processor) {<FILL_FUNCTION_BODY>} }; } public String getText() { return out.toString(); } public BasedSequence getSequence() { return out.toSequence(); } public void collect(Node node) { collect(node, 0); } public String collectAndGetText(Node node) { return collectAndGetText(node, 0); } public BasedSequence collectAndGetSequence(Node node) { return collectAndGetSequence(node, 0); } public void collect(Node node, int flags) { out = SpaceInsertingSequenceBuilder.emptyBuilder(node.getChars(), flags); this.flags = flags; myVisitor.visit(node); } public String collectAndGetText(Node node, int flags) { collect(node, flags); return out.toString(); } public BasedSequence collectAndGetSequence(Node node, int flags) { collect(node, flags); return out.toSequence(); } }
if (!node.isOrDescendantOfType(DoNotCollectText.class)) { out.setLastNode(node); if (node instanceof Block && out.isNotEmpty()) { out.appendEol(); } if (node instanceof TextContainer) { final TextContainer textContainer = (TextContainer) node; if (textContainer.collectText(out, flags, myVisitor)) { if (node instanceof BlankLineBreakNode && out.isNotEmpty()) { out.appendEol(); } processChildren(node, processor); } textContainer.collectEndText(out, flags, myVisitor); } else { processChildren(node, processor); } if (node instanceof LineBreakNode && out.needEol()) { out.appendEol(); } }
370
210
580
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-builder/src/main/java/com/vladsch/flexmark/util/builder/BuilderBase.java
BuilderBase
addExtensionApiPoint
class BuilderBase<T extends BuilderBase<T>> extends MutableDataSet { // loaded extensions final private HashSet<Class<?>> loadedExtensions = new HashSet<>(); // map of which api points were loaded by which extensions final private HashMap<Class<?>, HashSet<Object>> extensionApiPoints = new HashMap<>(); private Extension currentExtension; /** * Remove apiPoint from state information * * @param apiPoint api point object */ protected abstract void removeApiPoint(@NotNull 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); /** * Load extension if it is valid * * @param extension to load * @return true if extension was loaded */ protected abstract boolean loadExtension(@NotNull Extension extension); /** * @param extensions extensions to load * @return {@code this} */ final public @NotNull T extensions(@NotNull Collection<? extends Extension> extensions) { ArrayList<Extension> addedExtensions = new ArrayList<>(EXTENSIONS.get(this).size() + extensions.size()); // first give extensions a chance to modify parser options for (Extension extension : extensions) { currentExtension = extension; if (!loadedExtensions.contains(extension.getClass())) { preloadExtension(extension); addedExtensions.add(extension); } currentExtension = null; } for (Extension extension : extensions) { currentExtension = extension; Class<? extends Extension> extensionClass = extension.getClass(); if (!loadedExtensions.contains(extensionClass)) { if (loadExtension(extension)) { loadedExtensions.add(extensionClass); addedExtensions.add(extension); } } currentExtension = null; } if (!addedExtensions.isEmpty()) { // need to set extensions to options to make it all consistent addedExtensions.addAll(0, EXTENSIONS.get(this)); set(EXTENSIONS, addedExtensions); } //noinspection unchecked return (T) this; } /** * @return actual instance the builder is supposed to build */ @NotNull public abstract Object build(); /** * Call to add extension API point to track * * @param apiPoint point registered */ protected void addExtensionApiPoint(@NotNull Object apiPoint) {<FILL_FUNCTION_BODY>} /** * Tracks keys set by extension initialization * * @param key data key * @param value value for the key * @return builder */ @NotNull @Override public <V> MutableDataSet set(@NotNull DataKey<V> key, @NotNull V value) { addExtensionApiPoint(key); return super.set(key, value); } @NotNull @Override public <V> MutableDataSet set(@NotNull NullableDataKey<V> key, @Nullable V value) { addExtensionApiPoint(key); return super.set(key, value); } /** * Get the given key, if it does not exist then use the key's factory to create a new value and put it into the collection * so that the following get of the same key will find a value * * @param key data key * @return return stored value or newly created value * @deprecated use key.get(dataHolder) instead, which will do the same thing an carries nullable information for the data */ @Deprecated @Override public <V> V get(@NotNull DataKey<V> key) { return key.get(this); } protected BuilderBase(@Nullable DataHolder options) { super(options); } protected void loadExtensions() { if (contains(EXTENSIONS)) { extensions(EXTENSIONS.get(this)); } } protected BuilderBase() { super(); } /** * Remove given extensions from options[EXTENSIONS] data key. * * @param options options where EXTENSIONS key is set * @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<Class<? extends Extension>> excludeExtensions) { if (options.contains(EXTENSIONS)) { ArrayList<Extension> extensions = new ArrayList<>(EXTENSIONS.get(options)); boolean removed = extensions.removeIf(it -> excludeExtensions.contains(it.getClass())); if (removed) { if (options instanceof MutableDataHolder) { return ((MutableDataHolder) options).set(EXTENSIONS, extensions); } else { return options.toMutable().set(EXTENSIONS, extensions).toImmutable(); } } } return options; } }
Extension extension = currentExtension; if (extension != null) { Class<? extends Extension> extensionClass = extension.getClass(); HashSet<Object> apiPoints = extensionApiPoints.computeIfAbsent(extensionClass, k -> new HashSet<>()); apiPoints.add(apiPoint); }
1,300
81
1,381
<methods>public void <init>() ,public void <init>(@Nullable DataHolder) ,public @NotNull MutableDataSet clear() ,public @Nullable Object getOrCompute(@NotNull DataKeyBase<?>, @NotNull DataValueFactory<?>) ,public static transient com.vladsch.flexmark.util.data.MutableDataSet merge(com.vladsch.flexmark.util.data.DataHolder[]) ,public @NotNull MutableDataSet remove(@NotNull DataKeyBase<?>) ,public @NotNull MutableDataSet set(@NotNull DataKey<T>, @NotNull T) ,public @NotNull MutableDataSet set(@NotNull NullableDataKey<T>, @Nullable T) ,public @NotNull MutableDataSet setAll(@NotNull DataHolder) ,public @NotNull MutableDataSet setFrom(@NotNull MutableDataSetter) ,public @NotNull MutableDataHolder setIn(@NotNull MutableDataHolder) ,public @NotNull MutableDataSet toDataSet() ,public @NotNull DataSet toImmutable() ,public @NotNull MutableDataSet toMutable() <variables>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMaxAggregator.java
BoundedMaxAggregator
apply
class BoundedMaxAggregator implements BiFunction<Integer, Integer, Integer> { final public int maxBound; public BoundedMaxAggregator(int maxBound) { this.maxBound = maxBound; } @Override public Integer apply(@Nullable Integer aggregate, @Nullable Integer next) {<FILL_FUNCTION_BODY>} }
if (next != null && next < maxBound) return MaxAggregator.INSTANCE.apply(aggregate, next); else return aggregate;
89
39
128
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/BoundedMinAggregator.java
BoundedMinAggregator
apply
class BoundedMinAggregator implements BiFunction<Integer, Integer, Integer> { final public int minBound; public BoundedMinAggregator(int minBound) { this.minBound = minBound; } @Override public Integer apply(@Nullable Integer aggregate, @Nullable Integer next) {<FILL_FUNCTION_BODY>} }
if (next != null && next > minBound) return MinAggregator.INSTANCE.apply(aggregate, next); else return aggregate;
89
39
128
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ClassificationBag.java
ClassificationBag
categoriesBitSet
class ClassificationBag<K, V> { final private @NotNull OrderedSet<V> items; final @NotNull IndexedItemBitSetMap<K, V> bag; final @Nullable CollectionHost<V> host; public ClassificationBag(Function<V, K> mapper) { this(0, mapper); } public ClassificationBag(@NotNull Function<V, K> mapper, @Nullable CollectionHost<V> host) { this(0, mapper, host); } public ClassificationBag(int capacity, @NotNull Function<V, K> mapper) { this(capacity, mapper, null); } public ClassificationBag(int capacity, @NotNull Function<V, K> mapper, @Nullable CollectionHost<V> host) { this.host = host; this.items = new OrderedSet<>(capacity, new CollectionHost<V>() { @Override public void adding(int index, @Nullable V v, @Nullable Object v2) { if (ClassificationBag.this.host != null && !ClassificationBag.this.host.skipHostUpdate()) ClassificationBag.this.host.adding(index, v, v2); if (v != null) bag.addItem(v, index); } @Override public Object removing(int index, @Nullable V v) { if (ClassificationBag.this.host != null && !ClassificationBag.this.host.skipHostUpdate()) ClassificationBag.this.host.removing(index, v); if (v != null) bag.removeItem(v, index); return null; } @Override public void clearing() { if (ClassificationBag.this.host != null && !ClassificationBag.this.host.skipHostUpdate()) ClassificationBag.this.host.clearing(); bag.clear(); } @Override public void addingNulls(int index) { // nothing to be done, we're good if (ClassificationBag.this.host != null && !ClassificationBag.this.host.skipHostUpdate()) ClassificationBag.this.host.addingNulls(index); } @Override public boolean skipHostUpdate() { return false; } @Override public int getIteratorModificationCount() { return getModificationCount(); } }); this.bag = new IndexedItemBitSetMap<>(mapper); } @NotNull public OrderedSet<V> getItems() { return items; } @SuppressWarnings("WeakerAccess") public int getModificationCount() { return items.getModificationCount(); } public boolean add(@Nullable V item) { return items.add(item); } public boolean remove(@Nullable V item) { return items.remove(item); } public boolean remove(int index) { return items.removeIndex(index); } public boolean contains(@Nullable V item) { return items.contains(item); } public boolean containsCategory(@Nullable K category) { BitSet bitSet = bag.get(category); return bitSet != null && !bitSet.isEmpty(); } public @Nullable BitSet getCategorySet(@Nullable K category) { return bag.get(category); } @SuppressWarnings("WeakerAccess") public int getCategoryCount(@Nullable K category) { BitSet bitSet = bag.get(category); return bitSet == null ? 0 : bitSet.cardinality(); } public @NotNull Map<K, BitSet> getCategoryMap() { return bag; } public void clear() { items.clear(); } @SafeVarargs final public <X> @NotNull ReversibleIterable<X> getCategoryItems(@NotNull Class<? extends X> xClass, @NotNull K... categories) { return new IndexedIterable<X, V, ReversibleIterable<Integer>>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(categoriesBitSet(categories), false)); } final public <X> @NotNull ReversibleIterable<X> getCategoryItems(@NotNull Class<? extends X> xClass, @NotNull Collection<? extends K> categories) { return new IndexedIterable<X, V, ReversibleIterable<Integer>>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(categoriesBitSet(categories), false)); } final public <X> @NotNull ReversibleIterable<X> getCategoryItems(@NotNull Class<? extends X> xClass, @NotNull BitSet bitSet) { return new IndexedIterable<X, V, ReversibleIterable<Integer>>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(bitSet, false)); } @SafeVarargs final public <X> @NotNull ReversibleIterable<X> getCategoryItemsReversed(@NotNull Class<? extends X> xClass, @NotNull K... categories) { return new IndexedIterable<X, V, ReversibleIterable<Integer>>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(categoriesBitSet(categories), true)); } final public <X> @NotNull ReversibleIterable<X> getCategoryItemsReversed(@NotNull Class<? extends X> xClass, @NotNull Collection<? extends K> categories) { return new IndexedIterable<X, V, ReversibleIterable<Integer>>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(categoriesBitSet(categories), true)); } final public <X> @NotNull ReversibleIterable<X> getCategoryItemsReversed(@NotNull Class<? extends X> xClass, @NotNull BitSet bitSet) { return new IndexedIterable<X, V, ReversibleIterable<Integer>>(items.getConcurrentModsIndexedProxy(), new BitSetIterable(bitSet, true)); } @SafeVarargs @SuppressWarnings("WeakerAccess") final public @NotNull BitSet categoriesBitSet(@NotNull K... categories) { BitSet bitSet = new BitSet(); for (K category : categories) { BitSet bitSet1 = bag.get(category); if (bitSet1 != null) { bitSet.or(bitSet1); } } return bitSet; } final public @NotNull BitSet categoriesBitSet(@NotNull Collection<? extends K> categories) {<FILL_FUNCTION_BODY>} }
BitSet bitSet = new BitSet(); for (K category : categories) { BitSet bitSet1 = bag.get(category); if (bitSet1 != null) { bitSet.or(bitSet1); } } return bitSet;
1,684
73
1,757
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/CopyOnWriteRef.java
CopyOnWriteRef
getMutable
class CopyOnWriteRef<T> { private @Nullable T value; private int referenceCount; final private @NotNull Function<T, T> copyFunction; public CopyOnWriteRef(@Nullable T value, @NotNull Function<T, T> copyFunction) { this.value = value; referenceCount = 0; this.copyFunction = copyFunction; } public @Nullable T getPeek() { return value; } public @Nullable T getImmutable() { if (value != null) referenceCount++; return value; } public @Nullable T getMutable() {<FILL_FUNCTION_BODY>} public void setValue(@Nullable T value) { referenceCount = 0; this.value = copyFunction.apply(value); } public boolean isMutable() { return referenceCount == 0; } }
if (referenceCount > 0) { value = copyFunction.apply(value); referenceCount = 0; } return value;
229
39
268
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/IndexedItemSetMapBase.java
IndexedItemSetMapBase
containsItem
class IndexedItemSetMapBase<K, S, M> implements IndexedItemSetMap<K, S, M> { protected final HashMap<K, S> bag; public IndexedItemSetMapBase() { this(0); } public IndexedItemSetMapBase(int capacity) { this.bag = new HashMap<>(); } @Override public abstract @NotNull K mapKey(@NotNull M key); @Override public abstract @NotNull S newSet(); @Override public abstract boolean addSetItem(@NotNull S s, int item); @Override public abstract boolean removeSetItem(@NotNull S s, int item); @Override public abstract boolean containsSetItem(@NotNull S s, int item); @Override public boolean addItem(@NotNull M key, int item) { K mapKey = mapKey(key); S itemSet = bag.get(mapKey); if (itemSet == null) { itemSet = newSet(); bag.put(mapKey, itemSet); } return addSetItem(itemSet, item); } @Override public boolean removeItem(@NotNull 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) {<FILL_FUNCTION_BODY>} @Override public int size() { return bag.size(); } @Override public boolean isEmpty() { return bag.isEmpty(); } @Override public boolean containsKey(@Nullable Object o) { return bag.containsKey(o); } @Override public boolean containsValue(@Nullable Object o) { return bag.containsValue(o); } @Override public @Nullable S get(@Nullable Object o) { return bag.get(o); } @Override public @Nullable S put(@NotNull K k, @NotNull S vs) { return bag.put(k, vs); } @Override public @Nullable S remove(@Nullable Object o) { return bag.remove(o); } @Override public void putAll(@NotNull Map<? extends K, ? extends S> map) { bag.putAll(map); } @Override public void clear() { bag.clear(); } @Override public @NotNull Set<K> keySet() { return bag.keySet(); } @Override public @NotNull Collection<S> values() { return bag.values(); } @Override public @NotNull Set<Entry<K, S>> entrySet() { return bag.entrySet(); } }
K mapKey = mapKey(key); S itemSet = bag.get(mapKey); return itemSet != null && containsSetItem(itemSet, item);
726
45
771
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/ItemFactoryMap.java
ItemFactoryMap
getItem
class ItemFactoryMap<I, P> implements Map<Function<P, I>, I> { protected final HashMap<Function<P, I>, I> itemMap; protected final @NotNull P param; public ItemFactoryMap(@NotNull P param) { this(param, 0); } public ItemFactoryMap(@NotNull P param, int capacity) { this.itemMap = new HashMap<>(capacity); this.param = param; } public I getItem(Function<P, I> factory) {<FILL_FUNCTION_BODY>} @Override public @Nullable I get(@Nullable Object o) { if (o instanceof Function) { //noinspection unchecked return getItem((Function<P, I>) o); } return null; } @Override public int size() {return itemMap.size();} @Override public boolean isEmpty() {return itemMap.isEmpty();} @Override public boolean containsKey(@Nullable Object o) {return itemMap.containsKey(o);} @Override public @Nullable I put(@NotNull Function<P, I> factory, @NotNull I i) {return itemMap.put(factory, i);} @Override public void putAll(@NotNull Map<? extends Function<P, I>, ? extends I> map) {itemMap.putAll(map);} @Override public @Nullable I remove(@Nullable Object o) {return itemMap.remove(o);} @Override public void clear() {itemMap.clear();} @Override public boolean containsValue(@Nullable Object o) {return itemMap.containsValue(o);} @Override public @NotNull Set<Function<P, I>> keySet() {return itemMap.keySet();} @Override public @NotNull Collection<I> values() {return itemMap.values();} @Override public @NotNull Set<Entry<Function<P, I>, I>> entrySet() {return itemMap.entrySet();} }
I item = itemMap.get(factory); if (item == null) { item = factory.apply(param); itemMap.put(factory, item); } return item;
516
53
569
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MapEntry.java
MapEntry
equals
class MapEntry<K, V> implements Map.Entry<K, V> { final private @NotNull K key; final private @Nullable V value; public MapEntry(@NotNull K key, @Nullable V value) { this.key = key; this.value = value; } @Override public @NotNull K getKey() { return key; } @Override public @Nullable V getValue() { return value; } @Override public @Nullable V setValue(V v) { throw new UnsupportedOperationException(); } @Override public boolean equals(@Nullable Object o) {<FILL_FUNCTION_BODY>} @Override public int hashCode() { int result = key.hashCode(); result = 31 * result + (value != null ? value.hashCode() : 0); return result; } }
if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MapEntry<?, ?> entry = (MapEntry<?, ?>) o; if (!Objects.equals(key, entry.key)) return false; return Objects.equals(value, entry.value);
234
88
322
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MaxAggregator.java
MaxAggregator
apply
class MaxAggregator implements BiFunction<Integer, Integer, Integer> { final public static MaxAggregator INSTANCE = new MaxAggregator(); private MaxAggregator() { } @Override public @Nullable Integer apply(@Nullable Integer aggregate, @Nullable Integer next) {<FILL_FUNCTION_BODY>} }
return next == null || aggregate != null && aggregate >= next ? aggregate : next;
82
23
105
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/MinAggregator.java
MinAggregator
apply
class MinAggregator implements BiFunction<Integer, Integer, Integer> { final public static MinAggregator INSTANCE = new MinAggregator(); private MinAggregator() { } @Override public @Nullable Integer apply(@Nullable Integer aggregate, @Nullable Integer next) {<FILL_FUNCTION_BODY>} }
return next == null || aggregate != null && aggregate <= next ? aggregate : next;
82
23
105
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/SubClassingBag.java
SubClassingBag
typeBitSet
class SubClassingBag<T> { final private @NotNull ClassificationBag<Class<?>, T> items; final private @NotNull HashMap<Class<?>, BitSet> subClassMap; public SubClassingBag(@NotNull ClassificationBag<Class<?>, T> items, HashMap<Class<?>, @NotNull List<Class<?>>> subClassMap) { this.items = items; this.subClassMap = new HashMap<>(); for (Class<?> clazz : subClassMap.keySet()) { List<Class<?>> classList = subClassMap.get(clazz); BitSet bitSet = this.items.categoriesBitSet(classList); if (!bitSet.isEmpty()) { this.subClassMap.put(clazz, bitSet); } } } public @NotNull OrderedSet<T> getItems() { return items.getItems(); } public boolean contains(@Nullable T item) { return items.contains(item); } public boolean containsType(@Nullable Class<?> type) { return items.containsCategory(type); } public BitSet getTypeSet(@Nullable Class<?> category) { return subClassMap.get(category); } public int getTypeCount(@Nullable Class<?> category) { BitSet bitSet = subClassMap.get(category); return bitSet == null ? 0 : bitSet.cardinality(); } final public <X> @NotNull ReversibleIterable<X> itemsOfType(@NotNull Class<X> xClass, @NotNull Class<?>... categories) { return items.getCategoryItems(xClass, typeBitSet(xClass, categories)); } final public <X> @NotNull ReversibleIterable<X> itemsOfType(@NotNull Class<X> xClass, @NotNull Collection<Class<?>> categories) { return items.getCategoryItems(xClass, typeBitSet(xClass, categories)); } final public <X> @NotNull ReversibleIterable<X> reversedItemsOfType(@NotNull Class<X> xClass, @NotNull Class<?>... categories) { return items.getCategoryItemsReversed(xClass, typeBitSet(xClass, categories)); } final public <X> @NotNull ReversibleIterable<X> reversedItemsOfType(@NotNull Class<X> xClass, @NotNull Collection<Class<?>> categories) { return items.getCategoryItemsReversed(xClass, typeBitSet(xClass, categories)); } @SuppressWarnings("WeakerAccess") final public @NotNull BitSet typeBitSet(@NotNull Class<?> xClass, @NotNull Class<?>... categories) {<FILL_FUNCTION_BODY>} @SuppressWarnings("WeakerAccess") final public @NotNull BitSet typeBitSet(@NotNull Class<?> xClass, @NotNull Collection<Class<?>> categories) { BitSet bitSet = new BitSet(); for (Class<?> category : categories) { if (xClass.isAssignableFrom(category) && subClassMap.containsKey(category)) { bitSet.or(subClassMap.get(category)); } } return bitSet; } }
BitSet bitSet = new BitSet(); for (Class<?> category : categories) { if (xClass.isAssignableFrom(category) && subClassMap.containsKey(category)) { bitSet.or(subClassMap.get(category)); } } return bitSet;
829
80
909
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/ArrayIterable.java
MyIterator
hasNext
class MyIterator<E> implements ReversibleIterator<E> { final private E[] array; final private int startIndex; final private int endIndex; final private boolean isReversed; private int index; public MyIterator(E[] array, int startIndex, int endIndex, boolean isReversed) { this.isReversed = isReversed; this.array = array; this.startIndex = startIndex; this.endIndex = endIndex; index = isReversed ? endIndex : startIndex; } @Override public boolean hasNext() {<FILL_FUNCTION_BODY>} @Override public E next() { return isReversed ? array[--index] : array[index++]; } @Override public boolean isReversed() { return isReversed; } }
return isReversed ? index >= startIndex : index < endIndex;
230
21
251
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/BitSetIterator.java
BitSetIterator
next
class BitSetIterator implements ReversibleIterator<Integer> { final private @NotNull BitSet bitSet; final private boolean reversed; private int next; private int last; public BitSetIterator(@NotNull BitSet bitSet) { this(bitSet, false); } public BitSetIterator(@NotNull BitSet bitSet, boolean reversed) { this.bitSet = bitSet; this.reversed = reversed; next = reversed ? bitSet.previousSetBit(bitSet.length()) : bitSet.nextSetBit(0); last = -1; } @Override public boolean isReversed() { return reversed; } @Override public boolean hasNext() { return next != -1; } @Override public Integer next() {<FILL_FUNCTION_BODY>} @Override public void remove() { if (last == -1) throw new NoSuchElementException(); bitSet.clear(last); } public void forEachRemaining(@NotNull Consumer<? super Integer> consumer) { while (hasNext()) { consumer.accept(next()); } } }
if (next == -1) throw new NoSuchElementException(); last = next; next = reversed ? (next == 0 ? -1 : bitSet.previousSetBit(next - 1)) : bitSet.nextSetBit(next + 1); return last;
312
72
384
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedItemIterator.java
IndexedItemIterator
next
class IndexedItemIterator<R> implements ReversibleIndexedIterator<R> { final private Indexed<R> items; final private boolean reversed; private int next; private int last; private int modificationCount; public IndexedItemIterator(@NotNull Indexed<R> items) { this(items, false); } public IndexedItemIterator(@NotNull Indexed<R> items, boolean isReversed) { this.items = items; reversed = isReversed; next = reversed ? items.size() - 1 : 0; // empty forward iterator has no next if (next >= items.size()) next = -1; last = -1; this.modificationCount = items.modificationCount(); } @Override public boolean isReversed() { return reversed; } @Override public boolean hasNext() { return next != -1; } @Override public @NotNull R next() {<FILL_FUNCTION_BODY>} @Override public void remove() { if (last == -1) { throw new NoSuchElementException(); } if (modificationCount != items.modificationCount()) { throw new ConcurrentModificationException(); } items.removeAt(last); last = -1; modificationCount = items.modificationCount(); } @Override public int getIndex() { if (last < 0) { throw new NoSuchElementException(); } return last; } public void forEachRemaining(@NotNull Consumer<? super R> consumer) { while (hasNext()) { consumer.accept(next()); } } }
if (modificationCount != items.modificationCount()) { throw new ConcurrentModificationException(); } if (next == -1) { throw new NoSuchElementException(); } last = next; next = reversed ? (next <= 0 ? -1 : next - 1) : next == items.size() - 1 ? -1 : next + 1; return items.get(last);
455
109
564
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/IndexedIterator.java
IndexedIterator
remove
class IndexedIterator<R, S, I extends ReversibleIterator<Integer>> implements ReversibleIndexedIterator<R> { final private I iterator; final private Indexed<S> items; private int lastIndex; private int modificationCount; public IndexedIterator(@NotNull Indexed<S> items, @NotNull I iterator) { this.items = items; this.iterator = iterator; this.lastIndex = -1; this.modificationCount = items.modificationCount(); } @Override public boolean isReversed() { return iterator.isReversed(); } @Override public boolean hasNext() { return iterator.hasNext(); } @Override public @NotNull R next() { if (modificationCount != items.modificationCount()) { throw new ConcurrentModificationException(); } lastIndex = iterator.next(); //noinspection unchecked return (R) items.get(lastIndex); } @Override public void remove() {<FILL_FUNCTION_BODY>} @Override public int getIndex() { if (lastIndex < 0) { throw new NoSuchElementException(); } return lastIndex; } public void forEachRemaining(@NotNull Consumer<? super R> consumer) { while (hasNext()) { consumer.accept(next()); } } }
if (lastIndex == -1) { throw new NoSuchElementException(); } if (modificationCount != items.modificationCount()) { throw new ConcurrentModificationException(); } items.removeAt(lastIndex); lastIndex = -1; modificationCount = items.modificationCount();
375
86
461
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-collection/src/main/java/com/vladsch/flexmark/util/collection/iteration/Reverse.java
ReversedListIterator
next
class ReversedListIterator<T> implements ReversibleIterator<T> { final private @NotNull List<T> list; final private boolean isReversed; private int index; ReversedListIterator(@NotNull List<T> list, boolean isReversed) { this.list = list; this.isReversed = isReversed; if (isReversed) { this.index = list.size() == 0 ? -1 : list.size() - 1; } else { this.index = list.size() == 0 ? -1 : 0; } } @Override public boolean isReversed() { return isReversed; } @Override public void remove() { } @Override public boolean hasNext() { return index != -1; } @Override public T next() {<FILL_FUNCTION_BODY>} }
T t = list.get(index); if (index != -1) { if (isReversed) { index--; } else { if (index == list.size() - 1) { index = -1; } else { index++; } } } return t;
250
92
342
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKey.java
DataKey
toString
class DataKey<T> extends DataKeyBase<T> { /** * Creates a DataKey with non-null data value and factory * <p> * Use this constructor to ensure that factory is never called with null data holder value * * @param name See {@link #getName()}. * @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<T> factory) { super(name, defaultValue, factory); } /** * Creates a DataKey with non-null data value and factory * <p> * Use this constructor to ensure that factory is never called with null data holder value * * @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<T> supplier) { super(name, supplier.get(), (holder) -> supplier.get()); } /** * Creates a DataKey with a dynamic default value taken from a value of another key * <p> * does not cache the returned default value but will always delegate to another key until this key * gets its own value set. * * @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<T> defaultKey) { this(name, defaultKey.getDefaultValue(), defaultKey::get); } public DataKey(@NotNull String name, @NotNull T defaultValue) { this(name, defaultValue, options -> defaultValue); } @NotNull public DataNotNullValueFactory<T> getFactory() { return (DataNotNullValueFactory<T>) super.getFactory(); } @NotNull public T getDefaultValue() { return super.getDefaultValue(); } @NotNull public T getDefaultValue(@NotNull 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) { return dataHolder.set(this, value); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
// factory applied to null in constructor, no sense doing it again here T defaultValue = getDefaultValue(); return "DataKey<" + defaultValue.getClass().getSimpleName() + "> " + getName();
672
56
728
<methods>public void <init>(@NotNull String, T, @NotNull DataValueFactory<T>) ,public void <init>(@NotNull String, @NotNull DataKeyBase<T>) ,public void <init>(@NotNull String, T) ,public final boolean equals(java.lang.Object) ,public T get(@Nullable DataHolder) ,public T getDefaultValue() ,public T getDefaultValue(@NotNull DataHolder) ,public @NotNull DataValueFactory<T> getFactory() ,public final T getFrom(@Nullable DataHolder) ,public @NotNull String getName() ,public final int hashCode() ,public java.lang.String toString() <variables>private final non-sealed T defaultValue,private final non-sealed @NotNull DataValueFactory<T> factory,private final non-sealed @NotNull String name
vsch_flexmark-java
flexmark-java/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataKeyBase.java
DataKeyBase
toString
class DataKeyBase<T> implements MutableDataValueSetter<T> { final private @NotNull String name; final private @NotNull DataValueFactory<T> factory; final private T defaultValue; /** * Creates a NullableDataKey with a computed default value and a provided default value when data holder is null. * <p> * Use this constructor to ensure that factory is never called with null data holder value * * @param name See {@link #getName()}. * @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<T> factory) { this.name = name; this.defaultValue = defaultValue; this.factory = factory; } /** * Creates a NullableDataKey with a dynamic default value taken from a value of another key * <p> * does not cache the returned default value but will always delegate to another key until this key * gets its own value set. * * @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<T> defaultKey) { this(name, defaultKey.defaultValue, defaultKey::get); } public DataKeyBase(@NotNull String name, T defaultValue) { this(name, defaultValue, options -> defaultValue); } @NotNull public String getName() { return name; } @NotNull public DataValueFactory<T> getFactory() { return factory; } public T getDefaultValue() { return defaultValue; } public T getDefaultValue(@NotNull DataHolder holder) { return factory.apply(holder); } public T get(@Nullable DataHolder holder) { //noinspection unchecked return holder == null ? defaultValue : (T) holder.getOrCompute(this, this::getDefaultValue); } /** * @param holder data holder * @return return default value if holder is null, current value in holder or compute a new value * @deprecated use get */ @Deprecated final public T getFrom(@Nullable DataHolder holder) { return get(holder); } @Override public String toString() {<FILL_FUNCTION_BODY>} /** * Compare only by address. Every key instance is unique * * @param o other * @return true if equal */ @Override final public boolean equals(Object o) { return this == o; } @Override final public int hashCode() { return super.hashCode(); } }
if (defaultValue != null) { return "NullableDataKey<" + defaultValue.getClass().getSimpleName() + "> " + name; } else { return "NullableDataKey<unknown> " + name; }
735
63
798
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/DataSet.java
DataSet
registerDataKeyAggregator
class DataSet implements DataHolder { protected final HashMap<DataKeyBase<?>, Object> dataSet; public DataSet() { this(null); } public DataSet(@Nullable DataHolder other) { if (other == null) dataSet = new HashMap<>(); else dataSet = new HashMap<>(other.getAll()); } /** * aggregate actions of two data sets, actions not applied * * @param other first set of options * @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) { DataSet combined = new DataSet(other); combined.dataSet.putAll(overrides.getAll()); for (DataKeyAggregator combiner : ourDataKeyAggregators) { combined = combiner.aggregateActions(combined, other, overrides).toDataSet(); } return combined; } /** * Apply aggregate action to data and return result * * @return resulting data holder */ @NotNull public DataHolder aggregate() { DataHolder combined = this; for (DataKeyAggregator combiner : ourDataKeyAggregators) { combined = combiner.aggregate(combined); } return combined; } /** * Aggregate two sets of options by aggregating their aggregate action keys then applying those actions on the resulting collection * * @param other options with aggregate actions already applied, no aggregate action keys are expected or checked * @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(); } else if (overrides == null) { return other; } else if (other == null) { return overrides.toDataSet().aggregate().toImmutable(); } else { return aggregateActions(other, overrides).toDataSet().aggregate().toImmutable(); } } @Override public @NotNull Map<? extends DataKeyBase<?>, Object> getAll() { return dataSet; } @Override public @NotNull Collection<? extends DataKeyBase<?>> getKeys() { return dataSet.keySet(); } @Override public boolean contains(@NotNull DataKeyBase<?> key) { return dataSet.containsKey(key); } @Override public @Nullable Object getOrCompute(@NotNull DataKeyBase<?> key, @NotNull DataValueFactory<?> factory) { if (dataSet.containsKey(key)) { return dataSet.get(key); } else { return factory.apply(this); } } @NotNull public static DataSet merge(@NotNull DataHolder... dataHolders) { DataSet dataSet = new DataSet(); for (DataHolder dataHolder : dataHolders) { dataSet.dataSet.putAll(dataHolder.getAll()); } return dataSet; } @NotNull @Override public MutableDataSet toMutable() { return new MutableDataSet(this); } @NotNull @Override public DataSet toImmutable() { return this; } @Override public @NotNull DataSet toDataSet() { return this; } final private static ArrayList<DataKeyAggregator> ourDataKeyAggregators = new ArrayList<>(); public static void registerDataKeyAggregator(@NotNull DataKeyAggregator keyAggregator) {<FILL_FUNCTION_BODY>} static boolean isAggregatorRegistered(@NotNull DataKeyAggregator keyAggregator) { for (DataKeyAggregator aggregator : ourDataKeyAggregators) { if (aggregator.getClass() == keyAggregator.getClass()) return true; } return false; } static boolean invokeSetContains(@Nullable Set<Class<?>> invokeSet, @NotNull DataKeyAggregator aggregator) { if (invokeSet == null) return false; return invokeSet.contains(aggregator.getClass()); } @Override public String toString() { return "DataSet{" + "dataSet=" + dataSet + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof DataSet)) return false; DataSet set = (DataSet) o; return dataSet.equals(set.dataSet); } @Override public int hashCode() { return dataSet.hashCode(); } }
if (isAggregatorRegistered(keyAggregator)) { throw new IllegalStateException("Aggregator " + keyAggregator + " is already registered"); } // find where in the list it should go so that all combiners for (int i = 0; i < ourDataKeyAggregators.size(); i++) { DataKeyAggregator aggregator = ourDataKeyAggregators.get(i); if (invokeSetContains(aggregator.invokeAfterSet(), keyAggregator)) { // this one needs to be invoked before if (invokeSetContains(keyAggregator.invokeAfterSet(), aggregator)) { throw new IllegalStateException("Circular invokeAfter dependencies for " + keyAggregator + " and " + aggregator); } // add before this one ourDataKeyAggregators.add(i, keyAggregator); return; } } // add at the end ourDataKeyAggregators.add(keyAggregator);
1,243
240
1,483
<no_super_class>
vsch_flexmark-java
flexmark-java/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableDataSet.java
MutableDataSet
merge
class MutableDataSet extends DataSet implements MutableDataHolder { public MutableDataSet() { super(); } public MutableDataSet(@Nullable DataHolder other) { super(other); } @NotNull @Override public <T> MutableDataSet set(@NotNull DataKey<T> key, @NotNull T value) { return set((DataKeyBase<T>) key, value); } @NotNull @Override public <T> MutableDataSet set(@NotNull NullableDataKey<T> key, @Nullable T value) { return set((DataKeyBase<T>) key, value); } private <T> MutableDataSet set(@NotNull DataKeyBase<T> key, T value) { dataSet.put(key, value); return this; } @NotNull @Override public MutableDataSet setFrom(@NotNull MutableDataSetter dataSetter) { dataSetter.setIn(this); return this; } @NotNull @Override public MutableDataSet setAll(@NotNull DataHolder other) { dataSet.putAll(other.getAll()); return this; } public static MutableDataSet merge(DataHolder... dataHolders) {<FILL_FUNCTION_BODY>} @NotNull @Override public MutableDataHolder setIn(@NotNull MutableDataHolder dataHolder) { dataHolder.setAll(this); return dataHolder; } @NotNull @Override public MutableDataSet remove(@NotNull DataKeyBase<?> key) { dataSet.remove(key); return this; } @Override public @Nullable Object getOrCompute(@NotNull DataKeyBase<?> key, @NotNull DataValueFactory<?> factory) { if (dataSet.containsKey(key)) { return dataSet.get(key); } else { Object value = factory.apply(this); dataSet.put(key, value); return value; } } @NotNull @Override public MutableDataSet toMutable() { return this; } @NotNull @Override public DataSet toImmutable() { return new DataSet(this); } @Override public @NotNull MutableDataSet toDataSet() { return this; } @NotNull @Override public MutableDataSet clear() { dataSet.clear(); return this; } }
MutableDataSet dataSet = new MutableDataSet(); for (DataHolder dataHolder : dataHolders) { if (dataHolder != null) { dataSet.dataSet.putAll(dataHolder.getAll()); } } return dataSet;
649
73
722
<methods>public void <init>() ,public void <init>(@Nullable DataHolder) ,public @NotNull DataHolder aggregate() ,public static @NotNull DataHolder aggregate(@Nullable DataHolder, @Nullable DataHolder) ,public static @NotNull DataHolder aggregateActions(@NotNull DataHolder, @NotNull DataHolder) ,public boolean contains(@NotNull DataKeyBase<?>) ,public boolean equals(java.lang.Object) ,public @NotNull Map<? extends DataKeyBase<?>,Object> getAll() ,public @NotNull Collection<? extends DataKeyBase<?>> getKeys() ,public @Nullable Object getOrCompute(@NotNull DataKeyBase<?>, @NotNull DataValueFactory<?>) ,public int hashCode() ,public static transient @NotNull DataSet merge(@NotNull DataHolder []) ,public static void registerDataKeyAggregator(@NotNull DataKeyAggregator) ,public @NotNull DataSet toDataSet() ,public @NotNull DataSet toImmutable() ,public @NotNull MutableDataSet toMutable() ,public java.lang.String toString() <variables>protected final non-sealed HashMap<DataKeyBase<?>,java.lang.Object> dataSet,private static final ArrayList<com.vladsch.flexmark.util.data.DataKeyAggregator> ourDataKeyAggregators
vsch_flexmark-java
flexmark-java/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/MutableScopedDataSet.java
MutableScopedDataSet
getKeys
class MutableScopedDataSet extends MutableDataSet { protected final DataHolder parent; public MutableScopedDataSet(DataHolder parent) { super(); this.parent = parent; } public MutableScopedDataSet(DataHolder parent, MutableDataHolder other) { super(other); this.parent = parent; } public DataHolder getParent() { return parent; } @Override public @NotNull Map<? extends DataKeyBase<?>, Object> getAll() { if (parent != null) { HashMap<DataKeyBase<?>, Object> all = new HashMap<>(super.getAll()); for (DataKeyBase<?> key : parent.getKeys()) { if (!contains(key)) { all.put(key, key.get(parent)); } } return all; } else { return super.getAll(); } } @Override public @NotNull Collection<? extends DataKeyBase<?>> getKeys() {<FILL_FUNCTION_BODY>} @Override public boolean contains(@NotNull DataKeyBase<?> key) { return super.contains(key) || (parent != null && parent.contains(key)); } @Override public @Nullable Object getOrCompute(@NotNull DataKeyBase<?> key, @NotNull DataValueFactory<?> factory) { if (parent == null || super.contains(key) || !parent.contains(key)) { return super.getOrCompute(key, factory); } else { return parent.getOrCompute(key, factory); } } }
if (parent != null) { ArrayList<DataKeyBase<?>> all = new ArrayList<>(super.getKeys()); for (DataKeyBase<?> key : parent.getKeys()) { if (!contains(key)) { all.add(key); } } return all; } else { return super.getKeys(); }
427
97
524
<methods>public void <init>() ,public void <init>(@Nullable DataHolder) ,public @NotNull MutableDataSet clear() ,public @Nullable Object getOrCompute(@NotNull DataKeyBase<?>, @NotNull DataValueFactory<?>) ,public static transient com.vladsch.flexmark.util.data.MutableDataSet merge(com.vladsch.flexmark.util.data.DataHolder[]) ,public @NotNull MutableDataSet remove(@NotNull DataKeyBase<?>) ,public @NotNull MutableDataSet set(@NotNull DataKey<T>, @NotNull T) ,public @NotNull MutableDataSet set(@NotNull NullableDataKey<T>, @Nullable T) ,public @NotNull MutableDataSet setAll(@NotNull DataHolder) ,public @NotNull MutableDataSet setFrom(@NotNull MutableDataSetter) ,public @NotNull MutableDataHolder setIn(@NotNull MutableDataHolder) ,public @NotNull MutableDataSet toDataSet() ,public @NotNull DataSet toImmutable() ,public @NotNull MutableDataSet toMutable() <variables>
vsch_flexmark-java
flexmark-java/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/NullableDataKey.java
NullableDataKey
toString
class NullableDataKey<T> extends DataKeyBase<T> { /** * Creates a DataKey with nullable data value and factory with non-nullable dataHolder * <p> * Use this constructor to ensure that factory is never called with null data holder value * * @param name See {@link #getName()}. * @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<T> factory) { super(name, defaultValue, factory); } /** * Creates a DataKey with a computed default value dynamically. * <p> * On construction will invoke factory with null data holder to get the default value * * @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<T> factory) { super(name, factory.apply(null), factory); } /** * Creates a DataKey with nullable data value and factory not dependent on data holder * <p> * Use this constructor to ensure that factory is never called with null data holder value * * @param name See {@link #getName()}. * @param supplier data value factory for creating a new default value for the key not dependent on dataHolder */ public NullableDataKey(@NotNull String name, @NotNull Supplier<T> supplier) { super(name, supplier.get(), (holder) -> supplier.get()); } /** * Creates a NullableDataKey with a dynamic default value taken from a value of another key * <p> * does not cache the returned default value but will always delegate to another key until this key * gets its own value set. * * @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<T> defaultKey) { this(name, defaultKey.getDefaultValue(), defaultKey::get); } public NullableDataKey(@NotNull String name, @Nullable T defaultValue) { this(name, defaultValue, options -> defaultValue); } /** * Create a DataKey with null default value and factory producing null values * * @param name key name */ public NullableDataKey(@NotNull String name) { this(name, null, options -> null); } @Nullable public T getDefaultValue() { return super.getDefaultValue(); } @Nullable public T getDefaultValue(@NotNull DataHolder holder) { return super.getDefaultValue(holder); } @Nullable public T get(@Nullable DataHolder holder) { return super.get(holder); } @Override public @NotNull MutableDataHolder set(@NotNull MutableDataHolder dataHolder, @Nullable T value) { return dataHolder.set(this, value); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
// factory applied to null in constructor, no sense doing it again here T defaultValue = getDefaultValue(); if (defaultValue != null) { return "DataKey<" + defaultValue.getClass().getSimpleName() + "> " + getName(); } else { return "DataKey<null> " + getName(); }
837
89
926
<methods>public void <init>(@NotNull String, T, @NotNull DataValueFactory<T>) ,public void <init>(@NotNull String, @NotNull DataKeyBase<T>) ,public void <init>(@NotNull String, T) ,public final boolean equals(java.lang.Object) ,public T get(@Nullable DataHolder) ,public T getDefaultValue() ,public T getDefaultValue(@NotNull DataHolder) ,public @NotNull DataValueFactory<T> getFactory() ,public final T getFrom(@Nullable DataHolder) ,public @NotNull String getName() ,public final int hashCode() ,public java.lang.String toString() <variables>private final non-sealed T defaultValue,private final non-sealed @NotNull DataValueFactory<T> factory,private final non-sealed @NotNull String name
vsch_flexmark-java
flexmark-java/flexmark-util-data/src/main/java/com/vladsch/flexmark/util/data/ScopedDataSet.java
ScopedDataSet
getKeys
class ScopedDataSet extends DataSet { protected final DataHolder parent; public ScopedDataSet(@Nullable DataHolder parent) { super(); this.parent = parent; } public ScopedDataSet(@Nullable DataHolder parent, @Nullable DataHolder other) { super(other); this.parent = parent; } public DataHolder getParent() { return parent; } @Override public @NotNull Map<? extends DataKeyBase<?>, Object> getAll() { if (parent != null) { HashMap<DataKeyBase<?>, Object> all = new HashMap<>(parent.getAll()); all.putAll(super.getAll()); return all; } else { return super.getAll(); } } @Override public @NotNull Collection<? extends DataKeyBase<?>> getKeys() {<FILL_FUNCTION_BODY>} @Override public @NotNull 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) { return super.contains(key) || (parent != null && parent.contains(key)); } @Override public @Nullable Object getOrCompute(@NotNull DataKeyBase<?> key, @NotNull DataValueFactory<?> factory) { if (parent == null || super.contains(key) || !parent.contains(key)) { return super.getOrCompute(key, factory); } else { return parent.getOrCompute(key, factory); } } }
if (parent != null) { HashSet<DataKeyBase<?>> all = new HashSet<>(parent.getKeys()); all.addAll(super.getKeys()); return all; } else { return super.getKeys(); }
471
69
540
<methods>public void <init>() ,public void <init>(@Nullable DataHolder) ,public @NotNull DataHolder aggregate() ,public static @NotNull DataHolder aggregate(@Nullable DataHolder, @Nullable DataHolder) ,public static @NotNull DataHolder aggregateActions(@NotNull DataHolder, @NotNull DataHolder) ,public boolean contains(@NotNull DataKeyBase<?>) ,public boolean equals(java.lang.Object) ,public @NotNull Map<? extends DataKeyBase<?>,Object> getAll() ,public @NotNull Collection<? extends DataKeyBase<?>> getKeys() ,public @Nullable Object getOrCompute(@NotNull DataKeyBase<?>, @NotNull DataValueFactory<?>) ,public int hashCode() ,public static transient @NotNull DataSet merge(@NotNull DataHolder []) ,public static void registerDataKeyAggregator(@NotNull DataKeyAggregator) ,public @NotNull DataSet toDataSet() ,public @NotNull DataSet toImmutable() ,public @NotNull MutableDataSet toMutable() ,public java.lang.String toString() <variables>protected final non-sealed HashMap<DataKeyBase<?>,java.lang.Object> dataSet,private static final ArrayList<com.vladsch.flexmark.util.data.DataKeyAggregator> ourDataKeyAggregators
vsch_flexmark-java
flexmark-java/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyHandler.java
DependencyHandler
resolveDependencies
class DependencyHandler<D extends Dependent, S, R extends ResolvedDependencies<S>> { protected abstract @NotNull S createStage(List<D> dependents); protected abstract @NotNull Class getDependentClass(D dependent); protected abstract @NotNull R createResolvedDependencies(List<S> stages); public R resolveDependencies(List<D> dependentsList) {<FILL_FUNCTION_BODY>} protected DependentItemMap<D> prioritize(DependentItemMap<D> dependentMap) { return dependentMap; } }
if (dependentsList.size() == 0) { //noinspection unchecked return createResolvedDependencies((List<S>) Collections.EMPTY_LIST); } else if (dependentsList.size() == 1) { D dependent = dependentsList.get(0); List<D> dependents = Collections.singletonList(dependent); return createResolvedDependencies(Collections.singletonList(createStage(dependents))); } else { // resolve dependencies and processing lists int dependentCount = dependentsList.size(); DependentItemMap<D> dependentItemMap = new DependentItemMap<>(dependentCount); for (D dependent : dependentsList) { Class dependentClass = getDependentClass(dependent); if (dependentItemMap.containsKey(dependentClass)) { throw new IllegalStateException("Dependent class " + dependentClass + " is duplicated. Only one instance can be present in the list"); } DependentItem<D> item = new DependentItem<D>(dependentItemMap.size(), dependent, getDependentClass(dependent), dependent.affectsGlobalScope()); dependentItemMap.put(dependentClass, item); } for (Map.Entry<Class<?>, DependentItem<D>> entry : dependentItemMap) { DependentItem<D> item = entry.getValue(); Set<Class<?>> afterDependencies = item.dependent.getAfterDependents(); if (afterDependencies != null && afterDependencies.size() > 0) { for (Class<?> dependentClass : afterDependencies) { DependentItem<D> dependentItem = dependentItemMap.get(dependentClass); if (dependentItem != null) { item.addDependency(dependentItem); dependentItem.addDependent(item); } } } Set<Class<?>> beforeDependents = item.dependent.getBeforeDependents(); if (beforeDependents != null && beforeDependents.size() > 0) { for (Class<?> dependentClass : beforeDependents) { DependentItem<D> dependentItem = dependentItemMap.get(dependentClass); if (dependentItem != null) { dependentItem.addDependency(item); item.addDependent(dependentItem); } } } } dependentItemMap = prioritize(dependentItemMap); dependentCount = dependentItemMap.size(); BitSet newReady = new BitSet(dependentCount); Ref<BitSet> newReadyRef = new Ref<>(newReady); ReversibleIndexedIterator<DependentItem<D>> iterator = dependentItemMap.valueIterator(); while (iterator.hasNext()) { DependentItem<D> item = iterator.next(); if (!item.hasDependencies()) { newReadyRef.value.set(item.index); } } BitSet dependents = new BitSet(dependentCount); dependents.set(0, dependentItemMap.size()); ArrayList<S> dependencyStages = new ArrayList<>(); while (newReady.nextSetBit(0) != -1) { // process these independents in unspecified order since they do not have dependencies ArrayList<D> stageDependents = new ArrayList<>(); BitSet nextDependents = new BitSet(); // collect block processors ready for processing, any non-globals go into independents while (true) { int i = newReady.nextSetBit(0); if (i < 0) break; newReady.clear(i); DependentItem<D> item = dependentItemMap.getValue(i); assert item != null; stageDependents.add(item.dependent); dependents.clear(i); // removeIndex it from dependent's dependencies if (item.hasDependents()) { while (true) { int j = item.dependents.nextSetBit(0); if (j < 0) break; item.dependents.clear(j); DependentItem<D> dependentItem = dependentItemMap.getValue(j); assert dependentItem != null; if (!dependentItem.removeDependency(item)) { if (item.isGlobalScope) { nextDependents.set(j); } else { newReady.set(j); } } } } else if (item.isGlobalScope) { // globals go in their own stage nextDependents.or(newReady); break; } } // can process these in parallel since it will only contain non-globals or globals not dependent on other globals newReady = nextDependents; dependencyStages.add(createStage(stageDependents)); } if (dependents.nextSetBit(0) != -1) { throw new IllegalStateException("have dependents with dependency cycles" + dependents); } return createResolvedDependencies(dependencyStages); }
144
1,252
1,396
<no_super_class>