Skip to content

Commit

Permalink
Remove deprecated methods from extension package
Browse files Browse the repository at this point in the history
* Remove deprecated methods in asciidoctorj-core/org.asciidoctor.extension
* Remove deprecated constants in asciidoctorj-api/org.asciidoctor.extension

Fixes asciidoctor#1203
  • Loading branch information
abelsromero committed May 31, 2023
1 parent 1d78b5e commit 25d8a29
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 226 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,151 +7,6 @@

public abstract class BlockProcessor extends BaseProcessor {

/**
* This value is used as the config option key when defining the block type
* a Processor should process.
* Its value must be a list of String constants:
*
* <p>Example to make a BlockProcessor work on listings and examples named foo:
* <pre>
* <verbatim>
* Map&lt;String, Object&gt; config = new HashMap&lt;&gt;();
* config.put(CONTEXTS, Arrays.asList(EXAMPLE, LISTING));
* BlockProcessor blockProcessor = new BlockProcessor("foo", config);
* asciidoctor.javaExtensionRegistry().block(blockProcessor);
* </verbatim>
* </pre>
* </p>
*
* @deprecated Please use {@link Contexts#KEY}
*/
@Deprecated
public static final String CONTEXTS = "contexts";

/**
* Predefined constant for making a BlockProcessor work on open blocks.
* When passed with the {@link #CONTEXTS} config option this BlockProcessor works on open blocks:
* <pre>
* [foo]
* --
* An open block can be an anonymous container,
* or it can masquerade as any other block.
* --
* </pre>
*
* @deprecated Please use {@link Contexts#OPEN}
*/
@Deprecated
public static final String CONTEXT_OPEN = ":open";

/**
* Predefined constant for making a BlockProcessor work on example blocks.
* When passed with the {@link #CONTEXTS} config option this BlockProcessor works on example blocks:
* <pre>
* [foo]
* ====
* This is just a neat example.
* ====
* </pre>
*
* @deprecated Please use {@link Contexts#EXAMPLE}
*/
@Deprecated
public static final String CONTEXT_EXAMPLE = ":example";

/**
* Predefined constant for making a BlockProcessor work on sidebar blocks.
* When passed with the {@link #CONTEXTS} config option this BlockProcessor works on sidebar blocks:
* <pre>
* [foo]
* ****
* This is just a sidebar.
* ****
* </pre>
*
* @deprecated Please use {@link Contexts#SIDEBAR}
*/
@Deprecated
public static final String CONTEXT_SIDEBAR = ":sidebar";

/**
* Predefined constant for making a BlockProcessor work on literal blocks.
* When passed with the {@link #CONTEXTS} config option this BlockProcessor works on literal blocks:
* <pre>
* [foo]
* ....
* This is just a literal block.
* ....
* </pre>
*
* @deprecated Please use {@link Contexts#LITERAL}
*/
@Deprecated
public static final String CONTEXT_LITERAL = ":literal";

/**
* Predefined constant for making a BlockProcessor work on source blocks.
* When passed with the {@link #CONTEXTS} config option this BlockProcessor works on source blocks:
* <pre>
* [foo]
* ....
* This is just a literal block.
* ....
* </pre>
*
* @deprecated Please use {@link Contexts#LISTING}
*/
@Deprecated
public static final String CONTEXT_LISTING = ":listing";

/**
* Predefined constant for making a BlockProcessor work on quote blocks.
* When passed with the {@link #CONTEXTS} config option this BlockProcessor works on quote blocks:
* <pre>
* [foo]
* ____
* To be or not to be...
* ____
* </pre>
*
* @deprecated Please use {@link Contexts#QUOTE}
*/
@Deprecated
public static final String CONTEXT_QUOTE = ":quote";

/**
* Predefined constant for making a BlockProcessor work on passthrough blocks.
* When passed with the {@link #CONTEXTS} config option this BlockProcessor works on passthrough blocks:
*
* <pre>
* [foo]
* ++++
* &lt;h1&gt;Big text&lt;/h1&gt;
* ++++
* </pre>
*
* @deprecated Please use {@link Contexts#PASS}
*/
@Deprecated
public static final String CONTEXT_PASS = ":pass";

/**
* Predefined constant for making a BlockProcessor work on paragraph blocks.
* This is also the default for the {@link #CONTEXTS} config option if no other context is given.
* When passed with the {@link #CONTEXTS} config option this BlockProcessor works on paragraph blocks:
*
* <pre>
* [foo]
* Please process this paragraph.
*
* And don't process this.
* </pre>
*
* @deprecated Please use {@link Contexts#PARAGRAPH}
*/
@Deprecated
public static final String CONTEXT_PARAGRAPH = ":paragraph";

protected String name;

public BlockProcessor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,17 @@ public interface PreprocessorReader extends Reader {
/**
* Push source content onto the front of the reader and switch the context
* based on the file, document-relative path and line information given.
* This method is typically used in an {@link IncludeProcessor} to add content
* read from the target specified.
*
* @deprecated Use {@link #pushInclude(String, String, String, int, Map)} instead.
*
* @param data content to push
* @param file representation of name of the included file. Does not need to exists
* @param path representation of path of the included file. Does not need to exists
* @param lineNumber line number of the first line of the included content
* @param attributes additional attributes to pass
*/
@Deprecated
void push_include(String data, String file, String path, int lineNumber, Map<String, Object> attributes);

/**
* Push source content onto the front of the reader and switch the context
* based on the file, document-relative path and line information given.
* This method is typically used in an {@link IncludeProcessor} to add content
* This method is typically used in an {@link IncludeProcessor} to add content
* read from the target specified.
*
* @param data content to push
* @param file representation of name of the included file. Does not need to exists
* @param path representation of path of the included file. Does not need to exists
* @param file representation of name of the included file. Does not need to exist
* @param path representation of path of the included file. Does not need to exist
* @param lineNumber line number of the first line of the included content
* @param attributes additional attributes to pass
*/
void pushInclude(String data, String file, String path, int lineNumber, Map<String, Object> attributes);

/**
* @deprecated Please use {@link #getDocument()}
*
* @return Document representation.
*/
@Deprecated
Document document();

/**
* @return Document representation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@

public interface Reader {

/**
* Get the 1-based offset of the current line.
*
* @return 1-based offset.
* @deprecated Please use {@link #getLineNumber()}
*/
@Deprecated
int getLineno();

/**
* Get the 1-based offset of the current line.
*
Expand Down Expand Up @@ -45,7 +36,7 @@ public interface Reader {

/**
* Peek at the next line and check if it's empty (i.e., whitespace only)
*
* <p>
* This method Does not consume the line from the stack.
*
* @return True if the there are no more lines or if the next line is empty
Expand Down Expand Up @@ -73,15 +64,8 @@ public interface Reader {
*
* @return the String of the next line of the source data if data is present or
* nulll if there is no more data.
*/
String readLine();

/**
* @return A copy of the String List of lines remaining in this Reader
* @deprecated Use {@link #getLines()}
*/
@Deprecated
List<String> lines();
String readLine();

/**
* @return A copy of the String List of lines remaining in this Reader
Expand All @@ -90,15 +74,15 @@ public interface Reader {

/**
* Push the String line onto the beginning of the Array of source data.
*
* <p>
* Since this line was (assumed to be) previously retrieved through the
* reader, it is marked as seen.
*/
void restoreLine(String line);

/**
* Push multiple lines onto the beginning of the Array of source data.
*
* <p>
* Since this lines were (assumed to be) previously retrieved through the
* reader, they are marked as seen.
*/
Expand All @@ -107,7 +91,7 @@ public interface Reader {
/**
* Peek at the next line of source data. Processes the line, if not
* already marked as processed, but does not consume it.
*
* <p>
* This method will probe the reader for more lines.
*/
String peekLine();
Expand All @@ -130,7 +114,6 @@ public interface Reader {
boolean advance();

/**
*
* Public: Advance to the end of the reader, consuming all remaining lines
*/
void terminate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ public PreprocessorReaderImpl(IRubyObject rubyNode) {
super(rubyNode);
}

@Override
public void push_include(String data, String file, String path, int lineNumber, Map<String, Object> attributes) {
pushInclude(data, file, path, lineNumber, attributes);
}

@Override
public void pushInclude(String data, String file, String path, int lineNumber, Map<String, Object> attributes) {
RubyHash attributeHash = RubyHash.newHash(getRuntime());
Expand All @@ -27,12 +22,6 @@ public void pushInclude(String data, String file, String path, int lineNumber, M
getRubyProperty("push_include", data, file, path, lineNumber, attributes);
}

@Override
@Deprecated
public Document document() {
return getDocument();
}

@Override
public Document getDocument() {
return (Document) NodeConverter.createASTNode(getRubyProperty("document"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.asciidoctor.jruby.extension.internal;

import java.util.List;

import org.asciidoctor.extension.Reader;
import org.asciidoctor.jruby.internal.RubyObjectWrapper;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
import org.jruby.runtime.builtin.IRubyObject;

import java.util.List;

public class ReaderImpl extends RubyObjectWrapper implements Reader {

public ReaderImpl(IRubyObject rubyNode) {
Expand All @@ -25,12 +25,6 @@ static ReaderImpl createReader(Ruby runtime, List<String> lines) {
return new ReaderImpl(readerClass.callMethod("new", rubyLines));
}

@Override
@Deprecated
public int getLineno() {
return getLineNumber();
}

@Override
public int getLineNumber() {
return getInt("lineno");
Expand Down Expand Up @@ -71,11 +65,6 @@ public String readLine() {
return getString("read_line");
}

@Override
public List<String> lines() {
return getList("lines", String.class);
}

@Override
public List<String> getLines() {
return getList("lines", String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ArrowsAndBoxesBlock(String context, Document document) {
public Object process(StructuralNode parent, Reader reader,
Map<String, Object> attributes) {

List<String> lines = reader.lines();
List<String> lines = reader.getLines();

StringBuilder outputLines = new StringBuilder();
outputLines.append("<pre class=\"arrows-and-boxes\">");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void process(Document document, PreprocessorReader reader, String target,
str += "," + it.next().getValue();
}

reader.push_include(str, target, target, 1, attributes);
reader.pushInclude(str, target, target, 1, attributes);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void process(Document document, PreprocessorReader reader, String target,
Map<String, Object> attributes) {

StringBuilder content = readContent(target);
reader.push_include(content.toString(), target, target, 1, attributes);
reader.pushInclude(content.toString(), target, target, 1, attributes);
}

private StringBuilder readContent(String target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public RubyIncludeSource(Map<String, Object> config) {
public void process(Document document, PreprocessorReader reader, String target,
Map<String, Object> attributes) {
StringBuilder content = readContent(target);
reader.push_include(content.toString(), target, target, 1, attributes);
reader.pushInclude(content.toString(), target, target, 1, attributes);
}

private StringBuilder readContent(String target) {
Expand Down Expand Up @@ -171,7 +171,7 @@ public void an_inner_anonymous_class_should_be_registered() {
public void process(Document document, PreprocessorReader reader, String target,
Map<String, Object> attributes) {
StringBuilder content = readContent(target);
reader.push_include(content.toString(), target, target, 1, attributes);
reader.pushInclude(content.toString(), target, target, 1, attributes);
}

private StringBuilder readContent(String target) {
Expand Down
Loading

0 comments on commit 25d8a29

Please sign in to comment.