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-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependencyResolver.java
|
DependencyResolver
|
resolveDependencies
|
class DependencyResolver {
public static <D extends Dependent> @NotNull List<D> resolveFlatDependencies(@NotNull List<D> dependentsList, @Nullable Function<DependentItemMap<D>, DependentItemMap<D>> itemSorter, @Nullable Function<? super D, Class<?>> classExtractor) {
List<List<D>> list = resolveDependencies(dependentsList, itemSorter, classExtractor);
if (list.isEmpty()) {
return Collections.emptyList();
} else if (list.size() == 1) {
return list.get(0);
} else {
int totalSize = 0;
for (List<D> subList : list) {
totalSize += subList.size();
}
ArrayList<D> flatList = new ArrayList<>(totalSize);
for (List<D> subList : list) {
flatList.addAll(subList);
}
return flatList;
}
}
public static <D extends Dependent> @NotNull List<List<D>> resolveDependencies(@NotNull List<D> dependentsList, @Nullable Function<DependentItemMap<D>, DependentItemMap<D>> itemSorter, @Nullable Function<? super D, Class<?>> classExtractor) {<FILL_FUNCTION_BODY>}
}
|
if (dependentsList.size() == 0) {
return Collections.emptyList();
} else if (dependentsList.size() == 1) {
return Collections.singletonList(dependentsList);
} else {
// resolve dependencies and processing lists
int dependentCount = dependentsList.size();
DependentItemMap<D> dependentItemMap = new DependentItemMap<>(dependentCount);
if (classExtractor == null) classExtractor = D::getClass;
for (D dependent : dependentsList) {
Class<?> dependentClass = classExtractor.apply(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, classExtractor.apply(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) {
if (dependentClass == LastDependent.class) {
// must come after all others
for (DependentItem<D> dependentItem : dependentItemMap.valueIterable()) {
if (dependentItem != null && dependentItem != item) {
item.addDependency(dependentItem);
dependentItem.addDependent(item);
}
}
} else {
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) {
if (dependentClass == FirstDependent.class) {
// must come before all others
for (DependentItem<D> dependentItem : dependentItemMap.valueIterable()) {
if (dependentItem != null && dependentItem != item) {
dependentItem.addDependency(item);
item.addDependent(dependentItem);
}
}
} else {
DependentItem<D> dependentItem = dependentItemMap.get(dependentClass);
if (dependentItem != null) {
dependentItem.addDependency(item);
item.addDependent(dependentItem);
}
}
}
}
}
if (itemSorter != null) {
dependentItemMap = itemSorter.apply(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<List<D>> 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(stageDependents);
}
if (dependents.nextSetBit(0) != -1) {
throw new IllegalStateException("have dependents with dependency cycles" + dependents);
}
return dependencyStages;
}
| 328
| 1,416
| 1,744
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-dependency/src/main/java/com/vladsch/flexmark/util/dependency/DependentItem.java
|
DependentItem
|
addDependency
|
class DependentItem<D> {
final public int index;
final public D dependent;
final public Class<?> dependentClass;
final public boolean isGlobalScope;
BitSet dependencies;
BitSet dependents;
public DependentItem(int index, D dependent, Class<?> dependentClass, boolean isGlobalScope) {
this.index = index;
this.dependent = dependent;
this.dependentClass = dependentClass;
this.isGlobalScope = isGlobalScope;
}
public void addDependency(DependentItem<D> dependency) {
if (this.dependencies == null) this.dependencies = new BitSet();
this.dependencies.set(dependency.index);
}
public void addDependency(BitSet dependencies) {<FILL_FUNCTION_BODY>}
public boolean removeDependency(DependentItem<D> dependency) {
if (this.dependencies != null) {
this.dependencies.clear(dependency.index);
}
return hasDependencies();
}
public boolean removeDependency(BitSet dependencies) {
if (this.dependencies != null) {
this.dependencies.andNot(dependencies);
}
return hasDependencies();
}
public void addDependent(DependentItem<D> dependent) {
if (this.dependents == null) this.dependents = new BitSet();
this.dependents.set(dependent.index);
}
public void addDependent(BitSet dependents) {
if (this.dependents == null) this.dependents = new BitSet();
this.dependents.or(dependents);
}
public void removeDependent(DependentItem<D> dependent) {
if (this.dependents != null) {
this.dependents.clear(dependent.index);
}
}
public void removeDependent(BitSet dependents) {
if (this.dependents != null) {
this.dependents.andNot(dependents);
}
}
public boolean hasDependencies() {
return dependencies != null && dependencies.nextSetBit(0) != -1;
}
public boolean hasDependents() {
return dependents != null && dependents.nextSetBit(0) != -1;
}
}
|
if (this.dependencies == null) this.dependencies = new BitSet();
this.dependencies.or(dependencies);
| 583
| 35
| 618
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/KeyedItemFactoryMap.java
|
KeyedItemFactoryMap
|
getItem
|
class KeyedItemFactoryMap<K, I, P> implements Map<K, Function<P, I>> {
protected final @NotNull HashMap<K, Function<P, I>> factoryMap;
protected final @NotNull HashMap<K, I> itemMap;
protected final @NotNull P param;
public KeyedItemFactoryMap(@NotNull P param) {
this(param, 0);
}
public KeyedItemFactoryMap(@NotNull P param, int capacity) {
this.factoryMap = new HashMap<>(capacity);
this.itemMap = new HashMap<>();
this.param = param;
}
public @Nullable I getItem(@NotNull K key) {<FILL_FUNCTION_BODY>}
@Override
public int size() {return factoryMap.size();}
@Override
public boolean isEmpty() {return factoryMap.isEmpty();}
@Override
public @Nullable Function<P, I> get(@Nullable Object o) {return factoryMap.get(o);}
@Override
public boolean containsKey(@Nullable Object o) {return factoryMap.containsKey(o);}
@Override
public @Nullable Function<P, I> put(@NotNull K k, @NotNull Function<P, I> factory) {return factoryMap.put(k, factory);}
@Override
public void putAll(@NotNull Map<? extends K, ? extends Function<P, I>> map) {factoryMap.putAll(map);}
@Override
public @Nullable Function<P, I> remove(@Nullable Object o) {return factoryMap.remove(o);}
@Override
public void clear() {factoryMap.clear();}
@Override
public boolean containsValue(Object o) {return factoryMap.containsValue(o);}
@NotNull
@Override
public Set<K> keySet() {return factoryMap.keySet();}
@NotNull
@Override
public Collection<Function<P, I>> values() {return factoryMap.values();}
@NotNull
@Override
public Set<Entry<K, Function<P, I>>> entrySet() {return factoryMap.entrySet();}
}
|
I item = itemMap.get(key);
if (item == null) {
Function<P, I> factory = factoryMap.get(key);
if (factory == null) {
throw new IllegalStateException("Factory for key: " + key + " is not defined");
}
item = factory.apply(param);
itemMap.put(key, item);
}
return item;
| 534
| 105
| 639
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/collection/iteration/PositionIterator.java
|
PositionIterator
|
next
|
class PositionIterator<T, P extends IPositionHolder<T, P>> implements Iterator<P> {
private @Nullable P myIndex;
private @Nullable P myNext;
public PositionIterator(@NotNull P index) {
assert index.getAnchor() != CURRENT;
myIndex = null;
myNext = index;
}
@Override
public boolean hasNext() {
assert myNext == null || myNext.isValid() || myNext.getAnchor() == PREVIOUS;
return myNext != null && myNext.isValidElement();
}
@Override
public P next() {<FILL_FUNCTION_BODY>}
@Override
public void remove() {
if (myIndex == null)
throw new IllegalStateException("next() has not been called");
myIndex.remove();
}
}
|
if (myNext == null || !myNext.isValidElement()) throw new NoSuchElementException();
myIndex = myNext.withAnchor(PositionAnchor.CURRENT);
P oldNext = myNext;
if (myNext.getAnchor() == PREVIOUS) {
myNext = myNext.previousOrNull();
} else {
myNext = myNext.nextOrNull();
}
oldNext.detachListener();
assert myNext == null || myIndex.getIndex() != myNext.getIndex();
return myIndex;
| 220
| 146
| 366
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/data/CollectionDataKey.java
|
CollectionDataKey
|
toString
|
class CollectionDataKey<T> extends DataKey<Collection<T>> {
/**
* Creates a DataKey with a computed default value dynamically.
*
* @param name See {@link #getName()}.
* @param defaultValue default value for collection key
* @param factory data value factory for creating a new default value for the key
*/
public CollectionDataKey(@NotNull String name, @NotNull Collection<T> defaultValue, DataNotNullValueFactory<Collection<T>> factory) {
super(name, defaultValue, factory);
}
@NotNull
public DataNotNullValueFactory<Collection<T>> getFactory() {
return super.getFactory();
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
Collection<T> defaultValue = getDefaultValue();
return "CollectionDataKey<" + defaultValue.getClass().getSimpleName() + "> " + getName();
| 191
| 44
| 235
|
<methods>public void <init>(@NotNull String, @NotNull Collection<T>, @NotNull DataNotNullValueFactory<Collection<T>>) ,public void <init>(@NotNull String, @NotNull NotNullValueSupplier<Collection<T>>) ,public void <init>(@NotNull String, @NotNull DataKey<Collection<T>>) ,public void <init>(@NotNull String, @NotNull Collection<T>) ,public @NotNull Collection<T> get(@Nullable DataHolder) ,public @NotNull Collection<T> getDefaultValue() ,public @NotNull Collection<T> getDefaultValue(@NotNull DataHolder) ,public @NotNull DataNotNullValueFactory<Collection<T>> getFactory() ,public @NotNull MutableDataHolder set(@NotNull MutableDataHolder, @NotNull Collection<T>) ,public java.lang.String toString() <variables>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceEntry.java
|
BaseSequenceEntry
|
testEquals
|
class BaseSequenceEntry {
final private @NotNull WeakHashMap<Object, Boolean> quickEquals = new WeakHashMap<>();
private int hash;
public BaseSequenceEntry() {
}
/**
* Compare object to equality of entry's base sequence
* NOTE: if not char sequence or base of this entry's base sequence then will return false, so do not expect to pass a new instance of char[] and to get true for equivalent CharSubSequence
*
* @param baseSeq base sequence
* @param o object to compare
* @param equalsCall 1 element array where to return type of equals test done
* equality type used, 0 - quick class and/or length, 1 - hash, 2 - quick lookup, 3 - string content comparison, 4 - char sequence comparison
* @return true if object equivalent to this entry's base sequence, false otherwise
*/
public boolean testEquals(@NotNull BasedSequence baseSeq, @NotNull Object o, int[] equalsCall) {<FILL_FUNCTION_BODY>}
@Override
public boolean equals(Object o) {
throw new IllegalStateException("Not Supported, use testEquals()");
}
@Override
public int hashCode() {
throw new IllegalStateException("Not Supported, use getHashCode()");
}
}
|
equalsCall[0] = 0;
if (o == baseSeq || o == baseSeq.getBase()) return true;
if (!(o instanceof CharSequence)) return false;
CharSequence other = (CharSequence) o;
if (other.length() != baseSeq.length()) return false;
if (o instanceof IRichSequence<?>) {
IRichSequence<?> rich = (BasedSequence) o;
equalsCall[0] = 1;
if (rich.hashCode() != baseSeq.hashCode()) return false;
//fall through to quickEquals tests then slow content comparison
} else if (o instanceof String) {
String string = (String) o;
equalsCall[0] = 1;
if (string.hashCode() != baseSeq.hashCode()) return false;
//fall through to quickEquals tests then slow content comparison
}
// see if already have it in the weak hash map
Boolean result;
equalsCall[0] = 2;
// no need to synchronize. Only called by Manager from synchronized code
result = quickEquals.get(o);
if (result != null) return result;
if (baseSeq instanceof SubSequence && o instanceof String) {
equalsCall[0] = 3;
result = baseSeq.getBase().equals(o);
} else if (baseSeq instanceof SubSequence && o instanceof SubSequence) {
equalsCall[0] = 3;
result = baseSeq.getBase().equals(((SubSequence) o).getBase());
} else {
equalsCall[0] = 4;
result = baseSeq.equals(o);
}
quickEquals.put(o, result);
return result;
| 328
| 438
| 766
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-experimental/src/main/java/com/vladsch/flexmark/experimental/util/sequence/managed/BaseSequenceManager.java
|
BaseSequenceManager
|
getBaseSequence
|
class BaseSequenceManager {
// NOTE: baseMap will keep reference to BaseSequenceEntry as long as the underlying base object is in use
// baseSet relies on baseMap to keep references alive for used BasedSequence and its BaseSequenceEntry for quick fail/pass on equals
final private @NotNull WeakHashMap<Object, WeakReference<BasedSequence>> baseMap = new WeakHashMap<>();
final private @NotNull WeakHashMap<BasedSequence, BaseSequenceEntry> baseSet = new WeakHashMap<>();
public BaseSequenceManager() {
}
/**
* Get an equivalent existing based sequence base or a new one created by passed factory
* <p>
* NOTE: should only be called by base sequence which are the base for their category: {@link SubSequence} implementing managed sequence base
* <p>
* all others should delegate to these sequences for creating the base
*
* @param <T> type of base character sequence
* @param object object for the underlying based sequence base
* @param callTypes one element array for type of tests done to find result
* NOTE: 0 if map lookup, 10 - set search, 20 - construct and add to map/set
* with units digit giving max testEquals call type from all tests done
* @param factory factory to create based sequence from the object
* @return existing equivalent base or newly created base
*/
@NotNull
public <T> BasedSequence getBaseSequence(@NotNull T object, @Nullable int[] callTypes, @NotNull Function<T, BasedSequence> factory) {<FILL_FUNCTION_BODY>}
}
|
WeakReference<BasedSequence> baseEntry;
BasedSequence baseSeq;
int callType = 0;
synchronized (baseMap) {
baseEntry = baseMap.get(object);
if (baseEntry != null) {
baseSeq = baseEntry.get();
if (baseSeq != null) {
if (callTypes != null) callTypes[0] = callType;
return baseSeq;
}
baseMap.remove(object);
}
// see if we can find one in the set that matches
callType = 10;
int[] equalsCall = { 0 };
for (Map.Entry<BasedSequence, BaseSequenceEntry> entry : baseSet.entrySet()) {
if (entry != null) {
if (entry.getValue().testEquals(entry.getKey(), object, equalsCall)) {
callType = Math.max(callType, 10 + equalsCall[0]);
if (callTypes != null) callTypes[0] = callType;
return entry.getKey();
}
callType = Math.max(callType, 10 + equalsCall[0]);
}
}
BasedSequence newBaseSeq = factory.apply(object);
assert newBaseSeq == newBaseSeq.getBaseSequence();
assert newBaseSeq.getBase() == object;
// preserve entry search max call type
callType += 10;
if (callTypes != null) callTypes[0] = callType;
baseMap.put(object, new WeakReference<>(newBaseSeq));
baseSet.put(newBaseSeq, new BaseSequenceEntry());
return newBaseSeq;
}
| 390
| 431
| 821
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/ColumnSort.java
|
ColumnSort
|
columnSort
|
class ColumnSort {
final public int column;
final public @NotNull Sort sort;
private ColumnSort(int column, @NotNull Sort sort) {
this.column = column;
this.sort = sort;
}
@NotNull
public static ColumnSort columnSort(int column, @NotNull Sort sort) {
return new ColumnSort(column, sort);
}
@NotNull
public static ColumnSort columnSort(int column, boolean descending, boolean numeric, boolean numericLast) {<FILL_FUNCTION_BODY>}
}
|
if (numeric) {
if (numericLast) {
return new ColumnSort(column, descending ? Sort.DESCENDING_NUMERIC_LAST : Sort.ASCENDING_NUMERIC_LAST);
} else {
return new ColumnSort(column, descending ? Sort.DESCENDING_NUMERIC : Sort.ASCENDING_NUMERIC);
}
} else {
return new ColumnSort(column, descending ? Sort.DESCENDING : Sort.ASCENDING);
}
| 138
| 136
| 274
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/FormattedCounter.java
|
FormattedCounter
|
getFormatted
|
class FormattedCounter {
final private NumberFormat numberFormat;
final private Boolean isLowercase;
final private String delimiter;
private int count;
public FormattedCounter(NumberFormat format, Boolean lowercase, String delimiter) {
numberFormat = format;
isLowercase = lowercase;
this.delimiter = delimiter;
reset();
}
public void reset() {
count = 0;
}
public int getCount() {
return count;
}
public int nextCount() {
return ++count;
}
public String getFormatted(boolean withDelimiter) {<FILL_FUNCTION_BODY>}
}
|
String s = NumberFormat.getFormat(numberFormat, Utils.minLimit(count, 1));
String o = isLowercase == null ? s : isLowercase ? s.toLowerCase() : s.toUpperCase();
return withDelimiter && delimiter != null && !delimiter.isEmpty() ? o + delimiter : o;
| 178
| 90
| 268
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/MarkdownParagraph.java
|
TextTokenizer
|
next
|
class TextTokenizer {
final private CharSequence chars;
final private int maxIndex;
private int index = 0;
private int lastPos = 0;
private boolean isInWord = false;
private boolean isFirstNonBlank = true;
private int lastConsecutiveSpaces = 0;
private @Nullable Token token = null;
TextTokenizer(@NotNull CharSequence chars) {
this.chars = chars;
maxIndex = this.chars.length();
reset();
}
public void reset() {
index = 0;
lastPos = 0;
isInWord = false;
token = null;
lastConsecutiveSpaces = 0;
isFirstNonBlank = true;
next();
}
@Nullable
Token getToken() {
return token;
}
@NotNull
public List<Token> asList() {
ArrayList<Token> tokens = new ArrayList<>();
reset();
while (token != null) {
tokens.add(token);
next();
}
return tokens;
}
void next() {<FILL_FUNCTION_BODY>}
}
|
token = null;
while (index < maxIndex) {
char c = chars.charAt(index);
if (isInWord) {
if (c == ' ' || c == '\t' || c == '\n' || c == MARKDOWN_START_LINE_CHAR) {
isInWord = false;
boolean isFirstWord = isFirstNonBlank;
isFirstNonBlank = false;
if (lastPos < index) {
// have a word
token = Token.of(TextType.WORD, lastPos, index, isFirstWord);
lastPos = index;
break;
}
} else {
index++;
}
} else {
// in white space
if (c != ' ' && c != '\t' && c != '\n' && c != MARKDOWN_START_LINE_CHAR) {
if (lastPos < index) {
token = Token.of(TextType.SPACE, lastPos, index);
lastPos = index;
isInWord = true;
lastConsecutiveSpaces = 0;
break;
} else {
isInWord = true;
lastConsecutiveSpaces = 0;
}
} else {
if (c == '\n') {
if (lastConsecutiveSpaces >= 2) {
token = Token.of(TextType.MARKDOWN_BREAK, index - lastConsecutiveSpaces, index + 1);
} else {
token = Token.of(TextType.BREAK, index, index + 1);
}
lastPos = index + 1;
lastConsecutiveSpaces = 0;
isFirstNonBlank = true;
index++;
break;
} else if (c == MARKDOWN_START_LINE_CHAR) {
token = Token.of(TextType.MARKDOWN_START_LINE, index, index + 1);
lastPos = index + 1;
lastConsecutiveSpaces = 0;
index++;
break;
} else {
if (c == ' ') lastConsecutiveSpaces++;
else lastConsecutiveSpaces = 0;
index++;
}
}
}
}
if (lastPos < index) {
if (isInWord) {
token = Token.of(TextType.WORD, lastPos, index, isFirstNonBlank);
isFirstNonBlank = false;
} else {
token = Token.of(TextType.SPACE, lastPos, index);
}
lastPos = index;
}
| 302
| 664
| 966
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/RomanNumeral.java
|
RomanNumeral
|
toString
|
class RomanNumeral {
final private int num; // The number represented by this Roman numeral.
/*
The following arrays are used by the toString() function to construct
the standard Roman numeral representation of the number. For each i,
the number numbers[i] is represented by the corresponding string, letters[i].
*/
// @formatter:off
final private static int[] numbers = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };
final private static String[] letters = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };
// @formatter:on
final public static Pattern ROMAN_NUMERAL = Pattern.compile("M{0,3}(?:CM|DC{0,3}|CD|C{1,3})?(?:XC|LX{0,3}|XL|X{1,3})?(?:IX|VI{0,3}|IV|I{1,3})?");
final public static Pattern LOWERCASE_ROMAN_NUMERAL = Pattern.compile("m{0,3}(?:cm|dc{0,3}|cd|c{1,3})?(?:xc|lx{0,3}|xl|x{1,3})?(?:ix|vi{0,3}|iv|i{1,3})?");
final public static Pattern LIMITED_ROMAN_NUMERAL = Pattern.compile("(?:X{1,3})?(?:IX|VI{0,3}|IV|I{1,3})?");
final public static Pattern LIMITED_LOWERCASE_ROMAN_NUMERAL = Pattern.compile("(?:x{1,3})?(?:ix|vi{0,3}|iv|i{1,3})?");
public RomanNumeral(int arabic) {
// Constructor. Creates the Roman number with the int value specified
// by the parameter. Throws a NumberFormatException if arabic is
// not in the range 1 to 3999 inclusive.
if (arabic < 1)
throw new NumberFormatException("Value of RomanNumeral must be positive.");
if (arabic > 3999)
throw new NumberFormatException("Value of RomanNumeral must be 3999 or less.");
num = arabic;
}
public RomanNumeral(String roman) {
// Constructor. Creates the Roman number with the given representation.
// For example, RomanNumeral("xvii") is 17. If the parameter is not a
// legal Roman numeral, a NumberFormatException is thrown. Both upper and
// lower case letters are allowed.
if (roman.length() == 0)
throw new NumberFormatException("An empty string does not define a Roman numeral.");
roman = roman.toUpperCase();
int i = 0; // A position in the string, roman;
int arabic = 0; // Arabic numeral equivalent of the part of the string that has been converted so far.
while (i < roman.length()) {
char letter = roman.charAt(i);
int number = letterToNumber(letter);
if (number < 0)
throw new NumberFormatException("Illegal character \"" + letter + "\" in roman numeral.");
i++;
if (i == roman.length()) {
// There is no letter in the string following the one we have just processed.
// So just add the number corresponding to the single letter to arabic.
arabic += number;
} else {
// Look at the next letter in the string. If it has a larger Roman numeral
// equivalent than number, then the two letters are counted together as
// a Roman numeral with value (nextNumber - number).
int nextNumber = letterToNumber(roman.charAt(i));
if (nextNumber > number) {
// Combine the two letters to get one value, and move on to next position in string.
arabic += (nextNumber - number);
i++;
} else {
// Don't combine the letters. Just add the value of the one letter onto the number.
arabic += number;
}
}
}
if (arabic > 3999)
throw new NumberFormatException("Roman numeral must have value 3999 or less.");
num = arabic;
}
private int letterToNumber(char letter) {
// Find the integer value of letter considered as a Roman numeral. Return
// -1 if letter is not a legal Roman numeral. The letter must be upper case.
switch (letter) {
case 'I':
return 1;
case 'V':
return 5;
case 'X':
return 10;
case 'L':
return 50;
case 'C':
return 100;
case 'D':
return 500;
case 'M':
return 1000;
default:
return -1;
}
}
public String toString() {<FILL_FUNCTION_BODY>}
public int toInt() {
// Return the value of this Roman numeral as an int.
return num;
}
}
|
// Return the standard representation of this Roman numeral.
StringBuilder roman = new StringBuilder();
int N = num;
for (int i = 0; i < numbers.length; i++) {
while (N >= numbers[i]) {
roman.append(letters[i]);
N -= numbers[i];
}
}
return roman.toString();
| 1,392
| 96
| 1,488
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TableSection.java
|
TableSection
|
dumpRows
|
class TableSection {
final public TableSectionType sectionType;
final public ArrayList<TableRow> rows = new ArrayList<>();
protected int row;
protected int column;
public TableSection(TableSectionType sectionType) {
this.sectionType = sectionType;
row = 0;
column = 0;
}
public ArrayList<TableRow> getRows() {
return rows;
}
public int getRow() {
return row;
}
public int getColumn() {
return column;
}
public void nextRow() {
row++;
column = 0;
}
public void setCell(int row, int column, TableCell cell) {
expandTo(row).set(column, cell);
}
public void normalize() {
for (TableRow row : rows) {
row.normalize();
}
}
public TableRow expandTo(int row) {
return expandTo(row, null);
}
public TableRow expandTo(int row, TableCell cell) {
while (row >= rows.size()) {
TableRow tableRow = defaultRow();
rows.add(tableRow);
}
return rows.get(row);
}
public TableRow expandTo(int row, int column) {
return expandTo(row, column, null);
}
public TableRow expandTo(int row, int column, TableCell cell) {
while (row >= rows.size()) {
TableRow tableRow = defaultRow();
tableRow.expandTo(column, cell);
rows.add(tableRow);
}
return rows.get(row).expandTo(column);
}
public TableRow defaultRow() {
return new TableRow();
}
public TableCell defaultCell() {
return TableCell.NULL;
}
public TableRow get(int row) {
return expandTo(row, null);
}
public int getMaxColumns() {
int columns = 0;
for (TableRow row : rows) {
int spans = row.getSpannedColumns();
if (columns < spans) columns = spans;
}
return columns;
}
public int getMinColumns() {
int columns = 0;
for (TableRow row : rows) {
int spans = row.getSpannedColumns();
if (columns > spans || columns == 0) columns = spans;
}
return columns;
}
private CharSequence dumpRows() {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
// NOTE: show not simple name but name of container class if any
return this.getClass().getName().substring(getClass().getPackage().getName().length() + 1) + "[" +
"sectionType=" + sectionType +
", rows=[\n" + dumpRows() +
']';
}
}
|
StringBuilder sb = new StringBuilder();
for (TableRow row : rows) {
sb.append(" ").append(row.toString()).append("\n");
}
return sb;
| 747
| 51
| 798
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffset.java
|
TrackedOffset
|
toString
|
class TrackedOffset implements Comparable<TrackedOffset> {
private enum Flags {
AFTER_SPACE_EDIT,
AFTER_INSERT,
AFTER_DELETE,
}
final private static int F_AFTER_SPACE_EDIT = BitFieldSet.intMask(Flags.AFTER_SPACE_EDIT);
final private static int F_AFTER_INSERT = BitFieldSet.intMask(Flags.AFTER_INSERT);
final private static int F_AFTER_DELETE = BitFieldSet.intMask(Flags.AFTER_DELETE);
final private @Nullable TrackedOffset original;
final private int offset;
final private int flags;
private int spacesBefore;
private int spacesAfter;
private boolean isSpliced; // spaces reset to 0
private int index;
private TrackedOffset(int offset, boolean afterSpaceEdit, boolean afterInsert, boolean afterDelete) {
this.original = null;
this.offset = offset;
int flags = 0;
if (afterSpaceEdit) flags |= F_AFTER_SPACE_EDIT;
if (afterInsert) flags |= F_AFTER_INSERT;
if (afterDelete) flags |= F_AFTER_DELETE;
this.flags = flags;
this.index = -1;
this.spacesBefore = -1;
this.spacesAfter = -1;
}
private TrackedOffset(@NotNull TrackedOffset other) {
this.original = other.original;
this.offset = other.offset;
this.flags = other.flags;
this.index = -1;
this.spacesBefore = other.spacesBefore;
this.spacesAfter = other.spacesAfter;
}
private TrackedOffset(@NotNull TrackedOffset other, int offset) {
this.original = other;
this.offset = offset;
this.flags = other.flags;
this.index = -1;
this.spacesBefore = other.spacesBefore;
this.spacesAfter = other.spacesAfter;
}
public int getOffset() {
return offset;
}
public int getSpacesBefore() {
return spacesBefore;
}
public void setSpacesBefore(int spacesBefore) {
this.spacesBefore = spacesBefore;
}
public int getSpacesAfter() {
return spacesAfter;
}
public void setSpacesAfter(int spacesAfter) {
this.spacesAfter = spacesAfter;
}
public boolean isSpliced() {
return isSpliced;
}
public void setSpliced(boolean spliced) {
this.isSpliced = spliced;
}
public boolean isResolved() {
return index != -1;
}
public int getIndex() {
return index == -1 ? offset : index;
}
public void setIndex(int index) {
if (this.original != null) this.original.index = index;
this.index = index;
}
public boolean isAfterSpaceEdit() {
return BitFieldSet.any(flags, F_AFTER_SPACE_EDIT);
}
public boolean isAfterInsert() {
return BitFieldSet.any(flags, F_AFTER_INSERT);
}
public boolean isAfterDelete() {
return BitFieldSet.any(flags, F_AFTER_DELETE);
}
@NotNull
public TrackedOffset plusOffsetDelta(int delta) {
return new TrackedOffset(this, offset + delta);
}
@NotNull
public TrackedOffset withOffset(int offset) {
return new TrackedOffset(this, offset);
}
@Override
public int compareTo(@NotNull TrackedOffset o) {
return Integer.compare(offset, o.offset);
}
public int compareTo(@NotNull Integer o) {
return Integer.compare(offset, o);
}
public int compareTo(int offset) {
return Integer.compare(this.offset, offset);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || (getClass() != o.getClass() && !(o instanceof Integer))) return false;
if (o instanceof Integer) {
return ((Integer) o) == offset;
}
TrackedOffset offset = (TrackedOffset) o;
return this.offset == offset.offset;
}
@Override
public int hashCode() {
return offset;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
public static TrackedOffset track(@NotNull TrackedOffset other) {
return new TrackedOffset(other);
}
public static TrackedOffset track(int offset) {
return track(offset, false, false, false);
}
@SuppressWarnings("UnusedReturnValue")
public static TrackedOffset track(int offset, @Nullable Character c, boolean afterDelete) {
return track(offset, c != null && c == ' ', c != null && !afterDelete, afterDelete);
}
public static TrackedOffset track(int offset, boolean afterSpaceEdit, boolean afterInsert, boolean afterDelete) {
assert !afterInsert && !afterDelete || afterInsert != afterDelete : "Cannot have both afterInsert and afterDelete true";
return new TrackedOffset(offset, afterSpaceEdit, afterInsert, afterDelete);
}
}
|
return "{" + offset +
(isSpliced() ? " ><" : "") +
(spacesBefore >= 0 || spacesAfter >= 0 ? " " + (spacesBefore >= 0 ? Integer.toString(spacesBefore) : "?") + "|" + (spacesAfter >= 0 ? Integer.toString(spacesAfter) : "?") : "") +
(BitFieldSet.any(flags, F_AFTER_SPACE_EDIT | F_AFTER_INSERT | F_AFTER_DELETE) ? " " + (isAfterSpaceEdit() ? "s" : "") + (isAfterInsert() ? "i" : "") + (isAfterDelete() ? "d" : "") : "") +
(isResolved() ? " -> " + index : "") +
"}";
| 1,391
| 198
| 1,589
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffsetList.java
|
TrackedOffsetList
|
getUnresolvedOffsets
|
class TrackedOffsetList implements List<TrackedOffset> {
public static TrackedOffsetList EMPTY_LIST = new TrackedOffsetList(BasedSequence.NULL, Collections.emptyList());
@NotNull
public static TrackedOffsetList create(@NotNull BasedSequence baseSeq, @NotNull List<TrackedOffset> trackedOffsets) {
return trackedOffsets instanceof TrackedOffsetList ? (TrackedOffsetList) trackedOffsets : new TrackedOffsetList(baseSeq, trackedOffsets);
}
@NotNull
public static TrackedOffsetList create(@NotNull BasedSequence baseSeq, @NotNull int[] offsets) {
ArrayList<TrackedOffset> trackedOffsets = new ArrayList<>(offsets.length);
for (int offset : offsets) {
trackedOffsets.add(TrackedOffset.track(offset));
}
return new TrackedOffsetList(baseSeq, trackedOffsets);
}
final private @NotNull BasedSequence myBaseSeq;
final private @NotNull List<TrackedOffset> myTrackedOffsets;
final private @NotNull BasedOffsetTracker myBasedOffsetTracker;
private TrackedOffsetList(@NotNull BasedSequence baseSeq, @NotNull List<TrackedOffset> trackedOffsets) {
myBaseSeq = baseSeq;
myTrackedOffsets = new ArrayList<>(trackedOffsets);
myTrackedOffsets.sort(Comparator.comparing(TrackedOffset::getOffset));
ArrayList<Seg> segments = new ArrayList<>(trackedOffsets.size());
for (TrackedOffset trackedOffset : myTrackedOffsets) {
segments.add(Seg.segOf(trackedOffset.getOffset(), trackedOffset.getOffset() + 1));
}
SegmentOffsetTree segmentOffsetTree = SegmentOffsetTree.build(segments, "");
myBasedOffsetTracker = BasedOffsetTracker.create(baseSeq, segmentOffsetTree);
assert myBasedOffsetTracker.size() == myTrackedOffsets.size();
}
@NotNull
public TrackedOffsetList getUnresolvedOffsets() {<FILL_FUNCTION_BODY>}
public boolean haveUnresolved() {
for (TrackedOffset trackedOffset : myTrackedOffsets) {
if (!trackedOffset.isResolved()) return true;
}
return false;
}
@NotNull
public BasedSequence getBaseSeq() {
return myBaseSeq;
}
@NotNull
public List<TrackedOffset> getTrackedOffsets() {
return myTrackedOffsets;
}
@NotNull
public BasedOffsetTracker getBasedOffsetTracker() {
return myBasedOffsetTracker;
}
@NotNull
public TrackedOffsetList getTrackedOffsets(int startOffset, int endOffset) {
OffsetInfo startInfo = myBasedOffsetTracker.getOffsetInfo(startOffset, startOffset == endOffset);
OffsetInfo endInfo = myBasedOffsetTracker.getOffsetInfo(endOffset, true);
int startSeg = startInfo.pos;
int endSeg = endInfo.pos;
if (startSeg < 0 && endSeg >= 0) {
startSeg = 0;
endSeg++;
} else if (startSeg >= 0 && endSeg >= 0) {
endSeg++;
} else {
return EMPTY_LIST;
}
endSeg = Math.min(myBasedOffsetTracker.size(), endSeg);
if (startSeg >= endSeg) return EMPTY_LIST;
else {
if (myTrackedOffsets.get(startSeg).getOffset() < startOffset) startSeg++;
if (myTrackedOffsets.get(endSeg - 1).getOffset() > endOffset) endSeg--;
if (startSeg >= endSeg) return EMPTY_LIST;
else {
return new TrackedOffsetList(myBaseSeq, myTrackedOffsets.subList(startSeg, endSeg));
}
}
}
// @formatter:off
@Override public boolean add(TrackedOffset offset) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public TrackedOffset set(int index, TrackedOffset element) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public void add(int index, TrackedOffset element) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public TrackedOffset remove(int index) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public boolean addAll(@NotNull Collection<? extends TrackedOffset> c) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public boolean addAll(int index, @NotNull Collection<? extends TrackedOffset> c) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public boolean removeAll(@NotNull Collection<?> c) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public boolean retainAll(@NotNull Collection<?> c) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public void replaceAll(UnaryOperator<TrackedOffset> operator) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public void sort(Comparator<? super TrackedOffset> c) { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public void clear() { throw new IllegalStateException("Not supported. Immutable list."); }
@Override public boolean remove(Object o) { throw new IllegalStateException("Not supported. Immutable list."); }
// @formatter:on
@Override
public int size() {return myTrackedOffsets.size();}
@Override
public boolean isEmpty() {return myTrackedOffsets.isEmpty();}
@Override
public boolean contains(Object o) {return myTrackedOffsets.contains(o);}
@NotNull
@Override
public Iterator<TrackedOffset> iterator() {return myTrackedOffsets.iterator();}
@NotNull
@Override
public Object[] toArray() {return myTrackedOffsets.toArray();}
@NotNull
@Override
public <T> T[] toArray(@NotNull T[] a) {return myTrackedOffsets.toArray(a);}
@Override
public boolean containsAll(@NotNull Collection<?> c) {return myTrackedOffsets.containsAll(c);}
@Override
public boolean equals(Object o) {return myTrackedOffsets.equals(o);}
@Override
public int hashCode() {return myTrackedOffsets.hashCode();}
@Override
public TrackedOffset get(int index) {return myTrackedOffsets.get(index);}
@Override
public int indexOf(Object o) {return myTrackedOffsets.indexOf(o);}
@Override
public int lastIndexOf(Object o) {return myTrackedOffsets.lastIndexOf(o);}
@NotNull
@Override
public ListIterator<TrackedOffset> listIterator() {return myTrackedOffsets.listIterator();}
@NotNull
@Override
public ListIterator<TrackedOffset> listIterator(int index) {return myTrackedOffsets.listIterator(index);}
@NotNull
@Override
public List<TrackedOffset> subList(int fromIndex, int toIndex) {return myTrackedOffsets.subList(fromIndex, toIndex);}
@Override
public Spliterator<TrackedOffset> spliterator() {return myTrackedOffsets.spliterator();}
}
|
ArrayList<TrackedOffset> unresolved = new ArrayList<>();
for (TrackedOffset trackedOffset : myTrackedOffsets) {
if (!trackedOffset.isResolved()) unresolved.add(trackedOffset);
}
return unresolved.isEmpty() ? EMPTY_LIST : new TrackedOffsetList(myBaseSeq, unresolved);
| 1,886
| 90
| 1,976
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-format/src/main/java/com/vladsch/flexmark/util/format/TrackedOffsetUtils.java
|
TrackedOffsetUtils
|
resolveTrackedOffsets
|
class TrackedOffsetUtils {
/**
* Resolve any unresolved tracked offsets
*
* @param sequence original sequence for tracked offsets
* @param appendable line appendable containing resulting lines
* @param offsets tracked offsets
* @param maxTrailingBlankLines max trailing blank lines to use in resolving offsets
* @param traceDetails true if running tests and want detail printout to stdout
*/
public static void resolveTrackedOffsets(BasedSequence sequence, LineAppendable appendable, List<TrackedOffset> offsets, int maxTrailingBlankLines, boolean traceDetails) {<FILL_FUNCTION_BODY>}
}
|
if (!offsets.isEmpty()) {
TrackedOffsetList trackedOffsets = TrackedOffsetList.create(sequence, offsets);
// need to resolve any unresolved offsets
int unresolved = trackedOffsets.size();
int length = 0;
ISequenceBuilder<?, ?> appendableBuilder = appendable.getBuilder();
BasedSequence baseSeq = appendableBuilder instanceof SequenceBuilder ? ((SequenceBuilder) appendableBuilder).getBaseSequence() : sequence.getBaseSequence();
for (LineInfo lineInfo : appendable.getLinesInfo(maxTrailingBlankLines, 0, appendable.getLineCount())) {
BasedSequence line = lineInfo.getLine();
List<TrackedOffset> lineTrackedOffsets = trackedOffsets.getTrackedOffsets(line.getStartOffset(), line.getEndOffset());
if (!lineTrackedOffsets.isEmpty()) {
for (TrackedOffset trackedOffset : lineTrackedOffsets) {
BasedOffsetTracker tracker = BasedOffsetTracker.create(line);
if (!trackedOffset.isResolved()) {
int offset = trackedOffset.getOffset();
boolean baseIsWhiteSpaceAtOffset = baseSeq.isCharAt(offset, WHITESPACE);
if (baseIsWhiteSpaceAtOffset && !(baseSeq.isCharAt(offset - 1, WHITESPACE))) {
// we need to use previous non-blank and use that offset
OffsetInfo info = tracker.getOffsetInfo(offset - 1, false);
trackedOffset.setIndex(info.endIndex + length);
} else if (!baseIsWhiteSpaceAtOffset && baseSeq.isCharAt(offset + 1, WHITESPACE)) {
// we need to use this non-blank and use that offset
OffsetInfo info = tracker.getOffsetInfo(offset, false);
trackedOffset.setIndex(info.startIndex + length);
} else {
OffsetInfo info = tracker.getOffsetInfo(offset, true);
trackedOffset.setIndex(info.endIndex + length);
}
if (traceDetails) {
System.out.println(String.format("Resolved %d to %d, start: %d, in line[%d]: '%s'", offset, trackedOffset.getIndex(), length, lineInfo.index, line.getBuilder().append(line).toStringWithRanges(true)));
}
unresolved--;
}
}
}
length += line.length();
if (unresolved <= 0) break;
}
}
| 172
| 638
| 810
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/AttributeImpl.java
|
AttributeImpl
|
indexOfValue
|
class AttributeImpl implements Attribute {
final private String name;
final private char valueListDelimiter;
final private char valueNameDelimiter;
final private String value;
private AttributeImpl(CharSequence name, CharSequence value, char valueListDelimiter, char valueNameDelimiter) {
this.name = String.valueOf(name);
this.valueListDelimiter = valueListDelimiter;
this.valueNameDelimiter = valueNameDelimiter;
this.value = value == null ? "" : String.valueOf(value);
}
@Override
public MutableAttribute toMutable() {
return MutableAttributeImpl.of(this);
}
@Override
public char getValueListDelimiter() {
return valueListDelimiter;
}
@Override
public char getValueNameDelimiter() {
return valueNameDelimiter;
}
@Override
public String getName() {
return name;
}
@Override
public String getValue() {
return value;
}
@Override
public boolean isNonRendering() {
return name.indexOf(' ') != -1 || value.isEmpty() && NON_RENDERING_WHEN_EMPTY.contains(name);
}
@SuppressWarnings("WeakerAccess")
public static int indexOfValue(CharSequence value, CharSequence valueName, char valueListDelimiter, char valueNameDelimiter) {<FILL_FUNCTION_BODY>}
@Override
public boolean containsValue(CharSequence value) {
return indexOfValue(this.value, value, valueListDelimiter, valueNameDelimiter) != -1;
}
@Override
public Attribute replaceValue(CharSequence value) {
return value.equals(this.value) ? this : of(name, value, valueListDelimiter, valueNameDelimiter);
}
@Override
public Attribute setValue(CharSequence value) {
MutableAttribute mutable = toMutable().setValue(value);
return mutable.equals(this) ? this : mutable.toImmutable();
}
@Override
public Attribute removeValue(CharSequence value) {
MutableAttribute mutable = toMutable().removeValue(value);
return mutable.equals(this) ? this : mutable.toImmutable();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Attribute)) return false;
Attribute attribute = (Attribute) o;
if (!name.equals(attribute.getName())) return false;
return value.equals(attribute.getValue());
}
@Override
public int hashCode() {
int result = name.hashCode();
result = 31 * result + value.hashCode();
return result;
}
@Override
public String toString() {
return "AttributeImpl { " +
"name='" + name + '\'' +
", value='" + value + '\'' +
" }";
}
public static AttributeImpl of(Attribute other) {
return of(other.getName(), other.getValue(), other.getValueListDelimiter(), other.getValueNameDelimiter());
}
public static AttributeImpl of(CharSequence attrName) {
return of(attrName, attrName, SequenceUtils.NUL, SequenceUtils.NUL);
}
public static AttributeImpl of(CharSequence attrName, CharSequence value) {
return of(attrName, value, SequenceUtils.NUL, SequenceUtils.NUL);
}
public static AttributeImpl of(CharSequence attrName, CharSequence value, char valueListDelimiter) {
return of(attrName, value, valueListDelimiter, SequenceUtils.NUL);
}
public static AttributeImpl of(CharSequence attrName, CharSequence value, char valueListDelimiter, char valueNameDelimiter) {
if (attrName.equals(CLASS_ATTR)) {
return new AttributeImpl(attrName, value, ' ', SequenceUtils.NUL);
} else if (attrName.equals(STYLE_ATTR)) {
return new AttributeImpl(attrName, value, ';', ':');
}
return new AttributeImpl(attrName, value, valueListDelimiter, valueNameDelimiter);
}
}
|
if (valueName.length() == 0 || value.length() == 0) return -1;
if (valueListDelimiter == SequenceUtils.NUL) {
return value.equals(valueName) ? 0 : -1;
} else {
int lastPos = 0;
BasedSequence subSeq = BasedSequence.of(value);
while (lastPos < value.length()) {
int pos = subSeq.indexOf(valueName, lastPos);
if (pos == -1) break;
// see if it is 0 or preceded by a space, or at the end or followed by a space
int endPos = pos + valueName.length();
if (pos == 0
|| value.charAt(pos - 1) == valueListDelimiter
|| valueNameDelimiter != SequenceUtils.NUL && value.charAt(pos - 1) == valueNameDelimiter) {
if (endPos >= value.length()
|| value.charAt(endPos) == valueListDelimiter
|| valueNameDelimiter != SequenceUtils.NUL && value.charAt(endPos) == valueNameDelimiter) {
return pos;
}
}
lastPos = endPos + 1;
}
}
return -1;
| 1,117
| 324
| 1,441
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/Attributes.java
|
Attributes
|
toString
|
class Attributes {
final public static Attributes EMPTY = new Attributes();
protected LinkedHashMap<String, Attribute> attributes;
public Attributes() {
attributes = null;
}
public Attributes(Attributes attributes) {
this.attributes = attributes == null || attributes.attributes == null ? null : new LinkedHashMap<>(attributes.attributes);
}
public MutableAttributes toMutable() {
return new MutableAttributes(this);
}
public Attributes toImmutable() {
return this;
}
public Attribute get(CharSequence key) {
if (attributes == null || key == null || key.length() == 0) return null;
String useKey = String.valueOf(key);
return attributes.get(useKey);
}
public String getValue(CharSequence key) {
if (attributes == null || key == null || key.length() == 0) return "";
String useKey = String.valueOf(key);
Attribute attribute = attributes.get(useKey);
if (attribute == null) return "";
return attribute.getValue();
}
public boolean contains(CharSequence key) {
if (attributes == null || key == null || key.length() == 0) return false;
String useKey = String.valueOf(key);
return attributes.containsKey(useKey);
}
public boolean containsValue(CharSequence key, CharSequence value) {
if (attributes == null) return false;
String useKey = String.valueOf(key);
Attribute attribute = attributes.get(useKey);
return attribute != null && attribute.containsValue(value);
}
public boolean isEmpty() {
return attributes == null || attributes.isEmpty();
}
@SuppressWarnings("unchecked")
public Set<String> keySet() {
// CAUTION: attributes can be modified through this mutable set
return attributes != null ? attributes.keySet() : Collections.EMPTY_SET;
}
@SuppressWarnings("unchecked")
public Collection<Attribute> values() {
return attributes != null ? attributes.values() : Collections.EMPTY_LIST;
}
@SuppressWarnings("unchecked")
public Set<Map.Entry<String, Attribute>> entrySet() {
// CAUTION: attributes can be modified through this mutable set
return attributes != null ? attributes.entrySet() : Collections.EMPTY_SET;
}
public void forEach(BiConsumer<String, Attribute> action) {
if (attributes != null) {
for (Map.Entry<String, Attribute> entry : attributes.entrySet()) {
action.accept(entry.getKey(), entry.getValue());
}
}
}
public int size() {
return attributes == null ? 0 : attributes.size();
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
StringBuilder sb = new StringBuilder();
String sep = "";
for (String attrName : keySet()) {
sb.append(sep).append(attrName);
Attribute attribute = attributes.get(attrName);
if (!attribute.getValue().isEmpty()) sb.append("=").append("\"").append(attribute.getValue().replace("\"", "\\\"")).append("\"");
sep = " ";
}
return "Attributes{" + sb.toString() + '}';
| 752
| 121
| 873
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/MutableAttributes.java
|
MutableAttributes
|
removeValue
|
class MutableAttributes extends Attributes {
public MutableAttributes() {
super();
}
public MutableAttributes(Attributes attributes) {
super(attributes);
}
@Override
public MutableAttributes toMutable() {
return this;
}
@Override
public Attributes toImmutable() {
return new Attributes(this);
}
protected LinkedHashMap<String, Attribute> getAttributes() {
if (attributes == null) {
attributes = new LinkedHashMap<>();
}
return attributes;
}
public Attribute replaceValue(Attribute attribute) {
return replaceValue(attribute.getName(), attribute.getValue());
}
/**
* Attribute dependent value replacement
* class and style append new values to existing ones
* others set it to the new value
*
* @param key attribute name
* @param value new value
* @return new attribute
*/
public Attribute replaceValue(CharSequence key, CharSequence value) {
String useKey = String.valueOf(key);
Attribute attribute;
if (attributes == null) {
attribute = AttributeImpl.of(useKey, value);
} else {
attribute = attributes.get(useKey);
if (attribute != null) attribute = attribute.replaceValue(value);
else attribute = AttributeImpl.of(useKey, value);
}
getAttributes().put(useKey, attribute);
return attribute;
}
public Attribute addValue(Attribute attribute) {
return addValue(attribute.getName(), attribute.getValue());
}
public MutableAttributes addValues(Attributes attributes) {
for (Attribute attribute : attributes.values()) {
addValue(attribute.getName(), attribute.getValue());
}
return this;
}
public Attribute addValue(CharSequence key, CharSequence value) {
Attribute attribute;
String useKey = String.valueOf(key);
if (attributes == null) {
attribute = AttributeImpl.of(key, value);
} else {
attribute = attributes.get(useKey);
if (attribute != null) attribute = attribute.setValue(value);
else attribute = AttributeImpl.of(useKey, value);
}
getAttributes().put(useKey, attribute);
return attribute;
}
public Attribute removeValue(Attribute attribute) {
return removeValue(attribute.getName(), attribute.getValue());
}
public Attribute remove(Attribute attribute) {
return remove(attribute.getName());
}
public Attribute removeValue(CharSequence key, CharSequence value) {<FILL_FUNCTION_BODY>}
public void clear() {
attributes = null;
}
public Attribute remove(CharSequence key) {
if (attributes == null || key == null || key.length() == 0) return null;
String useKey = String.valueOf(key);
Attribute oldAttribute = attributes.get(useKey);
attributes.remove(useKey);
return oldAttribute;
}
public void replaceValues(MutableAttributes attributes) {
if (this.attributes == null) {
this.attributes = new LinkedHashMap<>(attributes.attributes);
} else {
this.attributes.putAll(attributes.attributes);
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
String sep = "";
for (String attrName : keySet()) {
sb.append(sep).append(attrName);
Attribute attribute = attributes.get(attrName);
if (!attribute.getValue().isEmpty()) sb.append("=").append("\"").append(attribute.getValue().replace("\"", "\\\"")).append("\"");
sep = " ";
}
return "MutableAttributes{" + sb.toString() + '}';
}
}
|
if (attributes == null || key == null || key.length() == 0) return null;
String useKey = String.valueOf(key);
Attribute oldAttribute = attributes.get(useKey);
Attribute attribute = oldAttribute.removeValue(value);
getAttributes().put(useKey, attribute);
return attribute;
| 968
| 84
| 1,052
|
<methods>public void <init>() ,public void <init>(com.vladsch.flexmark.util.html.Attributes) ,public boolean contains(java.lang.CharSequence) ,public boolean containsValue(java.lang.CharSequence, java.lang.CharSequence) ,public Set<Entry<java.lang.String,com.vladsch.flexmark.util.html.Attribute>> entrySet() ,public void forEach(BiConsumer<java.lang.String,com.vladsch.flexmark.util.html.Attribute>) ,public com.vladsch.flexmark.util.html.Attribute get(java.lang.CharSequence) ,public java.lang.String getValue(java.lang.CharSequence) ,public boolean isEmpty() ,public Set<java.lang.String> keySet() ,public int size() ,public com.vladsch.flexmark.util.html.Attributes toImmutable() ,public com.vladsch.flexmark.util.html.MutableAttributes toMutable() ,public java.lang.String toString() ,public Collection<com.vladsch.flexmark.util.html.Attribute> values() <variables>public static final com.vladsch.flexmark.util.html.Attributes EMPTY,protected LinkedHashMap<java.lang.String,com.vladsch.flexmark.util.html.Attribute> attributes
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/BackgroundColor.java
|
BackgroundColor
|
of
|
class BackgroundColor extends Color {
final public static BackgroundColor NULL = new BackgroundColor(new Color(0, true));
final public static BackgroundColor WHITE = new BackgroundColor(Color.WHITE);
final public static BackgroundColor LIGHT_GRAY = new BackgroundColor(Color.LIGHT_GRAY);
final public static BackgroundColor GRAY = new BackgroundColor(Color.GRAY);
final public static BackgroundColor DARK_GRAY = new BackgroundColor(Color.DARK_GRAY);
final public static BackgroundColor BLACK = new BackgroundColor(Color.BLACK);
final public static BackgroundColor RED = new BackgroundColor(Color.RED);
final public static BackgroundColor PINK = new BackgroundColor(Color.PINK);
final public static BackgroundColor ORANGE = new BackgroundColor(Color.ORANGE);
final public static BackgroundColor YELLOW = new BackgroundColor(Color.YELLOW);
final public static BackgroundColor GREEN = new BackgroundColor(Color.GREEN);
final public static BackgroundColor MAGENTA = new BackgroundColor(Color.MAGENTA);
final public static BackgroundColor CYAN = new BackgroundColor(Color.CYAN);
final public static BackgroundColor BLUE = new BackgroundColor(Color.BLUE);
protected BackgroundColor(Color other) { super(other.getRGB()); }
protected BackgroundColor(int rgb) { super(rgb); }
public static BackgroundColor of(Color color) { return new BackgroundColor(color); }
public static BackgroundColor of(int rgb) { return new BackgroundColor(rgb); }
public static BackgroundColor of(String colorName) {<FILL_FUNCTION_BODY>}
}
|
Color color = ColorStyler.getNamedColor(colorName);
return color == null ? NULL : new BackgroundColor(color);
| 446
| 35
| 481
|
<methods>public void <init>(int) ,public void <init>(int, boolean) ,public void <init>(int, int, int) ,public void <init>(float, float, float) ,public void <init>(java.awt.color.ColorSpace, float[], float) ,public void <init>(int, int, int, int) ,public void <init>(float, float, float, float) ,public static int HSBtoRGB(float, float, float) ,public static float[] RGBtoHSB(int, int, int, float[]) ,public java.awt.Color brighter() ,public synchronized java.awt.PaintContext createContext(java.awt.image.ColorModel, java.awt.Rectangle, java.awt.geom.Rectangle2D, java.awt.geom.AffineTransform, java.awt.RenderingHints) ,public java.awt.Color darker() ,public static java.awt.Color decode(java.lang.String) throws java.lang.NumberFormatException,public boolean equals(java.lang.Object) ,public int getAlpha() ,public int getBlue() ,public static java.awt.Color getColor(java.lang.String) ,public static java.awt.Color getColor(java.lang.String, java.awt.Color) ,public static java.awt.Color getColor(java.lang.String, int) ,public float[] getColorComponents(float[]) ,public float[] getColorComponents(java.awt.color.ColorSpace, float[]) ,public java.awt.color.ColorSpace getColorSpace() ,public float[] getComponents(float[]) ,public float[] getComponents(java.awt.color.ColorSpace, float[]) ,public int getGreen() ,public static java.awt.Color getHSBColor(float, float, float) ,public int getRGB() ,public float[] getRGBColorComponents(float[]) ,public float[] getRGBComponents(float[]) ,public int getRed() ,public int getTransparency() ,public int hashCode() ,public java.lang.String toString() <variables>public static final java.awt.Color BLACK,public static final java.awt.Color BLUE,public static final java.awt.Color CYAN,public static final java.awt.Color DARK_GRAY,private static final double FACTOR,public static final java.awt.Color GRAY,public static final java.awt.Color GREEN,public static final java.awt.Color LIGHT_GRAY,public static final java.awt.Color MAGENTA,public static final java.awt.Color ORANGE,public static final java.awt.Color PINK,public static final java.awt.Color RED,public static final java.awt.Color WHITE,public static final java.awt.Color YELLOW,public static final java.awt.Color black,public static final java.awt.Color blue,private java.awt.color.ColorSpace cs,public static final java.awt.Color cyan,public static final java.awt.Color darkGray,private float falpha,private float[] frgbvalue,private float[] fvalue,public static final java.awt.Color gray,public static final java.awt.Color green,public static final java.awt.Color lightGray,public static final java.awt.Color magenta,public static final java.awt.Color orange,public static final java.awt.Color pink,public static final java.awt.Color red,private static final long serialVersionUID,int value,public static final java.awt.Color white,public static final java.awt.Color yellow
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/Color.java
|
Color
|
of
|
class Color extends java.awt.Color {
final public static Color NULL = new Color(new java.awt.Color(0, true));
final public static Color WHITE = new Color(java.awt.Color.WHITE);
final public static Color LIGHT_GRAY = new Color(java.awt.Color.LIGHT_GRAY);
final public static Color GRAY = new Color(java.awt.Color.GRAY);
final public static Color DARK_GRAY = new Color(java.awt.Color.DARK_GRAY);
final public static Color BLACK = new Color(java.awt.Color.BLACK);
final public static Color RED = new Color(java.awt.Color.RED);
final public static Color PINK = new Color(java.awt.Color.PINK);
final public static Color ORANGE = new Color(java.awt.Color.ORANGE);
final public static Color YELLOW = new Color(java.awt.Color.YELLOW);
final public static Color GREEN = new Color(java.awt.Color.GREEN);
final public static Color MAGENTA = new Color(java.awt.Color.MAGENTA);
final public static Color CYAN = new Color(java.awt.Color.CYAN);
final public static Color BLUE = new Color(java.awt.Color.BLUE);
protected Color(java.awt.Color other) { super(other.getRGB()); }
protected Color(int rgb) { super(rgb); }
public static Color of(java.awt.Color color) { return new Color(color); }
public static Color of(int rgb) { return new Color(rgb); }
public static Color of(String colorName) {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return "Color { " + HtmlHelpers.toHtmlString(this) + " " + HtmlHelpers.toRgbString(this) + "}";
}
}
|
java.awt.Color color = ColorStyler.getNamedColor(colorName);
return color == null ? NULL : new Color(color);
| 497
| 37
| 534
|
<methods>public void <init>(int) ,public void <init>(int, boolean) ,public void <init>(int, int, int) ,public void <init>(float, float, float) ,public void <init>(java.awt.color.ColorSpace, float[], float) ,public void <init>(int, int, int, int) ,public void <init>(float, float, float, float) ,public static int HSBtoRGB(float, float, float) ,public static float[] RGBtoHSB(int, int, int, float[]) ,public java.awt.Color brighter() ,public synchronized java.awt.PaintContext createContext(java.awt.image.ColorModel, java.awt.Rectangle, java.awt.geom.Rectangle2D, java.awt.geom.AffineTransform, java.awt.RenderingHints) ,public java.awt.Color darker() ,public static java.awt.Color decode(java.lang.String) throws java.lang.NumberFormatException,public boolean equals(java.lang.Object) ,public int getAlpha() ,public int getBlue() ,public static java.awt.Color getColor(java.lang.String) ,public static java.awt.Color getColor(java.lang.String, java.awt.Color) ,public static java.awt.Color getColor(java.lang.String, int) ,public float[] getColorComponents(float[]) ,public float[] getColorComponents(java.awt.color.ColorSpace, float[]) ,public java.awt.color.ColorSpace getColorSpace() ,public float[] getComponents(float[]) ,public float[] getComponents(java.awt.color.ColorSpace, float[]) ,public int getGreen() ,public static java.awt.Color getHSBColor(float, float, float) ,public int getRGB() ,public float[] getRGBColorComponents(float[]) ,public float[] getRGBComponents(float[]) ,public int getRed() ,public int getTransparency() ,public int hashCode() ,public java.lang.String toString() <variables>public static final java.awt.Color BLACK,public static final java.awt.Color BLUE,public static final java.awt.Color CYAN,public static final java.awt.Color DARK_GRAY,private static final double FACTOR,public static final java.awt.Color GRAY,public static final java.awt.Color GREEN,public static final java.awt.Color LIGHT_GRAY,public static final java.awt.Color MAGENTA,public static final java.awt.Color ORANGE,public static final java.awt.Color PINK,public static final java.awt.Color RED,public static final java.awt.Color WHITE,public static final java.awt.Color YELLOW,public static final java.awt.Color black,public static final java.awt.Color blue,private java.awt.color.ColorSpace cs,public static final java.awt.Color cyan,public static final java.awt.Color darkGray,private float falpha,private float[] frgbvalue,private float[] fvalue,public static final java.awt.Color gray,public static final java.awt.Color green,public static final java.awt.Color lightGray,public static final java.awt.Color magenta,public static final java.awt.Color orange,public static final java.awt.Color pink,public static final java.awt.Color red,private static final long serialVersionUID,int value,public static final java.awt.Color white,public static final java.awt.Color yellow
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/FontStyle.java
|
FontStyle
|
of
|
class FontStyle {
final public static FontStyle PLAIN = new FontStyle(0);
final public static FontStyle BOLD = new FontStyle(Font.BOLD);
final public static FontStyle ITALIC = new FontStyle(Font.ITALIC);
final public static FontStyle BOLD_ITALIC = new FontStyle(Font.ITALIC | Font.BOLD);
final public int fontStyle;
private FontStyle(int fontStyle) {
this.fontStyle = fontStyle;
}
public boolean isItalic() {
return (fontStyle & Font.ITALIC) != 0;
}
public boolean isBold() {
return (fontStyle & Font.BOLD) != 0;
}
public static FontStyle of(int fontStyle) {<FILL_FUNCTION_BODY>}
}
|
if ((fontStyle & (Font.BOLD | Font.ITALIC)) == (Font.BOLD | Font.ITALIC)) return BOLD_ITALIC;
if ((fontStyle & (Font.BOLD)) == (Font.BOLD)) return BOLD;
if ((fontStyle & (Font.ITALIC)) == (Font.ITALIC)) return ITALIC;
return PLAIN;
| 213
| 101
| 314
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/FontStyleStyler.java
|
FontStyleStyler
|
getStyle
|
class FontStyleStyler extends HtmlStylerBase<FontStyle> {
@Override
public String getStyle(FontStyle item) {<FILL_FUNCTION_BODY>}
}
|
return item == null ? "" :
(item.isItalic() ? "font-style:italic;" : "font-style:normal;") +
(item.isBold() ? "font-weight:bold" : "font-weight:normal");
| 47
| 66
| 113
|
<methods>public non-sealed void <init>() ,public abstract java.lang.String getStyle(com.vladsch.flexmark.util.html.ui.FontStyle) ,public com.vladsch.flexmark.util.html.ui.FontStyle getStyleable(java.lang.Object) <variables>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/HtmlBuilder.java
|
HtmlBuilder
|
getHtmlStyler
|
class HtmlBuilder extends HtmlAppendableBase<HtmlBuilder> {
public HtmlBuilder() {
super(0, LineAppendable.F_PASS_THROUGH);
}
public HtmlBuilder(int indentSize, int formatOptions) {
super(indentSize, formatOptions);
}
@SuppressWarnings({ "UnusedReturnValue", "WeakerAccess" })
public HtmlBuilder closeAllTags() {
while (!getOpenTags().isEmpty()) {
CharSequence tag = getOpenTags().peek();
closeTag(tag);
}
return this;
}
public String toFinalizedString() {
//if (!openTags.isEmpty()) throw new IllegalStateException("Unclosed tags on toHtml call: " + tagStack());
closeAllTags();
return toString(0, 0);
}
@SuppressWarnings("WeakerAccess")
public HtmlBuilder attr(Object... convertible) {
for (Object convert : convertible) {
if (convert instanceof Attribute) {
super.attr((Attribute) convert);
super.withAttr();
} else {
//noinspection rawtypes
HtmlStyler styler = getHtmlStyler(convert);
// NOTE: show not simple name but name of container class if any
if (styler == null) throw new IllegalStateException("Don't know how to style " + convert.getClass().getName().substring(getClass().getPackage().getName().length() + 1));
//noinspection unchecked
String value = styler.getStyle(styler.getStyleable(convert));
if (value != null && !value.isEmpty()) {
Attribute style = AttributeImpl.of(Attribute.STYLE_ATTR, value);
super.attr(style);
super.withAttr();
}
}
}
return this;
}
@NotNull
@Override
public HtmlBuilder attr(@NotNull CharSequence name, @Nullable CharSequence value) {
super.withAttr();
return super.attr(name, value);
}
public HtmlBuilder style(CharSequence value) {
super.withAttr();
return super.attr(Attribute.STYLE_ATTR, value);
}
@NotNull
@Override
public HtmlBuilder attr(@NotNull Attribute... attribute) {
super.withAttr();
return super.attr(attribute);
}
@NotNull
@Override
public HtmlBuilder attr(@NotNull Attributes attributes) {
super.withAttr();
return super.attr(attributes);
}
public HtmlBuilder span() {
return tag("span", false);
}
public HtmlBuilder span(CharSequence text) {
tag("span", false);
text(text);
return closeSpan();
}
public HtmlBuilder span(boolean withLine, Runnable runnable) {
return tag("span", false, withLine, runnable);
}
public HtmlBuilder span(Runnable runnable) {
return span(false, runnable);
}
public HtmlBuilder spanLine(Runnable runnable) {
return span(true, runnable);
}
public HtmlBuilder closeSpan() {
return closeTag("span");
}
// statics
final public static HashMap<Class, HtmlStyler> stylerMap = new HashMap<>();
static {
ColorStyler colorStyler = new ColorStyler();
stylerMap.put(BackgroundColor.class, colorStyler);
stylerMap.put(Color.class, colorStyler);
//stylerMap.put(JBColor.class, colorStyler);
stylerMap.put(java.awt.Color.class, colorStyler);
FontStyler fontStyler = new FontStyler();
stylerMap.put(Font.class, fontStyler);
stylerMap.put(FontUIResource.class, fontStyler);
stylerMap.put(FontStyle.class, new FontStyleStyler());
}
public static void addColorStylerClass(Class clazz) {
HtmlStyler styler = stylerMap.get(Color.class);
stylerMap.put(clazz, styler);
}
public static HtmlStyler getHtmlStyler(Object item) {<FILL_FUNCTION_BODY>}
public static Attribute getAttribute(Object item) {
HtmlStyler styler = getHtmlStyler(item);
if (styler != null) {
//noinspection unchecked
String value = styler.getStyle(styler.getStyleable(item));
if (value != null && !value.isEmpty()) {
return AttributeImpl.of(Attribute.STYLE_ATTR, value);
}
}
return null;
}
// mimic string builder for comfort
public HtmlBuilder append(Object obj) { return super.append(String.valueOf(obj)); }
public HtmlBuilder append(String str) { return super.append(str); }
public HtmlBuilder append(StringBuffer sb) { return super.append(sb.toString()); }
@NotNull
public HtmlBuilder append(@NotNull CharSequence s) { return super.append(s); }
@NotNull
public HtmlBuilder append(@NotNull CharSequence s, int start, int end) { return super.append(s, start, end); }
public HtmlBuilder append(char[] str) { return super.append(String.valueOf(str)); }
public HtmlBuilder append(char[] str, int offset, int len) { return super.append(String.valueOf(str, offset, len)); }
public HtmlBuilder append(boolean b) { return super.append(b ? "true" : "false"); }
@NotNull
public HtmlBuilder append(char c) { return super.append(c); }
public HtmlBuilder append(int i) { return super.append(String.valueOf(i)); }
public HtmlBuilder append(long l) { return super.append(String.valueOf(l)); }
public HtmlBuilder append(float f) { return super.append(String.valueOf(f)); }
public HtmlBuilder append(double d) { return super.append(String.valueOf(d)); }
}
|
HtmlStyler styler = stylerMap.get(item.getClass());
if (styler != null) return styler;
// see if we have one that can handle this
for (Class value : stylerMap.keySet()) {
//noinspection unchecked
if (value.isAssignableFrom(item.getClass())) {
styler = stylerMap.get(value);
break;
}
}
if (styler != null) {
stylerMap.put(item.getClass(), styler);
}
return styler;
| 1,592
| 153
| 1,745
|
<methods>public void <init>(com.vladsch.flexmark.util.sequence.LineAppendable, boolean) ,public void <init>(int, int) ,public void <init>(@Nullable Appendable, int, int) ,public @NotNull HtmlBuilder addIndentOnFirstEOL(@NotNull Runnable) ,public @NotNull HtmlBuilder addPrefix(@NotNull CharSequence) ,public @NotNull HtmlBuilder addPrefix(@NotNull CharSequence, boolean) ,public @NotNull HtmlBuilder append(char) ,public @NotNull HtmlBuilder append(@NotNull CharSequence) ,public @NotNull HtmlBuilder append(@NotNull CharSequence, int, int) ,public @NotNull HtmlBuilder append(@NotNull LineAppendable, int, int, boolean) ,public @NotNull HtmlBuilder append(char, int) ,public T appendTo(@NotNull T, boolean, int, int, int, int) throws java.io.IOException,public @NotNull HtmlBuilder attr(@NotNull CharSequence, @NotNull CharSequence) ,public transient @NotNull HtmlBuilder attr(@NotNull Attribute []) ,public @NotNull HtmlBuilder attr(@NotNull Attributes) ,public @NotNull HtmlBuilder blankLine() ,public @NotNull HtmlBuilder blankLine(int) ,public @NotNull HtmlBuilder blankLineIf(boolean) ,public @NotNull HtmlBuilder changeOptions(int, int) ,public @NotNull HtmlBuilder closePre() ,public @NotNull HtmlBuilder closePreFormatted() ,public @NotNull HtmlBuilder closeTag(@NotNull CharSequence) ,public int column() ,public boolean endsWithEOL() ,public int getAfterEolPrefixDelta() ,public com.vladsch.flexmark.util.html.Attributes getAttributes() ,public @NotNull BasedSequence getBeforeEolPrefix() ,public @NotNull ISequenceBuilder<?,?> getBuilder() ,public @NotNull HtmlAppendable getEmptyAppendable() ,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 Stack<String> getOpenTags() ,public @NotNull List<String> getOpenTagsAfterLast(@NotNull CharSequence) ,public @NotNull BitFieldSet<LineAppendable.Options> getOptionSet() ,public int getOptions() ,public int getPendingEOL() ,public int getPendingSpace() ,public @NotNull BasedSequence getPrefix() ,public int getTrailingBlankLines(int) ,public boolean inPre() ,public @NotNull HtmlBuilder indent() ,public void insertLine(int, @NotNull CharSequence, @NotNull CharSequence) ,public boolean isPendingSpace() ,public boolean isPreFormatted() ,public boolean isSuppressCloseTagLine() ,public boolean isSuppressOpenTagLine() ,public @NotNull Iterator<LineInfo> iterator() ,public @NotNull HtmlBuilder line() ,public @NotNull HtmlBuilder lineIf(boolean) ,public @NotNull HtmlBuilder lineOnFirstText(boolean) ,public @NotNull HtmlBuilder lineWithTrailingSpaces(int) ,public int offset() ,public int offsetWithPending() ,public @NotNull HtmlBuilder openPre() ,public @NotNull HtmlBuilder openPreFormatted(boolean) ,public @NotNull HtmlBuilder popOptions() ,public @NotNull HtmlBuilder popPrefix() ,public @NotNull HtmlBuilder popPrefix(boolean) ,public @NotNull HtmlBuilder pushOptions() ,public @NotNull HtmlBuilder pushPrefix() ,public @NotNull HtmlBuilder raw(@NotNull CharSequence) ,public @NotNull HtmlBuilder raw(@NotNull CharSequence, int) ,public @NotNull HtmlBuilder rawIndentedPre(@NotNull CharSequence) ,public @NotNull HtmlBuilder rawPre(@NotNull CharSequence) ,public @NotNull HtmlBuilder removeExtraBlankLines(int, int, int, int) ,public @NotNull HtmlBuilder removeIndentOnFirstEOL(@NotNull Runnable) ,public @NotNull HtmlBuilder removeLines(int, int) ,public @NotNull HtmlBuilder setAttributes(@NotNull Attributes) ,public @NotNull HtmlBuilder setIndentPrefix(@Nullable CharSequence) ,public void setLine(int, @NotNull CharSequence, @NotNull CharSequence) ,public @NotNull HtmlBuilder setOptions(int) ,public @NotNull HtmlBuilder setPrefix(@NotNull CharSequence) ,public @NotNull HtmlBuilder setPrefix(@Nullable CharSequence, boolean) ,public void setPrefixLength(int, int) ,public @NotNull HtmlBuilder setSuppressCloseTagLine(boolean) ,public void setSuppressOpenTagLine(boolean) ,public @NotNull HtmlBuilder tag(@NotNull CharSequence) ,public @NotNull HtmlBuilder tag(@NotNull CharSequence, @NotNull Runnable) ,public @NotNull HtmlBuilder tag(@NotNull CharSequence, boolean) ,public @NotNull HtmlBuilder tag(@NotNull CharSequence, boolean, boolean, @NotNull Runnable) ,public @NotNull HtmlBuilder tagIndent(@NotNull CharSequence, @NotNull Runnable) ,public @NotNull HtmlBuilder tagLine(@NotNull CharSequence) ,public @NotNull HtmlBuilder tagLine(@NotNull CharSequence, boolean) ,public @NotNull HtmlBuilder tagLine(@NotNull CharSequence, @NotNull Runnable) ,public @NotNull HtmlBuilder tagLineIndent(@NotNull CharSequence, @NotNull Runnable) ,public @NotNull HtmlBuilder tagVoid(@NotNull CharSequence) ,public @NotNull HtmlBuilder tagVoidLine(@NotNull CharSequence) ,public @NotNull HtmlBuilder text(@NotNull CharSequence) ,public @NotNull CharSequence toSequence(int, int, boolean) ,public @NotNull String toString() ,public @NotNull String toString(int, int, boolean) ,public @NotNull HtmlBuilder unIndent() ,public @NotNull HtmlBuilder unIndentNoEol() ,public @NotNull HtmlBuilder withAttr() ,public @NotNull HtmlBuilder withCondIndent() ,public @NotNull HtmlBuilder withCondLineOnChildText() <variables>private final non-sealed com.vladsch.flexmark.util.sequence.LineAppendable appendable,private @Nullable MutableAttributes currentAttributes,private boolean indentOnFirstEol,private boolean lineOnChildText,private final @NotNull Stack<String> openTags,private boolean suppressCloseTagLine,private boolean suppressOpenTagLine,private boolean withAttributes
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/HtmlHelpers.java
|
HtmlHelpers
|
mixedColor
|
class HtmlHelpers {
public static String toHtmlError(String err, boolean withContext) {
if (err == null) return null;
if (withContext) {
Matcher matcher = Pattern.compile("(?:^|\n)(.*\n)(\\s*)\\^(\n?)$").matcher(err);
if (matcher.find()) {
String group = matcher.group(2);
if (group != null && !group.isEmpty()) {
int prevLineStart = matcher.group(1) != null ? matcher.start(1) : matcher.start(2);
String lastLine = Utils.repeat(" ", group.length());
err = err.substring(0, prevLineStart) + "<span style=\"font-family:monospaced\">" + err.substring(prevLineStart, matcher.start(2)).replace(" ", " ") + lastLine + "^</span>" + group;
}
}
}
return err.replace("\n", "<br>");
}
public static void setRegExError(String error, JTextPane jTextPane, Font textFont, BackgroundColor validTextFieldBackground, BackgroundColor warningTextFieldBackground) {
HtmlBuilder html = new HtmlBuilder();
html.tag("html").style("margin:2px;vertical-align:middle;").attr(validTextFieldBackground, textFont).tag("body");
html.attr(warningTextFieldBackground).tag("div");
html.append(toHtmlError(error, true));
html.closeTag("div");
html.closeTag("body");
html.closeTag("html");
jTextPane.setVisible(true);
jTextPane.setText(html.toFinalizedString());
jTextPane.revalidate();
jTextPane.getParent().revalidate();
jTextPane.getParent().getParent().revalidate();
}
public static String withContext(String text, String context, int pos, String prefix, String suffix) {
StringBuilder sb = new StringBuilder();
sb.append(text).append('\n');
sb.append(prefix).append(context).append(suffix).append('\n');
for (int i = 1; i < prefix.length(); i++) sb.append(' ');
sb.append('^').append('\n');
return sb.toString();
}
public static String toRgbString(java.awt.Color color) {
return (color == null) ? "rgb(0,0,0)" : "rgb(" + color.getRed() + "," + color.getGreen() + "," + color.getBlue() + ")";
}
public static String toHtmlString(java.awt.Color color) {
return (color == null) ? "#000000" : String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
}
public static java.awt.Color mixedColor(java.awt.Color originalColor, java.awt.Color overlayColor) {<FILL_FUNCTION_BODY>}
}
|
float[] hsbColor = java.awt.Color.RGBtoHSB(originalColor.getRed(), originalColor.getGreen(), originalColor.getBlue(), new float[3]);
float[] hsbError = java.awt.Color.RGBtoHSB(overlayColor.getRed(), overlayColor.getGreen(), overlayColor.getBlue(), new float[3]);
float[] hsbMixed = new float[3];
// kotlin code
//hsbMixed[0] = hsbError[0]
//hsbMixed[1] = hsbColor[1].rangeLimit(hsbError[1].max(0.3f).min(0.5f), 1.0f)
//hsbMixed[2] = hsbColor[2].rangeLimit(hsbError[2].max(0.3f).min(0.5f), 1.0f)
//return Color.getHSBColor(hsbMixed[0], hsbMixed[1], hsbMixed[2])
// incorrect translation from kotlin
//hsbMixed[0] = hsbError[0];
//hsbMixed[1] = min(max(rangeLimit(hsbColor[1], hsbError[1], 0.3f), 0.5f), 1.0f);
//hsbMixed[2] = min(max(rangeLimit(hsbColor[2], hsbError[2], 0.3f), 0.5f), 1.0f);
//return java.awt.Color.getHSBColor(hsbMixed[0], hsbMixed[1], hsbMixed[2]);
hsbMixed[0] = hsbError[0];
hsbMixed[1] = rangeLimit(hsbColor[1], min(max(hsbError[1], 0.3f), 0.5f), 1.0f);
hsbMixed[2] = rangeLimit(hsbColor[2], min(max(hsbError[2], 0.3f), 0.5f), 1.0f);
return java.awt.Color.getHSBColor(hsbMixed[0], hsbMixed[1], hsbMixed[2]);
| 786
| 560
| 1,346
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-html/src/main/java/com/vladsch/flexmark/util/html/ui/HtmlStylerBase.java
|
HtmlStylerBase
|
getStyleable
|
class HtmlStylerBase<T> implements HtmlStyler<T> {
@Override
public T getStyleable(Object item) {<FILL_FUNCTION_BODY>}
public abstract String getStyle(T item);
}
|
try {
//noinspection unchecked
return (T) item;
} catch (Throwable ignored) {
return null;
}
| 62
| 41
| 103
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/ArrayUtils.java
|
ArrayUtils
|
toArray
|
class ArrayUtils {
public static <T> boolean contained(T value, T[] array) {
return indexOf(value, array) != -1;
}
@SafeVarargs
public static <T> T[] append(Class<T> elemClass, T[] array, T... values) {
if (values.length > 0) {
//noinspection unchecked
T[] newInstance = (T[]) Array.newInstance(elemClass, array.length + values.length);
System.arraycopy(array, 0, newInstance, 0, array.length);
System.arraycopy(values, 0, newInstance, array.length, values.length);
return newInstance;
}
return array;
}
public static boolean contained(int value, int[] array) {
for (int item : array) {
if (item == value) return true;
}
return false;
}
public static <T> T firstOf(T[] ts, Predicate<? super T> predicate) { return firstOf(ts, 0, ts.length, predicate); }
public static <T> T firstOf(T[] ts, int fromIndex, Predicate<? super T> predicate) { return firstOf(ts, fromIndex, ts.length, predicate); }
@Nullable
public static <T> T firstOf(T[] ts, int fromIndex, int endIndex, Predicate<? super T> predicate) {
int i = indexOf(ts, fromIndex, endIndex, predicate);
return i == -1 ? null : ts[i];
}
public static <T> int indexOf(T t, T[] ts) { return indexOf(t, ts, 0, ts.length); }
public static <T> int indexOf(T t, T[] ts, int fromIndex) { return indexOf(t, ts, fromIndex, ts.length); }
public static <T> int indexOf(T t, T[] ts, int fromIndex, int endIndex) {
return indexOf(ts, fromIndex, endIndex, t1 -> Objects.equals(t, t1));
}
public static <T> int indexOf(T[] ts, Predicate<? super T> predicate) { return indexOf(ts, 0, ts.length, predicate); }
public static <T> int indexOf(T[] ts, int fromIndex, Predicate<? super T> predicate) { return indexOf(ts, fromIndex, ts.length, predicate); }
/**
* @param ts array
* @param fromIndex the start index from which search in the array. There is no
* restriction on the value of {@code fromIndex}.
* If it is less than 0, it has the same effect as if it were 0.
* If it is greater or equal to length of the array, -1 is returned.
* @param endIndex the end index of the array, ie. treat as if array.length was endIndex.
* There is no restriction on the value of {@code endIndex}. If it is
* greater than or equal to the length of this array, it has
* the same effect as if it were equal to length of this array.
* If it is negative, it has the same effect as if it were 0: -1 is returned.
* @param predicate condition for matching the search
* @param <T> type of array
*
* @return the index of the next occurrence of a match in the array which is
* greater than or equal to {@code fromIndex}, or {@code -1}
* if match does not occur after that point.
*/
public static <T> int indexOf(T[] ts, int fromIndex, int endIndex, Predicate<? super T> predicate) {
int iMax = ts.length;
if (endIndex > 0) {
if (fromIndex < 0) fromIndex = 0;
if (endIndex > iMax) endIndex = iMax;
if (fromIndex < endIndex) {
for (int i = fromIndex; i < endIndex; i++) {
if (predicate.test(ts[i])) return i;
}
}
}
return -1;
}
public static <T> T lastOf(T[] ts, Predicate<? super T> predicate) { return lastOf(ts, 0, ts.length, predicate); }
public static <T> T lastOf(T[] ts, int fromIndex, Predicate<? super T> predicate) { return lastOf(ts, 0, fromIndex, predicate); }
public static <T> T lastOf(T[] ts, int startIndex, int fromIndex, Predicate<? super T> predicate) {
int i = lastIndexOf(ts, startIndex, fromIndex, predicate);
return i == -1 ? null : ts[i];
}
public static <T> int lastIndexOf(T t, T[] ts) { return lastIndexOf(t, ts, 0, ts.length); }
public static <T> int lastIndexOf(T t, T[] ts, int fromIndex) { return lastIndexOf(t, ts, 0, fromIndex); }
public static <T> int lastIndexOf(T t, T[] ts, int startIndex, int fromIndex) {
return lastIndexOf(ts, startIndex, fromIndex, t1 -> Objects.equals(t, t1));
}
public static <T> int lastIndexOf(T[] ts, Predicate<? super T> predicate) { return lastIndexOf(ts, 0, ts.length, predicate); }
public static <T> int lastIndexOf(T[] ts, int fromIndex, Predicate<? super T> predicate) { return lastIndexOf(ts, 0, fromIndex, predicate); }
/**
* @param ts array
* @param startIndex the minimum index to search in the array. There is no
* restriction on the value of {@code startIndex}.
* If it is less than 0, it has the same effect as if it were 0.
* If it is greater or equal to length of the array, -1 is returned.
* @param fromIndex the index to start the search from. There is no
* restriction on the value of {@code fromIndex}. If it is
* greater than or equal to the length of this array, it has
* the same effect as if it were equal to one less than the
* length of this array: this entire array may be searched.
* If it is negative, it has the same effect as if it were -1:
* -1 is returned.
* @param predicate condition for matching the search
* @param <T> type of array
*
* @return the index of the last occurrence of a match in the array which is
* less than or equal to {@code fromIndex}, or {@code -1}
* if match does not occur before that point.
*/
public static <T> int lastIndexOf(T[] ts, int startIndex, int fromIndex, Predicate<? super T> predicate) {
int iMax = ts.length;
if (fromIndex >= 0) {
if (startIndex < 0) startIndex = 0;
if (fromIndex >= iMax) fromIndex = iMax - 1;
if (startIndex < fromIndex) {
for (int i = fromIndex; i >= startIndex; i--) {
if (predicate.test(ts[i])) return i;
}
}
}
return -1;
}
public static int[] toArray(@NotNull BitSet bitSet) {<FILL_FUNCTION_BODY>}
}
|
int i = bitSet.cardinality();
int[] bits = new int[i];
int lastSet = bitSet.length();
while (lastSet >= 0) {
lastSet = bitSet.previousSetBit(lastSet - 1);
if (lastSet < 0) break;
bits[--i] = lastSet;
}
assert i == 0;
return bits;
| 1,903
| 104
| 2,007
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/BitFieldSet.java
|
EnumBitFieldIterator
|
containsAll
|
class EnumBitFieldIterator<E extends Enum<E>> implements Iterator<E> {
int nextIndex;
int lastReturnedIndex = -1;
EnumBitFieldIterator() {
nextIndex = -1;
findNext();
}
public boolean hasNext() {
return nextIndex < universe.length;
}
@SuppressWarnings("unchecked")
public E next() {
if (nextIndex >= universe.length)
throw new NoSuchElementException();
lastReturnedIndex = nextIndex;
findNext();
return (E) universe[lastReturnedIndex];
}
void findNext() {
do {
nextIndex++;
if (nextIndex >= universe.length) break;
} while ((elements & bitMasks[nextIndex]) == 0);
}
public void remove() {
if (lastReturnedIndex == -1)
throw new IllegalStateException();
elements &= ~bitMasks[lastReturnedIndex];
lastReturnedIndex = -1;
}
}
/**
* Returns the number of elements in this set.
*
* @return the number of elements in this set
*/
public int size() {
return totalBits;
}
/**
* @return true if this set contains no elements
*/
public boolean isEmpty() {
return elements == 0;
}
/**
* Returns true if this set contains the specified element.
*
* @param e element to be checked for containment in this collection
* @return true if this set contains the specified element
*/
public boolean contains(Object e) {
if (e == null)
return false;
Class<?> eClass = e.getClass();
if (eClass != elementType && eClass.getSuperclass() != elementType)
return false;
return (elements & bitMasks[((Enum<?>) e).ordinal()]) != 0;
}
// Modification Operations
/**
* Adds the specified element to this set if it is not already present.
*
* @param e element to be added to this set
* @return true if the set changed as a result of the call
* @throws NullPointerException if e is null
*/
public boolean add(E e) {
typeCheck(e);
long oldElements = elements;
elements |= bitMasks[e.ordinal()];
return elements != oldElements;
}
/**
* Removes the specified element from this set if it is present.
*
* @param e element to be removed from this set, if present
* @return true if the set contained the specified element
*/
public boolean remove(Object e) {
if (e == null)
return false;
Class<?> eClass = e.getClass();
if (eClass != elementType && eClass.getSuperclass() != elementType)
return false;
long oldElements = elements;
elements &= ~bitMasks[((Enum<?>) e).ordinal()];
return elements != oldElements;
}
// Bulk Operations
/**
* Returns true if this set contains all of the elements
* in the specified collection.
*
* @param c collection to be checked for containment in this set
* @return true if this set contains all of the elements
* in the specified collection
* @throws NullPointerException if the specified collection is null
*/
public boolean containsAll(Collection<?> c) {<FILL_FUNCTION_BODY>
|
if (!(c instanceof BitFieldSet))
return super.containsAll(c);
BitFieldSet<?> es = (BitFieldSet<?>) c;
if (es.elementType != elementType)
return es.isEmpty();
return (es.elements & ~elements) == 0;
| 913
| 80
| 993
|
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public boolean removeAll(Collection<?>) <variables>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/DelimitedBuilder.java
|
DelimitedBuilder
|
appendAll
|
class DelimitedBuilder {
private String delimiter;
private StringBuilder out;
private boolean pending = false;
private int lastLen = 0;
private Stack<String> delimiterStack = null;
public DelimitedBuilder() {
this(",", 0);
}
public DelimitedBuilder(String delimiter) {
this(delimiter, 0);
}
public DelimitedBuilder(String delimiter, int capacity) {
this.delimiter = delimiter;
this.out = capacity == 0 ? null : new StringBuilder(capacity);
}
@Override
public String toString() {
if (delimiterStack != null && !delimiterStack.isEmpty()) throw new IllegalStateException("Delimiter stack is not empty");
return out == null ? "" : out.toString();
}
public boolean isEmpty() {
return !pending && (out == null || out.length() == 0);
}
public String getAndClear() {
if (delimiterStack != null && !delimiterStack.isEmpty()) throw new IllegalStateException("Delimiter stack is not empty");
String result = out == null ? "" : out.toString();
clear();
return result;
}
public DelimitedBuilder clear() {
out = null;
unmark();
return this;
}
public String toStringOrNull() {
if (delimiterStack != null && !delimiterStack.isEmpty()) throw new IllegalStateException("Delimiter stack is not empty");
return out == null ? null : out.toString();
}
public DelimitedBuilder mark() {
int length = out != null ? out.length() : 0;
if (lastLen != length) pending = true;
lastLen = length;
return this;
}
public DelimitedBuilder unmark() {
pending = false;
lastLen = out != null ? out.length() : 0;
return this;
}
public DelimitedBuilder push() {
return push(delimiter);
}
public DelimitedBuilder push(String delimiter) {
unmark();
if (delimiterStack == null) delimiterStack = new Stack<>();
delimiterStack.push(this.delimiter);
this.delimiter = delimiter;
return this;
}
public DelimitedBuilder pop() {
if (delimiterStack == null || delimiterStack.isEmpty()) throw new IllegalStateException("Nothing on the delimiter stack");
delimiter = delimiterStack.pop();
return this;
}
private void doPending() {
if (out == null) out = new StringBuilder();
if (pending) {
out.append(delimiter);
pending = false;
}
}
public DelimitedBuilder append(char v) {
doPending();
out.append(v);
return this;
}
public DelimitedBuilder append(int v) {
doPending();
out.append(v);
return this;
}
public DelimitedBuilder append(boolean v) {
doPending();
out.append(v);
return this;
}
public DelimitedBuilder append(long v) {
doPending();
out.append(v);
return this;
}
public DelimitedBuilder append(float v) {
doPending();
out.append(v);
return this;
}
public DelimitedBuilder append(double v) {
doPending();
out.append(v);
return this;
}
public DelimitedBuilder append(String v) {
if (v != null && !v.isEmpty()) {
doPending();
out.append(v);
}
return this;
}
public DelimitedBuilder append(String v, int start, int end) {
if (v != null && start < end) {
doPending();
out.append(v, start, end);
}
return this;
}
public DelimitedBuilder append(CharSequence v) {
if (v != null && v.length() > 0) {
doPending();
out.append(v);
}
return this;
}
public DelimitedBuilder append(CharSequence v, int start, int end) {
if (v != null && start < end) {
doPending();
out.append(v, start, end);
}
return this;
}
public DelimitedBuilder append(char[] v) {
if (v.length > 0) {
doPending();
out.append(v);
}
return this;
}
public DelimitedBuilder append(char[] v, int start, int end) {
if (start < end) {
doPending();
out.append(v, start, end);
}
return this;
}
public DelimitedBuilder append(Object o) {
return append(o.toString());
}
public DelimitedBuilder appendCodePoint(int codePoint) {
doPending();
out.appendCodePoint(codePoint);
return this;
}
public <V> DelimitedBuilder appendAll(V[] v) {
return appendAll(v, 0, v.length);
}
public <V> DelimitedBuilder appendAll(V[] v, int start, int end) {
for (int i = start; i < end; i++) {
V item = v[i];
append(item.toString());
mark();
}
return this;
}
public <V> DelimitedBuilder appendAll(String delimiter, V[] v) {
return appendAll(delimiter, v, 0, v.length);
}
public <V> DelimitedBuilder appendAll(String delimiter, V[] v, int start, int end) {
int lastLength = out != null ? out.length() : 0;
push(delimiter);
appendAll(v, start, end);
pop();
if (lastLength != (out != null ? out.length() : 0)) mark();
else unmark();
return this;
}
public <V> DelimitedBuilder appendAll(List<? extends V> v) {
return appendAll(v, 0, v.size());
}
public <V> DelimitedBuilder appendAll(List<? extends V> v, int start, int end) {<FILL_FUNCTION_BODY>}
public <V> DelimitedBuilder appendAll(String delimiter, List<? extends V> v) {
return appendAll(delimiter, v, 0, v.size());
}
public <V> DelimitedBuilder appendAll(String delimiter, List<? extends V> v, int start, int end) {
int lastLength = out != null ? out.length() : 0;
push(delimiter);
appendAll(v, start, end);
pop();
if (lastLength != (out != null ? out.length() : 0)) mark();
else unmark();
return this;
}
}
|
for (int i = start; i < end; i++) {
V item = v.get(i);
append(item.toString());
mark();
}
return this;
| 1,881
| 51
| 1,932
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/FileUtil.java
|
FileUtil
|
getFileContentWithExceptions
|
class FileUtil {
public static boolean isChildOf(File receiver, File ancestor) {
return (suffixWith(receiver.getPath(), File.separator)).startsWith(suffixWith(ancestor.getPath(), File.separator));
}
public static String getNameOnly(File receiver) {
String name = receiver.getName();
int pos = name.lastIndexOf('.');
return (pos > 0 && pos > name.lastIndexOf(File.separatorChar)) ? name.substring(0, pos) : name;
}
public static String getDotExtension(File receiver) {
String name = receiver.getName();
int pos = name.lastIndexOf('.');
return (pos > 0 && pos > name.lastIndexOf(File.separatorChar)) ? name.substring(pos) : "";
}
public static String pathSlash(File receiver) {
String path = receiver.getPath();
int pos = path.lastIndexOf(File.separatorChar);
return (pos != -1) ? path.substring(0, pos + 1) : "";
}
public static File plus(File receiver, String name) {
return new File(receiver, name);
}
@Nullable
public static String getFileContent(File receiver) {
StringBuilder sb = new StringBuilder();
String line;
try {
InputStream inputStream = new FileInputStream(receiver);
InputStreamReader streamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(streamReader);
while ((line = reader.readLine()) != null) {
sb.append(line);
sb.append("\n");
}
reader.close();
streamReader.close();
inputStream.close();
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@NotNull
public static String getFileContentWithExceptions(File receiver) throws IOException {<FILL_FUNCTION_BODY>}
@Nullable
public static byte[] getFileContentBytes(File receiver) {
try {
return Files.readAllBytes(receiver.toPath());
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@NotNull
public static byte[] getFileContentBytesWithExceptions(File receiver) throws IOException {
return Files.readAllBytes(receiver.toPath());
}
}
|
StringBuilder sb = new StringBuilder();
String line;
InputStream inputStream = new FileInputStream(receiver);
InputStreamReader streamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader reader = new BufferedReader(streamReader);
while ((line = reader.readLine()) != null) {
sb.append(line);
sb.append("\n");
}
reader.close();
streamReader.close();
inputStream.close();
return sb.toString();
| 632
| 133
| 765
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/MinMaxAvgDouble.java
|
MinMaxAvgDouble
|
add
|
class MinMaxAvgDouble {
private double min = Double.MAX_VALUE;
private double max = Double.MIN_VALUE;
private double total = 0.0;
public MinMaxAvgDouble() {
}
public void add(double value) {<FILL_FUNCTION_BODY>}
public void add(MinMaxAvgDouble other) {
total += other.total;
min = Math.min(min, other.min);
max = Math.max(max, other.max);
}
public void diff(double start, double end) {
add(end - start);
}
public double getMin() {
return min;
}
public double getMax() {
return max;
}
public double getTotal() {
return total;
}
public double getAvg(double count) {
return count == 0 ? 0 : total / count;
}
}
|
total += value;
min = Math.min(min, value);
max = Math.max(max, value);
| 241
| 33
| 274
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/MinMaxAvgFloat.java
|
MinMaxAvgFloat
|
add
|
class MinMaxAvgFloat {
private float min = Float.MAX_VALUE;
private float max = Float.MIN_VALUE;
private float total = 0.0f;
public MinMaxAvgFloat() {
}
public void add(float value) {<FILL_FUNCTION_BODY>}
public void add(MinMaxAvgFloat other) {
total += other.total;
min = Math.min(min, other.min);
max = Math.max(max, other.max);
}
public void diff(float start, float end) {
add(end - start);
}
public float getMin() {
return min;
}
public float getMax() {
return max;
}
public float getTotal() {
return total;
}
public float getAvg(float count) {
return count == 0 ? 0 : total / count;
}
}
|
total += value;
min = Math.min(min, value);
max = Math.max(max, value);
| 244
| 33
| 277
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/MinMaxAvgInt.java
|
MinMaxAvgInt
|
add
|
class MinMaxAvgInt {
private int min = Integer.MAX_VALUE;
private int max = Integer.MIN_VALUE;
private int total = 0;
public MinMaxAvgInt() {
}
public void add(int value) {
total += value;
min = Math.min(min, value);
max = Math.max(max, value);
}
public void add(MinMaxAvgInt other) {<FILL_FUNCTION_BODY>}
public void diff(int start, int end) {
add(end - start);
}
public int getMin() {
return min;
}
public int getMax() {
return max;
}
public int getTotal() {
return total;
}
public int getAvg(int count) {
return count == 0 ? 0 : total / count;
}
}
|
total += other.total;
min = Math.min(min, other.min);
max = Math.max(max, other.max);
| 233
| 39
| 272
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/MinMaxAvgLong.java
|
MinMaxAvgLong
|
add
|
class MinMaxAvgLong {
private long min = Long.MAX_VALUE;
private long max = Long.MIN_VALUE;
private long total = 0;
public MinMaxAvgLong() {
}
public void add(long value) {<FILL_FUNCTION_BODY>}
public void add(MinMaxAvgLong other) {
total += other.total;
min = Math.min(min, other.min);
max = Math.max(max, other.max);
}
public void diff(long start, long end) {
add(end - start);
}
public long getMin() {
return min;
}
public long getMax() {
return max;
}
public long getTotal() {
return total;
}
public long getAvg(long count) {
return count == 0 ? 0 : total / count;
}
}
|
total += value;
min = Math.min(min, value);
max = Math.max(max, value);
| 239
| 33
| 272
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/Pair.java
|
Pair
|
toString
|
class Pair<K, V> implements Paired<K, V> {
public static <K1, V1> Pair<K1, V1> of(K1 first, V1 second) {
return new Pair<>(first, second);
}
final private K first;
final private V second;
public Pair(K first, V second) {
this.first = first;
this.second = second;
}
@Override
public K getFirst() {
return first;
}
@Override
public V getSecond() {
return second;
}
@Override
public K getKey() {
return first;
}
@Override
public V getValue() {
return second;
}
@Override
public V setValue(V value) {
throw new IllegalStateException("setValue not supported");
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
if (!(o instanceof Map.Entry<?, ?>)) return false;
Map.Entry<?, ?> pair = (Map.Entry<?, ?>) o;
if (!Objects.equals(first, pair.getKey())) return false;
return Objects.equals(second, pair.getValue());
}
@Override
public int hashCode() {
int result = first != null ? first.hashCode() : 0;
result = 31 * result + (second != null ? second.hashCode() : 0);
return result;
}
}
|
StringBuilder out = new StringBuilder();
out.append('(');
if (first == null) out.append("null");
else out.append(first);
out.append(", ");
if (second == null) out.append("null");
else out.append(second);
out.append(')');
return out.toString();
| 433
| 94
| 527
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-misc/src/main/java/com/vladsch/flexmark/util/misc/TemplateUtil.java
|
MappedResolver
|
resolveRefs
|
class MappedResolver implements Resolver {
final protected Map<String, String> resolved;
public MappedResolver(Map<String, String> map) {
resolved = map;
}
public MappedResolver() {
this(new HashMap<>());
}
public MappedResolver set(String name, String value) {
resolved.put(name, value);
return this;
}
public Map<String, String> getMMap() {
return resolved;
}
@Override
public String resolve(String[] groups) {
return groups.length > 2 ? null : resolved.get(groups[1]);
}
}
public interface Resolver {
String resolve(String[] groups);
}
public static String resolveRefs(CharSequence text, Pattern pattern, Resolver resolver) {<FILL_FUNCTION_BODY>
|
if (text == null) return "";
Matcher matcher = pattern.matcher(text);
if (matcher.find()) {
StringBuffer sb = new StringBuffer();
do {
String[] groups = new String[matcher.groupCount() + 1];
for (int i = 0; i < groups.length; i++) {
groups[i] = matcher.group(i);
}
String resolved = resolver.resolve(groups);
matcher.appendReplacement(sb, resolved == null ? "" : resolved.replace("\\", "\\\\").replace("$", "\\$"));
} while (matcher.find());
matcher.appendTail(sb);
return sb.toString();
}
return text.toString();
| 221
| 195
| 416
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-options/src/main/java/com/vladsch/flexmark/util/options/BooleanOptionParser.java
|
BooleanOptionParser
|
parseOption
|
class BooleanOptionParser<T> implements OptionParser<T> {
final public static String OPTION_0_PARAMETERS_1_IGNORED = "Option {0} does not have any parameters. {1} was ignored";
final public static String KEY_OPTION_0_PARAMETERS_1_IGNORED = "options.parser.boolean-option.ignored";
final private String optionName;
public BooleanOptionParser(String optionName) {
this.optionName = optionName;
}
abstract protected T setOptions(T options);
abstract protected boolean isOptionSet(T options);
@Override
public String getOptionName() {
return optionName;
}
@Override
public Pair<T, List<ParsedOption<T>>> parseOption(BasedSequence optionText, T options, MessageProvider provider) {<FILL_FUNCTION_BODY>}
@Override
public String getOptionText(T options, T defaultOptions) {
return isOptionSet(options) && (defaultOptions == null || !isOptionSet(defaultOptions)) ? optionName : "";
}
}
|
if (optionText.isEmpty()) {
return new Pair<>(setOptions(options), Collections.singletonList(new ParsedOption<>(optionText, this, ParsedOptionStatus.VALID)));
} else {
if (provider == null) provider = MessageProvider.DEFAULT;
String message = provider.message(KEY_OPTION_0_PARAMETERS_1_IGNORED, OPTION_0_PARAMETERS_1_IGNORED, optionName, optionText);
return new Pair<>(setOptions(options), Collections.singletonList(new ParsedOption<>(optionText, this, ParsedOptionStatus.IGNORED, Collections.singletonList(new ParserMessage(optionText, ParsedOptionStatus.IGNORED, message)))));
}
| 275
| 194
| 469
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-options/src/main/java/com/vladsch/flexmark/util/options/OptionsParser.java
|
OptionsParser
|
parseOption
|
class OptionsParser<T> implements OptionParser<T> {
final public static String OPTION_0_IS_AMBIGUOUS = "Option {0} matches: ";
final public static String KEY_OPTION_0_IS_AMBIGUOUS = "options.parser.option.ambiguous";
final public static String OPTION_0_DOES_NOT_MATCH = "Option {0} does not match any of: ";
final public static String KEY_OPTION_0_DOES_NOT_MATCH = "options.parser.option.unknown";
final private String optionName;
final private OptionParser<T>[] parseableOptions;
final private String optionDelimiter;
final private String optionValueDelimiter;
public OptionsParser(String optionName, OptionParser<T>[] parseableOptions, char optionDelimiter, char optionValueDelimiter) {
this.optionName = optionName;
this.parseableOptions = parseableOptions;
this.optionDelimiter = Character.toString(optionDelimiter);
this.optionValueDelimiter = Character.toString(optionValueDelimiter);
}
@Override
public String getOptionName() {
return optionName;
}
@Override
public Pair<T, List<ParsedOption<T>>> parseOption(BasedSequence optionsText, T options, MessageProvider provider) {<FILL_FUNCTION_BODY>}
public void appendOptionNames(DelimitedBuilder out) {
for (OptionParser<T> parsableOption : parseableOptions) {
out.append(parsableOption.getOptionName()).mark();
}
}
@Override
public String getOptionText(T options, T defaultOptions) {
DelimitedBuilder out = new DelimitedBuilder(String.valueOf(optionDelimiter));
for (OptionParser<T> parsableOption : parseableOptions) {
String text = parsableOption.getOptionText(options, defaultOptions).trim();
if (!text.isEmpty()) out.append(text).mark();
}
return out.toString();
}
}
|
BasedSequence[] optionsList = optionsText.split(optionDelimiter, 0, BasedSequence.SPLIT_TRIM_SKIP_EMPTY, null);
T result = options;
if (provider == null) provider = MessageProvider.DEFAULT;
List<ParsedOption<T>> parsedOptions = new ArrayList<>(optionsList.length);
for (BasedSequence optionText : optionsList) {
OptionParser<T> matched = null;
DelimitedBuilder message = null;
BasedSequence[] optionList = optionText.split(optionValueDelimiter, 2, BasedSequence.SPLIT_SKIP_EMPTY, null);
if (optionList.length == 0) continue;
BasedSequence optionName = optionList[0];
BasedSequence optionValue = optionList.length > 1 ? optionList[1] : optionName.subSequence(optionName.length(), optionName.length());
for (OptionParser<T> optionParser : parseableOptions) {
if (optionParser.getOptionName().equals(optionName.toString())) {
matched = optionParser;
message = null;
break;
}
if (optionParser.getOptionName().startsWith(optionName.toString())) {
if (matched == null) {
matched = optionParser;
} else {
if (message == null) {
message = new DelimitedBuilder(", ");
message.append(provider.message(KEY_OPTION_0_IS_AMBIGUOUS, OPTION_0_IS_AMBIGUOUS, optionName));
message.append(matched.getOptionName()).mark();
}
message.append(optionParser.getOptionName()).mark();
}
}
}
// have our match
if (matched != null) {
if (message == null) {
Pair<T, List<ParsedOption<T>>> pair = matched.parseOption(optionValue, result, provider);
result = pair.getFirst();
parsedOptions.add(new ParsedOption<>(optionText, this, ParsedOptionStatus.VALID, null, pair.getSecond()));
} else {
parsedOptions.add(new ParsedOption<>(optionText, this, ParsedOptionStatus.ERROR, new ParserMessage(optionName, ParsedOptionStatus.ERROR, message.toString())));
}
} else {
message = new DelimitedBuilder(", ");
message.append(provider.message(KEY_OPTION_0_DOES_NOT_MATCH, OPTION_0_DOES_NOT_MATCH, optionName));
appendOptionNames(message);
parsedOptions.add(new ParsedOption<>(optionText, this, ParsedOptionStatus.ERROR, new ParserMessage(optionName, ParsedOptionStatus.ERROR, message.toString())));
}
}
return new Pair<>(result, parsedOptions);
| 527
| 720
| 1,247
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-options/src/main/java/com/vladsch/flexmark/util/options/ParserParams.java
|
ParserParams
|
add
|
class ParserParams {
public List<ParserMessage> messages = null;
public boolean skip = false;
public ParsedOptionStatus status = ParsedOptionStatus.VALID;
public ParserParams add(ParserMessage message) {<FILL_FUNCTION_BODY>}
public ParserParams escalate(ParsedOptionStatus other) {
status = status.escalate(other);
return this;
}
}
|
if (messages == null) messages = new ArrayList<>();
messages.add(message);
escalate(message.getStatus());
return this;
| 109
| 40
| 149
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/CharSubSequence.java
|
CharSubSequence
|
charAt
|
class CharSubSequence extends BasedSequenceImpl {
final private char[] baseChars;
final private CharSubSequence base;
final private int startOffset;
final private int endOffset;
private CharSubSequence(char[] chars, int hash) {
super(hash);
int iMax = chars.length;
base = this;
baseChars = chars;
startOffset = 0;
endOffset = baseChars.length;
}
private CharSubSequence(CharSubSequence baseSeq, int startIndex, int endIndex) {
super(0);
assert startIndex >= 0 && endIndex >= startIndex && endIndex <= baseSeq.baseChars.length : String.format("CharSubSequence must have (startIndex > 0 || endIndex < %d) && endIndex >= startIndex, got startIndex:%d, endIndex: %d", baseSeq.baseChars.length, startIndex, endIndex);
assert (startIndex > 0 || endIndex < baseSeq.baseChars.length) : String.format("CharSubSequence must be proper subsequences [1, %d) got startIndex:%d, endIndex: %d", Math.max(0, baseSeq.baseChars.length - 1), startIndex, endIndex);
base = baseSeq;
baseChars = baseSeq.baseChars;
startOffset = base.startOffset + startIndex;
endOffset = base.startOffset + endIndex;
}
@Override
public int getOptionFlags() {
return 0;
}
@Override
public boolean allOptions(int options) {
return false;
}
@Override
public boolean anyOptions(int options) {
return false;
}
@Override
public <T> T getOption(DataKeyBase<T> dataKey) {
return dataKey.get(null);
}
@Override
public @Nullable DataHolder getOptions() {
return null;
}
@NotNull
@Override
public CharSubSequence getBaseSequence() {
return base;
}
@NotNull
@Override
public char[] getBase() {
return baseChars;
}
public int getStartOffset() {
return startOffset;
}
public int getEndOffset() {
return endOffset;
}
@Override
public int length() {
return endOffset - startOffset;
}
@NotNull
@Override
public Range getSourceRange() {
return Range.of(startOffset, endOffset);
}
@Override
public int getIndexOffset(int index) {
SequenceUtils.validateIndexInclusiveEnd(index, length());
return startOffset + index;
}
@Override
public char charAt(int index) {<FILL_FUNCTION_BODY>}
@NotNull
@Override
public CharSubSequence subSequence(int startIndex, int endIndex) {
SequenceUtils.validateStartEnd(startIndex, endIndex, length());
return base.baseSubSequence(startOffset + startIndex, startOffset + endIndex);
}
@NotNull
@Override
public CharSubSequence baseSubSequence(int startIndex, int endIndex) {
SequenceUtils.validateStartEnd(startIndex, endIndex, baseChars.length);
return startIndex == startOffset && endIndex == endOffset ? this : base != this ? base.baseSubSequence(startIndex, endIndex) : new CharSubSequence(base, startIndex, endIndex);
}
public static CharSubSequence of(CharSequence charSequence) {
return of(charSequence, 0, charSequence.length());
}
public static CharSubSequence of(CharSequence charSequence, int startIndex) {
assert startIndex <= charSequence.length();
return of(charSequence, startIndex, charSequence.length());
}
/**
* @param chars char array
* @param startIndex start index in array
* @param endIndex end index in array
* @return CharSubSequence based sequence of array
* @deprecated NOTE: use BasedSequence.of() for creating based sequences
*/
@Deprecated
public static CharSubSequence of(char[] chars, int startIndex, int endIndex) {
assert startIndex >= 0 && startIndex <= endIndex && endIndex <= chars.length;
char[] useChars = new char[chars.length];
System.arraycopy(chars, 0, useChars, 0, chars.length);
return startIndex == 0 && endIndex == chars.length ? new CharSubSequence(useChars, 0) : new CharSubSequence(useChars, 0).subSequence(startIndex, endIndex);
}
/**
* @param charSequence char sequence
* @param startIndex start index in sequence
* @param endIndex end index in sequence
* @return char based sequence
*/
private static CharSubSequence of(CharSequence charSequence, int startIndex, int endIndex) {
assert startIndex >= 0 && startIndex <= endIndex && endIndex <= charSequence.length();
CharSubSequence charSubSequence;
if (charSequence instanceof CharSubSequence) {
charSubSequence = ((CharSubSequence) charSequence);
} else if (charSequence instanceof String) {
charSubSequence = new CharSubSequence(((String) charSequence).toCharArray(), ((String) charSequence).hashCode());
} else if (charSequence instanceof StringBuilder) {
char[] chars = new char[charSequence.length()];
((StringBuilder) charSequence).getChars(0, charSequence.length(), chars, 0);
charSubSequence = new CharSubSequence(chars, 0);
} else {
charSubSequence = new CharSubSequence(charSequence.toString().toCharArray(), 0);
}
if (startIndex == 0 && endIndex == charSequence.length()) {
return charSubSequence;
} else {
return charSubSequence.subSequence(startIndex, endIndex);
}
}
}
|
SequenceUtils.validateIndex(index, length());
char c = baseChars[index + startOffset];
return c == SequenceUtils.NUL ? SequenceUtils.ENC_NUL : c;
| 1,519
| 53
| 1,572
|
<methods>public void <init>(int) ,public void addSegments(@NotNull IBasedSegmentBuilder<?>) ,public int baseColumnAtEnd() ,public int baseColumnAtIndex(int) ,public int baseColumnAtStart() ,public int baseEndOfLine(int) ,public int baseEndOfLine() ,public int baseEndOfLineAnyEOL(int) ,public int baseEndOfLineAnyEOL() ,public @NotNull Pair<Integer,Integer> baseLineColumnAtEnd() ,public @NotNull Pair<Integer,Integer> baseLineColumnAtIndex(int) ,public @NotNull Pair<Integer,Integer> baseLineColumnAtStart() ,public @NotNull Range baseLineRangeAtEnd() ,public @NotNull Range baseLineRangeAtIndex(int) ,public @NotNull Range baseLineRangeAtStart() ,public int baseStartOfLine(int) ,public int baseStartOfLine() ,public int baseStartOfLineAnyEOL(int) ,public int baseStartOfLineAnyEOL() ,public final @NotNull BasedSequence baseSubSequence(int) ,public @NotNull BasedSequence baseSubSequence(int, int) ,public boolean containsAllOf(@NotNull BasedSequence) ,public boolean containsOnlyIn(@NotNull CharPredicate) ,public boolean containsOnlyNotIn(@NotNull CharPredicate) ,public boolean containsSomeIn(@NotNull CharPredicate) ,public boolean containsSomeNotIn(@NotNull CharPredicate) ,public boolean containsSomeOf(@NotNull BasedSequence) ,public @NotNull BasedSequence [] emptyArray() ,public @NotNull BasedSequence extendByAny(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByAny(@NotNull CharPredicate, int) ,public @NotNull BasedSequence extendByAnyNot(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByAnyNot(@NotNull CharPredicate, int) ,public @NotNull BasedSequence extendByOneOfAny(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByOneOfAnyNot(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToEndOfLine(boolean) ,public final @NotNull BasedSequence extendToEndOfLine() ,public final @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate, boolean) ,public final @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToStartOfLine(boolean) ,public final @NotNull BasedSequence extendToStartOfLine() ,public @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate, boolean) ,public static transient com.vladsch.flexmark.util.sequence.BasedSequence firstNonNull(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public @NotNull SequenceBuilder getBuilder() ,public @NotNull BasedSequence getEmptyPrefix() ,public @NotNull BasedSequence getEmptySuffix() ,public @NotNull SegmentTree getSegmentTree() ,public @NotNull BasedSequence intersect(@NotNull BasedSequence) ,public boolean isBaseCharAt(int, @NotNull CharPredicate) ,public boolean isContinuationOf(@NotNull BasedSequence) ,public boolean isContinuedBy(@NotNull BasedSequence) ,public @NotNull BasedSequence normalizeEOL(@NotNull ReplacedTextMapper) ,public @NotNull BasedSequence normalizeEndWithEOL(@NotNull ReplacedTextMapper) ,public @NotNull BasedSequence nullSequence() ,public @NotNull BasedSequence prefixOf(@NotNull BasedSequence) ,public @NotNull BasedSequence prefixWith(@Nullable CharSequence) ,public final @NotNull BasedSequence prefixWithIndent() ,public @NotNull BasedSequence prefixWithIndent(int) ,public char safeBaseCharAt(int) ,public char safeCharAt(int) ,public @NotNull BasedSequence sequenceOf(@Nullable CharSequence, int, int) ,public @NotNull BasedSequence spliceAtEnd(@NotNull BasedSequence) ,public @NotNull BasedSequence suffixOf(@NotNull BasedSequence) ,public @NotNull BasedSequence toMapped(com.vladsch.flexmark.util.sequence.mappers.CharMapper) ,public @Nullable String toStringOrNull() ,public @NotNull String unescape() ,public @NotNull BasedSequence unescape(@NotNull ReplacedTextMapper) ,public @NotNull String unescapeNoEntities() <variables>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/Html5Entities.java
|
Html5Entities
|
readEntities
|
class Html5Entities {
final private static Map<String, String> NAMED_CHARACTER_REFERENCES = readEntities();
final private static Pattern NUMERIC_PATTERN = Pattern.compile("^&#[Xx]?");
final private static String ENTITY_PATH = "/com/vladsch/flexmark/util/sequence/entities.properties";
public static String entityToString(String input) {
Matcher matcher = NUMERIC_PATTERN.matcher(input);
if (matcher.find()) {
int base = matcher.end() == 2 ? 10 : 16;
try {
int codePoint = Integer.parseInt(input.substring(matcher.end(), input.length() - 1), base);
if (codePoint == 0) {
return "\uFFFD";
}
return new String(Character.toChars(codePoint));
} catch (IllegalArgumentException e) {
return "\uFFFD";
}
} else {
String name = input.substring(1, input.length() - 1);
String s = NAMED_CHARACTER_REFERENCES.get(name);
if (s != null) {
return s;
} else {
return input;
}
}
}
public static BasedSequence entityToSequence(BasedSequence input) {
Matcher matcher = NUMERIC_PATTERN.matcher(input);
BasedSequence baseSeq = input.subSequence(0, 0);
if (matcher.find()) {
int base = matcher.end() == 2 ? 10 : 16;
try {
int codePoint = Integer.parseInt(input.subSequence(matcher.end(), input.length() - 1).toString(), base);
if (codePoint == 0) {
return PrefixedSubSequence.prefixOf("\uFFFD", baseSeq);
}
return PrefixedSubSequence.prefixOf(Arrays.toString(Character.toChars(codePoint)), baseSeq);
} catch (IllegalArgumentException e) {
return PrefixedSubSequence.prefixOf("\uFFFD", baseSeq);
}
} else {
String name = input.subSequence(1, input.length() - 1).toString();
String s = NAMED_CHARACTER_REFERENCES.get(name);
if (s != null) {
return PrefixedSubSequence.prefixOf(s, baseSeq);
} else {
return input;
}
}
}
private static Map<String, String> readEntities() {<FILL_FUNCTION_BODY>}
}
|
Map<String, String> entities = new HashMap<>();
InputStream stream = Html5Entities.class.getResourceAsStream(ENTITY_PATH);
Charset charset = StandardCharsets.UTF_8;
try {
String line;
InputStreamReader streamReader = new InputStreamReader(stream, charset);
BufferedReader bufferedReader = new BufferedReader(streamReader);
while ((line = bufferedReader.readLine()) != null) {
if (line.length() == 0) {
continue;
}
int equal = line.indexOf("=");
String key = line.substring(0, equal);
String value = line.substring(equal + 1);
entities.put(key, value);
}
} catch (IOException e) {
throw new IllegalStateException("Failed reading data for HTML named character references", e);
}
entities.put("NewLine", "\n");
return entities;
| 681
| 237
| 918
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedBasedSequence.java
|
MappedBasedSequence
|
sequenceOf
|
class MappedBasedSequence extends BasedSequenceImpl implements MappedSequence<BasedSequence>, ReplacedBasedSequence {
final private CharMapper mapper;
final private BasedSequence baseSeq;
private MappedBasedSequence(BasedSequence baseSeq, CharMapper mapper) {
super(0);
this.baseSeq = baseSeq;
this.mapper = mapper;
}
@NotNull
@Override
public CharMapper getCharMapper() {
return mapper;
}
@Override
public char charAt(int index) {
return mapper.map(baseSeq.charAt(index));
}
@NotNull
@Override
public BasedSequence getCharSequence() {
return baseSeq;
}
@Override
public int length() {
return baseSeq.length();
}
@Override
public @NotNull BasedSequence toMapped(CharMapper mapper) {
return mapper == CharMapper.IDENTITY ? this : new MappedBasedSequence(baseSeq, this.mapper.andThen(mapper));
}
@Override
public int getOptionFlags() {
return getBaseSequence().getOptionFlags();
}
@Override
public boolean allOptions(int options) {
return getBaseSequence().allOptions(options);
}
@Override
public boolean anyOptions(int options) {
return getBaseSequence().anyOptions(options);
}
@Override
public <T> T getOption(DataKeyBase<T> dataKey) {
return getBaseSequence().getOption(dataKey);
}
@Override
public @Nullable DataHolder getOptions() {
return getBaseSequence().getOptions();
}
@NotNull
@Override
public BasedSequence sequenceOf(@Nullable CharSequence baseSeq, int startIndex, int endIndex) {<FILL_FUNCTION_BODY>}
@NotNull
@Override
public BasedSequence subSequence(int startIndex, int endIndex) {
SequenceUtils.validateStartEnd(startIndex, endIndex, length());
if (startIndex == 0 && endIndex == baseSeq.length()) {
return this;
}
return new MappedBasedSequence(baseSeq.subSequence(startIndex, endIndex), mapper);
}
@NotNull
@Override
public Object getBase() {
return baseSeq.getBase();
}
@NotNull
@Override
public BasedSequence getBaseSequence() {
return baseSeq.getBaseSequence();
}
@Override
public int getStartOffset() {
return baseSeq.getStartOffset();
}
@Override
public int getEndOffset() {
return baseSeq.getEndOffset();
}
@Override
public int getIndexOffset(int index) {
return baseSeq.charAt(index) == charAt(index) ? baseSeq.getIndexOffset(index) : -1;
}
@Override
public void addSegments(@NotNull IBasedSegmentBuilder<?> builder) {
BasedUtils.generateSegments(builder, this);
}
@NotNull
@Override
public Range getSourceRange() {
return baseSeq.getSourceRange();
}
@NotNull
public static BasedSequence mappedOf(@NotNull BasedSequence baseSeq, @NotNull CharMapper mapper) {
return new MappedBasedSequence(baseSeq, mapper);
}
}
|
if (baseSeq instanceof MappedBasedSequence) {
return startIndex == 0 && endIndex == baseSeq.length() ? (BasedSequence) baseSeq : ((BasedSequence) baseSeq).subSequence(startIndex, endIndex).toMapped(mapper);
} else return new MappedBasedSequence(this.baseSeq.sequenceOf(baseSeq, startIndex, endIndex), mapper);
| 872
| 100
| 972
|
<methods>public void <init>(int) ,public void addSegments(@NotNull IBasedSegmentBuilder<?>) ,public int baseColumnAtEnd() ,public int baseColumnAtIndex(int) ,public int baseColumnAtStart() ,public int baseEndOfLine(int) ,public int baseEndOfLine() ,public int baseEndOfLineAnyEOL(int) ,public int baseEndOfLineAnyEOL() ,public @NotNull Pair<Integer,Integer> baseLineColumnAtEnd() ,public @NotNull Pair<Integer,Integer> baseLineColumnAtIndex(int) ,public @NotNull Pair<Integer,Integer> baseLineColumnAtStart() ,public @NotNull Range baseLineRangeAtEnd() ,public @NotNull Range baseLineRangeAtIndex(int) ,public @NotNull Range baseLineRangeAtStart() ,public int baseStartOfLine(int) ,public int baseStartOfLine() ,public int baseStartOfLineAnyEOL(int) ,public int baseStartOfLineAnyEOL() ,public final @NotNull BasedSequence baseSubSequence(int) ,public @NotNull BasedSequence baseSubSequence(int, int) ,public boolean containsAllOf(@NotNull BasedSequence) ,public boolean containsOnlyIn(@NotNull CharPredicate) ,public boolean containsOnlyNotIn(@NotNull CharPredicate) ,public boolean containsSomeIn(@NotNull CharPredicate) ,public boolean containsSomeNotIn(@NotNull CharPredicate) ,public boolean containsSomeOf(@NotNull BasedSequence) ,public @NotNull BasedSequence [] emptyArray() ,public @NotNull BasedSequence extendByAny(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByAny(@NotNull CharPredicate, int) ,public @NotNull BasedSequence extendByAnyNot(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByAnyNot(@NotNull CharPredicate, int) ,public @NotNull BasedSequence extendByOneOfAny(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByOneOfAnyNot(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToEndOfLine(boolean) ,public final @NotNull BasedSequence extendToEndOfLine() ,public final @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate, boolean) ,public final @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToStartOfLine(boolean) ,public final @NotNull BasedSequence extendToStartOfLine() ,public @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate, boolean) ,public static transient com.vladsch.flexmark.util.sequence.BasedSequence firstNonNull(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public @NotNull SequenceBuilder getBuilder() ,public @NotNull BasedSequence getEmptyPrefix() ,public @NotNull BasedSequence getEmptySuffix() ,public @NotNull SegmentTree getSegmentTree() ,public @NotNull BasedSequence intersect(@NotNull BasedSequence) ,public boolean isBaseCharAt(int, @NotNull CharPredicate) ,public boolean isContinuationOf(@NotNull BasedSequence) ,public boolean isContinuedBy(@NotNull BasedSequence) ,public @NotNull BasedSequence normalizeEOL(@NotNull ReplacedTextMapper) ,public @NotNull BasedSequence normalizeEndWithEOL(@NotNull ReplacedTextMapper) ,public @NotNull BasedSequence nullSequence() ,public @NotNull BasedSequence prefixOf(@NotNull BasedSequence) ,public @NotNull BasedSequence prefixWith(@Nullable CharSequence) ,public final @NotNull BasedSequence prefixWithIndent() ,public @NotNull BasedSequence prefixWithIndent(int) ,public char safeBaseCharAt(int) ,public char safeCharAt(int) ,public @NotNull BasedSequence sequenceOf(@Nullable CharSequence, int, int) ,public @NotNull BasedSequence spliceAtEnd(@NotNull BasedSequence) ,public @NotNull BasedSequence suffixOf(@NotNull BasedSequence) ,public @NotNull BasedSequence toMapped(com.vladsch.flexmark.util.sequence.mappers.CharMapper) ,public @Nullable String toStringOrNull() ,public @NotNull String unescape() ,public @NotNull BasedSequence unescape(@NotNull ReplacedTextMapper) ,public @NotNull String unescapeNoEntities() <variables>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/MappedRichSequence.java
|
MappedRichSequence
|
toMapped
|
class MappedRichSequence extends IRichSequenceBase<RichSequence> implements RichSequence, MappedSequence<RichSequence> {
final private CharMapper mapper;
final private RichSequence base;
private MappedRichSequence(CharMapper mapper, RichSequence baseSeq) {
super(0);
this.base = baseSeq;
this.mapper = mapper;
}
@NotNull
@Override
public CharMapper getCharMapper() {
return mapper;
}
@NotNull
@Override
public RichSequence getCharSequence() {
return base;
}
@Override
public char charAt(int index) {
return mapper.map(base.charAt(index));
}
public RichSequence getBaseSequence() {
return base;
}
@Override
public int length() {
return base.length();
}
@NotNull
@Override
public RichSequence[] emptyArray() {
return base.emptyArray();
}
@NotNull
@Override
public RichSequence nullSequence() {
return base.nullSequence();
}
@NotNull
@Override
public RichSequence sequenceOf(@Nullable CharSequence baseSeq, int startIndex, int endIndex) {
if (baseSeq instanceof MappedRichSequence) {
return startIndex == 0 && endIndex == baseSeq.length() ? (RichSequence) baseSeq : ((RichSequence) baseSeq).subSequence(startIndex, endIndex).toMapped(mapper);
} else return new MappedRichSequence(mapper, base.sequenceOf(baseSeq, startIndex, endIndex));
}
@Override
public <B extends ISequenceBuilder<B, RichSequence>> @NotNull B getBuilder() {
//noinspection unchecked
return (B) RichSequenceBuilder.emptyBuilder();
}
@NotNull
@Override
public RichSequence toMapped(CharMapper mapper) {<FILL_FUNCTION_BODY>}
@NotNull
@Override
public RichSequence subSequence(int startIndex, int endIndex) {
RichSequence baseSequence = base.subSequence(startIndex, endIndex);
return baseSequence == base ? this : new MappedRichSequence(mapper, baseSequence);
}
public static RichSequence mappedOf(CharMapper mapper, RichSequence baseSeq) {
return mappedOf(mapper, baseSeq, 0, baseSeq.length());
}
public static RichSequence mappedOf(CharMapper mapper, RichSequence baseSeq, int startIndex) {
return mappedOf(mapper, baseSeq, startIndex, baseSeq.length());
}
public static RichSequence mappedOf(CharMapper mapper, RichSequence baseSeq, int startIndex, int endIndex) {
if (baseSeq instanceof MappedRichSequence) return startIndex == 0 && endIndex == baseSeq.length() ? baseSeq.toMapped(mapper) : baseSeq.subSequence(startIndex, endIndex).toMapped(mapper);
else return new MappedRichSequence(mapper, baseSeq.subSequence(startIndex, endIndex));
}
}
|
return mapper == CharMapper.IDENTITY ? this : new MappedRichSequence(this.mapper.andThen(mapper), base);
| 789
| 36
| 825
|
<methods>public void <init>(int) ,public final transient @NotNull RichSequence append(java.lang.CharSequence[]) ,public final @NotNull RichSequence append(Iterable<? extends java.lang.CharSequence>) ,public final @NotNull RichSequence appendEOL() ,public final transient @NotNull RichSequence appendRangesTo(@NotNull StringBuilder, @Nullable CharMapper, com.vladsch.flexmark.util.sequence.Range[]) ,public final transient @NotNull RichSequence appendRangesTo(@NotNull StringBuilder, com.vladsch.flexmark.util.sequence.Range[]) ,public final @NotNull RichSequence appendRangesTo(@NotNull StringBuilder, Iterable<? extends com.vladsch.flexmark.util.sequence.Range>) ,public final @NotNull RichSequence appendRangesTo(@NotNull StringBuilder, @Nullable CharMapper, Iterable<? extends com.vladsch.flexmark.util.sequence.Range>) ,public final @NotNull RichSequence appendSpace() ,public final @NotNull RichSequence appendSpaces(int) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, @Nullable CharMapper) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, @Nullable CharMapper, int) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, int) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, int, int) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, @Nullable CharMapper, int, int) ,public final @NotNull List<Range> blankLinesRemovedRanges() ,public final @NotNull List<Range> blankLinesRemovedRanges(int) ,public final @NotNull List<Range> blankLinesRemovedRanges(int, int) ,public final @NotNull List<Range> blankLinesRemovedRanges(@NotNull CharPredicate, int, int) ,public final int columnAtIndex(int) ,public int compareTo(@NotNull CharSequence) ,public final int countLeading(@NotNull CharPredicate) ,public final int countLeading(@NotNull CharPredicate, int) ,public final int countLeading(@NotNull CharPredicate, int, int) ,public final int countLeadingColumns(int, @NotNull CharPredicate) ,public final int countLeadingNot(@NotNull CharPredicate) ,public final int countLeadingNot(@NotNull CharPredicate, int) ,public final int countLeadingNot(@NotNull CharPredicate, int, int) ,public final int countLeadingNotSpace() ,public final int countLeadingNotSpace(int) ,public final int countLeadingNotSpace(int, int) ,public final int countLeadingNotSpaceTab() ,public final int countLeadingNotSpaceTab(int) ,public final int countLeadingNotSpaceTab(int, int) ,public final int countLeadingNotWhitespace() ,public final int countLeadingNotWhitespace(int) ,public final int countLeadingNotWhitespace(int, int) ,public final int countLeadingSpace() ,public final int countLeadingSpace(int) ,public final int countLeadingSpace(int, int) ,public final int countLeadingSpaceTab() ,public final int countLeadingSpaceTab(int) ,public final int countLeadingSpaceTab(int, int) ,public final int countLeadingWhitespace() ,public final int countLeadingWhitespace(int) ,public final int countLeadingWhitespace(int, int) ,public final int countOfAny(@NotNull CharPredicate, int) ,public final int countOfAny(@NotNull CharPredicate) ,public final int countOfAny(@NotNull CharPredicate, int, int) ,public final int countOfAnyNot(@NotNull CharPredicate, int) ,public final int countOfAnyNot(@NotNull CharPredicate) ,public final int countOfAnyNot(@NotNull CharPredicate, int, int) ,public final int countOfNotSpaceTab() ,public final int countOfNotWhitespace() ,public final int countOfSpaceTab() ,public final int countOfWhitespace() ,public final int countTrailing(@NotNull CharPredicate) ,public final int countTrailing(@NotNull CharPredicate, int) ,public final int countTrailing(@NotNull CharPredicate, int, int) ,public final int countTrailingNot(@NotNull CharPredicate) ,public final int countTrailingNot(@NotNull CharPredicate, int) ,public final int countTrailingNot(@NotNull CharPredicate, int, int) ,public final int countTrailingNotSpace() ,public final int countTrailingNotSpace(int) ,public final int countTrailingNotSpace(int, int) ,public final int countTrailingNotSpaceTab() ,public final int countTrailingNotSpaceTab(int) ,public final int countTrailingNotSpaceTab(int, int) ,public final int countTrailingNotWhitespace() ,public final int countTrailingNotWhitespace(int) ,public final int countTrailingNotWhitespace(int, int) ,public final int countTrailingSpace() ,public final int countTrailingSpace(int) ,public final int countTrailingSpace(int, int) ,public final int countTrailingSpaceTab() ,public final int countTrailingSpaceTab(int) ,public final int countTrailingSpaceTab(int, int) ,public final int countTrailingWhitespace() ,public final int countTrailingWhitespace(int) ,public final int countTrailingWhitespace(int, int) ,public @NotNull RichSequence delete(int, int) ,public final char endCharAt(int) ,public final int endOfDelimitedBy(@NotNull CharSequence, int) ,public final int endOfDelimitedByAny(@NotNull CharPredicate, int) ,public final int endOfDelimitedByAnyNot(@NotNull CharPredicate, int) ,public final int endOfLine(int) ,public final int endOfLineAnyEOL(int) ,public final @NotNull RichSequence endSequence(int, int) ,public final @NotNull RichSequence endSequence(int) ,public final boolean endsWith(@NotNull CharSequence) ,public final boolean endsWith(@NotNull CharSequence, boolean) ,public final boolean endsWith(@NotNull CharPredicate) ,public final boolean endsWithAnyEOL() ,public final boolean endsWithEOL() ,public final boolean endsWithIgnoreCase(@NotNull CharSequence) ,public final boolean endsWithSpace() ,public final boolean endsWithSpaceTab() ,public final boolean endsWithWhitespace() ,public final int eolEndLength() ,public final int eolEndLength(int) ,public final @NotNull Range eolEndRange(int) ,public final int eolStartLength(int) ,public @NotNull Range eolStartRange(int) ,public final boolean equals(java.lang.Object) ,public final boolean equals(@Nullable Object, boolean) ,public final boolean equalsIgnoreCase(@Nullable Object) ,public final transient @NotNull RichSequence extractRanges(com.vladsch.flexmark.util.sequence.Range[]) ,public final @NotNull RichSequence extractRanges(Iterable<com.vladsch.flexmark.util.sequence.Range>) ,public final char firstChar() ,public final int hashCode() ,public final @NotNull RichSequence ifNull(@NotNull RichSequence) ,public final @NotNull RichSequence ifNullEmptyAfter(@NotNull RichSequence) ,public final @NotNull RichSequence ifNullEmptyBefore(@NotNull RichSequence) ,public final int indexOf(@NotNull CharSequence) ,public final int indexOf(@NotNull CharSequence, int) ,public final int indexOf(@NotNull CharSequence, int, int) ,public final int indexOf(char) ,public final int indexOf(char, int) ,public final int indexOf(char, int, int) ,public final @NotNull int [] indexOfAll(@NotNull CharSequence) ,public final int indexOfAny(@NotNull CharPredicate) ,public final int indexOfAny(@NotNull CharPredicate, int) ,public final int indexOfAny(@NotNull CharPredicate, int, int) ,public final int indexOfAnyNot(@NotNull CharPredicate) ,public final int indexOfAnyNot(@NotNull CharPredicate, int) ,public final int indexOfAnyNot(@NotNull CharPredicate, int, int) ,public final int indexOfNot(char) ,public final int indexOfNot(char, int) ,public final int indexOfNot(char, int, int) ,public @NotNull RichSequence insert(int, @NotNull CharSequence) ,public final boolean isBlank() ,public boolean isCharAt(int, @NotNull CharPredicate) ,public final boolean isEmpty() ,public boolean isIn(@NotNull String []) ,public boolean isIn(@NotNull Collection<? extends CharSequence>) ,public final boolean isNotBlank() ,public final boolean isNotEmpty() ,public final boolean isNotNull() ,public final boolean isNull() ,public final char lastChar() ,public final int lastIndexOf(char) ,public final int lastIndexOf(char, int) ,public final int lastIndexOf(@NotNull CharSequence) ,public final int lastIndexOf(@NotNull CharSequence, int) ,public final int lastIndexOf(@NotNull CharSequence, int, int) ,public final int lastIndexOf(char, int, int) ,public final int lastIndexOfAny(@NotNull CharPredicate, int) ,public final int lastIndexOfAny(@NotNull CharPredicate) ,public final int lastIndexOfAny(@NotNull CharPredicate, int, int) ,public final int lastIndexOfAnyNot(@NotNull CharPredicate) ,public final int lastIndexOfAnyNot(@NotNull CharPredicate, int) ,public final int lastIndexOfAnyNot(@NotNull CharPredicate, int, int) ,public final int lastIndexOfNot(char) ,public final int lastIndexOfNot(char, int) ,public final int lastIndexOfNot(char, int, int) ,public final @NotNull Range leadingBlankLinesRange() ,public final @NotNull Range leadingBlankLinesRange(int) ,public final @NotNull Range leadingBlankLinesRange(int, int) ,public final @NotNull Range leadingBlankLinesRange(@NotNull CharPredicate, int, int) ,public final @NotNull RichSequence lineAt(int) ,public final @NotNull RichSequence lineAtAnyEOL(int) ,public final @NotNull Pair<Integer,Integer> lineColumnAtIndex(int) ,public final @NotNull Range lineRangeAt(int) ,public final @NotNull Range lineRangeAtAnyEOL(int) ,public final boolean matchChars(@NotNull CharSequence, int, boolean) ,public final boolean matchChars(@NotNull CharSequence, int) ,public final boolean matchChars(@NotNull CharSequence, boolean) ,public final boolean matchChars(@NotNull CharSequence) ,public final boolean matchCharsIgnoreCase(@NotNull CharSequence, int) ,public final boolean matchCharsIgnoreCase(@NotNull CharSequence) ,public final boolean matchCharsReversed(@NotNull CharSequence, int, boolean) ,public final boolean matchCharsReversed(@NotNull CharSequence, int) ,public final boolean matchCharsReversedIgnoreCase(@NotNull CharSequence, int) ,public final int matchedCharCount(@NotNull CharSequence, int, int, boolean) ,public final int matchedCharCount(@NotNull CharSequence, int, boolean) ,public final int matchedCharCount(@NotNull CharSequence, int, int) ,public final int matchedCharCount(@NotNull CharSequence, int) ,public final int matchedCharCount(@NotNull CharSequence, int, int, boolean, boolean) ,public final int matchedCharCountIgnoreCase(@NotNull CharSequence, int) ,public final int matchedCharCountIgnoreCase(@NotNull CharSequence, int, int) ,public final int matchedCharCountReversed(@NotNull CharSequence, int, int) ,public final int matchedCharCountReversed(@NotNull CharSequence, int, boolean) ,public final int matchedCharCountReversed(@NotNull CharSequence, int) ,public final int matchedCharCountReversed(@NotNull CharSequence, int, int, boolean) ,public final int matchedCharCountReversedIgnoreCase(@NotNull CharSequence, int, int) ,public final int matchedCharCountReversedIgnoreCase(@NotNull CharSequence, int) ,public final boolean matches(@NotNull CharSequence, boolean) ,public final boolean matches(@NotNull CharSequence) ,public final boolean matchesIgnoreCase(@NotNull CharSequence) ,public final char midCharAt(int) ,public final @NotNull RichSequence midSequence(int, int) ,public final @NotNull RichSequence midSequence(int) ,public final @NotNull String normalizeEOL() ,public final @NotNull String normalizeEndWithEOL() ,public final @NotNull RichSequence nullIf(boolean) ,public final transient @NotNull RichSequence nullIf(@NotNull Predicate<? super CharSequence>, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIf(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIf(@NotNull BiPredicate<? super RichSequence,? super CharSequence>, java.lang.CharSequence[]) ,public final @NotNull RichSequence nullIfBlank() ,public final @NotNull RichSequence nullIfEmpty() ,public final transient @NotNull RichSequence nullIfEndsWith(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfEndsWith(boolean, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfEndsWithIgnoreCase(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNot(@NotNull BiPredicate<? super RichSequence,? super CharSequence>, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNot(@NotNull Predicate<? super CharSequence>, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNot(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotEndsWith(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotEndsWith(boolean, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotEndsWithIgnoreCase(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotStartsWith(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotStartsWith(boolean, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotStartsWithIgnoreCase(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfStartsWith(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfStartsWith(boolean, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfStartsWithIgnoreCase(java.lang.CharSequence[]) ,public @NotNull RichSequence padEnd(int, char) ,public @NotNull RichSequence padEnd(int) ,public @NotNull RichSequence padStart(int, char) ,public @NotNull RichSequence padStart(int) ,public final @NotNull RichSequence padding(int, char) ,public final @NotNull RichSequence padding(int) ,public final @NotNull RichSequence prefixOnceWith(@Nullable CharSequence) ,public final @NotNull RichSequence prefixOnceWithEOL() ,public final @NotNull RichSequence prefixOnceWithSpace() ,public @NotNull RichSequence prefixWith(@Nullable CharSequence) ,public final @NotNull RichSequence prefixWithEOL() ,public final @NotNull RichSequence prefixWithSpace() ,public final @NotNull RichSequence prefixWithSpaces(int) ,public final @NotNull RichSequence removePrefix(@NotNull CharSequence) ,public final @NotNull RichSequence removePrefix(@NotNull CharSequence, boolean) ,public final @NotNull RichSequence removePrefixIgnoreCase(@NotNull CharSequence) ,public final @NotNull RichSequence removeProperPrefix(@NotNull CharSequence) ,public final @NotNull RichSequence removeProperPrefix(@NotNull CharSequence, boolean) ,public final @NotNull RichSequence removeProperPrefixIgnoreCase(@NotNull CharSequence) ,public final @NotNull RichSequence removeProperSuffix(@NotNull CharSequence) ,public final @NotNull RichSequence removeProperSuffix(@NotNull CharSequence, boolean) ,public final @NotNull RichSequence removeProperSuffixIgnoreCase(@NotNull CharSequence) ,public final @NotNull RichSequence removeSuffix(@NotNull CharSequence) ,public final @NotNull RichSequence removeSuffix(@NotNull CharSequence, boolean) ,public final @NotNull RichSequence removeSuffixIgnoreCase(@NotNull CharSequence) ,public final @NotNull RichSequence replace(int, int, @NotNull CharSequence) ,public final @NotNull RichSequence replace(@NotNull CharSequence, @NotNull CharSequence) ,public char safeCharAt(int) ,public @NotNull RichSequence safeSubSequence(int, int) ,public @NotNull RichSequence safeSubSequence(int) ,public final @NotNull RichSequence sequenceOf(@Nullable CharSequence) ,public final @NotNull RichSequence sequenceOf(@Nullable CharSequence, int) ,public final @NotNull RichSequence [] split(@NotNull CharSequence, boolean, @Nullable CharPredicate) ,public final @NotNull RichSequence [] split(@NotNull CharSequence) ,public final @NotNull RichSequence [] split(@NotNull CharSequence, int, boolean, @Nullable CharPredicate) ,public final @NotNull RichSequence [] split(@NotNull CharSequence, int, int) ,public final @NotNull RichSequence [] split(@NotNull CharSequence, int, int, @Nullable CharPredicate) ,public final @NotNull RichSequence [] splitEOL() ,public final @NotNull RichSequence [] splitEOL(boolean) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence, int, boolean, @Nullable CharPredicate) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence, int, int) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence, boolean, @Nullable CharPredicate) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence, int, int, @Nullable CharPredicate) ,public final @NotNull List<RichSequence> splitListEOL() ,public final @NotNull List<RichSequence> splitListEOL(boolean) ,public final @NotNull List<RichSequence> splitListEOL(boolean, @Nullable CharPredicate) ,public final int startOfDelimitedBy(@NotNull CharSequence, int) ,public final int startOfDelimitedByAny(@NotNull CharPredicate, int) ,public final int startOfDelimitedByAnyNot(@NotNull CharPredicate, int) ,public final int startOfLine(int) ,public final int startOfLineAnyEOL(int) ,public final boolean startsWith(@NotNull CharSequence) ,public final boolean startsWith(@NotNull CharSequence, boolean) ,public final boolean startsWith(@NotNull CharPredicate) ,public final boolean startsWithAnyEOL() ,public final boolean startsWithEOL() ,public final boolean startsWithIgnoreCase(@NotNull CharSequence) ,public final boolean startsWithSpace() ,public final boolean startsWithSpaceTab() ,public final boolean startsWithWhitespace() ,public final @NotNull RichSequence subSequence(int) ,public final @NotNull RichSequence subSequence(@NotNull Range) ,public final @NotNull RichSequence subSequenceAfter(@NotNull Range) ,public final @NotNull RichSequence subSequenceBefore(@NotNull Range) ,public final Pair<com.vladsch.flexmark.util.sequence.RichSequence,com.vladsch.flexmark.util.sequence.RichSequence> subSequenceBeforeAfter(com.vladsch.flexmark.util.sequence.Range) ,public final @NotNull RichSequence suffixOnceWith(@Nullable CharSequence) ,public final @NotNull RichSequence suffixOnceWithEOL() ,public final @NotNull RichSequence suffixOnceWithSpace() ,public @NotNull RichSequence suffixWith(@Nullable CharSequence) ,public final @NotNull RichSequence suffixWithEOL() ,public final @NotNull RichSequence suffixWithSpace() ,public final @NotNull RichSequence suffixWithSpaces(int) ,public final @NotNull RichSequence toLowerCase() ,public final @NotNull RichSequence toNbSp() ,public final @NotNull RichSequence toSpc() ,public @NotNull String toString() ,public @Nullable String toStringOrNull() ,public final @NotNull RichSequence toUpperCase() ,public final @NotNull String toVisibleWhitespaceString() ,public final @NotNull Range trailingBlankLinesRange() ,public final @NotNull Range trailingBlankLinesRange(int) ,public final @NotNull Range trailingBlankLinesRange(int, int) ,public final @NotNull Range trailingBlankLinesRange(com.vladsch.flexmark.util.misc.CharPredicate, int, int) ,public final @NotNull RichSequence trim(@NotNull CharPredicate) ,public final @NotNull RichSequence trim(int) ,public final @NotNull RichSequence trim() ,public final @NotNull RichSequence trim(int, @NotNull CharPredicate) ,public final @NotNull RichSequence trimEOL() ,public final @NotNull RichSequence trimEnd(@NotNull CharPredicate) ,public final @NotNull RichSequence trimEnd(int) ,public final @NotNull RichSequence trimEnd() ,public final @NotNull RichSequence trimEnd(int, @NotNull CharPredicate) ,public final @NotNull Range trimEndRange(int, @NotNull CharPredicate) ,public final @NotNull Range trimEndRange(@NotNull CharPredicate) ,public final @NotNull Range trimEndRange(int) ,public final @NotNull Range trimEndRange() ,public final @NotNull RichSequence trimLeadBlankLines() ,public final @NotNull Range trimRange(int, @NotNull CharPredicate) ,public final @NotNull Range trimRange(@NotNull CharPredicate) ,public final @NotNull Range trimRange(int) ,public final @NotNull Range trimRange() ,public final @NotNull RichSequence trimStart(@NotNull CharPredicate) ,public final @NotNull RichSequence trimStart(int) ,public final @NotNull RichSequence trimStart() ,public final @NotNull RichSequence trimStart(int, @NotNull CharPredicate) ,public final @NotNull Range trimStartRange(int, @NotNull CharPredicate) ,public final @NotNull Range trimStartRange(@NotNull CharPredicate) ,public final @NotNull Range trimStartRange(int) ,public final @NotNull Range trimStartRange() ,public final @NotNull RichSequence trimTailBlankLines() ,public @NotNull RichSequence trimToEndOfLine(boolean) ,public @NotNull RichSequence trimToEndOfLine(int) ,public @NotNull RichSequence trimToEndOfLine() ,public @NotNull RichSequence trimToEndOfLine(boolean, int) ,public @NotNull RichSequence trimToEndOfLine(@NotNull CharPredicate, boolean, int) ,public @NotNull RichSequence trimToStartOfLine(boolean) ,public @NotNull RichSequence trimToStartOfLine(int) ,public @NotNull RichSequence trimToStartOfLine() ,public @NotNull RichSequence trimToStartOfLine(boolean, int) ,public @NotNull RichSequence trimToStartOfLine(@NotNull CharPredicate, boolean, int) ,public final @NotNull Pair<RichSequence,RichSequence> trimmed(@NotNull CharPredicate) ,public final @NotNull Pair<RichSequence,RichSequence> trimmed(int) ,public final @NotNull Pair<RichSequence,RichSequence> trimmed() ,public final @NotNull Pair<RichSequence,RichSequence> trimmed(int, @NotNull CharPredicate) ,public final @NotNull RichSequence trimmedEOL() ,public final @NotNull RichSequence trimmedEnd(@NotNull CharPredicate) ,public final @NotNull RichSequence trimmedEnd(int) ,public final @NotNull RichSequence trimmedEnd() ,public final @NotNull RichSequence trimmedEnd(int, @NotNull CharPredicate) ,public final @NotNull RichSequence trimmedStart(@NotNull CharPredicate) ,public final @NotNull RichSequence trimmedStart(int) ,public final @NotNull RichSequence trimmedStart() ,public final @NotNull RichSequence trimmedStart(int, @NotNull CharPredicate) ,public final void validateIndex(int) ,public final void validateIndexInclusiveEnd(int) ,public final void validateStartEnd(int, int) <variables>private int hash
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/PlaceholderReplacer.java
|
PlaceholderReplacer
|
replaceAll
|
class PlaceholderReplacer {
public static <T> void replaceAll(Collection<T> spanList, Function<String, String> mapper, char openPlaceholder, char closePlaceholder, Function<T, String> getter, BiConsumer<T, String> setter) {<FILL_FUNCTION_BODY>}
}
|
if (spanList.isEmpty()) return;
StringBuilder sb = null;
// accumulate text from < to >, because placeholder can be broken up across multiple spans
for (T span : spanList) {
String textValue = getter.apply(span);
int length = textValue.length();
int lastPos = 0;
StringBuilder plainText = null;
while (lastPos < length) {
if (sb == null) {
int pos = textValue.indexOf(openPlaceholder, lastPos);
if (pos == -1) {
// nothing in this one
if (lastPos > 0) {
// had partial text
if (plainText != null) plainText.append(textValue.substring(lastPos));
else setter.accept(span, textValue.substring(lastPos));
}
break;
} else {
sb = new StringBuilder();
if (lastPos < pos) {
// have plain text
if (plainText == null) plainText = new StringBuilder();
plainText.append(textValue.substring(lastPos, pos));
}
lastPos = pos + 1;
if (lastPos >= length && plainText == null) setter.accept(span, "");
}
} else {
int pos = textValue.indexOf(closePlaceholder, lastPos);
if (pos == -1) {
sb.append(textValue.substring(lastPos));
if (plainText == null) setter.accept(span, "");
lastPos = length;
} else {
// part of it is non-plain text
sb.append(textValue.substring(lastPos, pos));
lastPos = pos + 1;
String placeholder = sb.toString();
String result = mapper.apply(placeholder);
sb = null;
if (result == null) {
result = openPlaceholder + placeholder + closePlaceholder;
}
if (plainText == null) plainText = new StringBuilder();
plainText.append(result);
}
}
}
if (plainText != null) {
// have replacement text for the span
setter.accept(span, plainText.toString());
}
}
| 79
| 564
| 643
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/PrefixedSubSequence.java
|
PrefixedSubSequence
|
getIndexOffset
|
class PrefixedSubSequence extends BasedSequenceImpl implements ReplacedBasedSequence {
final private CharSequence prefix;
final private BasedSequence base;
private PrefixedSubSequence(CharSequence prefix, BasedSequence baseSeq, int startIndex, int endIndex) {
super(0);
this.prefix = prefix;
this.base = baseSeq.subSequence(startIndex, endIndex);
}
@NotNull
@Override
public Object getBase() {
return base.getBase();
}
@NotNull
@Override
public BasedSequence getBaseSequence() {
return base.getBaseSequence();
}
@Override
public int getStartOffset() {
return base.getStartOffset();
}
@Override
public int getEndOffset() {
return base.getEndOffset();
}
@NotNull
@Override
public Range getSourceRange() {
return base.getSourceRange();
}
@NotNull
@Override
public BasedSequence baseSubSequence(int startIndex, int endIndex) {
return base.baseSubSequence(startIndex, endIndex);
}
@Override
public int getOptionFlags() {
return getBaseSequence().getOptionFlags();
}
@Override
public boolean allOptions(int options) {
return getBaseSequence().allOptions(options);
}
@Override
public boolean anyOptions(int options) {
return getBaseSequence().anyOptions(options);
}
@Override
public <T> T getOption(DataKeyBase<T> dataKey) {
return getBaseSequence().getOption(dataKey);
}
@Override
public @Nullable DataHolder getOptions() {
return getBaseSequence().getOptions();
}
@Override
public int length() {
return prefix.length() + base.length();
}
@Override
public int getIndexOffset(int index) {<FILL_FUNCTION_BODY>}
@Override
public void addSegments(@NotNull IBasedSegmentBuilder<?> builder) {
if (prefix.length() != 0) {
builder.append(base.getStartOffset(), base.getStartOffset());
builder.append(prefix.toString());
}
base.addSegments(builder);
}
@Override
public char charAt(int index) {
SequenceUtils.validateIndex(index, length());
int prefixLength = prefix.length();
if (index < prefixLength) {
return prefix.charAt(index);
} else {
return base.charAt(index - prefixLength);
}
}
@NotNull
@Override
public BasedSequence subSequence(int startIndex, int endIndex) {
SequenceUtils.validateStartEnd(startIndex, endIndex, length());
int prefixLength = prefix.length();
if (startIndex < prefixLength) {
if (endIndex <= prefixLength) {
// all from prefix
return new PrefixedSubSequence(prefix.subSequence(startIndex, endIndex), base.subSequence(0, 0), 0, 0);
} else {
// some from prefix some from base
return new PrefixedSubSequence(prefix.subSequence(startIndex, prefixLength), base, 0, endIndex - prefixLength);
}
} else {
// all from base
return base.subSequence(startIndex - prefixLength, endIndex - prefixLength);
}
}
@NotNull
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(prefix);
base.appendTo(sb);
return sb.toString();
}
public static PrefixedSubSequence repeatOf(CharSequence prefix, int count, BasedSequence baseSeq) {
return prefixOf(RepeatedSequence.repeatOf(prefix, count).toString(), baseSeq, 0, baseSeq.length());
}
public static PrefixedSubSequence repeatOf(char prefix, int count, BasedSequence baseSeq) {
return prefixOf(RepeatedSequence.repeatOf(prefix, count), baseSeq, 0, baseSeq.length());
}
public static PrefixedSubSequence prefixOf(CharSequence prefix, BasedSequence baseSeq) {
return prefixOf(prefix, baseSeq, 0, baseSeq.length());
}
public static PrefixedSubSequence prefixOf(CharSequence prefix, BasedSequence baseSeq, int startIndex) {
return prefixOf(prefix, baseSeq, startIndex, baseSeq.length());
}
public static PrefixedSubSequence prefixOf(CharSequence prefix, BasedSequence baseSeq, int startIndex, int endIndex) {
return new PrefixedSubSequence(prefix, baseSeq, startIndex, endIndex);
}
@Deprecated
public static PrefixedSubSequence of(CharSequence prefix, BasedSequence baseSeq) {
return prefixOf(prefix, baseSeq);
}
@Deprecated
public static PrefixedSubSequence of(CharSequence prefix, BasedSequence baseSeq, int startIndex) {
return prefixOf(prefix, baseSeq, startIndex);
}
@Deprecated
public static PrefixedSubSequence of(CharSequence prefix, BasedSequence baseSeq, int startIndex, int endIndex) {
return prefixOf(prefix, baseSeq, startIndex, endIndex);
}
}
|
SequenceUtils.validateIndexInclusiveEnd(index, length());
if (index < prefix.length()) {
// NOTE: to allow creation of segmented sequences from modified original base return -1 for all such modified content positions
return -1;
}
return base.getIndexOffset(index - prefix.length());
| 1,345
| 81
| 1,426
|
<methods>public void <init>(int) ,public void addSegments(@NotNull IBasedSegmentBuilder<?>) ,public int baseColumnAtEnd() ,public int baseColumnAtIndex(int) ,public int baseColumnAtStart() ,public int baseEndOfLine(int) ,public int baseEndOfLine() ,public int baseEndOfLineAnyEOL(int) ,public int baseEndOfLineAnyEOL() ,public @NotNull Pair<Integer,Integer> baseLineColumnAtEnd() ,public @NotNull Pair<Integer,Integer> baseLineColumnAtIndex(int) ,public @NotNull Pair<Integer,Integer> baseLineColumnAtStart() ,public @NotNull Range baseLineRangeAtEnd() ,public @NotNull Range baseLineRangeAtIndex(int) ,public @NotNull Range baseLineRangeAtStart() ,public int baseStartOfLine(int) ,public int baseStartOfLine() ,public int baseStartOfLineAnyEOL(int) ,public int baseStartOfLineAnyEOL() ,public final @NotNull BasedSequence baseSubSequence(int) ,public @NotNull BasedSequence baseSubSequence(int, int) ,public boolean containsAllOf(@NotNull BasedSequence) ,public boolean containsOnlyIn(@NotNull CharPredicate) ,public boolean containsOnlyNotIn(@NotNull CharPredicate) ,public boolean containsSomeIn(@NotNull CharPredicate) ,public boolean containsSomeNotIn(@NotNull CharPredicate) ,public boolean containsSomeOf(@NotNull BasedSequence) ,public @NotNull BasedSequence [] emptyArray() ,public @NotNull BasedSequence extendByAny(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByAny(@NotNull CharPredicate, int) ,public @NotNull BasedSequence extendByAnyNot(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByAnyNot(@NotNull CharPredicate, int) ,public @NotNull BasedSequence extendByOneOfAny(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByOneOfAnyNot(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToEndOfLine(boolean) ,public final @NotNull BasedSequence extendToEndOfLine() ,public final @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate, boolean) ,public final @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToStartOfLine(boolean) ,public final @NotNull BasedSequence extendToStartOfLine() ,public @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate, boolean) ,public static transient com.vladsch.flexmark.util.sequence.BasedSequence firstNonNull(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public @NotNull SequenceBuilder getBuilder() ,public @NotNull BasedSequence getEmptyPrefix() ,public @NotNull BasedSequence getEmptySuffix() ,public @NotNull SegmentTree getSegmentTree() ,public @NotNull BasedSequence intersect(@NotNull BasedSequence) ,public boolean isBaseCharAt(int, @NotNull CharPredicate) ,public boolean isContinuationOf(@NotNull BasedSequence) ,public boolean isContinuedBy(@NotNull BasedSequence) ,public @NotNull BasedSequence normalizeEOL(@NotNull ReplacedTextMapper) ,public @NotNull BasedSequence normalizeEndWithEOL(@NotNull ReplacedTextMapper) ,public @NotNull BasedSequence nullSequence() ,public @NotNull BasedSequence prefixOf(@NotNull BasedSequence) ,public @NotNull BasedSequence prefixWith(@Nullable CharSequence) ,public final @NotNull BasedSequence prefixWithIndent() ,public @NotNull BasedSequence prefixWithIndent(int) ,public char safeBaseCharAt(int) ,public char safeCharAt(int) ,public @NotNull BasedSequence sequenceOf(@Nullable CharSequence, int, int) ,public @NotNull BasedSequence spliceAtEnd(@NotNull BasedSequence) ,public @NotNull BasedSequence suffixOf(@NotNull BasedSequence) ,public @NotNull BasedSequence toMapped(com.vladsch.flexmark.util.sequence.mappers.CharMapper) ,public @Nullable String toStringOrNull() ,public @NotNull String unescape() ,public @NotNull BasedSequence unescape(@NotNull ReplacedTextMapper) ,public @NotNull String unescapeNoEntities() <variables>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RepeatedSequence.java
|
RepeatedSequence
|
charAt
|
class RepeatedSequence implements CharSequence {
public static RepeatedSequence NULL = new RepeatedSequence(BasedSequence.NULL, 0, 0);
final private CharSequence chars;
final private int startIndex;
final private int endIndex;
private int hashCode;
private RepeatedSequence(CharSequence chars, int startIndex, int endIndex) {
this.chars = chars;
this.startIndex = startIndex;
this.endIndex = endIndex;
}
@Override
public int length() {
return endIndex - startIndex;
}
@Override
public char charAt(int index) {<FILL_FUNCTION_BODY>}
@Override
public CharSequence subSequence(int startIndex, int endIndex) {
if (startIndex >= 0 && startIndex <= endIndex && endIndex <= this.endIndex - this.startIndex) {
return (startIndex == endIndex) ? NULL : startIndex == this.startIndex && endIndex == this.endIndex ? this : new RepeatedSequence(chars, this.startIndex + startIndex, this.startIndex + endIndex);
}
throw new IllegalArgumentException("subSequence($startIndex, $endIndex) in RepeatedCharSequence('', " + this.startIndex + ", " + this.endIndex + ")");
}
public RepeatedSequence repeat(int count) {
int endIndex = startIndex + (this.endIndex - startIndex) * count;
return startIndex >= this.endIndex ? NULL : this.endIndex == endIndex ? this : new RepeatedSequence(chars, startIndex, endIndex);
}
@Override
public int hashCode() {
int h = hashCode;
if (h == 0 && length() > 0) {
for (int i = 0; i < length(); i++) {
h = 31 * h + charAt(i);
}
hashCode = h;
}
return h;
}
@Override
public boolean equals(Object obj) {
return obj == this || (obj instanceof CharSequence && toString().equals(obj.toString()));
}
@NotNull
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this, 0, length());
return sb.toString();
}
@NotNull
public static CharSequence ofSpaces(int count) {
return new RepeatedSequence(" ", 0, count);
}
@NotNull
public static CharSequence repeatOf(char c, int count) {
return new RepeatedSequence(String.valueOf(c), 0, count);
}
@NotNull
public static CharSequence repeatOf(@NotNull CharSequence chars, int count) {
return new RepeatedSequence(chars, 0, chars.length() * count);
}
@NotNull
public static CharSequence repeatOf(@NotNull CharSequence chars, int startIndex, int endIndex) {
return new RepeatedSequence(chars, startIndex, endIndex);
}
@NotNull
@Deprecated
public static CharSequence of(char c, int count) {
return repeatOf(c, count);
}
@NotNull
@Deprecated
public static CharSequence of(@NotNull CharSequence chars, int count) {
return repeatOf(chars, count);
}
@NotNull
@Deprecated
public static CharSequence of(@NotNull CharSequence chars, int startIndex, int endIndex) {
return repeatOf(chars, startIndex, endIndex);
}
}
|
if (index < 0 || index >= endIndex - startIndex) throw new IndexOutOfBoundsException();
return chars.charAt((startIndex + index) % chars.length());
| 903
| 47
| 950
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/ReplacedTextMapper.java
|
ReplacedTextMapper
|
originalOffset
|
class ReplacedTextMapper {
private ReplacedTextMapper parent;
private BasedSequence original;
private ArrayList<ReplacedTextRegion> regions = new ArrayList<>();
private ArrayList<BasedSequence> replacedSegments = new ArrayList<>();
private int replacedLength = 0;
private BasedSequence replacedSequence = null;
public ReplacedTextMapper(BasedSequence original) {
this.original = original;
this.parent = null;
}
private ReplacedTextMapper(ReplacedTextMapper other) {
this.parent = other.parent;
this.original = other.original;
this.regions = other.regions;
this.replacedSegments = other.replacedSegments;
this.replacedLength = other.replacedLength;
this.replacedSequence = other.getReplacedSequence();
}
public void startNestedReplacement(BasedSequence sequence) {
assert sequence.equals(this.getReplacedSequence());
// create parent from our data and re-initialize
this.parent = new ReplacedTextMapper(this);
this.original = sequence;
this.regions = new ArrayList<>();
this.replacedSegments = new ArrayList<>();
this.replacedLength = 0;
this.replacedSequence = null;
}
public boolean isModified() {
return replacedLength > 0;
}
public boolean isFinalized() {
return replacedSequence != null;
}
private void finalizeMods() {
if (replacedSequence == null) {
replacedSequence = replacedSegments.isEmpty() ? BasedSequence.NULL : SegmentedSequence.create(original, replacedSegments);
}
}
public ReplacedTextMapper getParent() {
return parent;
}
public void addReplacedText(int startIndex, int endIndex, BasedSequence replacedSequence) {
if (isFinalized()) throw new IllegalStateException("Cannot modify finalized ReplacedTextMapper");
regions.add(new ReplacedTextRegion(original.subSequence(startIndex, endIndex).getSourceRange(), Range.of(startIndex, endIndex), Range.of(replacedLength, replacedLength + replacedSequence.length())));
replacedLength += replacedSequence.length();
replacedSegments.add(replacedSequence);
}
public void addOriginalText(int startIndex, int endIndex) {
if (isFinalized()) throw new IllegalStateException("Cannot modify finalized ReplacedTextMapper");
if (startIndex < endIndex) {
BasedSequence originalSegment = original.subSequence(startIndex, endIndex);
regions.add(new ReplacedTextRegion(originalSegment.getSourceRange(), Range.of(startIndex, endIndex), Range.of(replacedLength, replacedLength + originalSegment.length())));
replacedLength += originalSegment.length();
replacedSegments.add(originalSegment);
}
}
public ArrayList<ReplacedTextRegion> getRegions() {
finalizeMods();
return regions;
}
public ArrayList<BasedSequence> getReplacedSegments() {
finalizeMods();
return replacedSegments;
}
public BasedSequence getReplacedSequence() {
finalizeMods();
return replacedSequence;
}
public int getReplacedLength() {
finalizeMods();
return replacedLength;
}
private int parentOriginalOffset(int originalIndex) {
return parent != null ? parent.originalOffset(originalIndex) : originalIndex;
}
public int originalOffset(int replacedIndex) {<FILL_FUNCTION_BODY>}
}
|
finalizeMods();
if (regions.isEmpty()) return parentOriginalOffset(replacedIndex);
if (replacedIndex == replacedLength) return parentOriginalOffset(original.length());
int originalIndex = replacedIndex;
for (ReplacedTextRegion region : regions) {
if (region.containsReplacedIndex(replacedIndex)) {
originalIndex = region.getOriginalRange().getStart() + replacedIndex - region.getReplacedRange().getStart();
if (originalIndex > region.getOriginalRange().getEnd()) {
originalIndex = region.getOriginalRange().getEnd();
}
break;
}
}
return parentOriginalOffset(originalIndex);
| 891
| 172
| 1,063
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/RichSequenceImpl.java
|
RichSequenceImpl
|
subSequence
|
class RichSequenceImpl extends IRichSequenceBase<RichSequence> implements RichSequence {
final CharSequence charSequence;
private RichSequenceImpl(CharSequence charSequence) {
super(charSequence instanceof String ? charSequence.hashCode() : 0);
this.charSequence = charSequence;
}
@NotNull
@Override
public RichSequence[] emptyArray() {
return EMPTY_ARRAY;
}
@NotNull
@Override
public RichSequence nullSequence() {
return NULL;
}
@NotNull
@Override
public RichSequence sequenceOf(@Nullable CharSequence charSequence, int startIndex, int endIndex) {
return of(charSequence, startIndex, endIndex);
}
@Override
public <B extends ISequenceBuilder<B, RichSequence>> @NotNull B getBuilder() {
//noinspection unchecked
return (B) RichSequenceBuilder.emptyBuilder();
}
@NotNull
@Override
public RichSequence subSequence(int startIndex, int endIndex) {<FILL_FUNCTION_BODY>}
@Override
public int length() {
return charSequence.length();
}
@Override
public char charAt(int index) {
char c = charSequence.charAt(index);
return c == SequenceUtils.NUL ? SequenceUtils.ENC_NUL : c;
}
@NotNull
@Override
public RichSequence toMapped(CharMapper mapper) {
return MappedRichSequence.mappedOf(mapper, this);
}
static RichSequence create(CharSequence charSequence, int startIndex, int endIndex) {
if (charSequence instanceof RichSequence) return ((RichSequence) charSequence).subSequence(startIndex, endIndex);
else if (charSequence != null) {
if (startIndex == 0 && endIndex == charSequence.length()) return new RichSequenceImpl(charSequence);
else return new RichSequenceImpl(charSequence.subSequence(startIndex, endIndex));
} else return NULL;
}
@Deprecated
public static RichSequence of(CharSequence charSequence) {
return RichSequence.of(charSequence, 0, charSequence.length());
}
@Deprecated
public static RichSequence of(CharSequence charSequence, int startIndex) {
return RichSequence.of(charSequence, startIndex, charSequence.length());
}
@Deprecated
public static RichSequence of(CharSequence charSequence, int startIndex, int endIndex) {
return RichSequence.of(charSequence, startIndex, endIndex);
}
}
|
SequenceUtils.validateStartEnd(startIndex, endIndex, length());
if (startIndex == 0 && endIndex == charSequence.length()) return this;
return create(charSequence, startIndex, endIndex);
| 646
| 55
| 701
|
<methods>public void <init>(int) ,public final transient @NotNull RichSequence append(java.lang.CharSequence[]) ,public final @NotNull RichSequence append(Iterable<? extends java.lang.CharSequence>) ,public final @NotNull RichSequence appendEOL() ,public final transient @NotNull RichSequence appendRangesTo(@NotNull StringBuilder, @Nullable CharMapper, com.vladsch.flexmark.util.sequence.Range[]) ,public final transient @NotNull RichSequence appendRangesTo(@NotNull StringBuilder, com.vladsch.flexmark.util.sequence.Range[]) ,public final @NotNull RichSequence appendRangesTo(@NotNull StringBuilder, Iterable<? extends com.vladsch.flexmark.util.sequence.Range>) ,public final @NotNull RichSequence appendRangesTo(@NotNull StringBuilder, @Nullable CharMapper, Iterable<? extends com.vladsch.flexmark.util.sequence.Range>) ,public final @NotNull RichSequence appendSpace() ,public final @NotNull RichSequence appendSpaces(int) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, @Nullable CharMapper) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, @Nullable CharMapper, int) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, int) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, int, int) ,public final @NotNull RichSequence appendTo(@NotNull StringBuilder, @Nullable CharMapper, int, int) ,public final @NotNull List<Range> blankLinesRemovedRanges() ,public final @NotNull List<Range> blankLinesRemovedRanges(int) ,public final @NotNull List<Range> blankLinesRemovedRanges(int, int) ,public final @NotNull List<Range> blankLinesRemovedRanges(@NotNull CharPredicate, int, int) ,public final int columnAtIndex(int) ,public int compareTo(@NotNull CharSequence) ,public final int countLeading(@NotNull CharPredicate) ,public final int countLeading(@NotNull CharPredicate, int) ,public final int countLeading(@NotNull CharPredicate, int, int) ,public final int countLeadingColumns(int, @NotNull CharPredicate) ,public final int countLeadingNot(@NotNull CharPredicate) ,public final int countLeadingNot(@NotNull CharPredicate, int) ,public final int countLeadingNot(@NotNull CharPredicate, int, int) ,public final int countLeadingNotSpace() ,public final int countLeadingNotSpace(int) ,public final int countLeadingNotSpace(int, int) ,public final int countLeadingNotSpaceTab() ,public final int countLeadingNotSpaceTab(int) ,public final int countLeadingNotSpaceTab(int, int) ,public final int countLeadingNotWhitespace() ,public final int countLeadingNotWhitespace(int) ,public final int countLeadingNotWhitespace(int, int) ,public final int countLeadingSpace() ,public final int countLeadingSpace(int) ,public final int countLeadingSpace(int, int) ,public final int countLeadingSpaceTab() ,public final int countLeadingSpaceTab(int) ,public final int countLeadingSpaceTab(int, int) ,public final int countLeadingWhitespace() ,public final int countLeadingWhitespace(int) ,public final int countLeadingWhitespace(int, int) ,public final int countOfAny(@NotNull CharPredicate, int) ,public final int countOfAny(@NotNull CharPredicate) ,public final int countOfAny(@NotNull CharPredicate, int, int) ,public final int countOfAnyNot(@NotNull CharPredicate, int) ,public final int countOfAnyNot(@NotNull CharPredicate) ,public final int countOfAnyNot(@NotNull CharPredicate, int, int) ,public final int countOfNotSpaceTab() ,public final int countOfNotWhitespace() ,public final int countOfSpaceTab() ,public final int countOfWhitespace() ,public final int countTrailing(@NotNull CharPredicate) ,public final int countTrailing(@NotNull CharPredicate, int) ,public final int countTrailing(@NotNull CharPredicate, int, int) ,public final int countTrailingNot(@NotNull CharPredicate) ,public final int countTrailingNot(@NotNull CharPredicate, int) ,public final int countTrailingNot(@NotNull CharPredicate, int, int) ,public final int countTrailingNotSpace() ,public final int countTrailingNotSpace(int) ,public final int countTrailingNotSpace(int, int) ,public final int countTrailingNotSpaceTab() ,public final int countTrailingNotSpaceTab(int) ,public final int countTrailingNotSpaceTab(int, int) ,public final int countTrailingNotWhitespace() ,public final int countTrailingNotWhitespace(int) ,public final int countTrailingNotWhitespace(int, int) ,public final int countTrailingSpace() ,public final int countTrailingSpace(int) ,public final int countTrailingSpace(int, int) ,public final int countTrailingSpaceTab() ,public final int countTrailingSpaceTab(int) ,public final int countTrailingSpaceTab(int, int) ,public final int countTrailingWhitespace() ,public final int countTrailingWhitespace(int) ,public final int countTrailingWhitespace(int, int) ,public @NotNull RichSequence delete(int, int) ,public final char endCharAt(int) ,public final int endOfDelimitedBy(@NotNull CharSequence, int) ,public final int endOfDelimitedByAny(@NotNull CharPredicate, int) ,public final int endOfDelimitedByAnyNot(@NotNull CharPredicate, int) ,public final int endOfLine(int) ,public final int endOfLineAnyEOL(int) ,public final @NotNull RichSequence endSequence(int, int) ,public final @NotNull RichSequence endSequence(int) ,public final boolean endsWith(@NotNull CharSequence) ,public final boolean endsWith(@NotNull CharSequence, boolean) ,public final boolean endsWith(@NotNull CharPredicate) ,public final boolean endsWithAnyEOL() ,public final boolean endsWithEOL() ,public final boolean endsWithIgnoreCase(@NotNull CharSequence) ,public final boolean endsWithSpace() ,public final boolean endsWithSpaceTab() ,public final boolean endsWithWhitespace() ,public final int eolEndLength() ,public final int eolEndLength(int) ,public final @NotNull Range eolEndRange(int) ,public final int eolStartLength(int) ,public @NotNull Range eolStartRange(int) ,public final boolean equals(java.lang.Object) ,public final boolean equals(@Nullable Object, boolean) ,public final boolean equalsIgnoreCase(@Nullable Object) ,public final transient @NotNull RichSequence extractRanges(com.vladsch.flexmark.util.sequence.Range[]) ,public final @NotNull RichSequence extractRanges(Iterable<com.vladsch.flexmark.util.sequence.Range>) ,public final char firstChar() ,public final int hashCode() ,public final @NotNull RichSequence ifNull(@NotNull RichSequence) ,public final @NotNull RichSequence ifNullEmptyAfter(@NotNull RichSequence) ,public final @NotNull RichSequence ifNullEmptyBefore(@NotNull RichSequence) ,public final int indexOf(@NotNull CharSequence) ,public final int indexOf(@NotNull CharSequence, int) ,public final int indexOf(@NotNull CharSequence, int, int) ,public final int indexOf(char) ,public final int indexOf(char, int) ,public final int indexOf(char, int, int) ,public final @NotNull int [] indexOfAll(@NotNull CharSequence) ,public final int indexOfAny(@NotNull CharPredicate) ,public final int indexOfAny(@NotNull CharPredicate, int) ,public final int indexOfAny(@NotNull CharPredicate, int, int) ,public final int indexOfAnyNot(@NotNull CharPredicate) ,public final int indexOfAnyNot(@NotNull CharPredicate, int) ,public final int indexOfAnyNot(@NotNull CharPredicate, int, int) ,public final int indexOfNot(char) ,public final int indexOfNot(char, int) ,public final int indexOfNot(char, int, int) ,public @NotNull RichSequence insert(int, @NotNull CharSequence) ,public final boolean isBlank() ,public boolean isCharAt(int, @NotNull CharPredicate) ,public final boolean isEmpty() ,public boolean isIn(@NotNull String []) ,public boolean isIn(@NotNull Collection<? extends CharSequence>) ,public final boolean isNotBlank() ,public final boolean isNotEmpty() ,public final boolean isNotNull() ,public final boolean isNull() ,public final char lastChar() ,public final int lastIndexOf(char) ,public final int lastIndexOf(char, int) ,public final int lastIndexOf(@NotNull CharSequence) ,public final int lastIndexOf(@NotNull CharSequence, int) ,public final int lastIndexOf(@NotNull CharSequence, int, int) ,public final int lastIndexOf(char, int, int) ,public final int lastIndexOfAny(@NotNull CharPredicate, int) ,public final int lastIndexOfAny(@NotNull CharPredicate) ,public final int lastIndexOfAny(@NotNull CharPredicate, int, int) ,public final int lastIndexOfAnyNot(@NotNull CharPredicate) ,public final int lastIndexOfAnyNot(@NotNull CharPredicate, int) ,public final int lastIndexOfAnyNot(@NotNull CharPredicate, int, int) ,public final int lastIndexOfNot(char) ,public final int lastIndexOfNot(char, int) ,public final int lastIndexOfNot(char, int, int) ,public final @NotNull Range leadingBlankLinesRange() ,public final @NotNull Range leadingBlankLinesRange(int) ,public final @NotNull Range leadingBlankLinesRange(int, int) ,public final @NotNull Range leadingBlankLinesRange(@NotNull CharPredicate, int, int) ,public final @NotNull RichSequence lineAt(int) ,public final @NotNull RichSequence lineAtAnyEOL(int) ,public final @NotNull Pair<Integer,Integer> lineColumnAtIndex(int) ,public final @NotNull Range lineRangeAt(int) ,public final @NotNull Range lineRangeAtAnyEOL(int) ,public final boolean matchChars(@NotNull CharSequence, int, boolean) ,public final boolean matchChars(@NotNull CharSequence, int) ,public final boolean matchChars(@NotNull CharSequence, boolean) ,public final boolean matchChars(@NotNull CharSequence) ,public final boolean matchCharsIgnoreCase(@NotNull CharSequence, int) ,public final boolean matchCharsIgnoreCase(@NotNull CharSequence) ,public final boolean matchCharsReversed(@NotNull CharSequence, int, boolean) ,public final boolean matchCharsReversed(@NotNull CharSequence, int) ,public final boolean matchCharsReversedIgnoreCase(@NotNull CharSequence, int) ,public final int matchedCharCount(@NotNull CharSequence, int, int, boolean) ,public final int matchedCharCount(@NotNull CharSequence, int, boolean) ,public final int matchedCharCount(@NotNull CharSequence, int, int) ,public final int matchedCharCount(@NotNull CharSequence, int) ,public final int matchedCharCount(@NotNull CharSequence, int, int, boolean, boolean) ,public final int matchedCharCountIgnoreCase(@NotNull CharSequence, int) ,public final int matchedCharCountIgnoreCase(@NotNull CharSequence, int, int) ,public final int matchedCharCountReversed(@NotNull CharSequence, int, int) ,public final int matchedCharCountReversed(@NotNull CharSequence, int, boolean) ,public final int matchedCharCountReversed(@NotNull CharSequence, int) ,public final int matchedCharCountReversed(@NotNull CharSequence, int, int, boolean) ,public final int matchedCharCountReversedIgnoreCase(@NotNull CharSequence, int, int) ,public final int matchedCharCountReversedIgnoreCase(@NotNull CharSequence, int) ,public final boolean matches(@NotNull CharSequence, boolean) ,public final boolean matches(@NotNull CharSequence) ,public final boolean matchesIgnoreCase(@NotNull CharSequence) ,public final char midCharAt(int) ,public final @NotNull RichSequence midSequence(int, int) ,public final @NotNull RichSequence midSequence(int) ,public final @NotNull String normalizeEOL() ,public final @NotNull String normalizeEndWithEOL() ,public final @NotNull RichSequence nullIf(boolean) ,public final transient @NotNull RichSequence nullIf(@NotNull Predicate<? super CharSequence>, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIf(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIf(@NotNull BiPredicate<? super RichSequence,? super CharSequence>, java.lang.CharSequence[]) ,public final @NotNull RichSequence nullIfBlank() ,public final @NotNull RichSequence nullIfEmpty() ,public final transient @NotNull RichSequence nullIfEndsWith(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfEndsWith(boolean, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfEndsWithIgnoreCase(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNot(@NotNull BiPredicate<? super RichSequence,? super CharSequence>, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNot(@NotNull Predicate<? super CharSequence>, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNot(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotEndsWith(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotEndsWith(boolean, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotEndsWithIgnoreCase(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotStartsWith(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotStartsWith(boolean, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfNotStartsWithIgnoreCase(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfStartsWith(java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfStartsWith(boolean, java.lang.CharSequence[]) ,public final transient @NotNull RichSequence nullIfStartsWithIgnoreCase(java.lang.CharSequence[]) ,public @NotNull RichSequence padEnd(int, char) ,public @NotNull RichSequence padEnd(int) ,public @NotNull RichSequence padStart(int, char) ,public @NotNull RichSequence padStart(int) ,public final @NotNull RichSequence padding(int, char) ,public final @NotNull RichSequence padding(int) ,public final @NotNull RichSequence prefixOnceWith(@Nullable CharSequence) ,public final @NotNull RichSequence prefixOnceWithEOL() ,public final @NotNull RichSequence prefixOnceWithSpace() ,public @NotNull RichSequence prefixWith(@Nullable CharSequence) ,public final @NotNull RichSequence prefixWithEOL() ,public final @NotNull RichSequence prefixWithSpace() ,public final @NotNull RichSequence prefixWithSpaces(int) ,public final @NotNull RichSequence removePrefix(@NotNull CharSequence) ,public final @NotNull RichSequence removePrefix(@NotNull CharSequence, boolean) ,public final @NotNull RichSequence removePrefixIgnoreCase(@NotNull CharSequence) ,public final @NotNull RichSequence removeProperPrefix(@NotNull CharSequence) ,public final @NotNull RichSequence removeProperPrefix(@NotNull CharSequence, boolean) ,public final @NotNull RichSequence removeProperPrefixIgnoreCase(@NotNull CharSequence) ,public final @NotNull RichSequence removeProperSuffix(@NotNull CharSequence) ,public final @NotNull RichSequence removeProperSuffix(@NotNull CharSequence, boolean) ,public final @NotNull RichSequence removeProperSuffixIgnoreCase(@NotNull CharSequence) ,public final @NotNull RichSequence removeSuffix(@NotNull CharSequence) ,public final @NotNull RichSequence removeSuffix(@NotNull CharSequence, boolean) ,public final @NotNull RichSequence removeSuffixIgnoreCase(@NotNull CharSequence) ,public final @NotNull RichSequence replace(int, int, @NotNull CharSequence) ,public final @NotNull RichSequence replace(@NotNull CharSequence, @NotNull CharSequence) ,public char safeCharAt(int) ,public @NotNull RichSequence safeSubSequence(int, int) ,public @NotNull RichSequence safeSubSequence(int) ,public final @NotNull RichSequence sequenceOf(@Nullable CharSequence) ,public final @NotNull RichSequence sequenceOf(@Nullable CharSequence, int) ,public final @NotNull RichSequence [] split(@NotNull CharSequence, boolean, @Nullable CharPredicate) ,public final @NotNull RichSequence [] split(@NotNull CharSequence) ,public final @NotNull RichSequence [] split(@NotNull CharSequence, int, boolean, @Nullable CharPredicate) ,public final @NotNull RichSequence [] split(@NotNull CharSequence, int, int) ,public final @NotNull RichSequence [] split(@NotNull CharSequence, int, int, @Nullable CharPredicate) ,public final @NotNull RichSequence [] splitEOL() ,public final @NotNull RichSequence [] splitEOL(boolean) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence, int, boolean, @Nullable CharPredicate) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence, int, int) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence, boolean, @Nullable CharPredicate) ,public final @NotNull List<RichSequence> splitList(@NotNull CharSequence, int, int, @Nullable CharPredicate) ,public final @NotNull List<RichSequence> splitListEOL() ,public final @NotNull List<RichSequence> splitListEOL(boolean) ,public final @NotNull List<RichSequence> splitListEOL(boolean, @Nullable CharPredicate) ,public final int startOfDelimitedBy(@NotNull CharSequence, int) ,public final int startOfDelimitedByAny(@NotNull CharPredicate, int) ,public final int startOfDelimitedByAnyNot(@NotNull CharPredicate, int) ,public final int startOfLine(int) ,public final int startOfLineAnyEOL(int) ,public final boolean startsWith(@NotNull CharSequence) ,public final boolean startsWith(@NotNull CharSequence, boolean) ,public final boolean startsWith(@NotNull CharPredicate) ,public final boolean startsWithAnyEOL() ,public final boolean startsWithEOL() ,public final boolean startsWithIgnoreCase(@NotNull CharSequence) ,public final boolean startsWithSpace() ,public final boolean startsWithSpaceTab() ,public final boolean startsWithWhitespace() ,public final @NotNull RichSequence subSequence(int) ,public final @NotNull RichSequence subSequence(@NotNull Range) ,public final @NotNull RichSequence subSequenceAfter(@NotNull Range) ,public final @NotNull RichSequence subSequenceBefore(@NotNull Range) ,public final Pair<com.vladsch.flexmark.util.sequence.RichSequence,com.vladsch.flexmark.util.sequence.RichSequence> subSequenceBeforeAfter(com.vladsch.flexmark.util.sequence.Range) ,public final @NotNull RichSequence suffixOnceWith(@Nullable CharSequence) ,public final @NotNull RichSequence suffixOnceWithEOL() ,public final @NotNull RichSequence suffixOnceWithSpace() ,public @NotNull RichSequence suffixWith(@Nullable CharSequence) ,public final @NotNull RichSequence suffixWithEOL() ,public final @NotNull RichSequence suffixWithSpace() ,public final @NotNull RichSequence suffixWithSpaces(int) ,public final @NotNull RichSequence toLowerCase() ,public final @NotNull RichSequence toNbSp() ,public final @NotNull RichSequence toSpc() ,public @NotNull String toString() ,public @Nullable String toStringOrNull() ,public final @NotNull RichSequence toUpperCase() ,public final @NotNull String toVisibleWhitespaceString() ,public final @NotNull Range trailingBlankLinesRange() ,public final @NotNull Range trailingBlankLinesRange(int) ,public final @NotNull Range trailingBlankLinesRange(int, int) ,public final @NotNull Range trailingBlankLinesRange(com.vladsch.flexmark.util.misc.CharPredicate, int, int) ,public final @NotNull RichSequence trim(@NotNull CharPredicate) ,public final @NotNull RichSequence trim(int) ,public final @NotNull RichSequence trim() ,public final @NotNull RichSequence trim(int, @NotNull CharPredicate) ,public final @NotNull RichSequence trimEOL() ,public final @NotNull RichSequence trimEnd(@NotNull CharPredicate) ,public final @NotNull RichSequence trimEnd(int) ,public final @NotNull RichSequence trimEnd() ,public final @NotNull RichSequence trimEnd(int, @NotNull CharPredicate) ,public final @NotNull Range trimEndRange(int, @NotNull CharPredicate) ,public final @NotNull Range trimEndRange(@NotNull CharPredicate) ,public final @NotNull Range trimEndRange(int) ,public final @NotNull Range trimEndRange() ,public final @NotNull RichSequence trimLeadBlankLines() ,public final @NotNull Range trimRange(int, @NotNull CharPredicate) ,public final @NotNull Range trimRange(@NotNull CharPredicate) ,public final @NotNull Range trimRange(int) ,public final @NotNull Range trimRange() ,public final @NotNull RichSequence trimStart(@NotNull CharPredicate) ,public final @NotNull RichSequence trimStart(int) ,public final @NotNull RichSequence trimStart() ,public final @NotNull RichSequence trimStart(int, @NotNull CharPredicate) ,public final @NotNull Range trimStartRange(int, @NotNull CharPredicate) ,public final @NotNull Range trimStartRange(@NotNull CharPredicate) ,public final @NotNull Range trimStartRange(int) ,public final @NotNull Range trimStartRange() ,public final @NotNull RichSequence trimTailBlankLines() ,public @NotNull RichSequence trimToEndOfLine(boolean) ,public @NotNull RichSequence trimToEndOfLine(int) ,public @NotNull RichSequence trimToEndOfLine() ,public @NotNull RichSequence trimToEndOfLine(boolean, int) ,public @NotNull RichSequence trimToEndOfLine(@NotNull CharPredicate, boolean, int) ,public @NotNull RichSequence trimToStartOfLine(boolean) ,public @NotNull RichSequence trimToStartOfLine(int) ,public @NotNull RichSequence trimToStartOfLine() ,public @NotNull RichSequence trimToStartOfLine(boolean, int) ,public @NotNull RichSequence trimToStartOfLine(@NotNull CharPredicate, boolean, int) ,public final @NotNull Pair<RichSequence,RichSequence> trimmed(@NotNull CharPredicate) ,public final @NotNull Pair<RichSequence,RichSequence> trimmed(int) ,public final @NotNull Pair<RichSequence,RichSequence> trimmed() ,public final @NotNull Pair<RichSequence,RichSequence> trimmed(int, @NotNull CharPredicate) ,public final @NotNull RichSequence trimmedEOL() ,public final @NotNull RichSequence trimmedEnd(@NotNull CharPredicate) ,public final @NotNull RichSequence trimmedEnd(int) ,public final @NotNull RichSequence trimmedEnd() ,public final @NotNull RichSequence trimmedEnd(int, @NotNull CharPredicate) ,public final @NotNull RichSequence trimmedStart(@NotNull CharPredicate) ,public final @NotNull RichSequence trimmedStart(int) ,public final @NotNull RichSequence trimmedStart() ,public final @NotNull RichSequence trimmedStart(int, @NotNull CharPredicate) ,public final void validateIndex(int) ,public final void validateIndexInclusiveEnd(int) ,public final void validateStartEnd(int, int) <variables>private int hash
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequence.java
|
SegmentedSequence
|
create
|
class SegmentedSequence extends BasedSequenceImpl implements ReplacedBasedSequence {
protected final BasedSequence baseSeq; // base sequence
protected final int startOffset; // this sequence's start offset in base
protected final int endOffset; // this sequence's end offset in base
protected final int length; // length of this sequence
protected SegmentedSequence(BasedSequence baseSeq, int startOffset, int endOffset, int length) {
super(0);
assert baseSeq == baseSeq.getBaseSequence();
if (startOffset < 0 && endOffset < 0) {
// NOTE: segmented sequence with no based segments in it gets both offsets as -1
startOffset = 0;
endOffset = 0;
}
assert startOffset >= 0 : "startOffset: " + startOffset;
assert endOffset >= startOffset && endOffset <= baseSeq.length() : "endOffset: " + endOffset;
this.baseSeq = baseSeq;
this.startOffset = startOffset;
this.endOffset = endOffset;
this.length = length;
}
@NotNull
@Override
final public Object getBase() {
return baseSeq.getBase();
}
@NotNull
@Override
final public BasedSequence getBaseSequence() {
return baseSeq;
}
/**
* Get the start in the base sequence for this segmented sequence.
* <p>
* NOTE: this is the startOffset determined when the sequence was built from segments and may differ from
* the startOffset of the first based segment in this sequence
*
* @return start in base sequence
*/
final public int getStartOffset() {
return startOffset;
}
/**
* Get the end offset in the base sequence
* <p>
* NOTE: this is the endOffset determined when the sequence was built from segments and may differ from
* the endOffset of the last based segment in this sequence
*
* @return end in base sequence
*/
final public int getEndOffset() {
return endOffset;
}
@Override
final public int getOptionFlags() {
return getBaseSequence().getOptionFlags();
}
@Override
final public boolean allOptions(int options) {
return getBaseSequence().allOptions(options);
}
@Override
final public boolean anyOptions(int options) {
return getBaseSequence().anyOptions(options);
}
@Override
final public <T> T getOption(DataKeyBase<T> dataKey) {
return getBaseSequence().getOption(dataKey);
}
@Override
final public @Nullable DataHolder getOptions() {
return getBaseSequence().getOptions();
}
@Override
final public int length() {
return length;
}
@NotNull
@Override
final public Range getSourceRange() {
return Range.of(getStartOffset(), getEndOffset());
}
@NotNull
@Override
final public BasedSequence baseSubSequence(int startIndex, int endIndex) {
SequenceUtils.validateStartEnd(startIndex, endIndex, baseSeq.length());
return baseSeq.baseSubSequence(startIndex, endIndex);
}
/**
* Use {@link BasedSequence#getBuilder()} and then {@link SequenceBuilder#addAll(Iterable)} or
* if you know which are based segments vs. out of base Strings then use {@link BasedSegmentBuilder}
* to construct segments directly.
* <p>
* Use only if you absolutely need to use this old method because it calls the builder.addAll() for all the segments
* anyway.
* <p>
* If you need the location where content would have been use the FencedCodeBlock.getOpeningMarker().getEndOffset() + 1
*
* @param basedSequence base sequence for the segments
* @param segments list of based sequences to put into a based sequence
* @return based sequence of segments. Result is a sequence which looks like
* all the segments were concatenated, while still maintaining
* the original offset for each character when using {@link #getIndexOffset(int)}(int index)
*/
public static BasedSequence create(BasedSequence basedSequence, @NotNull Iterable<? extends BasedSequence> segments) {
return create(basedSequence.getBuilder().addAll(segments));
}
public static BasedSequence create(BasedSequence... segments) {
return segments.length == 0 ? BasedSequence.NULL : create(segments[0], new ArrayIterable<>(segments));
}
public static BasedSequence create(SequenceBuilder builder) {<FILL_FUNCTION_BODY>}
/**
* @param basedSequence base sequence for the segments
* @param segments list of based sequences to put into a based sequence
* @return based sequence of segments. Result is a sequence which looks like
* all the segments were concatenated, while still maintaining
* the original offset for each character when using {@link #getIndexOffset(int)}(int index)
* @deprecated use {@link BasedSequence#getBuilder()} and then {@link SequenceBuilder#addAll(Iterable)} or if you know which are based segments vs. out of base Strings then use {@link BasedSegmentBuilder} to construct segments directly.
* If you absolutely need to use the old method then use {@link SegmentedSequence#create(BasedSequence, Iterable)}
*/
@Deprecated
public static BasedSequence of(BasedSequence basedSequence, @NotNull Iterable<? extends BasedSequence> segments) {
return create(basedSequence, segments);
}
@Deprecated
public static BasedSequence of(BasedSequence... segments) {
return create(segments);
}
}
|
BasedSequence baseSubSequence = builder.getSingleBasedSequence();
if (baseSubSequence != null) {
return baseSubSequence;
} else if (!builder.isEmpty()) {
BasedSequence baseSequence = builder.getBaseSequence();
if (baseSequence.anyOptions(F_FULL_SEGMENTED_SEQUENCES)) {
return SegmentedSequenceFull.create(baseSequence, builder.getSegmentBuilder());
} else if (baseSequence.anyOptions(F_TREE_SEGMENTED_SEQUENCES)) {
return SegmentedSequenceTree.create(baseSequence, builder.getSegmentBuilder());
} else {
// Can decide based on segments and length but tree based is not slower and much more efficient
// return SegmentedSequenceFull.create(baseSequence, builder.getSegmentBuilder());
return SegmentedSequenceTree.create(baseSequence, builder.getSegmentBuilder());
}
}
return BasedSequence.NULL;
| 1,420
| 235
| 1,655
|
<methods>public void <init>(int) ,public void addSegments(@NotNull IBasedSegmentBuilder<?>) ,public int baseColumnAtEnd() ,public int baseColumnAtIndex(int) ,public int baseColumnAtStart() ,public int baseEndOfLine(int) ,public int baseEndOfLine() ,public int baseEndOfLineAnyEOL(int) ,public int baseEndOfLineAnyEOL() ,public @NotNull Pair<Integer,Integer> baseLineColumnAtEnd() ,public @NotNull Pair<Integer,Integer> baseLineColumnAtIndex(int) ,public @NotNull Pair<Integer,Integer> baseLineColumnAtStart() ,public @NotNull Range baseLineRangeAtEnd() ,public @NotNull Range baseLineRangeAtIndex(int) ,public @NotNull Range baseLineRangeAtStart() ,public int baseStartOfLine(int) ,public int baseStartOfLine() ,public int baseStartOfLineAnyEOL(int) ,public int baseStartOfLineAnyEOL() ,public final @NotNull BasedSequence baseSubSequence(int) ,public @NotNull BasedSequence baseSubSequence(int, int) ,public boolean containsAllOf(@NotNull BasedSequence) ,public boolean containsOnlyIn(@NotNull CharPredicate) ,public boolean containsOnlyNotIn(@NotNull CharPredicate) ,public boolean containsSomeIn(@NotNull CharPredicate) ,public boolean containsSomeNotIn(@NotNull CharPredicate) ,public boolean containsSomeOf(@NotNull BasedSequence) ,public @NotNull BasedSequence [] emptyArray() ,public @NotNull BasedSequence extendByAny(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByAny(@NotNull CharPredicate, int) ,public @NotNull BasedSequence extendByAnyNot(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByAnyNot(@NotNull CharPredicate, int) ,public @NotNull BasedSequence extendByOneOfAny(@NotNull CharPredicate) ,public @NotNull BasedSequence extendByOneOfAnyNot(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToEndOfLine(boolean) ,public final @NotNull BasedSequence extendToEndOfLine() ,public final @NotNull BasedSequence extendToEndOfLine(@NotNull CharPredicate, boolean) ,public final @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate) ,public final @NotNull BasedSequence extendToStartOfLine(boolean) ,public final @NotNull BasedSequence extendToStartOfLine() ,public @NotNull BasedSequence extendToStartOfLine(@NotNull CharPredicate, boolean) ,public static transient com.vladsch.flexmark.util.sequence.BasedSequence firstNonNull(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public @NotNull SequenceBuilder getBuilder() ,public @NotNull BasedSequence getEmptyPrefix() ,public @NotNull BasedSequence getEmptySuffix() ,public @NotNull SegmentTree getSegmentTree() ,public @NotNull BasedSequence intersect(@NotNull BasedSequence) ,public boolean isBaseCharAt(int, @NotNull CharPredicate) ,public boolean isContinuationOf(@NotNull BasedSequence) ,public boolean isContinuedBy(@NotNull BasedSequence) ,public @NotNull BasedSequence normalizeEOL(@NotNull ReplacedTextMapper) ,public @NotNull BasedSequence normalizeEndWithEOL(@NotNull ReplacedTextMapper) ,public @NotNull BasedSequence nullSequence() ,public @NotNull BasedSequence prefixOf(@NotNull BasedSequence) ,public @NotNull BasedSequence prefixWith(@Nullable CharSequence) ,public final @NotNull BasedSequence prefixWithIndent() ,public @NotNull BasedSequence prefixWithIndent(int) ,public char safeBaseCharAt(int) ,public char safeCharAt(int) ,public @NotNull BasedSequence sequenceOf(@Nullable CharSequence, int, int) ,public @NotNull BasedSequence spliceAtEnd(@NotNull BasedSequence) ,public @NotNull BasedSequence suffixOf(@NotNull BasedSequence) ,public @NotNull BasedSequence toMapped(com.vladsch.flexmark.util.sequence.mappers.CharMapper) ,public @Nullable String toStringOrNull() ,public @NotNull String unescape() ,public @NotNull BasedSequence unescape(@NotNull ReplacedTextMapper) ,public @NotNull String unescapeNoEntities() <variables>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceFull.java
|
SegmentedSequenceFull
|
create
|
class SegmentedSequenceFull extends SegmentedSequence {
final private boolean nonBaseChars; // true if contains non-base chars
final private int[] baseOffsets; // list of base offsets, offset by baseStartOffset
final private int baseStartOffset; // start offset for baseOffsets of this sequence, offset from baseSeq for all chars, including non-base chars
private SegmentedSequenceFull(BasedSequence baseSeq, int startOffset, int endOffset, int length, boolean nonBaseChars, int[] baseOffsets, int baseStartOffset) {
super(baseSeq, startOffset, endOffset, length);
this.nonBaseChars = nonBaseChars;
this.baseOffsets = baseOffsets;
this.baseStartOffset = baseStartOffset;
}
@Override
public int getIndexOffset(int index) {
SequenceUtils.validateIndexInclusiveEnd(index, length());
int offset = baseOffsets[baseStartOffset + index];
return offset < 0 ? -1 : offset;
}
@Override
public void addSegments(@NotNull IBasedSegmentBuilder<?> builder) {
// FIX: clean up and optimize the structure. it is error prone and inefficient
BasedUtils.generateSegments(builder, this);
}
@Override
public char charAt(int index) {
SequenceUtils.validateIndex(index, length());
int offset = baseOffsets[baseStartOffset + index];
if (offset < 0) {
/* HACK: allows having characters which are not from original base sequence
but with the only penalty for charAt access being an extra indirection,
which is a small price to pay for having the flexibility of adding out of
context text to the based sequence.
*/
return (char) (-offset - 1);
} else {
return baseSeq.charAt(offset);
}
}
@NotNull
@Override
public BasedSequence subSequence(int startIndex, int endIndex) {
SequenceUtils.validateStartEnd(startIndex, endIndex, length());
if (startIndex == 0 && endIndex == length) {
return this;
} else {
return subSequence(baseSeq, baseOffsets, baseStartOffset + startIndex, nonBaseChars, endIndex - startIndex);
}
}
/**
* Base Constructor
*
* @param baseSequence base sequence for segmented sequence
* @param builder builder for which to construct segmented sequence
* @return segmented sequence
*/
public static SegmentedSequenceFull create(@NotNull BasedSequence baseSequence, ISegmentBuilder<?> builder) {<FILL_FUNCTION_BODY>}
private SegmentedSequenceFull subSequence(final BasedSequence baseSeq, final int[] baseOffsets, final int baseStartOffset, final boolean nonBaseChars, final int length) {
int iMax = baseOffsets.length - 1;
assert baseStartOffset + length <= iMax : "Sub-sequence offsets list length < baseStartOffset + sub-sequence length";
int startOffset = 0;
int endOffset = 0;
if (!nonBaseChars) {
if (baseStartOffset < iMax) {
// start is the offset at our start, even when length = 0
startOffset = baseOffsets[baseStartOffset];
} else {
startOffset = baseSeq.getEndOffset();
}
if (length == 0) {
endOffset = startOffset;
} else {
endOffset = baseOffsets[baseStartOffset + length - 1] + 1;
assert startOffset <= endOffset;
}
} else {
// start is the first real start in this sequence or after it in the parent
boolean finished = false;
for (int iS = baseStartOffset; iS < iMax; iS++) {
if (baseOffsets[iS] < 0) continue;
startOffset = baseOffsets[iS];
if (length != 0) {
// end is the last real offset + 1 in this sequence up to the start index where startOffset was found
for (int iE = baseStartOffset + length; iE-- > iS; ) {
if (baseOffsets[iE] < 0) continue;
endOffset = baseOffsets[iE] + 1;
assert startOffset <= endOffset;
finished = true;
break;
}
}
if (!finished) {
endOffset = startOffset;
}
finished = true;
break;
}
if (!finished) {
// if no real start after then it is the base's end since we had no real start after, these chars and after are all out of base chars
startOffset = baseSeq.getEndOffset();
endOffset = startOffset;
}
}
return new SegmentedSequenceFull(
baseSeq,
startOffset,
endOffset,
length,
nonBaseChars,
baseOffsets,
baseStartOffset
);
}
/**
* @param basedSequence base sequence for the segments
* @param segments list of based sequences to put into a based sequence
* @return based sequence of segments. Result is a sequence which looks like
* all the segments were concatenated, while still maintaining
* the original offset for each character when using {@link #getIndexOffset(int)}(int index)
* @deprecated use {@link BasedSequence#getBuilder()} and then {@link SequenceBuilder#addAll(Iterable)}
* or if you know which are based segments vs. out of base Strings then use {@link BasedSegmentBuilder}
* to construct segments directly. If you must use segments then use {@link SegmentedSequence#create(BasedSequence, Iterable)}
* which does the builder calls for you.
*/
@Deprecated
public static BasedSequence of(BasedSequence basedSequence, @NotNull Iterable<? extends BasedSequence> segments) {
return SegmentedSequence.create(basedSequence, segments);
}
@Deprecated
public static BasedSequence of(BasedSequence... segments) {
return SegmentedSequence.create(segments);
}
}
|
BasedSequence baseSeq = baseSequence.getBaseSequence();
int length = builder.length();
int baseStartOffset = 0;
int[] baseOffsets = new int[length + 1];
int index = 0;
for (Object part : builder) {
if (part instanceof Range) {
if (((Range) part).isEmpty()) continue;
int iMax = ((Range) part).getEnd();
for (int i = ((Range) part).getStart(); i < iMax; i++) {
baseOffsets[index++] = i;
}
} else if (part instanceof CharSequence) {
CharSequence sequence = (CharSequence) part;
int iMax = sequence.length();
for (int i = 0; i < iMax; i++) {
baseOffsets[index++] = -sequence.charAt(i) - 1;
}
} else if (part != null) {
throw new IllegalStateException("Invalid part type " + part.getClass());
}
}
int end = baseOffsets[length - 1];
baseOffsets[length] = end < 0 ? end - 1 : end + 1;
int startOffset = builder.getStartOffset();
int endOffset = builder.getEndOffset();
boolean nonBaseChars = builder.getTextLength() > 0;
if (baseSeq.anyOptions(F_COLLECT_SEGMENTED_STATS)) {
SegmentedSequenceStats stats = baseSeq.getOption(SEGMENTED_STATS);
if (stats != null) {
stats.addStats(builder.noAnchorsSize(), length, baseOffsets.length * 4);
}
}
return new SegmentedSequenceFull(
baseSeq,
startOffset,
endOffset,
length,
nonBaseChars,
baseOffsets,
baseStartOffset
);
| 1,539
| 480
| 2,019
|
<methods>public final boolean allOptions(int) ,public final boolean anyOptions(int) ,public final @NotNull BasedSequence baseSubSequence(int, int) ,public static com.vladsch.flexmark.util.sequence.BasedSequence create(com.vladsch.flexmark.util.sequence.BasedSequence, @NotNull Iterable<? extends BasedSequence>) ,public static transient com.vladsch.flexmark.util.sequence.BasedSequence create(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public static com.vladsch.flexmark.util.sequence.BasedSequence create(com.vladsch.flexmark.util.sequence.builder.SequenceBuilder) ,public final @NotNull Object getBase() ,public final @NotNull BasedSequence getBaseSequence() ,public final int getEndOffset() ,public final T getOption(DataKeyBase<T>) ,public final int getOptionFlags() ,public final @Nullable DataHolder getOptions() ,public final @NotNull Range getSourceRange() ,public final int getStartOffset() ,public final int length() ,public static com.vladsch.flexmark.util.sequence.BasedSequence of(com.vladsch.flexmark.util.sequence.BasedSequence, @NotNull Iterable<? extends BasedSequence>) ,public static transient com.vladsch.flexmark.util.sequence.BasedSequence of(com.vladsch.flexmark.util.sequence.BasedSequence[]) <variables>protected final non-sealed com.vladsch.flexmark.util.sequence.BasedSequence baseSeq,protected final non-sealed int endOffset,protected final non-sealed int length,protected final non-sealed int startOffset
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/SegmentedSequenceTree.java
|
Cache
|
create
|
class Cache {
final @NotNull Segment segment;
final @NotNull CharSequence chars;
final int indexDelta;
public Cache(@NotNull Segment segment, @NotNull CharSequence chars, int startIndex) {
this.segment = segment;
this.chars = chars;
indexDelta = startIndex - segment.getStartIndex();
}
public char charAt(int index) {
return chars.charAt(index + indexDelta);
}
public int charIndex(int index) {
return index + indexDelta;
}
}
private SegmentedSequenceTree(BasedSequence baseSeq, int startOffset, int endOffset, int length, @NotNull SegmentTree segmentTree) {
super(baseSeq, startOffset, endOffset, length);
this.segmentTree = segmentTree;
startIndex = 0;
startPos = 0;
endPos = segmentTree.size();
}
private SegmentedSequenceTree(BasedSequence baseSeq, @NotNull SegmentTree segmentTree, @NotNull SegmentTreeRange subSequenceRange) {
super(baseSeq, subSequenceRange.startOffset, subSequenceRange.endOffset, subSequenceRange.length);
this.segmentTree = segmentTree;
startIndex = subSequenceRange.startIndex;
startPos = subSequenceRange.startPos;
endPos = subSequenceRange.endPos;
}
@NotNull
private Cache getCache(int index) {
Cache cache = this.cache.get();
if (cache == null || cache.segment.notInSegment(index + startIndex)) {
Segment segment = segmentTree.findSegment(index + startIndex, startPos, endPos, baseSeq, cache == null ? null : cache.segment);
assert segment != null;
cache = new Cache(segment, segment.getCharSequence(), startIndex);
this.cache.set(cache);
}
return cache;
}
@Nullable
private Segment getCachedSegment() {
Cache cache = this.cache.get();
return cache == null ? null : cache.segment;
}
@Override
public int getIndexOffset(int index) {
if (index == length) {
Cache cache = getCache(index - 1);
CharSequence charSequence = cache.chars;
if (charSequence instanceof BasedSequence) {
return ((BasedSequence) charSequence).getIndexOffset(cache.charIndex(index));
} else {
return -1;
}
} else {
SequenceUtils.validateIndexInclusiveEnd(index, length());
Cache cache = getCache(index);
CharSequence charSequence = cache.chars;
if (charSequence instanceof BasedSequence) {
return ((BasedSequence) charSequence).getIndexOffset(cache.charIndex(index));
} else {
return -1;
}
}
}
@Override
public void addSegments(@NotNull IBasedSegmentBuilder<?> builder) {
segmentTree.addSegments(builder, startIndex, startIndex + length, startOffset, endOffset, startPos, endPos);
}
@NotNull
@Override
public SegmentTree getSegmentTree() {
return segmentTree;
}
@Override
public char charAt(int index) {
SequenceUtils.validateIndex(index, length());
return getCache(index).charAt(index);
}
@NotNull
@Override
public BasedSequence subSequence(int startIndex, int endIndex) {
if (startIndex == 0 && endIndex == length) {
return this;
} else {
SequenceUtils.validateStartEnd(startIndex, endIndex, length());
SegmentTreeRange subSequenceRange = segmentTree.getSegmentRange(startIndex + this.startIndex, endIndex + this.startIndex, startPos, endPos, baseSeq, getCachedSegment());
return new SegmentedSequenceTree(baseSeq, segmentTree, subSequenceRange);
}
}
/**
* Base Constructor
*
* @param baseSeq base sequence
* @param builder builder containing segments for this sequence
* @return segmented sequence
*/
public static SegmentedSequenceTree create(@NotNull BasedSequence baseSeq, ISegmentBuilder<?> builder) {<FILL_FUNCTION_BODY>
|
SegmentTree segmentTree = SegmentTree.build(builder.getSegments(), builder.getText());
if (baseSeq.anyOptions(F_COLLECT_SEGMENTED_STATS)) {
SegmentedSequenceStats stats = baseSeq.getOption(SEGMENTED_STATS);
if (stats != null) {
stats.addStats(builder.noAnchorsSize(), builder.length(), segmentTree.getTreeData().length * 4 + segmentTree.getSegmentBytes().length);
}
}
return new SegmentedSequenceTree(baseSeq.getBaseSequence(), builder.getStartOffset(), builder.getEndOffset(), builder.length(), segmentTree);
| 1,083
| 171
| 1,254
|
<methods>public final boolean allOptions(int) ,public final boolean anyOptions(int) ,public final @NotNull BasedSequence baseSubSequence(int, int) ,public static com.vladsch.flexmark.util.sequence.BasedSequence create(com.vladsch.flexmark.util.sequence.BasedSequence, @NotNull Iterable<? extends BasedSequence>) ,public static transient com.vladsch.flexmark.util.sequence.BasedSequence create(com.vladsch.flexmark.util.sequence.BasedSequence[]) ,public static com.vladsch.flexmark.util.sequence.BasedSequence create(com.vladsch.flexmark.util.sequence.builder.SequenceBuilder) ,public final @NotNull Object getBase() ,public final @NotNull BasedSequence getBaseSequence() ,public final int getEndOffset() ,public final T getOption(DataKeyBase<T>) ,public final int getOptionFlags() ,public final @Nullable DataHolder getOptions() ,public final @NotNull Range getSourceRange() ,public final int getStartOffset() ,public final int length() ,public static com.vladsch.flexmark.util.sequence.BasedSequence of(com.vladsch.flexmark.util.sequence.BasedSequence, @NotNull Iterable<? extends BasedSequence>) ,public static transient com.vladsch.flexmark.util.sequence.BasedSequence of(com.vladsch.flexmark.util.sequence.BasedSequence[]) <variables>protected final non-sealed com.vladsch.flexmark.util.sequence.BasedSequence baseSeq,protected final non-sealed int endOffset,protected final non-sealed int length,protected final non-sealed int startOffset
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/TagRange.java
|
TagRange
|
withStart
|
class TagRange extends Range {
protected final String tag;
public static TagRange of(CharSequence tag, int start, int end) {
return new TagRange(tag, start, end);
}
public TagRange(CharSequence tag, Range range) {
super(range);
this.tag = String.valueOf(tag);
}
public TagRange(CharSequence tag, int start, int end) {
super(start, end);
this.tag = String.valueOf(tag);
}
public String getTag() {
return tag;
}
public TagRange withTag(CharSequence tag) {
return this.tag.equals(String.valueOf(tag)) ? this : new TagRange(tag, getStart(), getEnd());
}
@Override
public TagRange withStart(int start) {<FILL_FUNCTION_BODY>}
@Override
public TagRange withEnd(int end) {
return end == getEnd() ? this : new TagRange(getTag(), getStart(), end);
}
@Override
public TagRange withRange(int start, int end) {
return start == getStart() && end == getEnd() ? this : new TagRange(getTag(), start, end);
}
}
|
return start == getStart() ? this : new TagRange(getTag(), start, getEnd());
| 319
| 26
| 345
|
<methods>public @NotNull BasedSequence basedSafeSubSequence(@NotNull CharSequence) ,public @NotNull BasedSequence basedSubSequence(@NotNull CharSequence) ,public @NotNull CharSequence charSubSequence(@NotNull CharSequence) ,public int compare(@NotNull Range) ,public int component1() ,public int component2() ,public boolean contains(@NotNull Range) ,public boolean contains(int) ,public boolean contains(int, int) ,public boolean doesContain(@NotNull Range) ,public boolean doesContain(int) ,public boolean doesContain(int, int) ,public boolean doesNotOverlap(@NotNull Range) ,public boolean doesNotOverlapNorAdjacent(@NotNull Range) ,public boolean doesNotOverlapOrAdjacent(@NotNull Range) ,public boolean doesOverlap(@NotNull Range) ,public boolean doesOverlapOrAdjacent(@NotNull Range) ,public boolean doesProperlyContain(@NotNull Range) ,public static @NotNull Range emptyOf(int) ,public com.vladsch.flexmark.util.sequence.Range endMinus(int) ,public com.vladsch.flexmark.util.sequence.Range endPlus(int) ,public boolean equals(java.lang.Object) ,public @NotNull Range exclude(@NotNull Range) ,public @NotNull Range expandToInclude(@NotNull Range) ,public @NotNull Range expandToInclude(int, int) ,public int getEnd() ,public int getEndOffset() ,public int getSpan() ,public int getStart() ,public int getStartOffset() ,public int hashCode() ,public @NotNull Range include(@NotNull Range) ,public @NotNull Range include(int) ,public @NotNull Range include(int, int) ,public @NotNull Range intersect(@NotNull Range) ,public boolean isAdjacent(int) ,public boolean isAdjacent(@NotNull Range) ,public boolean isAdjacentAfter(int) ,public boolean isAdjacentAfter(@NotNull Range) ,public boolean isAdjacentBefore(int) ,public boolean isAdjacentBefore(@NotNull Range) ,public boolean isContainedBy(@NotNull Range) ,public boolean isContainedBy(int, int) ,public boolean isEmpty() ,public boolean isEnd(int) ,public boolean isEqual(@NotNull Range) ,public boolean isLast(int) ,public boolean isNotEmpty() ,public boolean isNotNull() ,public boolean isNull() ,public boolean isProperlyContainedBy(@NotNull Range) ,public boolean isProperlyContainedBy(int, int) ,public boolean isStart(int) ,public boolean isValidIndex(int) ,public boolean leadBy(int) ,public boolean leads(int) ,public static @NotNull Range of(int, int) ,public static @NotNull Range ofLength(int, int) ,public boolean overlaps(@NotNull Range) ,public boolean overlapsOrAdjacent(@NotNull Range) ,public boolean properlyContains(@NotNull Range) ,public @NotNull RichSequence richSafeSubSequence(@NotNull CharSequence) ,public @NotNull RichSequence richSubSequence(@NotNull CharSequence) ,public @NotNull CharSequence safeSubSequence(@NotNull CharSequence) ,public com.vladsch.flexmark.util.sequence.Range shiftLeft(int) ,public com.vladsch.flexmark.util.sequence.Range shiftRight(int) ,public com.vladsch.flexmark.util.sequence.Range startMinus(int) ,public com.vladsch.flexmark.util.sequence.Range startPlus(int) ,public @NotNull BasedSequence subSequence(@NotNull CharSequence) ,public java.lang.String toString() ,public boolean trailedBy(int) ,public boolean trails(int) ,public com.vladsch.flexmark.util.sequence.Range withEnd(int) ,public com.vladsch.flexmark.util.sequence.Range withRange(int, int) ,public com.vladsch.flexmark.util.sequence.Range withStart(int) <variables>public static final com.vladsch.flexmark.util.sequence.Range EMPTY,public static final com.vladsch.flexmark.util.sequence.Range NULL,private final non-sealed int end,private final non-sealed int start
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/BasedSegmentBuilder.java
|
BasedSegmentBuilder
|
handleOverlap
|
class BasedSegmentBuilder extends SegmentBuilderBase<BasedSegmentBuilder> implements IBasedSegmentBuilder<BasedSegmentBuilder> {
final @NotNull BasedSequence baseSeq;
final @NotNull SegmentOptimizer optimizer;
protected BasedSegmentBuilder(@NotNull BasedSequence baseSeq) {
this(baseSeq, new CharRecoveryOptimizer(PositionAnchor.CURRENT));
}
protected BasedSegmentBuilder(@NotNull BasedSequence baseSeq, @NotNull SegmentOptimizer optimizer) {
super();
this.baseSeq = baseSeq.getBaseSequence();
this.optimizer = optimizer;
}
protected BasedSegmentBuilder(@NotNull BasedSequence baseSeq, int options) {
this(baseSeq, new CharRecoveryOptimizer(PositionAnchor.CURRENT), options);
}
protected BasedSegmentBuilder(@NotNull BasedSequence baseSeq, @NotNull SegmentOptimizer optimizer, int options) {
super(options);
this.baseSeq = baseSeq.getBaseSequence();
this.optimizer = optimizer;
}
@Override
public @NotNull BasedSequence getBaseSequence() {
return baseSeq;
}
@Override
protected Object[] optimizeText(@NotNull Object[] parts) {
return optimizer.apply(baseSeq, parts);
}
@Override
protected Object[] handleOverlap(@NotNull Object[] parts) {<FILL_FUNCTION_BODY>}
@NotNull
@Override
public String toStringWithRangesVisibleWhitespace() {
return super.toStringWithRangesVisibleWhitespace(baseSeq);
}
@NotNull
@Override
public String toStringWithRanges() {
return super.toStringWithRanges(baseSeq);
}
@NotNull
@Override
public String toStringChars() {
return super.toString(baseSeq);
}
@NotNull
public static BasedSegmentBuilder emptyBuilder(@NotNull BasedSequence sequence) {
return new BasedSegmentBuilder(sequence);
}
@NotNull
public static BasedSegmentBuilder emptyBuilder(@NotNull BasedSequence sequence, int options) {
return new BasedSegmentBuilder(sequence, options);
}
@NotNull
public static BasedSegmentBuilder emptyBuilder(@NotNull BasedSequence sequence, @NotNull SegmentOptimizer optimizer) {
return new BasedSegmentBuilder(sequence, optimizer);
}
@NotNull
public static BasedSegmentBuilder emptyBuilder(@NotNull BasedSequence sequence, @NotNull SegmentOptimizer optimizer, int options) {
return new BasedSegmentBuilder(sequence, optimizer, options);
}
}
|
// convert overlap to text from our base
// range overlaps with last segment in the list
Range lastSeg = (Range) parts[0];
CharSequence text = (CharSequence) parts[1];
Range range = (Range) parts[2];
assert !lastSeg.isNull() && lastSeg.getEnd() > range.getStart();
Range overlap;
Range after = Range.NULL;
if (range.getEnd() <= lastSeg.getStart()) {
// the whole thing is before
overlap = range;
} else if (range.getStart() <= lastSeg.getStart()) {
// part before, maybe some after
overlap = Range.of(range.getStart(), Math.min(range.getEnd(), lastSeg.getEnd()));
if (lastSeg.getEnd() < range.getEnd()) {
after = Range.of(lastSeg.getEnd(), range.getEnd());
}
} else if (range.getEnd() <= lastSeg.getEnd()) {
// all contained within
overlap = range;
} else {
assert range.getStart() < lastSeg.getEnd();
overlap = range.withEnd(lastSeg.getEnd());
after = range.withStart(lastSeg.getEnd());
}
int overlapSpan = overlap.getSpan();
assert overlapSpan + after.getSpan() == range.getSpan();
// append overlap to text
if (text.length() == 0) {
parts[1] = baseSeq.subSequence(overlap.getStart(), overlap.getEnd()).toString();
} else {
parts[1] = text.toString() + baseSeq.subSequence(overlap.getStart(), overlap.getEnd()).toString();
}
parts[2] = after;
return parts;
| 646
| 444
| 1,090
|
<methods>public @NotNull BasedSegmentBuilder append(@NotNull Range) ,public @NotNull BasedSegmentBuilder append(int, int) ,public @NotNull BasedSegmentBuilder append(@NotNull CharSequence) ,public @NotNull BasedSegmentBuilder append(char) ,public @NotNull BasedSegmentBuilder append(char, int) ,public @NotNull BasedSegmentBuilder appendAnchor(int) ,public @Nullable Range getBaseSubSequenceRange() ,public int getEndOffset() ,public int getEndOffsetIfNeeded() ,public int getOptions() ,public @NotNull Object getPart(int) ,public @NotNull Iterable<Seg> getSegments() ,public int getSpan() ,public int getStartOffset() ,public int getStartOffsetIfNeeded() ,public com.vladsch.flexmark.util.sequence.builder.SegmentStats getStats() ,public java.lang.CharSequence getText() ,public int getTextFirst256Length() ,public int getTextFirst256Segments() ,public int getTextLength() ,public int getTextSegments() ,public int getTextSpaceLength() ,public int getTextSpaceSegments() ,public boolean haveOffsets() ,public boolean isBaseSubSequenceRange() ,public boolean isEmpty() ,public boolean isIncludeAnchors() ,public boolean isTrackTextFirst256() ,public @NotNull Iterator<Object> iterator() ,public int length() ,public boolean needEndOffset() ,public boolean needStartOffset() ,public int noAnchorsSize() ,public int size() ,public @NotNull String toString(@NotNull CharSequence, @NotNull CharSequence, @NotNull CharSequence, @NotNull Function<CharSequence,CharSequence>) ,public @NotNull String toString(@NotNull CharSequence) ,public java.lang.String toString() ,public java.lang.String toStringPrep() ,public @NotNull String toStringWithRanges(@NotNull CharSequence) ,public @NotNull String toStringWithRangesVisibleWhitespace(@NotNull CharSequence) ,public void trimToSize() <variables>public static final int[] EMPTY_PARTS,public static final int MIN_PART_CAPACITY,protected int anchorsSize,protected int endOffset,protected int immutableOffset,protected int length,protected final non-sealed int options,protected @NotNull int [] parts,protected int partsSize,protected int startOffset,protected final non-sealed com.vladsch.flexmark.util.sequence.builder.SegmentStats stats,protected final java.lang.StringBuilder text,protected final non-sealed com.vladsch.flexmark.util.sequence.builder.SegmentStats textStats
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/RichSequenceBuilder.java
|
RichSequenceBuilder
|
append
|
class RichSequenceBuilder implements ISequenceBuilder<RichSequenceBuilder, RichSequence> {
@NotNull
public static RichSequenceBuilder emptyBuilder() {
return new RichSequenceBuilder();
}
final private StringBuilder segments;
private RichSequenceBuilder() {
this.segments = new StringBuilder();
}
public RichSequenceBuilder(int initialCapacity) {
this.segments = new StringBuilder(initialCapacity);
}
@NotNull
public RichSequenceBuilder getBuilder() {
return new RichSequenceBuilder();
}
@Override
public char charAt(int index) {
return segments.charAt(index);
}
@NotNull
@Override
public RichSequenceBuilder append(@Nullable CharSequence chars, int startIndex, int endIndex) {<FILL_FUNCTION_BODY>}
@NotNull
@Override
public RichSequenceBuilder append(char c) {
segments.append(c);
return this;
}
@NotNull
@Override
public RichSequenceBuilder append(char c, int count) {
while (count-- > 0) segments.append(c);
return this;
}
@NotNull
@Override
public RichSequence getSingleBasedSequence() {
return toSequence();
}
@NotNull
@Override
public RichSequence toSequence() {
return RichSequence.of(segments);
}
@Override
public int length() {
return segments.length();
}
@Override
public String toString() {
return segments.toString();
}
}
|
if (chars != null && chars.length() > 0 && startIndex < endIndex) {
segments.append(chars, startIndex, endIndex);
}
return this;
| 399
| 51
| 450
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/Seg.java
|
Seg
|
toString
|
class Seg {
final public static Seg NULL = new Seg(Range.NULL.getStart(), Range.NULL.getEnd());
final public static Seg ANCHOR_0 = new Seg(0, 0);
final public static int MAX_TEXT_OFFSET = Integer.MAX_VALUE >> 1;
final public static int F_TEXT_OPTION = Integer.MAX_VALUE & ~(MAX_TEXT_OFFSET);
final private int start;
final private int end;
private Seg(int start, int end) {
this.start = start;
this.end = end;
}
public int getStart() {
return start;
}
public int getEnd() {
return end;
}
public int getSegStart() {
return isText() ? getTextStart() : start;
}
public int getSegEnd() {
return isText() ? getTextEnd() : end;
}
public int getTextStart() {
return getTextOffset(start);
}
public static int getTextOffset(int startOffset) {
return (-startOffset - 1) & MAX_TEXT_OFFSET;
}
public int getTextEnd() {
return getTextOffset(end);
}
public boolean isFirst256Start() {
return isFirst256Start(start);
}
public static boolean isFirst256Start(int start) {
return ((-start - 1) & F_TEXT_OPTION) != 0;
}
public boolean isRepeatedTextEnd() {
return isRepeatedTextEnd(end);
}
public static boolean isRepeatedTextEnd(int end) {
return ((-end - 1) & F_TEXT_OPTION) != 0;
}
public boolean isText() {
return start < 0 && end < 0 && (start & MAX_TEXT_OFFSET) > (end & MAX_TEXT_OFFSET);
}
/**
* Test segment type being from original sequence
*
* @return true if it is
*/
public boolean isBase() {
return start >= 0 && end >= 0 && start <= end;
}
/**
* Test segment type being from original sequence
*
* @return true if it is
*/
public boolean isAnchor() {
return start >= 0 && end >= 0 && start == end;
}
public boolean isNull() {
return !(isBase() || isText());
}
@NotNull
public Range getRange() {
assert isBase();
return Range.of(start, end);
}
/**
* Return length of text or if text is null span of range
*
* @return length of this part in the sequence
*/
public int length() {
return isBase() ? end - start : isText() ? (start & MAX_TEXT_OFFSET) - (end & MAX_TEXT_OFFSET) : 0;
}
public String toString(@NotNull CharSequence allText) {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
if (this.isNull()) {
return "NULL";
} else if (isBase()) {
if (start == end) {
return "BASE[" + start + ")";
} else {
return "BASE[" + start + ", " + end + ")";
}
} else {
return "TEXT[" + getTextStart() + ", " + getTextEnd() + ")";
}
}
@NotNull
public static Seg segOf(int startOffset, int endOffset) {
return startOffset == 0 && endOffset == 0 ? ANCHOR_0 : new Seg(startOffset, endOffset);
}
public static int getTextStart(int startOffset, boolean isFirst256) {
assert startOffset < MAX_TEXT_OFFSET;
return -(isFirst256 ? startOffset | F_TEXT_OPTION : startOffset) - 1;
}
public static int getTextEnd(int startOffset, boolean isRepeatedText) {
assert startOffset < MAX_TEXT_OFFSET;
return -(isRepeatedText ? startOffset | F_TEXT_OPTION : startOffset) - 1;
}
@NotNull
public static Seg textOf(int startOffset, int endOffset, boolean isFirst256, boolean isRepeatedText) {
return new Seg(getTextStart(startOffset, isFirst256), getTextEnd(endOffset, isRepeatedText));
}
}
|
if (this.isNull()) {
return "NULL";
} else if (isBase()) {
if (start == end) {
return "[" + start + ")";
} else {
return "[" + start + ", " + end + ")";
}
} else {
CharSequence charSequence = allText.subSequence(getTextStart(), getTextEnd());
if (isRepeatedTextEnd() && length() > 1) {
if (isFirst256Start()) {
return "a:" + (length() + "x'" + escapeJavaString(charSequence.subSequence(0, 1)) + "'");
} else {
return "" + (length() + "x'" + escapeJavaString(charSequence.subSequence(0, 1)) + "'");
}
} else {
String chars = length() <= 20 ? charSequence.toString() : charSequence.subSequence(0, 10).toString() + "…" + charSequence.subSequence(length() - 10, length()).toString();
if (isFirst256Start()) {
return "a:'" + escapeJavaString(chars) + "'";
} else {
return "'" + escapeJavaString(chars) + "'";
}
}
}
| 1,153
| 318
| 1,471
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentBuilderBase.java
|
SegIterator
|
handleOverlap
|
class SegIterator implements Iterator<Seg> {
final SegmentBuilderBase<?> builder;
int nextIndex;
public SegIterator(SegmentBuilderBase<?> builder) {
this.builder = builder;
}
@Override
public boolean hasNext() {
return nextIndex < builder.size();
}
@Override
public Seg next() {
return builder.getSegPart(nextIndex++);
}
}
@Override
public int getOptions() {
return options;
}
@Override
public boolean isIncludeAnchors() {
return (options & F_INCLUDE_ANCHORS) != 0;
}
/**
* Span for offsets of this list
*
* @return -ve if no information in the list, or span of offsets
*/
@Override
public int getSpan() {
return startOffset > endOffset ? -1 : endOffset - startOffset;
}
@Nullable
private Seg getSegOrNull(int index) {
int i = index * 2;
return i + 1 >= parts.length ? null : Seg.segOf(parts[i], parts[i + 1]);
}
@NotNull
private Seg getSeg(int index) {
int i = index * 2;
return i + 1 >= parts.length ? Seg.NULL : Seg.segOf(parts[i], parts[i + 1]);
}
@NotNull
public Object getPart(int index) {
if (index == partsSize && haveDanglingText()) {
// return dangling text
return text.subSequence(immutableOffset, text.length());
} else {
int i = index * 2;
Seg seg = i + 1 >= parts.length ? Seg.NULL : Seg.segOf(parts[i], parts[i + 1]);
return seg.isBase() ? seg.getRange() : seg.isText() ? text.subSequence(seg.getTextStart(), seg.getTextEnd()) : Range.NULL;
}
}
@NotNull
Seg getSegPart(int index) {
if (index == partsSize && haveDanglingText()) {
// return dangling text
return Seg.textOf(immutableOffset, text.length(), textStats.isTextFirst256(), textStats.isRepeatedText());
} else {
int i = index * 2;
return i + 1 >= parts.length ? Seg.NULL : Seg.segOf(parts[i], parts[i + 1]);
}
}
private void setSegEnd(int index, int endOffset) {
int i = index * 2;
assert i + 1 < parts.length;
// parts[i] = startOffset;
// adjust anchor count
if (parts[i] == endOffset) {
if (parts[i] != parts[i + 1]) anchorsSize++;
} else if (parts[i] == parts[i + 1]) anchorsSize--;
parts[i + 1] = endOffset;
}
private void addSeg(int startOffset, int endOffset) {
ensureCapacity(partsSize);
int i = partsSize * 2;
parts[i] = startOffset;
parts[i + 1] = endOffset;
partsSize++;
if (startOffset == endOffset) anchorsSize++;
}
@Nullable
private Seg lastSegOrNull() {
return partsSize == 0 ? null : getSegOrNull(partsSize - 1);
}
protected boolean haveDanglingText() {
return text.length() > immutableOffset;
}
protected Object[] optimizeText(@NotNull Object[] parts) {
return parts;
}
protected Object[] handleOverlap(@NotNull Object[] parts) {<FILL_FUNCTION_BODY>
|
// range overlaps with last segment in the list
Range lastSeg = (Range) parts[0];
CharSequence text = (CharSequence) parts[1];
Range range = (Range) parts[2];
assert !lastSeg.isNull() && lastSeg.getEnd() > range.getStart();
if (lastSeg.getEnd() < range.getEnd()) {
// there is a part of the overlap outside the last seg range
if (text.length() > 0) {
// append the chopped off base part
parts[2] = Range.of(lastSeg.getEnd(), range.getEnd());
} else {
// extend the last base seg to include this range
parts[0] = lastSeg.withEnd(range.getEnd());
parts[2] = Range.NULL;
}
} else {
parts[2] = Range.NULL;
}
return parts;
| 969
| 227
| 1,196
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/SegmentedSequenceStats.java
|
StatsEntry
|
getStatsText
|
class StatsEntry implements Comparable<StatsEntry> {
int segments;
int count;
final MinMaxAvgLong segStats = new MinMaxAvgLong();
final MinMaxAvgLong length = new MinMaxAvgLong();
final MinMaxAvgLong overhead = new MinMaxAvgLong();
public StatsEntry(int segments) {
assert segments >= 1 : "segments: " + segments + " < 1";
this.segments = segments;
}
public void add(int segments, int length, int overhead) {
count++;
this.segStats.add(segments);
this.length.add(length);
this.overhead.add(overhead);
}
public void add(@NotNull StatsEntry other) {
count += other.count;
this.segStats.add(other.segStats);
this.length.add(other.length);
this.overhead.add(other.overhead);
}
@Override
public int compareTo(@NotNull SegmentedSequenceStats.StatsEntry o) {
int segs = Integer.compare(segments, o.segments);
if (segs != 0) return segs;
else return Integer.compare(count, o.count);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
return segments == ((StatsEntry) o).segments;
}
@Override
public int hashCode() {
return segments;
}
}
private ArrayList<SegmentedSequenceStats.StatsEntry> aggregatedStats;
final private HashMap<StatsEntry, StatsEntry> stats = new HashMap<>();
private SegmentedSequenceStats() {
}
public void addStats(int segments, int length, int overhead) {
StatsEntry entry = new StatsEntry(segments);
entry = stats.computeIfAbsent(entry, k -> k);
entry.add(segments, length, overhead);
}
public int getCount(int segments) {
StatsEntry entry = new StatsEntry(segments);
if (stats.containsKey(entry)) {
return stats.get(entry).count;
}
return 0;
}
@NotNull
public String getStatsText(List<StatsEntry> entries) {<FILL_FUNCTION_BODY>
|
StringBuilder out = new StringBuilder();
int iMax = entries.size();
out.append(
String.format("%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%10s,%8s",
"count",
"min-seg",
"avg-seg",
"max-seg",
"min-len",
"avg-len",
"max-len",
"min-ovr",
"avg-ovr",
"max-ovr",
"tot-len",
"tot-chr",
"tot-ovr",
"ovr %"
)
).append("\n");
for (int i = iMax; i-- > 0; ) {
StatsEntry entry = entries.get(i);
out.append(
String.format("%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%10d,%8.3f",
entry.count,
entry.count == 1 ? entry.segments : entry.segStats.getMin(),
entry.count == 1 ? entry.segments : entry.segStats.getAvg(entry.count),
entry.count == 1 ? entry.segments : entry.segStats.getMax(),
entry.length.getMin(),
entry.length.getAvg(entry.count),
entry.length.getMax(),
entry.overhead.getMin(),
entry.overhead.getAvg(entry.count),
entry.overhead.getMax(),
entry.length.getTotal(),
entry.length.getTotal() * 2,
entry.overhead.getTotal(),
entry.length.getTotal() == 0 ? 0 : 100.0 * entry.overhead.getTotal() / entry.length.getTotal() / 2.0
)
).append("\n");
}
return out.toString();
| 619
| 567
| 1,186
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/StringSequenceBuilder.java
|
StringSequenceBuilder
|
append
|
class StringSequenceBuilder implements ISequenceBuilder<StringSequenceBuilder, CharSequence> {
@NotNull
public static StringSequenceBuilder emptyBuilder() {
return new StringSequenceBuilder();
}
final private StringBuilder segments;
private StringSequenceBuilder() {
this.segments = new StringBuilder();
}
public StringSequenceBuilder(int initialCapacity) {
this.segments = new StringBuilder(initialCapacity);
}
@NotNull
public StringSequenceBuilder getBuilder() {
return new StringSequenceBuilder();
}
@Override
public char charAt(int index) {
return segments.charAt(index);
}
@NotNull
@Override
public StringSequenceBuilder append(@Nullable CharSequence chars, int startIndex, int endIndex) {<FILL_FUNCTION_BODY>}
@NotNull
@Override
public StringSequenceBuilder append(char c) {
segments.append(c);
return this;
}
@NotNull
@Override
public StringSequenceBuilder append(char c, int count) {
while (count-- > 0) segments.append(c);
return this;
}
@NotNull
@Override
public CharSequence getSingleBasedSequence() {
return toSequence();
}
@NotNull
@Override
public CharSequence toSequence() {
return segments;
}
@Override
public int length() {
return segments.length();
}
@Override
public String toString() {
return segments.toString();
}
}
|
if (chars != null && chars.length() > 0 && startIndex < endIndex) {
segments.append(chars, startIndex, endIndex);
}
return this;
| 393
| 51
| 444
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/BasedOffsetTracker.java
|
BasedOffsetTracker
|
getOffsetInfo
|
class BasedOffsetTracker {
protected final @NotNull BasedSequence sequence; // sequence on which this tracker is based, not the base sequence of original sequence
protected final @NotNull SegmentOffsetTree segmentOffsetTree;
private @Nullable Segment lastSegment;
protected BasedOffsetTracker(@NotNull BasedSequence sequence, @NotNull SegmentTree segmentTree) {
this.sequence = sequence;
this.segmentOffsetTree = segmentTree.getSegmentOffsetTree(sequence.getBaseSequence());
}
protected BasedOffsetTracker(@NotNull BasedSequence sequence, @NotNull SegmentOffsetTree segmentOffsetTree) {
this.sequence = sequence;
this.segmentOffsetTree = segmentOffsetTree;
}
public int size() {
return segmentOffsetTree.size();
}
/**
* Return the range of indices in the sequence of this based offset tracker that correspond
* to the given offset in the base sequence from which this sequence was derived.
* <p>
* NOTE: indented use is the recover the editing caret position from original text after some text
* transformation such as formatting, rendering HTML or paragraph wrapping.
*
* @param offset offset in base sequence
* @param isEndOffset if true then offset represents the range [offset, offset) so it is located between character at offset-1 and character at offset
* if false then offset represents the character at offset and the range [offset, offset+1)
* @return information about the offset in this sequence
*/
@NotNull
public OffsetInfo getOffsetInfo(int offset, boolean isEndOffset) {<FILL_FUNCTION_BODY>}
@NotNull
public BasedSequence getSequence() {
return sequence;
}
@NotNull
public SegmentOffsetTree getSegmentOffsetTree() {
return segmentOffsetTree;
}
@Override
public String toString() {
return "BasedOffsetTracker{" +
"tree=" + segmentOffsetTree +
'}';
}
/**
* Create a based offset tracker for the given sequence
*
* @param sequence sequence which to create offset tracker
* @return based offset tracker
*/
@NotNull
public static BasedOffsetTracker create(@NotNull BasedSequence sequence) {
SegmentTree segmentTree = sequence.getSegmentTree();
return new BasedOffsetTracker(sequence, segmentTree);
}
/**
* Create a based offset tracker for the given sequence
*
* @param sequence sequence which to create offset tracker
* @param segmentOffsetTree segment offset tree for the sequence
* @return based offset tracker
*/
@NotNull
public static BasedOffsetTracker create(@NotNull BasedSequence sequence, @NotNull SegmentOffsetTree segmentOffsetTree) {
return new BasedOffsetTracker(sequence, segmentOffsetTree);
}
}
|
// if is end offset then will not
int offsetEnd = isEndOffset ? offset : offset + 1;
// if offsetEnd <= firstSegment.startOffset then indexRange is [0,0)
// if offset >= lastSegment.endOffset then indexRange is [sequence.length, sequence.length)
// otherwise, find segment for the offset in the segmentOffsetTree:
// if offsetEnd > segment.startOffset && offset < segment.endOffset then
// indexRange.start = segment.startIndex + offset - segment.startOffset, indexRange.length = offsetEnd-offset
// if offsetEnd == segment.startOffset
// indexRange is preceding TEXT segment indexRange or if none then [segment.startIndex, segment.startIndex)
// if offset == segment.endOffset
// indexRange is preceding TEXT segment indexRange or if none then [segment.startIndex, segment.startIndex)
OffsetInfo lastResult;
if (offsetEnd <= sequence.getStartOffset()) {
// before sequence
lastResult = new OffsetInfo(-1, offset, true, 0);
} else if (offset >= sequence.getEndOffset()) {
// after sequence
lastResult = new OffsetInfo(segmentOffsetTree.size(), offset, true, sequence.length());
} else {
Segment seg = segmentOffsetTree.findSegmentByOffset(offset, sequence.getBaseSequence(), lastSegment);
if (seg == null) {
// outside the sequence
if (offset < segmentOffsetTree.getSegment(0, sequence).getStartOffset()) {
lastResult = new OffsetInfo(-1, offset, true, 0);
} else {
if (offset < segmentOffsetTree.getSegment(segmentOffsetTree.size() - 1, sequence).getEndOffset()) {
// RELEASE: remove exception
throw new IllegalStateException("Unexpected");
}
lastResult = new OffsetInfo(segmentOffsetTree.size(), offset, true, sequence.length());
}
} else {
lastSegment = seg;
if (offsetEnd > seg.getStartOffset() && offset < seg.getEndOffset()) {
// inside base segment
int startIndex = seg.getStartIndex() + offset - seg.getStartOffset();
int endIndex = seg.getStartIndex() + offsetEnd - seg.getStartOffset();
lastResult = new OffsetInfo(seg.getPos(), offset, isEndOffset, startIndex, endIndex);
} else if (offsetEnd <= seg.getStartOffset()) {
int startIndex;
int endIndex;
Segment textSegment = segmentOffsetTree.getPreviousText(seg, sequence);
if (textSegment != null) {
startIndex = textSegment.getStartIndex();
endIndex = textSegment.getEndIndex();
} else {
endIndex = startIndex = seg.getStartIndex();
}
lastResult = new OffsetInfo(seg.getPos() - 1, offset, true, startIndex, endIndex);
} else if (offset >= seg.getEndOffset()) {
int startIndex;
int endIndex;
Segment textSegment = segmentOffsetTree.getNextText(seg, sequence);
if (textSegment != null) {
startIndex = textSegment.getStartIndex();
endIndex = textSegment.getEndIndex();
} else {
endIndex = startIndex = seg.getEndIndex();
}
lastResult = new OffsetInfo(seg.getPos() + 1, offset, true, startIndex, endIndex);
} else {
throw new IllegalStateException(String.format("Unexpected offset: [%d, %d), seg: %s, not inside nor at start nor at end", offset, offsetEnd, seg.toString()));
}
}
}
return lastResult;
| 689
| 934
| 1,623
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/OffsetInfo.java
|
OffsetInfo
|
toString
|
class OffsetInfo {
final public int pos;
final public int offset;
final public boolean isEndOffset;
final public int startIndex;
final public int endIndex;
public OffsetInfo(int pos, int offset, boolean isEndOffset, int startIndex) {
this(pos, offset, isEndOffset, startIndex, startIndex);
}
public OffsetInfo(int pos, int offset, boolean isEndOffset, int startIndex, int endIndex) {
this.pos = pos;
this.offset = offset;
this.isEndOffset = isEndOffset;
this.startIndex = startIndex;
this.endIndex = endIndex;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "OffsetInfo{ " +
"p=" + pos +
", o=" + (isEndOffset ? "[" + offset + ")" : "[" + offset + ", " + (offset + 1) + ")") +
", i=[" + startIndex + ", " + endIndex + ") }";
| 196
| 77
| 273
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/Segment.java
|
Text
|
getSegByteLength
|
class Text extends Segment {
protected final @NotNull CharSequence chars;
public Text(int pos, byte[] bytes, int byteOffset, int indexOffset) {
super(pos, bytes, byteOffset, indexOffset);
int type = bytes[byteOffset++] & 0x00ff;
int segTypeMask = type & TYPE_MASK;
int length;
if (hasAll(type, TYPE_NO_SIZE_BYTES)) {
length = type & 0x000f;
} else {
int lengthBytes = (type & TYPE_LENGTH_BYTES) >> 2;
length = getInt(bytes, byteOffset, lengthBytes + 1);
byteOffset += lengthBytes + 1;
}
switch (segTypeMask) {
case TYPE_TEXT:
chars = new TextCharSequence(bytes, byteOffset, 0, length);
break;
case TYPE_TEXT_ASCII:
chars = new TextAsciiCharSequence(bytes, byteOffset, 0, length);
break;
case TYPE_REPEATED_TEXT:
chars = new TextRepeatedSequence(getChar(bytes, byteOffset), length);
break;
case TYPE_REPEATED_ASCII:
chars = new TextRepeatedSequence((char) (0x00ff & bytes[byteOffset]), length);
break;
case TYPE_REPEATED_SPACE:
chars = new TextRepeatedSequence(' ', length);
break;
case TYPE_REPEATED_EOL:
chars = new TextRepeatedSequence('\n', length);
break;
default:
throw new IllegalStateException("Invalid text type " + segTypeMask);
}
}
@Override
public int length() {
return chars.length();
}
@Override
public char charAt(int index) {
if (index < startIndex || index - startIndex >= chars.length()) {
throw new IndexOutOfBoundsException("index " + index + " out of bounds [" + startIndex + ", " + startIndex + chars.length() + ")");
}
return chars.charAt(index - startIndex);
}
@Override
public boolean isBase() {
return false;
}
@Override
public boolean isAnchor() {
return false;
}
@Override
public boolean isText() {
return true;
}
int textType() {
return bytes[byteOffset] & TYPE_MASK;
}
@Override
public boolean isFirst256Start() {
int textType = textType();
return textType == TYPE_TEXT_ASCII || textType == TYPE_REPEATED_ASCII || textType == TYPE_REPEATED_SPACE || textType == TYPE_REPEATED_EOL;
}
@Override
public boolean isRepeatedTextEnd() {
int textType = textType();
return textType == TYPE_REPEATED_TEXT || textType == TYPE_REPEATED_ASCII || textType == TYPE_REPEATED_SPACE || textType == TYPE_REPEATED_EOL;
}
@Override
public int getStartOffset() {
return -1;
}
@Override
public int getEndOffset() {
return -1;
}
@NotNull
@Override
public CharSequence getCharSequence() {
return chars;
}
}
public static Segment getSegment(byte[] bytes, int byteOffset, int pos, int indexOffset, @NotNull BasedSequence basedSequence) {
int type = bytes[byteOffset] & TYPE_MASK;
switch (type) {
case TYPE_ANCHOR:
case TYPE_BASE:
return new Base(pos, bytes, byteOffset, indexOffset, basedSequence);
case TYPE_TEXT:
case TYPE_REPEATED_TEXT:
case TYPE_TEXT_ASCII:
case TYPE_REPEATED_ASCII:
case TYPE_REPEATED_SPACE:
case TYPE_REPEATED_EOL:
return new Text(pos, bytes, byteOffset, indexOffset);
default:
throw new IllegalStateException("Invalid text type " + type);
}
}
public static SegType getSegType(@NotNull Seg seg, @NotNull CharSequence textChars) {
if (seg.isBase()) {
return seg.isAnchor() ? SegType.ANCHOR : SegType.BASE;
} else if (seg.isText()) {
boolean first256Start = seg.isFirst256Start();
boolean repeatedTextEnd = seg.isRepeatedTextEnd();
if (first256Start) {
// ascii text
if (repeatedTextEnd) {
// repeated chars
char c = textChars.charAt(seg.getTextStart());
if (c == ' ') return SegType.REPEATED_SPACE;
else if (c == '\n') return SegType.REPEATED_EOL;
else return SegType.REPEATED_ASCII;
} else {
return SegType.TEXT_ASCII;
}
} else {
return repeatedTextEnd ? SegType.REPEATED_TEXT : SegType.TEXT;
}
} else {
throw new IllegalStateException("Unknown seg type " + seg);
}
}
public static int getOffsetBytes(int offset) {
return offset < 16 ? 0 : offset < 256 ? 1 : offset < 65536 ? 2 : offset < 65536 * 256 ? 3 : 4;
}
public static int getLengthBytes(int length) {
return length < 16 ? 0 : length < 256 ? 1 : length < 65536 ? 2 : length < 65536 * 256 ? 3 : 4;
}
public static int getIntBytes(int length) {
return length < 256 ? 1 : length < 65536 ? 2 : length < 65536 * 256 ? 3 : 4;
}
public static int getSegByteLength(@NotNull Segment.SegType segType, int segStart, int segLength) {<FILL_FUNCTION_BODY>
|
int length = 1;
if (segType.hasBoth()) {
length += getIntBytes(segStart) + getIntBytes(segLength);
} else if (segType.hasOffset()) {
length += getOffsetBytes(segStart);
} else if (segType.hasLength()) {
length += getLengthBytes(segLength);
}
if (segType.hasChar()) length += 2;
else if (segType.hasChars()) length += 2 * segLength;
else if (segType.hasByte()) length += 1;
else if (segType.hasBytes()) length += segLength;
return length;
| 1,607
| 163
| 1,770
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentOffsetTree.java
|
SegmentOffsetTree
|
findSegmentPos
|
class SegmentOffsetTree extends SegmentTree {
final protected @NotNull int[] startIndices;
protected SegmentOffsetTree(@NotNull int[] treeData, @NotNull byte[] segmentBytes, @NotNull int[] startIndices) {
super(treeData, segmentBytes);
this.startIndices = startIndices;
}
@NotNull
public static SegmentOffsetTree build(@NotNull Iterable<Seg> segments, @NotNull CharSequence allText) {
SegmentTreeData segmentTreeData = buildTreeData(segments, allText, false);
assert segmentTreeData.startIndices != null;
return new SegmentOffsetTree(segmentTreeData.treeData, segmentTreeData.segmentBytes, segmentTreeData.startIndices);
}
@NotNull
public static SegmentOffsetTree build(@NotNull BasedSegmentBuilder builder) {
@NotNull SegmentTreeData segmentTreeData = buildTreeData(builder.getSegments(), builder.getText(), true);
return new SegmentTree(segmentTreeData.treeData, segmentTreeData.segmentBytes).getSegmentOffsetTree(builder.getBaseSequence());
}
@NotNull
public static SegmentOffsetTree build(@NotNull BasedSequence baseSeq) {
return baseSeq.getSegmentTree().getSegmentOffsetTree(baseSeq);
}
public int endOffset(int pos) {
return super.aggrLength(pos);
}
public int getStartIndex(int pos) {
return pos < 0 ? 0 : pos >= startIndices.length ? startIndices[startIndices.length - 1] : startIndices[pos];
}
@NotNull
public Segment getSegment(int pos, @NotNull BasedSequence baseSeq) {
return Segment.getSegment(segmentBytes, byteOffset(pos), pos, startIndices[pos], baseSeq);
}
public @Nullable SegmentTreePos findSegmentPosByOffset(int offset) {
return findSegmentPos(offset, treeData, 0, size());
}
@Nullable
public Segment getPreviousText(@NotNull Segment segment, @NotNull BasedSequence baseSeq) {
if (segment.getPos() == 0) {
if (segment.getStartIndex() > 0) {
Segment textSeg = getSegment(0, -1, 0, baseSeq);
if (textSeg.isText()) return textSeg;
}
} else {
Segment prevSegment = getSegment(segment.getPos() - 1, baseSeq);
return getNextText(prevSegment, baseSeq);
}
return null;
}
@Nullable
public Segment getNextText(@NotNull Segment segment, @NotNull BasedSequence baseSeq) {
if (segment.getByteOffset() + segment.getByteLength() < segmentBytes.length) {
Segment textSeg = getSegment(segment.getByteOffset() + segment.getByteLength(), -1, segment.getEndIndex(), baseSeq);
if (textSeg.isText()) return textSeg;
}
return null;
}
public @Nullable Segment findSegmentByOffset(int offset, @NotNull BasedSequence baseSeq, @Nullable Segment hint) {
int startPos = 0;
int endPos = size();
SegmentTreePos treePos = super.findSegmentPos(offset, startPos, endPos);
if (treePos != null) {
return Segment.getSegment(segmentBytes, byteOffset(treePos.pos), treePos.pos, startIndices[treePos.pos], baseSeq);
}
return null;
}
@NotNull
public String toString(@NotNull BasedSequence baseSeq) {
DelimitedBuilder out = new DelimitedBuilder(", ");
out.append(getClass().getSimpleName()).append("{aggr: {");
int iMax = size();
for (int i = 0; i < iMax; i++) {
out.append("[").append(aggrLength(i)).append(", ").append(byteOffset(i)).append(":");
out.append(", :").append(startIndices[i]);
out.append("]").mark();
}
out.unmark().append(" }, seg: { ");
int offset = 0;
while (offset < segmentBytes.length) {
Segment segment = Segment.getSegment(segmentBytes, offset, 0, 0, baseSeq);
out.append(offset).append(":").append(segment).mark();
offset += segment.getByteLength();
}
out.unmark().append(" } }");
return out.toString();
}
@Deprecated
@Override
public boolean hasPreviousAnchor(int pos) {
return false;
}
@Deprecated
@Override
public int previousAnchorOffset(int pos) {
return 0;
}
@Deprecated
@Override
public int aggrLength(int pos) {
//NOTE: used by toString() so can only deprecate
return super.aggrLength(pos);
}
@Deprecated
@Override
public @Nullable SegmentTreePos findSegmentPos(int index) {
throw new IllegalStateException("Method in SegmentOffsetTree should not be used");
}
@Deprecated
@Override
public @Nullable Segment findSegment(int index, @NotNull BasedSequence baseSeq, @Nullable Segment hint) {
throw new IllegalStateException("Method in SegmentOffsetTree should not be used");
}
@Deprecated
@Override
public @Nullable Segment findSegment(int index, int startPos, int endPos, @NotNull BasedSequence baseSeq, @Nullable Segment hint) {
throw new IllegalStateException("Method in SegmentOffsetTree should not be used");
}
@Deprecated
@Override
public @NotNull SegmentTreeRange getSegmentRange(int startIndex, int endIndex, int startPos, int endPos, @NotNull BasedSequence baseSeq, @Nullable Segment hint) {
return super.getSegmentRange(startIndex, endIndex, startPos, endPos, baseSeq, hint);
}
@Deprecated
@Override
public void addSegments(@NotNull IBasedSegmentBuilder<?> builder, @NotNull SegmentTreeRange treeRange) {
throw new IllegalStateException("Method in SegmentOffsetTree should not be used");
}
@Deprecated
@Override
public void addSegments(@NotNull IBasedSegmentBuilder<?> builder, int startIndex, int endIndex, int startOffset, int endOffset, int startPos, int endPos) {
throw new IllegalStateException("Method in SegmentOffsetTree should not be used");
}
@Deprecated
@Override
public @Nullable SegmentTreePos findSegmentPos(int index, int startPos, int endPos) {<FILL_FUNCTION_BODY>}
@Deprecated
@Override
public @Nullable Segment getPrevAnchor(int pos, @NotNull BasedSequence baseSeq) {
throw new IllegalStateException("Method in SegmentOffsetTree should not be used");
}
}
|
throw new IllegalStateException("Method in SegmentOffsetTree should not be used");
| 1,769
| 22
| 1,791
|
<methods>public void addSegments(@NotNull IBasedSegmentBuilder<?>, @NotNull SegmentTreeRange) ,public void addSegments(@NotNull IBasedSegmentBuilder<?>, int, int, int, int, int, int) ,public int aggrLength(int) ,public static int aggrLength(int, int[]) ,public static @NotNull SegmentTree build(@NotNull Iterable<Seg>, @NotNull CharSequence) ,public static @NotNull SegmentTree build(@NotNull BasedSegmentBuilder) ,public static SegmentTree.@NotNull SegmentTreeData buildTreeData(@NotNull Iterable<Seg>, @NotNull CharSequence, boolean) ,public int byteOffset(int) ,public static int byteOffset(int, int[]) ,public int byteOffsetData(int) ,public static int byteOffsetData(int, int[]) ,public @Nullable Segment findSegment(int, @NotNull BasedSequence, @Nullable Segment) ,public @Nullable Segment findSegment(int, int, int, @NotNull BasedSequence, @Nullable Segment) ,public static @Nullable Segment findSegment(int, int[], int, int, byte[], @NotNull BasedSequence) ,public @Nullable SegmentTreePos findSegmentPos(int) ,public @Nullable SegmentTreePos findSegmentPos(int, int, int) ,public static @Nullable SegmentTreePos findSegmentPos(int, int[], int, int) ,public static int getAnchorOffset(int) ,public static int getByteOffset(int) ,public static @NotNull CharSequence getCharSequence(@NotNull Segment, int, int, int, int) ,public @Nullable Segment getPrevAnchor(int, @NotNull BasedSequence) ,public static @Nullable Segment getPrevAnchor(int, int[], byte[], @NotNull BasedSequence) ,public @NotNull Segment getSegment(int, int, int, @NotNull BasedSequence) ,public @NotNull Segment getSegment(int, @NotNull BasedSequence) ,public static @NotNull Segment getSegment(int, int[], byte[], @NotNull BasedSequence) ,public byte[] getSegmentBytes() ,public @NotNull SegmentOffsetTree getSegmentOffsetTree(@NotNull BasedSequence) ,public @NotNull SegmentTreeRange getSegmentRange(int, int, int, int, @NotNull BasedSequence, @Nullable Segment) ,public int getTextEndOffset(com.vladsch.flexmark.util.sequence.builder.tree.Segment, @NotNull BasedSequence) ,public int getTextStartOffset(com.vladsch.flexmark.util.sequence.builder.tree.Segment, @NotNull BasedSequence) ,public int[] getTreeData() ,public boolean hasPreviousAnchor(int) ,public static boolean hasPreviousAnchor(int, int[]) ,public int previousAnchorOffset(int) ,public static int previousAnchorOffset(int, int[]) ,public static void setTreeData(int, int[], int, int, int) ,public int size() ,public @NotNull String toString(@NotNull BasedSequence) ,public @NotNull String toString() <variables>public static final int F_ANCHOR_FLAGS,public static final int MAX_VALUE,protected final non-sealed byte[] segmentBytes,protected final non-sealed int[] treeData
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTreePos.java
|
SegmentTreePos
|
equals
|
class SegmentTreePos {
final public int pos;
final public int startIndex;
final public int iterations;
public SegmentTreePos(int pos, int startIndex, int iterations) {
this.pos = pos;
this.startIndex = startIndex;
this.iterations = iterations;
}
@Override
public boolean equals(Object o) {<FILL_FUNCTION_BODY>}
@Override
public int hashCode() {
int result = pos;
result = 31 * result + startIndex;
return result;
}
@Override
public String toString() {
return "{" + pos + ", s: " + startIndex + ", i: " + iterations + '}';
}
}
|
if (this == o) return true;
if (!(o instanceof SegmentTreePos)) return false;
SegmentTreePos pos1 = (SegmentTreePos) o;
if (pos != pos1.pos) return false;
return startIndex == pos1.startIndex;
| 190
| 74
| 264
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/builder/tree/SegmentTreeRange.java
|
SegmentTreeRange
|
toString
|
class SegmentTreeRange {
final public int startIndex;
final public int endIndex;
final public int startOffset;
final public int endOffset;
final public int startPos;
final public int endPos;
final public int length;
public SegmentTreeRange(int startIndex, int endIndex, int startOffset, int endOffset, int startPos, int endPos) {
this.startIndex = startIndex;
this.endIndex = endIndex;
this.startOffset = startOffset;
this.endOffset = endOffset;
this.startPos = startPos;
this.endPos = endPos;
this.length = endIndex - startIndex;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
return "SegmentTreeRange{" +
"startIndex=" + startIndex +
", endIndex=" + endIndex +
", startOffset=" + startOffset +
", endOffset=" + endOffset +
", startPos=" + startPos +
", endPos=" + endPos +
", length=" + length +
'}';
| 198
| 92
| 290
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpaceMapper.java
|
SpaceMapper
|
areEquivalent
|
class SpaceMapper {
final public static CharMapper toNonBreakSpace = new ToNonBreakSpace();
final public static CharMapper fromNonBreakSpace = new FromNonBreakSpace();
public static boolean areEquivalent(char c1, char c2) {<FILL_FUNCTION_BODY>}
public static @NotNull CharMapper toSpaces(@NotNull CharPredicate predicate) {
return new FromPredicate(predicate);
}
private static class FromNonBreakSpace implements CharMapper {
FromNonBreakSpace() {}
@Override
public char map(char c) {
return c == SequenceUtils.NBSP ? SequenceUtils.SPC : c;
}
}
private static class FromPredicate implements CharMapper {
final @NotNull CharPredicate myPredicate;
FromPredicate(@NotNull CharPredicate predicate) {
myPredicate = predicate;
}
@Override
public char map(char c) {
return myPredicate.test(c) ? SequenceUtils.SPC : c;
}
}
private static class ToNonBreakSpace implements CharMapper {
ToNonBreakSpace() {}
@Override
public char map(char c) {
return c == SequenceUtils.SPC ? SequenceUtils.NBSP : c;
}
}
}
|
return c1 == c2 || (c1 == ' ' && c2 == SequenceUtils.NBSP) || (c2 == ' ' && c1 == SequenceUtils.NBSP);
| 331
| 49
| 380
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInCharsHandler.java
|
SpecialLeadInCharsHandler
|
escape
|
class SpecialLeadInCharsHandler implements SpecialLeadInHandler {
final CharPredicate predicate;
protected SpecialLeadInCharsHandler(CharPredicate predicate) {
this.predicate = predicate;
}
/**
* Escape special lead-in characters which start a block element if first non-whitespace on the line
* <p>
* The leadIn sequence is always followed by a space or EOL so if lead in does not require a space to start a block element
* then test if it starts with the special sequence, otherwise test if it equals the special sequence
*
* @param sequence char sequence appearing as first non-whitespace on a line
* @param options options
* @param consumer consumer of char sequences to be called for the leadIn if it is changed by this handler
* @return true if sequence was a lead in for the handler
*/
@Override
public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer<CharSequence> consumer) {<FILL_FUNCTION_BODY>}
/**
* UnEscape special lead-in characters which start a block element if first non-whitespace on the line
* <p>
* The leadIn sequence is always followed by a space or EOL so if lead in does not require a space to start a block element
* then test if it starts with the special sequence, otherwise test if it equals the special sequence
*
* @param sequence char sequence appearing as first non-whitespace on a line
* @param options options
* @param consumer consumer of char sequences to be called for the leadIn if it is changed by this handler
* @return true if sequence was a lead in for the handler
*/
@Override
public boolean unEscape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer<CharSequence> consumer) {
if (sequence.length() == 2 && sequence.charAt(0) == '\\' && predicate.test(sequence.charAt(1))) {
consumer.accept(sequence.subSequence(1));
return true;
}
return false;
}
@NotNull
public static SpecialLeadInCharsHandler create(char leadInChar) {
return new SpecialLeadInCharsHandler(CharPredicate.anyOf(leadInChar));
}
@NotNull
public static SpecialLeadInCharsHandler create(@NotNull CharSequence leadInChar) {
return new SpecialLeadInCharsHandler(CharPredicate.anyOf(leadInChar));
}
}
|
if (sequence.length() == 1 && predicate.test(sequence.charAt(0))) {
consumer.accept("\\");
consumer.accept(sequence);
return true;
}
return false;
| 610
| 55
| 665
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-sequence/src/main/java/com/vladsch/flexmark/util/sequence/mappers/SpecialLeadInStartsWithCharsHandler.java
|
SpecialLeadInStartsWithCharsHandler
|
unEscape
|
class SpecialLeadInStartsWithCharsHandler implements SpecialLeadInHandler {
final CharPredicate predicate;
protected SpecialLeadInStartsWithCharsHandler(CharPredicate predicate) {
this.predicate = predicate;
}
/**
* Escape special lead-in characters which start a block element if first non-whitespace on the line
* <p>
* The leadIn sequence is always followed by a space or EOL so if lead in does not require a space to start a block element
* then test if it starts with the special sequence, otherwise test if it equals the special sequence
*
* @param sequence char sequence appearing as first non-whitespace on a line
* @param options options
* @param consumer consumer of char sequences to be called for the leadIn if it is changed by this handler
* @return true if sequence was a lead in for the handler
*/
@Override
public boolean escape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer<CharSequence> consumer) {
if (sequence.length() >= 1 && predicate.test(sequence.charAt(0))) {
consumer.accept("\\");
consumer.accept(sequence);
return true;
}
return false;
}
/**
* UnEscape special lead-in characters which start a block element if first non-whitespace on the line
* <p>
* The leadIn sequence is always followed by a space or EOL so if lead in does not require a space to start a block element
* then test if it starts with the special sequence, otherwise test if it equals the special sequence
*
* @param sequence char sequence appearing as first non-whitespace on a line
* @param options options
* @param consumer consumer of char sequences to be called for the leadIn if it is changed by this handler
* @return true if sequence was a lead in for the handler
*/
@Override
public boolean unEscape(@NotNull BasedSequence sequence, @Nullable DataHolder options, @NotNull Consumer<CharSequence> consumer) {<FILL_FUNCTION_BODY>}
@NotNull
public static SpecialLeadInStartsWithCharsHandler create(char leadInChar) {
return new SpecialLeadInStartsWithCharsHandler(CharPredicate.anyOf(leadInChar));
}
@NotNull
public static SpecialLeadInStartsWithCharsHandler create(@NotNull CharSequence leadInChar) {
return new SpecialLeadInStartsWithCharsHandler(CharPredicate.anyOf(leadInChar));
}
}
|
if (sequence.length() >= 2 && sequence.charAt(0) == '\\' && predicate.test(sequence.charAt(1))) {
consumer.accept(sequence.subSequence(1));
return true;
}
return false;
| 619
| 64
| 683
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstActionHandler.java
|
AstActionHandler
|
processChildren
|
class AstActionHandler<C extends AstActionHandler<C, N, A, H>, N, A extends AstAction<N>, H extends AstHandler<N, A>> {
final private @NotNull Map<Class<? extends N>, H> customHandlersMap = new HashMap<>();
final private @NotNull AstNode<N> astAdapter;
public AstActionHandler(@NotNull AstNode<N> astAdapter) {
this.astAdapter = astAdapter;
}
@SafeVarargs
final protected @NotNull C addActionHandlers(@NotNull H[]... handlers) {
for (H[] moreHandlers : handlers) {
for (H handler : moreHandlers) {
customHandlersMap.put(handler.getNodeType(), handler);
}
}
//noinspection unchecked
return (C) this;
}
protected @NotNull C addActionHandler(@NotNull H handler) {
customHandlersMap.put(handler.getNodeType(), handler);
//noinspection unchecked
return (C) this;
}
private @Nullable A getAction(@Nullable H handler) {
return handler == null ? null : handler.getAdapter();
}
public @Nullable A getAction(@NotNull N node) {
return getAction(customHandlersMap.get(node.getClass()));
}
public @Nullable A getAction(@NotNull Class<?> nodeClass) {
return getAction(customHandlersMap.get(nodeClass));
}
protected @Nullable H getHandler(@NotNull N node) {
return customHandlersMap.get(node.getClass());
}
protected @Nullable H getHandler(@NotNull Class<?> nodeClass) {
return customHandlersMap.get(nodeClass);
}
public @NotNull Set<Class<? extends N>> getNodeClasses() {
return customHandlersMap.keySet();
}
/**
* Node processing called for every node being processed
* <p>
* Override this to add customizations to standard processing callback.
*
* @param node node being processed
* @param withChildren whether to process child nodes if there is no handler for the node type
* @param processor processor to invoke to perform the processing, BiConsumer taking N node, and A action
*/
protected void processNode(@NotNull N node, boolean withChildren, @NotNull BiConsumer<N, A> processor) {
A action = getAction(node);
if (action != null) {
processor.accept(node, action);
} else if (withChildren) {
processChildren(node, processor);
}
}
protected final void processChildren(@NotNull N node, @NotNull BiConsumer<N, A> processor) {<FILL_FUNCTION_BODY>}
/**
* Process the node and return value from the processor
*
* @param node node to process
* @param defaultValue default value if no handler is defined for the node
* @param processor processor to pass the node and handler for processing
* @param <R> type of result returned by processor
* @return result or defaultValue
*/
final protected <R> R processNodeOnly(@NotNull N node, R defaultValue, @NotNull BiFunction<N, A, R> processor) {
Object[] value = { defaultValue };
processNode(node, false, (n, h) -> value[0] = processor.apply(n, h));
//noinspection unchecked
return (R) value[0];
}
}
|
N child = astAdapter.getFirstChild(node);
while (child != null) {
// A subclass of this visitor might modify the node, resulting in getNext returning a different node or no
// node after visiting it. So get the next node before visiting.
N next = astAdapter.getNext(child);
processNode(child, true, processor);
child = next;
}
| 868
| 100
| 968
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-util-visitor/src/main/java/com/vladsch/flexmark/util/visitor/AstHandler.java
|
AstHandler
|
hashCode
|
class AstHandler<N, A extends AstAction<? super N>> {
final private @NotNull Class<? extends N> aClass;
final private @NotNull A adapter;
public AstHandler(@NotNull Class<? extends N> klass, @NotNull A adapter) {
aClass = klass;
this.adapter = adapter;
}
public @NotNull Class<? extends N> getNodeType() {
return aClass;
}
public @NotNull A getAdapter() {
return adapter;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AstHandler<?, ?> other = (AstHandler<?, ?>) o;
if (aClass != other.aClass) return false;
return adapter == other.adapter;
}
@Override
public int hashCode() {<FILL_FUNCTION_BODY>}
}
|
int result = aClass.hashCode();
result = 31 * result + adapter.hashCode();
return result;
| 254
| 33
| 287
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark-youtrack-converter/src/main/java/com/vladsch/flexmark/youtrack/converter/YouTrackConverterExtension.java
|
YouTrackConverterExtension
|
extend
|
class YouTrackConverterExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension {
private YouTrackConverterExtension() {
}
public static YouTrackConverterExtension create() {
return new YouTrackConverterExtension();
}
@Override
public void extend(Parser.Builder parserBuilder) {
}
@Override
public void rendererOptions(@NotNull MutableDataHolder options) {
String rendererType = HtmlRenderer.TYPE.get(options);
if (rendererType.equals("HTML")) {
// add youtrack equivalence
HtmlRenderer.addRenderTypeEquivalence(options, "YOUTRACK", "JIRA");
options.set(HtmlRenderer.TYPE, "YOUTRACK");
} else if (!rendererType.equals("YOUTRACK")) {
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("YOUTRACK")) {
htmlRendererBuilder.nodeRendererFactory(new YouTrackConverterNodeRenderer.Factory());
} else {
throw new IllegalStateException("YouTrack Converter Extension used with non YouTrack Renderer " + rendererType);
}
| 292
| 75
| 367
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/AutoLink.java
|
AutoLink
|
getSegmentsForChars
|
class AutoLink extends DelimitedLinkNode {
public AutoLink() {
}
@NotNull
@Override
public BasedSequence[] getSegments() {
return new BasedSequence[] { openingMarker, pageRef, anchorMarker, anchorRef, closingMarker };
}
@NotNull
@Override
public BasedSequence[] getSegmentsForChars() {<FILL_FUNCTION_BODY>}
@Override
public void getAstExtra(@NotNull StringBuilder out) {
segmentSpanChars(out, openingMarker, "open");
segmentSpanChars(out, text, "text");
if (pageRef.isNotNull()) segmentSpanChars(out, pageRef, "pageRef");
if (anchorMarker.isNotNull()) segmentSpanChars(out, anchorMarker, "anchorMarker");
if (anchorRef.isNotNull()) segmentSpanChars(out, anchorRef, "anchorRef");
segmentSpanChars(out, closingMarker, "close");
}
public AutoLink(BasedSequence chars) {
super(chars);
}
public AutoLink(BasedSequence openingMarker, BasedSequence text, BasedSequence closingMarker) {
super(openingMarker, text, closingMarker);
setUrlChars(text);
}
}
|
return new BasedSequence[] {
openingMarker,
pageRef,
anchorMarker,
anchorRef,
closingMarker
};
| 312
| 38
| 350
|
<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) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.sequence.BasedSequence getClosingMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getLeadSegment() ,public com.vladsch.flexmark.util.sequence.BasedSequence getOpeningMarker() ,public @NotNull BasedSequence [] getSegments() ,public com.vladsch.flexmark.util.sequence.BasedSequence getText() ,public void setClosingMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setOpeningMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setText(com.vladsch.flexmark.util.sequence.BasedSequence) <variables>protected com.vladsch.flexmark.util.sequence.BasedSequence closingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence openingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence text
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/FencedCodeBlock.java
|
FencedCodeBlock
|
getAstExtra
|
class FencedCodeBlock extends Block implements DoNotDecorate {
private int fenceIndent;
private BasedSequence openingMarker = BasedSequence.NULL;
private BasedSequence info = BasedSequence.NULL;
private BasedSequence attributes = BasedSequence.NULL;
private BasedSequence closingMarker = BasedSequence.NULL;
@Override
public void getAstExtra(@NotNull StringBuilder out) {<FILL_FUNCTION_BODY>}
@NotNull
@Override
public BasedSequence[] getSegments() {
return new BasedSequence[] { openingMarker, info, attributes, getContentChars(), closingMarker };
}
public FencedCodeBlock() {
}
public FencedCodeBlock(BasedSequence chars) {
super(chars);
}
public FencedCodeBlock(BasedSequence chars, BasedSequence openingMarker, BasedSequence info, List<BasedSequence> segments, BasedSequence closingMarker) {
super(chars, segments);
this.openingMarker = openingMarker;
this.info = info;
this.closingMarker = closingMarker;
}
public BasedSequence getOpeningMarker() {
return openingMarker;
}
public void setOpeningMarker(BasedSequence openingMarker) {
this.openingMarker = openingMarker;
}
public void setInfo(BasedSequence info) {
this.info = info;
}
public BasedSequence getClosingMarker() {
return closingMarker;
}
public void setClosingMarker(BasedSequence closingMarker) {
this.closingMarker = closingMarker;
}
public BasedSequence getOpeningFence() {
return this.openingMarker;
}
/**
* @return the sequence for the info part of the node
* @see <a href="http://spec.commonmark.org/0.18/#info-string">CommonMark spec</a>
*/
public BasedSequence getInfo() {
return info;
}
public BasedSequence getAttributes() {
return attributes;
}
public void setAttributes(BasedSequence attributes) {
this.attributes = attributes;
}
public BasedSequence getInfoDelimitedByAny(CharPredicate delimiters) {
BasedSequence language = BasedSequence.NULL;
if (info.isNotNull() && !info.isBlank()) {
int delimiter = info.indexOfAny(delimiters);
if (delimiter == -1) {
language = info;
} else {
language = info.subSequence(0, delimiter);
}
}
return language;
}
public BasedSequence getClosingFence() {
return this.closingMarker;
}
public int getFenceLength() {
return getInfo().length();
}
public int getFenceIndent() {
return fenceIndent;
}
public void setFenceIndent(int fenceIndent) {
this.fenceIndent = fenceIndent;
}
}
|
BasedSequence content = getContentChars();
int lines = getContentLines().size();
segmentSpanChars(out, openingMarker, "open");
segmentSpanChars(out, info, "info");
segmentSpanChars(out, attributes, "attributes");
segmentSpan(out, content, "content");
out.append(" lines[").append(lines).append("]");
segmentSpanChars(out, closingMarker, "close");
| 757
| 113
| 870
|
<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/src/main/java/com/vladsch/flexmark/ast/HardLineBreak.java
|
HardLineBreak
|
collectText
|
class HardLineBreak extends Node implements DoNotTrim, TextContainer {
@NotNull
@Override
public BasedSequence[] getSegments() {
return EMPTY_SEGMENTS;
}
public HardLineBreak() {
}
public HardLineBreak(BasedSequence chars) {
super(chars);
}
@Override
public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?, BasedSequence>, BasedSequence> out, int flags, NodeVisitor nodeVisitor) {<FILL_FUNCTION_BODY>}
}
|
BasedSequence chars = getChars();
out.add(chars.subSequence(chars.length() - 1, chars.length()));
return false;
| 143
| 45
| 188
|
<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/src/main/java/com/vladsch/flexmark/ast/Heading.java
|
Heading
|
getAnchorRefText
|
class Heading extends Block implements AnchorRefTarget {
protected int level;
protected BasedSequence openingMarker = BasedSequence.NULL;
protected BasedSequence text = BasedSequence.NULL;
protected BasedSequence closingMarker = BasedSequence.NULL;
protected String anchorRefId = "";
protected boolean explicitAnchorRefId = false;
@Override
public void getAstExtra(@NotNull StringBuilder out) {
delimitedSegmentSpanChars(out, openingMarker, text, closingMarker, "text");
}
@NotNull
@Override
public BasedSequence[] getSegments() {
return new BasedSequence[] { openingMarker, text, closingMarker };
}
@Override
public String getAnchorRefText() {<FILL_FUNCTION_BODY>}
@Override
public String getAnchorRefId() {
return anchorRefId;
}
@Override
public void setAnchorRefId(String anchorRefId) {
this.anchorRefId = anchorRefId;
}
@Override
public boolean isExplicitAnchorRefId() {
return explicitAnchorRefId;
}
@Override
public void setExplicitAnchorRefId(boolean explicitAnchorRefId) {
this.explicitAnchorRefId = explicitAnchorRefId;
}
public Heading() {
}
public Heading(BasedSequence chars) {
super(chars);
}
public Heading(BasedSequence chars, List<BasedSequence> segments) {
super(chars, segments);
}
public Heading(BlockContent blockContent) {
super(blockContent);
}
public boolean isAtxHeading() {
return openingMarker != BasedSequence.NULL;
}
public boolean isSetextHeading() {
return openingMarker == BasedSequence.NULL && closingMarker != BasedSequence.NULL;
}
public BasedSequence getOpeningMarker() {
return openingMarker;
}
public void setOpeningMarker(BasedSequence openingMarker) {
this.openingMarker = openingMarker == null ? BasedSequence.NULL : openingMarker;
}
public BasedSequence getText() {
return text;
}
public void setText(BasedSequence text) {
this.text = text == null ? BasedSequence.NULL : text;
}
public BasedSequence getClosingMarker() {
return closingMarker;
}
public void setClosingMarker(BasedSequence closingMarker) {
this.closingMarker = closingMarker == null ? BasedSequence.NULL : closingMarker;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
}
|
boolean trimLeadingSpaces = HtmlRenderer.HEADER_ID_REF_TEXT_TRIM_LEADING_SPACES.get(getDocument());
boolean trimTrailingSpaces = HtmlRenderer.HEADER_ID_REF_TEXT_TRIM_TRAILING_SPACES.get(getDocument());
return new TextCollectingVisitor().collectAndGetText(this, TextContainer.F_FOR_HEADING_ID + (trimLeadingSpaces ? 0 : TextContainer.F_NO_TRIM_REF_TEXT_START) + (trimTrailingSpaces ? 0 : TextContainer.F_NO_TRIM_REF_TEXT_END));
| 692
| 163
| 855
|
<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/src/main/java/com/vladsch/flexmark/ast/HtmlEntity.java
|
HtmlEntity
|
collectText
|
class HtmlEntity extends Node implements TextContainer {
@Override
public void getAstExtra(@NotNull StringBuilder out) {
if (!getChars().isEmpty()) out.append(" \"").append(getChars()).append("\"");
}
// TODO: add opening and closing marker with intermediate text so that completions can be easily done
@NotNull
@Override
public BasedSequence[] getSegments() {
return EMPTY_SEGMENTS;
}
public HtmlEntity() {
}
public HtmlEntity(BasedSequence chars) {
super(chars);
}
@Override
public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?, BasedSequence>, BasedSequence> out, int flags, NodeVisitor nodeVisitor) {<FILL_FUNCTION_BODY>}
}
|
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;
| 208
| 91
| 299
|
<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/src/main/java/com/vladsch/flexmark/ast/Image.java
|
Image
|
getAstExtra
|
class Image extends InlineLinkNode {
private BasedSequence urlContent = BasedSequence.NULL;
@NotNull
@Override
public BasedSequence[] getSegments() {
return new BasedSequence[] {
textOpeningMarker,
text,
textClosingMarker,
linkOpeningMarker,
urlOpeningMarker,
url,
pageRef,
anchorMarker,
anchorRef,
urlClosingMarker,
urlContent,
titleOpeningMarker,
titleOpeningMarker,
title,
titleClosingMarker,
linkClosingMarker
};
}
@Override
public void getAstExtra(@NotNull StringBuilder out) {<FILL_FUNCTION_BODY>}
public Image() {
}
public Image(BasedSequence chars) {
super(chars);
}
public Image(BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence linkOpenMarker, BasedSequence url, BasedSequence titleOpenMarker, BasedSequence title, BasedSequence titleCloseMarker, BasedSequence linkCloseMarker) {
super(textOpenMarker, text, textCloseMarker, linkOpenMarker, url, titleOpenMarker, title, titleCloseMarker, linkCloseMarker);
}
public Image(BasedSequence chars, BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence linkOpenMarker, BasedSequence url, BasedSequence titleOpenMarker, BasedSequence title, BasedSequence titleCloseMarker, BasedSequence linkCloseMarker) {
super(chars, textOpenMarker, text, textCloseMarker, linkOpenMarker, url, titleOpenMarker, title, titleCloseMarker, linkCloseMarker);
}
public Image(BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence linkOpenMarker, BasedSequence url, BasedSequence linkCloseMarker) {
super(textOpenMarker, text, textCloseMarker, linkOpenMarker, url, linkCloseMarker);
}
public Image(BasedSequence chars, BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence linkOpenMarker, BasedSequence url, BasedSequence linkCloseMarker) {
super(chars, textOpenMarker, text, textCloseMarker, linkOpenMarker, url, linkCloseMarker);
}
@Override
public void setTextChars(BasedSequence textChars) {
int textCharsLength = textChars.length();
this.textOpeningMarker = textChars.subSequence(0, 2);
this.text = textChars.subSequence(2, textCharsLength - 1).trim();
this.textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength);
}
public void setUrlContent(BasedSequence urlContent) {
this.urlContent = urlContent;
}
public BasedSequence getUrlContent() {
return urlContent;
}
}
|
delimitedSegmentSpanChars(out, textOpeningMarker, text, textClosingMarker, "text");
segmentSpanChars(out, linkOpeningMarker, "linkOpen");
delimitedSegmentSpanChars(out, urlOpeningMarker, url, urlClosingMarker, "url");
if (pageRef.isNotNull()) segmentSpanChars(out, pageRef, "pageRef");
if (anchorMarker.isNotNull()) segmentSpanChars(out, anchorMarker, "anchorMarker");
if (anchorRef.isNotNull()) segmentSpanChars(out, anchorRef, "anchorRef");
if (urlContent.isNotNull()) segmentSpanChars(out, urlContent, "urlContent");
delimitedSegmentSpanChars(out, titleOpeningMarker, title, titleClosingMarker, "title");
segmentSpanChars(out, linkClosingMarker, "linkClose");
| 708
| 216
| 924
|
<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/src/main/java/com/vladsch/flexmark/ast/ImageRef.java
|
ImageRef
|
setTextChars
|
class ImageRef extends RefNode {
public ImageRef() {
}
public ImageRef(BasedSequence chars) {
super(chars);
}
public ImageRef(BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence referenceOpenMarker, BasedSequence reference, BasedSequence referenceCloseMarker) {
super(textOpenMarker, text, textCloseMarker, referenceOpenMarker, reference, referenceCloseMarker);
}
public ImageRef(BasedSequence chars, BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence referenceOpenMarker, BasedSequence reference, BasedSequence referenceCloseMarker) {
super(chars, textOpenMarker, text, textCloseMarker, referenceOpenMarker, reference, referenceCloseMarker);
}
public ImageRef(BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker) {
super(textOpenMarker, text, textCloseMarker);
}
public ImageRef(BasedSequence chars, BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker) {
super(chars, textOpenMarker, text, textCloseMarker);
}
public ImageRef(BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence referenceOpenMarker, BasedSequence referenceCloseMarker) {
super(textOpenMarker, text, textCloseMarker, referenceOpenMarker, referenceCloseMarker);
}
@Override
public void setTextChars(BasedSequence textChars) {<FILL_FUNCTION_BODY>}
}
|
int textCharsLength = textChars.length();
this.textOpeningMarker = textChars.subSequence(0, 2);
this.text = textChars.subSequence(2, textCharsLength - 1).trim();
this.textClosingMarker = textChars.subSequence(textCharsLength - 1, textCharsLength);
| 369
| 92
| 461
|
<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) ,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 <init>(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) ,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) ,public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?,com.vladsch.flexmark.util.sequence.BasedSequence>,com.vladsch.flexmark.util.sequence.BasedSequence>, int, com.vladsch.flexmark.util.ast.NodeVisitor) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.sequence.BasedSequence getDummyReference() ,public @NotNull BasedSequence getReference() ,public com.vladsch.flexmark.util.sequence.BasedSequence getReferenceClosingMarker() ,public com.vladsch.flexmark.ast.Reference getReferenceNode(com.vladsch.flexmark.util.ast.Document) ,public com.vladsch.flexmark.ast.Reference getReferenceNode(com.vladsch.flexmark.ast.util.ReferenceRepository) ,public com.vladsch.flexmark.util.sequence.BasedSequence getReferenceOpeningMarker() ,public @NotNull BasedSequence [] getSegments() ,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 boolean isDefined() ,public boolean isDummyReference() ,public boolean isReferenceTextCombined() ,public boolean isTentative() ,public void setDefined(boolean) ,public void setReference(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setReferenceChars(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setReferenceClosingMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setReferenceOpeningMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setText(com.vladsch.flexmark.util.sequence.BasedSequence) ,public 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) <variables>protected boolean isDefined,protected com.vladsch.flexmark.util.sequence.BasedSequence reference,protected com.vladsch.flexmark.util.sequence.BasedSequence referenceClosingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence referenceOpeningMarker,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/src/main/java/com/vladsch/flexmark/ast/IndentedCodeBlock.java
|
IndentedCodeBlock
|
collectText
|
class IndentedCodeBlock extends Block implements TextContainer {
@NotNull
@Override
public BasedSequence[] getSegments() {
return EMPTY_SEGMENTS;
}
public IndentedCodeBlock() {
}
public IndentedCodeBlock(BasedSequence chars) {
super(chars);
}
public IndentedCodeBlock(BasedSequence chars, List<BasedSequence> segments) {
super(chars, segments);
}
public IndentedCodeBlock(BlockContent blockContent) {
super(blockContent);
}
@Override
public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?, BasedSequence>, BasedSequence> out, int flags, NodeVisitor nodeVisitor) {<FILL_FUNCTION_BODY>}
}
|
final BasedSequence chars = getContentChars();
if (any(flags, F_NODE_TEXT)) {
out.append(chars);
} else {
ReplacedTextMapper textMapper = new ReplacedTextMapper(chars);
BasedSequence unescaped = Escaping.unescape(chars, textMapper);
if (!unescaped.isEmpty()) {
out.append(unescaped);
}
}
return false;
| 201
| 115
| 316
|
<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/src/main/java/com/vladsch/flexmark/ast/InlineLinkNode.java
|
InlineLinkNode
|
getSegments
|
class InlineLinkNode extends LinkNode {
protected BasedSequence textOpeningMarker = BasedSequence.NULL;
protected BasedSequence text = BasedSequence.NULL;
protected BasedSequence textClosingMarker = BasedSequence.NULL;
protected BasedSequence linkOpeningMarker = BasedSequence.NULL;
protected BasedSequence linkClosingMarker = BasedSequence.NULL;
@NotNull
@Override
public BasedSequence[] getSegments() {<FILL_FUNCTION_BODY>}
@NotNull
@Override
public BasedSequence[] getSegmentsForChars() {
return new BasedSequence[] {
textOpeningMarker,
text,
textClosingMarker,
linkOpeningMarker,
urlOpeningMarker,
pageRef,
anchorMarker,
anchorRef,
urlClosingMarker,
titleOpeningMarker,
title,
titleClosingMarker,
linkClosingMarker
};
}
@Override
public void getAstExtra(@NotNull StringBuilder out) {
delimitedSegmentSpanChars(out, textOpeningMarker, text, textClosingMarker, "text");
segmentSpanChars(out, linkOpeningMarker, "linkOpen");
delimitedSegmentSpanChars(out, urlOpeningMarker, url, urlClosingMarker, "url");
if (pageRef.isNotNull()) segmentSpanChars(out, pageRef, "pageRef");
if (anchorMarker.isNotNull()) segmentSpanChars(out, anchorMarker, "anchorMarker");
if (anchorRef.isNotNull()) segmentSpanChars(out, anchorRef, "anchorRef");
delimitedSegmentSpanChars(out, titleOpeningMarker, title, titleClosingMarker, "title");
segmentSpanChars(out, linkClosingMarker, "linkClose");
}
public InlineLinkNode() {
}
public InlineLinkNode(BasedSequence chars) {
super(chars);
}
public InlineLinkNode(BasedSequence textOpeningMarker, BasedSequence text, BasedSequence textClosingMarker, BasedSequence linkOpeningMarker, BasedSequence url, BasedSequence titleOpeningMarker, BasedSequence title, BasedSequence titleClosingMarker, BasedSequence linkClosingMarker) {
this.textOpeningMarker = textOpeningMarker;
this.text = text.trim();
this.textClosingMarker = textClosingMarker;
this.linkOpeningMarker = linkOpeningMarker;
this.url = url;
this.titleOpeningMarker = titleOpeningMarker;
this.title = title;
this.titleClosingMarker = titleClosingMarker;
this.linkClosingMarker = linkClosingMarker;
}
public InlineLinkNode(BasedSequence chars, BasedSequence textOpeningMarker, BasedSequence text, BasedSequence textClosingMarker, BasedSequence linkOpeningMarker, BasedSequence url, BasedSequence titleOpeningMarker, BasedSequence title, BasedSequence titleClosingMarker, BasedSequence linkClosingMarker) {
super(chars);
this.textOpeningMarker = textOpeningMarker;
this.text = text.trim();
this.textClosingMarker = textClosingMarker;
this.linkOpeningMarker = linkOpeningMarker;
this.url = url;
this.titleOpeningMarker = titleOpeningMarker;
this.title = title;
this.titleClosingMarker = titleClosingMarker;
this.linkClosingMarker = linkClosingMarker;
}
public InlineLinkNode(BasedSequence textOpeningMarker, BasedSequence text, BasedSequence textClosingMarker, BasedSequence linkOpeningMarker, BasedSequence url, BasedSequence linkClosingMarker) {
this.textOpeningMarker = textOpeningMarker;
this.text = text.trim();
this.textClosingMarker = textClosingMarker;
this.linkOpeningMarker = linkOpeningMarker;
this.url = url;
this.linkClosingMarker = linkClosingMarker;
}
public InlineLinkNode(BasedSequence chars, BasedSequence textOpeningMarker, BasedSequence text, BasedSequence textClosingMarker, BasedSequence linkOpeningMarker, BasedSequence url, BasedSequence linkClosingMarker) {
super(chars);
this.textOpeningMarker = textOpeningMarker;
this.text = text.trim();
this.textClosingMarker = textClosingMarker;
this.linkOpeningMarker = linkOpeningMarker;
this.url = url;
this.linkClosingMarker = linkClosingMarker;
}
public void setUrl(BasedSequence linkOpeningMarker, BasedSequence url, BasedSequence linkClosingMarker) {
this.linkOpeningMarker = linkOpeningMarker;
this.setUrlChars(url);
this.linkClosingMarker = linkClosingMarker;
}
public abstract void setTextChars(BasedSequence textChars);
public BasedSequence getText() {
return text;
}
public BasedSequence getTextOpeningMarker() {
return textOpeningMarker;
}
public void setTextOpeningMarker(BasedSequence textOpeningMarker) {
this.textOpeningMarker = textOpeningMarker;
}
public void setText(BasedSequence text) {
this.text = text.trim();
}
public BasedSequence getTextClosingMarker() {
return textClosingMarker;
}
public void setTextClosingMarker(BasedSequence textClosingMarker) {
this.textClosingMarker = textClosingMarker;
}
public BasedSequence getLinkOpeningMarker() {
return linkOpeningMarker;
}
public void setLinkOpeningMarker(BasedSequence linkOpeningMarker) {
this.linkOpeningMarker = linkOpeningMarker;
}
public BasedSequence getLinkClosingMarker() {
return linkClosingMarker;
}
public void setLinkClosingMarker(BasedSequence linkClosingMarker) {
this.linkClosingMarker = linkClosingMarker;
}
@NotNull
@Override
protected String toStringAttributes() {
return "text=" + text + ", url=" + url + ", title=" + title;
}
}
|
return new BasedSequence[] {
textOpeningMarker,
text,
textClosingMarker,
linkOpeningMarker,
urlOpeningMarker,
url,
pageRef,
anchorMarker,
anchorRef,
urlClosingMarker,
titleOpeningMarker,
title,
titleClosingMarker,
linkClosingMarker
};
| 1,519
| 96
| 1,615
|
<methods>public void <init>() ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence) ,public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?,com.vladsch.flexmark.util.sequence.BasedSequence>,com.vladsch.flexmark.util.sequence.BasedSequence>, int, com.vladsch.flexmark.util.ast.NodeVisitor) <variables>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/Link.java
|
Link
|
setTextChars
|
class Link extends InlineLinkNode {
public Link() {
}
public Link(BasedSequence chars) {
super(chars);
}
public Link(BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence linkOpenMarker, BasedSequence url, BasedSequence titleOpenMarker, BasedSequence title, BasedSequence titleCloseMarker, BasedSequence linkCloseMarker) {
super(textOpenMarker, text, textCloseMarker, linkOpenMarker, url, titleOpenMarker, title, titleCloseMarker, linkCloseMarker);
}
public Link(BasedSequence chars, BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence linkOpenMarker, BasedSequence url, BasedSequence titleOpenMarker, BasedSequence title, BasedSequence titleCloseMarker, BasedSequence linkCloseMarker) {
super(chars, textOpenMarker, text, textCloseMarker, linkOpenMarker, url, titleOpenMarker, title, titleCloseMarker, linkCloseMarker);
}
public Link(BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence linkOpenMarker, BasedSequence url, BasedSequence linkCloseMarker) {
super(textOpenMarker, text, textCloseMarker, linkOpenMarker, url, linkCloseMarker);
}
public Link(BasedSequence chars, BasedSequence textOpenMarker, BasedSequence text, BasedSequence textCloseMarker, BasedSequence linkOpenMarker, BasedSequence url, BasedSequence linkCloseMarker) {
super(chars, textOpenMarker, text, textCloseMarker, linkOpenMarker, url, linkCloseMarker);
}
@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);
| 407
| 92
| 499
|
<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/src/main/java/com/vladsch/flexmark/ast/LinkNode.java
|
LinkNode
|
collectText
|
class LinkNode extends LinkNodeBase implements DoNotLinkDecorate, TextContainer {
public LinkNode() {
}
public LinkNode(BasedSequence chars) {
super(chars);
}
@Override
public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?, BasedSequence>, BasedSequence> out, int flags, NodeVisitor nodeVisitor) {<FILL_FUNCTION_BODY>}
}
|
int urlType = flags & F_LINK_TEXT_TYPE;
BasedSequence url;
switch (urlType) {
case F_LINK_PAGE_REF:
url = getPageRef();
break;
case F_LINK_ANCHOR:
url = getAnchorRef();
break;
case F_LINK_URL:
url = getUrl();
break;
case F_LINK_NODE_TEXT:
url = BasedSequence.NULL; // not used
break;
default:
case F_LINK_TEXT:
return true;
}
if (urlType == F_LINK_NODE_TEXT) {
out.append(getChars());
} else {
ReplacedTextMapper textMapper = new ReplacedTextMapper(url);
BasedSequence unescaped = Escaping.unescape(url, textMapper);
BasedSequence percentDecoded = Escaping.percentDecodeUrl(unescaped, textMapper);
out.append(percentDecoded);
}
return false;
| 110
| 270
| 380
|
<methods>public void <init>() ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence) ,public com.vladsch.flexmark.util.sequence.BasedSequence getAnchorMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getAnchorRef() ,public com.vladsch.flexmark.util.sequence.BasedSequence getPageRef() ,public com.vladsch.flexmark.util.sequence.BasedSequence getTitle() ,public com.vladsch.flexmark.util.sequence.BasedSequence getTitleClosingMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getTitleOpeningMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getUrl() ,public com.vladsch.flexmark.util.sequence.BasedSequence getUrlClosingMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getUrlOpeningMarker() ,public void setAnchorMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setAnchorRef(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setPageRef(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTitle(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTitleChars(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTitleClosingMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTitleOpeningMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setUrl(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setUrlChars(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setUrlClosingMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setUrlOpeningMarker(com.vladsch.flexmark.util.sequence.BasedSequence) <variables>protected com.vladsch.flexmark.util.sequence.BasedSequence anchorMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence anchorRef,protected com.vladsch.flexmark.util.sequence.BasedSequence pageRef,protected com.vladsch.flexmark.util.sequence.BasedSequence title,protected com.vladsch.flexmark.util.sequence.BasedSequence titleClosingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence titleOpeningMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence url,protected com.vladsch.flexmark.util.sequence.BasedSequence urlClosingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence urlOpeningMarker
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/LinkNodeBase.java
|
LinkNodeBase
|
setUrlChars
|
class LinkNodeBase extends Node {
protected BasedSequence urlOpeningMarker = BasedSequence.NULL;
protected BasedSequence url = BasedSequence.NULL;
protected BasedSequence pageRef = BasedSequence.NULL;
protected BasedSequence anchorMarker = BasedSequence.NULL;
protected BasedSequence anchorRef = BasedSequence.NULL;
protected BasedSequence urlClosingMarker = BasedSequence.NULL;
protected BasedSequence titleOpeningMarker = BasedSequence.NULL;
protected BasedSequence title = BasedSequence.NULL;
protected BasedSequence titleClosingMarker = BasedSequence.NULL;
public LinkNodeBase() {
}
public LinkNodeBase(BasedSequence chars) {
super(chars);
}
public void setTitleChars(BasedSequence titleChars) {
if (titleChars != null && titleChars != BasedSequence.NULL) {
int titleCharsLength = titleChars.length();
titleOpeningMarker = titleChars.subSequence(0, 1);
title = titleChars.subSequence(1, titleCharsLength - 1);
titleClosingMarker = titleChars.subSequence(titleCharsLength - 1, titleCharsLength);
} else {
titleOpeningMarker = BasedSequence.NULL;
title = BasedSequence.NULL;
titleClosingMarker = BasedSequence.NULL;
}
}
public void setUrlChars(BasedSequence url) {<FILL_FUNCTION_BODY>}
public BasedSequence getPageRef() {
return pageRef;
}
public void setPageRef(BasedSequence pageRef) {
this.pageRef = pageRef;
}
public BasedSequence getAnchorMarker() {
return anchorMarker;
}
public void setAnchorMarker(BasedSequence anchorMarker) {
this.anchorMarker = anchorMarker;
}
public BasedSequence getAnchorRef() {
return anchorRef;
}
public void setAnchorRef(BasedSequence anchorRef) {
this.anchorRef = anchorRef;
}
public BasedSequence getUrl() {
return url;
}
public BasedSequence getTitle() {
return title;
}
public BasedSequence getUrlOpeningMarker() {
return urlOpeningMarker;
}
public void setUrlOpeningMarker(BasedSequence urlOpeningMarker) {
this.urlOpeningMarker = urlOpeningMarker;
}
public void setUrl(BasedSequence url) {
this.url = url;
}
public BasedSequence getUrlClosingMarker() {
return urlClosingMarker;
}
public void setUrlClosingMarker(BasedSequence urlClosingMarker) {
this.urlClosingMarker = urlClosingMarker;
}
public BasedSequence getTitleOpeningMarker() {
return titleOpeningMarker;
}
public void setTitleOpeningMarker(BasedSequence titleOpeningMarker) {
this.titleOpeningMarker = titleOpeningMarker;
}
public void setTitle(BasedSequence title) {
this.title = title;
}
public BasedSequence getTitleClosingMarker() {
return titleClosingMarker;
}
public void setTitleClosingMarker(BasedSequence titleClosingMarker) {
this.titleClosingMarker = titleClosingMarker;
}
}
|
if (url != null && url != BasedSequence.NULL) {
// strip off <> wrapping
if (url.startsWith("<") && url.endsWith(">")) {
urlOpeningMarker = url.subSequence(0, 1);
this.url = url.subSequence(1, url.length() - 1);
urlClosingMarker = url.subSequence(url.length() - 1);
} else {
this.url = url;
}
// parse out the anchor marker and ref
int pos = this.url.indexOf('#');
if (pos < 0) {
this.pageRef = this.url;
} else {
this.pageRef = this.url.subSequence(0, pos);
this.anchorMarker = this.url.subSequence(pos, pos + 1);
this.anchorRef = this.url.subSequence(pos + 1);
}
} else {
this.urlOpeningMarker = BasedSequence.NULL;
this.url = BasedSequence.NULL;
this.urlClosingMarker = BasedSequence.NULL;
}
| 832
| 279
| 1,111
|
<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/src/main/java/com/vladsch/flexmark/ast/ListItem.java
|
ListItem
|
isItemParagraph
|
class ListItem extends Block implements ParagraphItemContainer, BlankLineContainer, ParagraphContainer {
protected BasedSequence openingMarker = BasedSequence.NULL;
protected BasedSequence markerSuffix = BasedSequence.NULL;
private boolean tight = true;
private boolean hadBlankAfterItemParagraph = false;
private boolean containsBlankLine = false;
private int priority = Integer.MIN_VALUE;
public ListItem() {
}
public ListItem(ListItem other) {
this.openingMarker = other.openingMarker;
this.markerSuffix = other.markerSuffix;
this.tight = other.tight;
this.hadBlankAfterItemParagraph = other.hadBlankAfterItemParagraph;
this.containsBlankLine = other.containsBlankLine;
this.priority = other.priority;
takeChildren(other);
setCharsFromContent();
}
public ListItem(BasedSequence chars) {
super(chars);
}
public ListItem(BasedSequence chars, List<BasedSequence> segments) {
super(chars, segments);
}
public ListItem(BlockContent blockContent) {
super(blockContent);
}
public boolean isOrderedItem() {
return false;
}
@Override
public void getAstExtra(@NotNull StringBuilder out) {
segmentSpanChars(out, openingMarker, "open");
segmentSpanChars(out, markerSuffix, "openSuffix");
if (isTight()) out.append(" isTight");
else out.append(" isLoose");
if (isHadBlankAfterItemParagraph()) out.append(" hadBlankLineAfter");
else if (isContainsBlankLine()) out.append(" hadBlankLine");
}
@NotNull
@Override
public BasedSequence[] getSegments() {
return new BasedSequence[] { openingMarker, markerSuffix };
}
public boolean canChangeMarker() {
return true;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public BasedSequence getOpeningMarker() {
return openingMarker;
}
public void setOpeningMarker(BasedSequence openingMarker) {
this.openingMarker = openingMarker;
}
public BasedSequence getMarkerSuffix() {
return markerSuffix;
}
public void setMarkerSuffix(BasedSequence markerSuffix) {
assert markerSuffix.isNull() || openingMarker.getBase() == markerSuffix.getBase();
this.markerSuffix = markerSuffix;
}
public void setTight(boolean tight) {
this.tight = tight;
}
public void setLoose(boolean loose) {
this.tight = !loose;
}
public boolean isTight() {
return tight && isInTightList();
}
public boolean isOwnTight() {
return tight;
}
public boolean isLoose() {
return !isTight();
}
@Override
public boolean isParagraphEndWrappingDisabled(Paragraph node) {
return getFirstChild() != node && getLastChild() == node || getFirstChild() == node && (getParent() == null || getParent().getLastChildAny(ListItem.class) == this);
}
@Override
public boolean isParagraphStartWrappingDisabled(Paragraph node) {
return isItemParagraph(node);
}
@Override
public boolean isParagraphInTightListItem(Paragraph node) {
if (!isTight()) return false;
// see if this is the first paragraph child item
return isItemParagraph(node);
}
public boolean isItemParagraph(Paragraph node) {<FILL_FUNCTION_BODY>}
@Override
public boolean isParagraphWrappingDisabled(Paragraph node, ListOptions listOptions, DataHolder options) {
assert node.getParent() == this;
return listOptions.isInTightListItem(node);
}
public boolean isInTightList() {
return !(getParent() instanceof ListBlock) || ((ListBlock) getParent()).isTight();
}
public boolean isHadBlankAfterItemParagraph() {
return hadBlankAfterItemParagraph;
}
public boolean isContainsBlankLine() {
return containsBlankLine;
}
public void setContainsBlankLine(boolean containsBlankLine) {
this.containsBlankLine = containsBlankLine;
}
@SuppressWarnings("SameParameterValue")
public void setHadBlankAfterItemParagraph(boolean hadBlankAfterItemParagraph) {
this.hadBlankAfterItemParagraph = hadBlankAfterItemParagraph;
}
@Override
public Node getLastBlankLineChild() {
return getLastChild();
}
}
|
// see if this is the first paragraph child item
Node child = getFirstChild();
while (child != null && !(child instanceof Paragraph)) child = child.getNext();
return child == node;
| 1,280
| 54
| 1,334
|
<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/src/main/java/com/vladsch/flexmark/ast/OrderedList.java
|
OrderedList
|
getAstExtra
|
class OrderedList extends ListBlock {
private int startNumber;
private char delimiter;
@NotNull
@Override
public BasedSequence[] getSegments() {
return EMPTY_SEGMENTS;
}
public OrderedList() {
}
public OrderedList(BasedSequence chars) {
super(chars);
}
public OrderedList(BasedSequence chars, List<BasedSequence> segments) {
super(chars, segments);
}
public OrderedList(BlockContent blockContent) {
super(blockContent);
}
@Override
public void getAstExtra(@NotNull StringBuilder out) {<FILL_FUNCTION_BODY>}
public int getStartNumber() {
return startNumber;
}
public void setStartNumber(int startNumber) {
this.startNumber = startNumber;
}
public char getDelimiter() {
return delimiter;
}
public void setDelimiter(char delimiter) {
this.delimiter = delimiter;
}
}
|
super.getAstExtra(out);
if (startNumber > 1) out.append(" start:").append(startNumber);
out.append(" delimiter:'").append(delimiter).append("'");
| 283
| 55
| 338
|
<methods>public void <init>() ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence, List<com.vladsch.flexmark.util.sequence.BasedSequence>) ,public void <init>(com.vladsch.flexmark.util.ast.BlockContent) ,public void getAstExtra(@NotNull StringBuilder) ,public com.vladsch.flexmark.util.ast.Node getLastBlankLineChild() ,public boolean isLoose() ,public boolean isTight() ,public void setLoose(boolean) ,public void setTight(boolean) <variables>private boolean tight
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/Paragraph.java
|
Paragraph
|
setContent
|
class Paragraph extends Block implements TextContainer {
final private static int[] EMPTY_INDENTS = new int[0];
private int[] lineIndents = EMPTY_INDENTS;
private boolean trailingBlankLine = false;
private boolean hasTableSeparator;
@NotNull
@Override
public BasedSequence[] getSegments() {
return EMPTY_SEGMENTS;
}
@Override
public void getAstExtra(@NotNull StringBuilder out) {
super.getAstExtra(out);
if (trailingBlankLine) out.append(" isTrailingBlankLine");
}
public Paragraph() {
}
public Paragraph(BasedSequence chars) {
super(chars);
}
public Paragraph(BasedSequence chars, List<BasedSequence> lineSegments, List<Integer> lineIndents) {
super(chars, lineSegments);
if (lineSegments.size() != lineIndents.size())
throw new IllegalArgumentException("line segments and line indents have to be of the same size");
setLineIndents(lineIndents);
}
public Paragraph(BasedSequence chars, List<BasedSequence> lineSegments, int[] lineIndents) {
super(chars, lineSegments);
if (lineSegments.size() != lineIndents.length)
throw new IllegalArgumentException("line segments and line indents have to be of the same size");
this.lineIndents = lineIndents;
}
public Paragraph(BlockContent blockContent) {
super(blockContent);
setLineIndents(blockContent.getLineIndents());
}
protected void setLineIndents(List<Integer> lineIndents) {
this.lineIndents = new int[lineIndents.size()];
int i = 0;
for (int indent : lineIndents) {
this.lineIndents[i++] = indent;
}
}
@Override
// FIX: add indent tracking then deprecate. ContentNode does not have indents
// @Deprecated
public void setContent(@NotNull BasedSequence chars, @NotNull List<BasedSequence> lineSegments) {
super.setContent(chars, lineSegments);
}
public void setContent(BasedSequence chars, List<BasedSequence> lineSegments, List<Integer> lineIndents) {
super.setContent(chars, lineSegments);
if (lineSegments.size() != lineIndents.size())
throw new IllegalArgumentException("line segments and line indents have to be of the same size");
setLineIndents(lineIndents);
}
@Override
// FIX: add indent tracking then deprecate. ContentNode does not have indents
// @Deprecated
public void setContent(@NotNull List<BasedSequence> lineSegments) {
super.setContent(lineSegments);
}
@Override
public void setContent(@NotNull BlockContent blockContent) {
super.setContent(blockContent);
setLineIndents(blockContent.getLineIndents());
}
public void setContent(BlockContent blockContent, int startLine, int endLine) {
super.setContent(blockContent.getLines().subList(startLine, endLine));
setLineIndents(blockContent.getLineIndents().subList(startLine, endLine));
}
public void setContent(Paragraph other, int startLine, int endLine) {<FILL_FUNCTION_BODY>}
public void setLineIndents(int[] lineIndents) {
this.lineIndents = lineIndents;
}
public int getLineIndent(int line) {
return lineIndents[line];
}
public int[] getLineIndents() {
return lineIndents;
}
public boolean isTrailingBlankLine() {
return trailingBlankLine;
}
public void setTrailingBlankLine(boolean trailingBlankLine) {
this.trailingBlankLine = trailingBlankLine;
}
public void setHasTableSeparator(boolean hasTableSeparator) {
this.hasTableSeparator = hasTableSeparator;
}
public boolean hasTableSeparator() {
return hasTableSeparator;
}
@Override
public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?, BasedSequence>, BasedSequence> out, int flags, NodeVisitor nodeVisitor) {
return true;
}
@Override
public void collectEndText(ISequenceBuilder<? extends ISequenceBuilder<?, BasedSequence>, BasedSequence> out, int flags, NodeVisitor nodeVisitor) {
if (trailingBlankLine) {
out.add("\n");
}
}
}
|
super.setContent(other.getContentLines(startLine, endLine));
if (endLine > startLine) {
int[] lineIndents = new int[endLine - startLine];
System.arraycopy(other.lineIndents, startLine, lineIndents, 0, endLine - startLine);
this.lineIndents = lineIndents;
} else {
this.lineIndents = EMPTY_INDENTS;
}
| 1,204
| 115
| 1,319
|
<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/src/main/java/com/vladsch/flexmark/ast/Reference.java
|
Reference
|
getSegmentsForChars
|
class Reference extends LinkNodeBase implements ReferenceNode<ReferenceRepository, Reference, RefNode> {
protected BasedSequence openingMarker = BasedSequence.NULL;
protected BasedSequence reference = BasedSequence.NULL;
protected BasedSequence closingMarker = BasedSequence.NULL;
@NotNull
@Override
public BasedSequence[] getSegments() {
return new BasedSequence[] {
openingMarker,
reference,
closingMarker,
urlOpeningMarker,
url,
pageRef,
anchorMarker,
anchorRef,
urlClosingMarker,
titleOpeningMarker,
title,
titleClosingMarker
};
}
@NotNull
@Override
public BasedSequence[] getSegmentsForChars() {<FILL_FUNCTION_BODY>}
@Override
public int compareTo(Reference other) {
return SequenceUtils.compare(getReference(), other.getReference(), true);
}
@Nullable
@Override
public RefNode getReferencingNode(@NotNull Node node) {
return node instanceof RefNode ? (RefNode) node : null;
}
@Override
public void getAstExtra(@NotNull StringBuilder out) {
delimitedSegmentSpanChars(out, openingMarker, reference, closingMarker, "ref");
delimitedSegmentSpanChars(out, urlOpeningMarker, url, urlClosingMarker, "url");
delimitedSegmentSpanChars(out, titleOpeningMarker, title, titleClosingMarker, "title");
}
public Reference(BasedSequence label, BasedSequence url, BasedSequence title) {
super(BasedSequence.NULL);
this.openingMarker = label.subSequence(0, 1);
this.reference = label.subSequence(1, label.length() - 2).trim();
this.closingMarker = label.subSequence(label.length() - 2, label.length());
setUrlChars(url);
if (title != null) {
this.titleOpeningMarker = title.subSequence(0, 1);
this.title = title.subSequence(1, title.length() - 1);
this.titleClosingMarker = title.subSequence(title.length() - 1, title.length());
}
setCharsFromContent();
}
public BasedSequence getOpeningMarker() {
return openingMarker;
}
public void setOpeningMarker(BasedSequence openingMarker) {
this.openingMarker = openingMarker;
}
public BasedSequence getClosingMarker() {
return closingMarker;
}
public void setClosingMarker(BasedSequence closingMarker) {
this.closingMarker = closingMarker;
}
public BasedSequence getUrlOpeningMarker() {
return urlOpeningMarker;
}
public void setUrlOpeningMarker(BasedSequence urlOpeningMarker) {
this.urlOpeningMarker = urlOpeningMarker;
}
public BasedSequence getUrlClosingMarker() {
return urlClosingMarker;
}
public void setUrlClosingMarker(BasedSequence urlClosingMarker) {
this.urlClosingMarker = urlClosingMarker;
}
public BasedSequence getTitleOpeningMarker() {
return titleOpeningMarker;
}
public void setTitleOpeningMarker(BasedSequence titleOpeningMarker) {
this.titleOpeningMarker = titleOpeningMarker;
}
public BasedSequence getTitleClosingMarker() {
return titleClosingMarker;
}
public void setTitleClosingMarker(BasedSequence titleClosingMarker) {
this.titleClosingMarker = titleClosingMarker;
}
public BasedSequence getReference() {
return reference;
}
public void setReference(BasedSequence reference) {
this.reference = reference;
}
public BasedSequence getUrl() {
return url;
}
public void setUrl(BasedSequence url) {
this.url = url;
}
public BasedSequence getPageRef() {
return pageRef;
}
public void setPageRef(BasedSequence pageRef) {
this.pageRef = pageRef;
}
public BasedSequence getAnchorMarker() {
return anchorMarker;
}
public void setAnchorMarker(BasedSequence anchorMarker) {
this.anchorMarker = anchorMarker;
}
public BasedSequence getAnchorRef() {
return anchorRef;
}
public void setAnchorRef(BasedSequence anchorRef) {
this.anchorRef = anchorRef;
}
public BasedSequence getTitle() {
return title;
}
public void setTitle(BasedSequence title) {
this.title = title;
}
@NotNull
@Override
protected String toStringAttributes() {
return "reference=" + reference + ", url=" + url;
}
}
|
return new BasedSequence[] {
openingMarker,
reference,
closingMarker,
PrefixedSubSequence.prefixOf(" ", closingMarker.getEmptySuffix()),
urlOpeningMarker,
pageRef,
anchorMarker,
anchorRef,
urlClosingMarker,
titleOpeningMarker,
title,
titleClosingMarker
};
| 1,224
| 94
| 1,318
|
<methods>public void <init>() ,public void <init>(com.vladsch.flexmark.util.sequence.BasedSequence) ,public com.vladsch.flexmark.util.sequence.BasedSequence getAnchorMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getAnchorRef() ,public com.vladsch.flexmark.util.sequence.BasedSequence getPageRef() ,public com.vladsch.flexmark.util.sequence.BasedSequence getTitle() ,public com.vladsch.flexmark.util.sequence.BasedSequence getTitleClosingMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getTitleOpeningMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getUrl() ,public com.vladsch.flexmark.util.sequence.BasedSequence getUrlClosingMarker() ,public com.vladsch.flexmark.util.sequence.BasedSequence getUrlOpeningMarker() ,public void setAnchorMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setAnchorRef(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setPageRef(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTitle(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTitleChars(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTitleClosingMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setTitleOpeningMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setUrl(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setUrlChars(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setUrlClosingMarker(com.vladsch.flexmark.util.sequence.BasedSequence) ,public void setUrlOpeningMarker(com.vladsch.flexmark.util.sequence.BasedSequence) <variables>protected com.vladsch.flexmark.util.sequence.BasedSequence anchorMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence anchorRef,protected com.vladsch.flexmark.util.sequence.BasedSequence pageRef,protected com.vladsch.flexmark.util.sequence.BasedSequence title,protected com.vladsch.flexmark.util.sequence.BasedSequence titleClosingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence titleOpeningMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence url,protected com.vladsch.flexmark.util.sequence.BasedSequence urlClosingMarker,protected com.vladsch.flexmark.util.sequence.BasedSequence urlOpeningMarker
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/Text.java
|
Text
|
collectText
|
class Text extends Node implements TextContainer {
public Text() {
}
public Text(BasedSequence chars) {
super(chars);
}
public Text(String chars) {
super(BasedSequence.of(chars));
}
public Text(String chars, BasedSequence baseSeq) {
super(PrefixedSubSequence.prefixOf(chars, baseSeq));
}
@NotNull
@Override
public BasedSequence[] getSegments() {
return EMPTY_SEGMENTS;
}
@Override
public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?, BasedSequence>, BasedSequence> out, int flags, NodeVisitor nodeVisitor) {<FILL_FUNCTION_BODY>}
@Override
public void getAstExtra(@NotNull StringBuilder out) {
astExtraChars(out);
if (getChars() instanceof PrefixedSubSequence) {
astChars(out, getChars(), "text");
}
}
@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);
if (!unescaped.isEmpty()) out.append(unescaped);
}
return false;
| 294
| 99
| 393
|
<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/src/main/java/com/vladsch/flexmark/ast/TextBase.java
|
TextBase
|
collectText
|
class TextBase extends Node implements TextContainer {
public TextBase() {
}
public TextBase(BasedSequence chars) {
super(chars);
}
public TextBase(String chars) {
super(BasedSequence.of(chars));
}
@NotNull
@Override
public BasedSequence[] getSegments() {
return EMPTY_SEGMENTS;
}
@Override
public void getAstExtra(@NotNull StringBuilder out) {
astExtraChars(out);
}
@Override
public boolean collectText(ISequenceBuilder<? extends ISequenceBuilder<?, BasedSequence>, BasedSequence> out, int flags, NodeVisitor nodeVisitor) {<FILL_FUNCTION_BODY>}
@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;
| 226
| 91
| 317
|
<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/src/main/java/com/vladsch/flexmark/ast/util/AnchorRefTargetBlockVisitor.java
|
AnchorRefTargetBlockVisitor
|
visit
|
class AnchorRefTargetBlockVisitor extends NodeVisitorBase {
protected abstract void visit(AnchorRefTarget node);
protected boolean preVisit(@NotNull Node node) {
return true;
}
public void visit(@NotNull Node node) {<FILL_FUNCTION_BODY>}
}
|
if (node instanceof AnchorRefTarget) visit((AnchorRefTarget) node);
if (preVisit(node) && node instanceof Block) {
visitChildren(node);
}
| 77
| 50
| 127
|
<methods>public non-sealed void <init>() ,public void visitChildren(@NotNull Node) <variables>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/BlockVisitorExt.java
|
BlockVisitorExt
|
VISIT_HANDLERS
|
class BlockVisitorExt {
public static <V extends BlockVisitor> VisitHandler<?>[] VISIT_HANDLERS(V visitor) {<FILL_FUNCTION_BODY>}
}
|
return new VisitHandler<?>[] {
new VisitHandler<>(BlockQuote.class, visitor::visit),
new VisitHandler<>(BulletList.class, visitor::visit),
new VisitHandler<>(Document.class, visitor::visit),
new VisitHandler<>(FencedCodeBlock.class, visitor::visit),
new VisitHandler<>(Heading.class, visitor::visit),
new VisitHandler<>(HtmlBlock.class, visitor::visit),
new VisitHandler<>(HtmlCommentBlock.class, visitor::visit),
new VisitHandler<>(IndentedCodeBlock.class, visitor::visit),
new VisitHandler<>(BulletListItem.class, visitor::visit),
new VisitHandler<>(OrderedListItem.class, visitor::visit),
new VisitHandler<>(OrderedList.class, visitor::visit),
new VisitHandler<>(Paragraph.class, visitor::visit),
new VisitHandler<>(Reference.class, visitor::visit),
new VisitHandler<>(ThematicBreak.class, visitor::visit)
};
| 51
| 268
| 319
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/ClassifyingBlockTracker.java
|
ClassifyingBlockTracker
|
validateLinked
|
class ClassifyingBlockTracker implements BlockTracker, BlockParserTracker {
protected final ClassificationBag<Class<?>, Node> nodeClassifier = new ClassificationBag<>(NodeClassifier.INSTANCE);
protected final OrderedMultiMap<BlockParser, Block> allBlockParsersMap = new OrderedMultiMap<>(new CollectionHost<Paired<BlockParser, Block>>() {
@Override
public void adding(int index, @Nullable Paired<BlockParser, Block> paired, @Nullable Object v) {
Block block = paired.getSecond();
if (block != null) nodeClassifier.add(block);
}
@Override
public Object removing(int index, @Nullable Paired<BlockParser, Block> paired) {
Block block = paired.getSecond();
if (block != null) nodeClassifier.remove(block);
return paired;
}
@Override
public void clearing() {
nodeClassifier.clear();
}
@Override
public void addingNulls(int index) {
// ignore
}
@Override
public boolean skipHostUpdate() {
return false;
}
@Override
public int getIteratorModificationCount() {
return allBlockParsersMap.getModificationCount();
}
});
public OrderedSet<BlockParser> allBlockParsers() {
return allBlockParsersMap.keySet();
}
public OrderedSet<Block> allBlocks() {
return allBlockParsersMap.valueSet();
}
public Block getValue(BlockParser parser) {
return allBlockParsersMap.getKeyValue(parser);
}
public BlockParser getKey(Block parser) {
return allBlockParsersMap.getValueKey(parser);
}
public boolean containsKey(BlockParser parser) {
return allBlockParsersMap.containsKey(parser);
}
public boolean containsValue(Block parser) {
return allBlockParsersMap.containsValue(parser);
}
public ClassificationBag<Class<?>, Node> getNodeClassifier() {
return nodeClassifier;
}
@Override
public void blockParserAdded(BlockParser blockParser) {
allBlockParsersMap.putKeyValue(blockParser, blockParser.getBlock());
}
@Override
public void blockParserRemoved(BlockParser blockParser) {
allBlockParsersMap.removeKey(blockParser);
}
private void validateLinked(Node node) {<FILL_FUNCTION_BODY>}
@Override
public void blockAdded(@NotNull Block node) {
validateLinked(node);
allBlockParsersMap.putValueKey(node, null);
}
@Override
public void blockAddedWithChildren(@NotNull Block node) {
validateLinked(node);
allBlockParsersMap.putValueKey(node, null);
addBlocks(node.getChildren());
}
@Override
public void blockAddedWithDescendants(@NotNull Block node) {
validateLinked(node);
allBlockParsersMap.putValueKey(node, null);
addBlocks(node.getDescendants());
}
private void addBlocks(ReversiblePeekingIterable<Node> nodes) {
for (Node child : nodes) {
if (child instanceof Block) {
allBlockParsersMap.putValueKey((Block) child, null);
}
}
}
private void validateUnlinked(Node node) {
if (!(node.getNext() == null && node.getParent() == null)) {
throw new IllegalStateException("Removed block " + node + " is still linked in the AST");
}
}
@Override
public void blockRemoved(@NotNull Block node) {
validateUnlinked(node);
allBlockParsersMap.removeValue(node);
}
@Override
public void blockRemovedWithChildren(@NotNull Block node) {
validateUnlinked(node);
allBlockParsersMap.removeValue(node);
removeBlocks(node.getChildren());
}
@Override
public void blockRemovedWithDescendants(@NotNull Block node) {
validateUnlinked(node);
allBlockParsersMap.removeValue(node);
removeBlocks(node.getDescendants());
}
private void removeBlocks(ReversiblePeekingIterable<Node> nodes) {
for (Node child : nodes) {
if (child instanceof Block) {
allBlockParsersMap.removeValue(child);
}
}
}
}
|
if (node.getNext() == null && node.getParent() == null) {
throw new IllegalStateException("Added block " + node + " is not linked into the AST");
}
| 1,176
| 50
| 1,226
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/HtmlInnerVisitorExt.java
|
HtmlInnerVisitorExt
|
VISIT_HANDLERS
|
class HtmlInnerVisitorExt {
public static <V extends HtmlInnerVisitor> VisitHandler<?>[] VISIT_HANDLERS(V visitor) {<FILL_FUNCTION_BODY>}
}
|
return new VisitHandler<?>[] {
new VisitHandler<>(HtmlInnerBlock.class, visitor::visit),
new VisitHandler<>(HtmlInnerBlockComment.class, visitor::visit),
};
| 55
| 54
| 109
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/InlineVisitorExt.java
|
InlineVisitorExt
|
VISIT_HANDLERS
|
class InlineVisitorExt {
public static <V extends InlineVisitor> VisitHandler<?>[] VISIT_HANDLERS(V visitor) {<FILL_FUNCTION_BODY>}
}
|
return new VisitHandler<?>[] {
new VisitHandler<>(AutoLink.class, visitor::visit),
new VisitHandler<>(Code.class, visitor::visit),
new VisitHandler<>(Emphasis.class, visitor::visit),
new VisitHandler<>(HardLineBreak.class, visitor::visit),
new VisitHandler<>(HtmlEntity.class, visitor::visit),
new VisitHandler<>(HtmlInline.class, visitor::visit),
new VisitHandler<>(HtmlInlineComment.class, visitor::visit),
new VisitHandler<>(Image.class, visitor::visit),
new VisitHandler<>(ImageRef.class, visitor::visit),
new VisitHandler<>(Link.class, visitor::visit),
new VisitHandler<>(LinkRef.class, visitor::visit),
new VisitHandler<>(MailLink.class, visitor::visit),
new VisitHandler<>(SoftLineBreak.class, visitor::visit),
new VisitHandler<>(StrongEmphasis.class, visitor::visit),
new VisitHandler<>(Text.class, visitor::visit),
};
| 53
| 277
| 330
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/LineCollectingVisitor.java
|
LineCollectingVisitor
|
finalizeLines
|
class LineCollectingVisitor {
final private NodeVisitor myVisitor;
private List<Range> myLines;
private List<Integer> myEOLs;
private int myStartOffset;
private int myEndOffset;
public LineCollectingVisitor() {
myVisitor = new NodeVisitor(
new VisitHandler<>(Text.class, this::visit),
new VisitHandler<>(TextBase.class, this::visit),
new VisitHandler<>(HtmlEntity.class, this::visit),
new VisitHandler<>(HtmlInline.class, this::visit),
new VisitHandler<>(SoftLineBreak.class, this::visit),
new VisitHandler<>(HardLineBreak.class, this::visit)
);
myLines = Collections.EMPTY_LIST;
}
private void finalizeLines() {<FILL_FUNCTION_BODY>}
public List<Range> getLines() {
finalizeLines();
return myLines;
}
public List<Integer> getEOLs() {
finalizeLines();
return myEOLs;
}
public void collect(Node node) {
myLines = new ArrayList<>();
myEOLs = new ArrayList<>();
myStartOffset = node.getStartOffset();
myEndOffset = node.getEndOffset();
myVisitor.visit(node);
}
public List<Range> collectAndGetRanges(Node node) {
collect(node);
return getLines();
}
private void visit(SoftLineBreak node) {
Range range = Range.of(myStartOffset, node.getEndOffset());
myLines.add(range);
myEOLs.add(node.getTextLength());
myStartOffset = node.getEndOffset();
}
private void visit(HardLineBreak node) {
Range range = Range.of(myStartOffset, node.getEndOffset());
myLines.add(range);
myEOLs.add(node.getTextLength());
myStartOffset = node.getEndOffset();
}
private void visit(HtmlEntity node) {
myEndOffset = node.getEndOffset();
}
private void visit(HtmlInline node) {
myEndOffset = node.getEndOffset();
}
private void visit(Text node) {
myEndOffset = node.getEndOffset();
}
private void visit(TextBase node) {
myEndOffset = node.getEndOffset();
}
}
|
if (myStartOffset < myEndOffset) {
Range range = Range.of(myStartOffset, myEndOffset);
myLines.add(range);
myEOLs.add(0);
myStartOffset = myEndOffset;
}
| 647
| 67
| 714
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/LinkResolverAdapter.java
|
LinkResolverAdapter
|
resolveLink
|
class LinkResolverAdapter extends AstActionHandler<LinkResolverAdapter, Node, LinkResolvingHandler.LinkResolvingVisitor<Node>, LinkResolvingHandler<Node>> implements LinkResolvingHandler.LinkResolvingVisitor<Node> {
protected static final LinkResolvingHandler[] EMPTY_HANDLERS = new LinkResolvingHandler[0];
public LinkResolverAdapter(LinkResolvingHandler... handlers) {
super(Node.AST_ADAPTER);
super.addActionHandlers(handlers);
}
public LinkResolverAdapter(LinkResolvingHandler[]... handlers) {
super(Node.AST_ADAPTER);
//noinspection unchecked
super.addActionHandlers(handlers);
}
public LinkResolverAdapter(Collection<LinkResolvingHandler> handlers) {
super(Node.AST_ADAPTER);
addHandlers(handlers);
}
// add handler variations
public LinkResolverAdapter addHandlers(Collection<LinkResolvingHandler> handlers) {
return super.addActionHandlers(handlers.toArray(EMPTY_HANDLERS));
}
public LinkResolverAdapter addHandlers(LinkResolvingHandler[] handlers) {
return super.addActionHandlers(handlers);
}
public LinkResolverAdapter addHandlers(LinkResolvingHandler[]... handlers) {
//noinspection unchecked
return super.addActionHandlers(handlers);
}
public LinkResolverAdapter addHandler(LinkResolvingHandler handler) {
//noinspection unchecked
return super.addActionHandler(handler);
}
@Override
public ResolvedLink resolveLink(Node node, LinkResolverBasicContext context, ResolvedLink link) {<FILL_FUNCTION_BODY>}
}
|
return processNodeOnly(node, link, (n, handler) -> handler.resolveLink(n, context, link));
| 437
| 32
| 469
|
<methods>public void <init>(@NotNull AstNode<Node>) ,public LinkResolvingHandler.@Nullable LinkResolvingVisitor<Node> getAction(@NotNull Node) ,public LinkResolvingHandler.@Nullable LinkResolvingVisitor<Node> getAction(@NotNull Class<?>) ,public @NotNull Set<Class<? extends Node>> getNodeClasses() <variables>private final non-sealed @NotNull AstNode<Node> astAdapter,private final @NotNull Map<Class<? extends Node>,LinkResolvingHandler<Node>> customHandlersMap
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/Parsing.java
|
PatternTypeFlags
|
withAllowNameSpace
|
class PatternTypeFlags {
final @Nullable Boolean intellijDummyIdentifier;
final @Nullable Boolean htmlForTranslator;
final @Nullable String translationHtmlInlineTagPattern;
final @Nullable String translationAutolinkTagPattern;
final @Nullable Boolean spaceInLinkUrl;
final @Nullable Boolean parseJekyllMacroInLinkUrl;
final @Nullable String itemPrefixChars;
final @Nullable Boolean listsItemMarkerSpace;
final @Nullable Boolean listsOrderedItemDotOnly;
final @Nullable Boolean allowNameSpace;
PatternTypeFlags(DataHolder options) {
this.intellijDummyIdentifier = Parser.INTELLIJ_DUMMY_IDENTIFIER.get(options);
this.htmlForTranslator = Parser.HTML_FOR_TRANSLATOR.get(options);
this.translationHtmlInlineTagPattern = Parser.TRANSLATION_HTML_INLINE_TAG_PATTERN.get(options);
this.translationAutolinkTagPattern = Parser.TRANSLATION_AUTOLINK_TAG_PATTERN.get(options);
this.spaceInLinkUrl = Parser.SPACE_IN_LINK_URLS.get(options);
this.parseJekyllMacroInLinkUrl = Parser.PARSE_JEKYLL_MACROS_IN_URLS.get(options);
this.itemPrefixChars = LISTS_ITEM_PREFIX_CHARS.get(options);
this.listsItemMarkerSpace = LISTS_ITEM_MARKER_SPACE.get(options);
this.listsOrderedItemDotOnly = LISTS_ORDERED_ITEM_DOT_ONLY.get(options);
this.allowNameSpace = HTML_ALLOW_NAME_SPACE.get(options);
}
public PatternTypeFlags(
@Nullable Boolean intellijDummyIdentifier
, @Nullable Boolean htmlForTranslator
, @Nullable String translationHtmlInlineTagPattern
, @Nullable String translationAutolinkTagPattern
, @Nullable Boolean spaceInLinkUrl
, @Nullable Boolean parseJekyllMacroInLinkUrl
, @Nullable String itemPrefixChars
, @Nullable Boolean listsItemMarkerSpace
, @Nullable Boolean listsOrderedItemDotOnly
, @Nullable Boolean allowNameSpace
) {
this.intellijDummyIdentifier = intellijDummyIdentifier;
this.htmlForTranslator = htmlForTranslator;
this.translationHtmlInlineTagPattern = translationHtmlInlineTagPattern;
this.translationAutolinkTagPattern = translationAutolinkTagPattern;
this.spaceInLinkUrl = spaceInLinkUrl;
this.parseJekyllMacroInLinkUrl = parseJekyllMacroInLinkUrl;
this.itemPrefixChars = itemPrefixChars;
this.listsItemMarkerSpace = listsItemMarkerSpace;
this.listsOrderedItemDotOnly = listsOrderedItemDotOnly;
this.allowNameSpace = allowNameSpace;
}
PatternTypeFlags withJekyllMacroInLinkUrl() { return new PatternTypeFlags(intellijDummyIdentifier, null, null, null, null, parseJekyllMacroInLinkUrl, null, null, null, null); }
PatternTypeFlags withJekyllMacroSpaceInLinkUrl() { return new PatternTypeFlags(intellijDummyIdentifier, null, null, null, spaceInLinkUrl, parseJekyllMacroInLinkUrl, null, null, null, null); }
PatternTypeFlags withHtmlTranslator() { return new PatternTypeFlags(intellijDummyIdentifier, htmlForTranslator, translationHtmlInlineTagPattern, translationAutolinkTagPattern, null, null, null, null, null, null); }
PatternTypeFlags withItemPrefixChars() { return new PatternTypeFlags(null, null, null, null, null, null, itemPrefixChars, listsItemMarkerSpace, listsOrderedItemDotOnly, null); }
PatternTypeFlags withAllowNameSpace() {<FILL_FUNCTION_BODY>}
/**
* Compare where null entry equals any other value
*
* @param o other
* @return true if equal
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PatternTypeFlags that = (PatternTypeFlags) o;
if (intellijDummyIdentifier != null && !intellijDummyIdentifier.equals(that.intellijDummyIdentifier)) return false;
if (htmlForTranslator != null && !htmlForTranslator.equals(that.htmlForTranslator)) return false;
if (translationHtmlInlineTagPattern != null && !translationHtmlInlineTagPattern.equals(that.translationHtmlInlineTagPattern)) return false;
if (translationAutolinkTagPattern != null && !translationAutolinkTagPattern.equals(that.translationAutolinkTagPattern)) return false;
if (spaceInLinkUrl != null && !spaceInLinkUrl.equals(that.spaceInLinkUrl)) return false;
if (parseJekyllMacroInLinkUrl != null && !parseJekyllMacroInLinkUrl.equals(that.parseJekyllMacroInLinkUrl)) return false;
if (itemPrefixChars != null && !itemPrefixChars.equals(that.itemPrefixChars)) return false;
if (listsItemMarkerSpace != null && !listsItemMarkerSpace.equals(that.listsItemMarkerSpace)) return false;
if (allowNameSpace != null && !allowNameSpace.equals(that.allowNameSpace)) return false;
return listsOrderedItemDotOnly == null || listsOrderedItemDotOnly.equals(that.listsOrderedItemDotOnly);
}
@Override
public int hashCode() {
int result = intellijDummyIdentifier != null ? intellijDummyIdentifier.hashCode() : 0;
result = 31 * result + (htmlForTranslator != null ? htmlForTranslator.hashCode() : 0);
result = 31 * result + (translationHtmlInlineTagPattern != null ? translationHtmlInlineTagPattern.hashCode() : 0);
result = 31 * result + (translationAutolinkTagPattern != null ? translationAutolinkTagPattern.hashCode() : 0);
result = 31 * result + (spaceInLinkUrl != null ? spaceInLinkUrl.hashCode() : 0);
result = 31 * result + (parseJekyllMacroInLinkUrl != null ? parseJekyllMacroInLinkUrl.hashCode() : 0);
result = 31 * result + (itemPrefixChars != null ? itemPrefixChars.hashCode() : 0);
result = 31 * result + (listsItemMarkerSpace != null ? listsItemMarkerSpace.hashCode() : 0);
result = 31 * result + (listsOrderedItemDotOnly != null ? listsOrderedItemDotOnly.hashCode() : 0);
result = 31 * result + (allowNameSpace != null ? allowNameSpace.hashCode() : 0);
return result;
}
}
|
return new PatternTypeFlags(null, null, null, null, null, null, null, null, null, allowNameSpace);
| 1,768
| 31
| 1,799
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/ReferenceRepository.java
|
ReferenceRepository
|
getReferencedElements
|
class ReferenceRepository extends NodeRepository<Reference> {
public ReferenceRepository(DataHolder options) {
super(Parser.REFERENCES_KEEP.get(options));
}
@NotNull
@Override
public DataKey<ReferenceRepository> getDataKey() {
return Parser.REFERENCES;
}
@NotNull
@Override
public DataKey<KeepType> getKeepDataKey() {
return Parser.REFERENCES_KEEP;
}
@NotNull
@Override
public String normalizeKey(@NotNull CharSequence key) {
return Escaping.normalizeReference(key, true);
}
@NotNull
@Override
public Set<Reference> getReferencedElements(Node parent) {<FILL_FUNCTION_BODY>}
}
|
HashSet<Reference> references = new HashSet<>();
visitNodes(parent, value -> {
if (value instanceof RefNode) {
Reference reference = ((RefNode) value).getReferenceNode(ReferenceRepository.this);
if (reference != null) {
references.add(reference);
}
}
}, LinkRef.class, ImageRef.class);
return references;
| 204
| 100
| 304
|
<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,Reference>> entrySet() ,public boolean equals(java.lang.Object) ,public @Nullable Reference get(@NotNull Object) ,public abstract @NotNull DataKey<? extends NodeRepository<Reference>> getDataKey() ,public @Nullable Reference getFromRaw(@NotNull CharSequence) ,public abstract @NotNull DataKey<KeepType> getKeepDataKey() ,public abstract @NotNull Set<Reference> getReferencedElements(com.vladsch.flexmark.util.ast.Node) ,public @NotNull Collection<Reference> getValues() ,public int hashCode() ,public boolean isEmpty() ,public @NotNull Set<String> keySet() ,public @NotNull String normalizeKey(@NotNull CharSequence) ,public @Nullable Reference put(@NotNull String, @NotNull Reference) ,public void putAll(@NotNull Map<? extends String,? extends Reference>) ,public @Nullable Reference putRawKey(@NotNull CharSequence, @NotNull Reference) ,public @Nullable Reference remove(@NotNull Object) ,public int size() ,public static boolean transferReferences(@NotNull NodeRepository<T>, @NotNull NodeRepository<T>, boolean, @Nullable Map<String,String>) ,public @NotNull List<Reference> values() <variables>protected final non-sealed com.vladsch.flexmark.util.ast.KeepType keepType,protected final ArrayList<com.vladsch.flexmark.ast.Reference> nodeList,protected final Map<java.lang.String,com.vladsch.flexmark.ast.Reference> nodeMap
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/TextCollectingVisitor.java
|
TextCollectingVisitor
|
visit
|
class TextCollectingVisitor {
SequenceBuilder out;
final private NodeVisitor myVisitor;
final HashSet<Class<?>> myLineBreakNodes;
protected static Class<?>[] concatArrays(Class<?>[]... classes) {
int total = 0;
for (Class<?>[] classList : classes) {
total += classList.length;
}
Class<?>[] result = new Class<?>[total];
int index = 0;
for (Class<?>[] classList : classes) {
System.arraycopy(classList, 0, result, index, classList.length);
index += classList.length;
}
return result;
}
public TextCollectingVisitor(Class<?>... lineBreakNodes) {
myLineBreakNodes = lineBreakNodes.length == 0 ? null : new HashSet<>(Arrays.asList(lineBreakNodes));
myVisitor = new NodeVisitor(
new VisitHandler<>(Text.class, this::visit),
new VisitHandler<>(TextBase.class, this::visit),
new VisitHandler<>(HtmlEntity.class, this::visit),
new VisitHandler<>(SoftLineBreak.class, this::visit),
new VisitHandler<>(Paragraph.class, this::visit),
new VisitHandler<>(HardLineBreak.class, this::visit)
)
{
@Override
public void processNode(@NotNull Node node, boolean withChildren, @NotNull BiConsumer<Node, Visitor<Node>> processor) {
Visitor<Node> visitor = getAction(node);
if (visitor != null) {
processor.accept(node, visitor);
} else {
processChildren(node, processor);
if (myLineBreakNodes != null && myLineBreakNodes.contains(node.getClass()) && !node.isOrDescendantOfType(DoNotCollectText.class)) {
out.add("\n");
}
}
}
};
}
public String getText() {
return out.toString();
}
public void collect(Node node) {
out = SequenceBuilder.emptyBuilder(node.getChars());
myVisitor.visit(node);
}
public String collectAndGetText(Node node) {
collect(node);
return out.toString();
}
public BasedSequence collectAndGetSequence(Node node) {
collect(node);
return out.toSequence();
}
private void visit(Paragraph node) {<FILL_FUNCTION_BODY>}
private void visit(SoftLineBreak node) {
out.add(node.getChars());
}
private void visit(HardLineBreak node) {
BasedSequence chars = node.getChars();
out.add(chars.subSequence(chars.length() - 1, chars.length()));
}
private void visit(HtmlEntity node) {
out.add(node.getChars().unescape());
}
private void visit(Text node) {
if (!node.isOrDescendantOfType(DoNotCollectText.class)) {
out.add(node.getChars());
}
}
private void visit(TextBase node) {
out.add(node.getChars());
}
}
|
if (!node.isOrDescendantOfType(DoNotCollectText.class)) {
if (!out.isEmpty()) {
out.add("\n\n");
}
myVisitor.visitChildren(node);
}
| 844
| 61
| 905
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/TextNodeConverter.java
|
TextNodeConverter
|
insertMergedBefore
|
class TextNodeConverter {
final private BasedSequence nodeChars;
private BasedSequence remainingChars;
final private ArrayList<Node> list = new ArrayList<>();
public TextNodeConverter(BasedSequence nodeChars) {
this.nodeChars = nodeChars;
this.remainingChars = nodeChars;
}
public void appendChild(Node child) {
BasedSequence childChars = child.getChars();
assert nodeChars.containsAllOf(childChars) : "child " + child.toAstString(false) + " is not within parent sequence " + Node.toSegmentSpan(nodeChars, null);
assert remainingChars.containsAllOf(childChars) : "child " + child.toAstString(false) + " is not within remaining sequence " + Node.toSegmentSpan(remainingChars, null);
child.unlink();
if (!(child instanceof Text)) {
if (remainingChars.getStartOffset() < childChars.getStartOffset()) {
// add preceding chars as Text
list.add(new Text(remainingChars.subSequence(0, childChars.getStartOffset() - remainingChars.getStartOffset())));
}
// punch out remaining node chars
remainingChars = remainingChars.subSequence(childChars.getEndOffset() - remainingChars.getStartOffset());
list.add(child);
}
}
public void addChildrenOf(Node parent) {
Node child = parent.getFirstChild();
while (child != null) {
Node nextChild = child.getNext();
appendChild(child);
child = nextChild;
}
}
public void appendMergedTo(Node parent) {
mergeList();
for (Node child : list) {
parent.appendChild(child);
}
clear();
}
public void clear() {
list.clear();
remainingChars = BasedSequence.NULL;
}
// insert and clear list
public void insertMergedBefore(Node sibling) {<FILL_FUNCTION_BODY>}
// insert and clear list
public static void mergeTextNodes(Node parent) {
Node prevNode = null;
Node child = parent.getFirstChild();
while (child != null) {
Node nextChild = child.getNext();
if (prevNode instanceof Text && child instanceof Text && prevNode.getChars().isContinuedBy(child.getChars())) {
// merge them
child.setChars(prevNode.getChars().spliceAtEnd(child.getChars()));
prevNode.unlink();
}
prevNode = child;
child = nextChild;
}
}
// insert and clear list
public void insertMergedAfter(Node sibling) {
mergeList();
for (Node node : list) {
sibling.insertAfter(node);
sibling = node;
}
clear();
}
private void mergeList() {
if (!remainingChars.isEmpty()) {
list.add(new Text(remainingChars));
remainingChars = BasedSequence.NULL;
}
}
public List<Node> getMergedList() {
mergeList();
return list;
}
}
|
mergeList();
for (Node node : list) {
sibling.insertBefore(node);
}
clear();
| 830
| 35
| 865
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/ast/util/TextNodeMergingList.java
|
TextNodeMergingList
|
mergeList
|
class TextNodeMergingList {
private ArrayList<Node> list = new ArrayList<>();
private boolean isMerged = true;
public void add(Node node) {
list.add(node);
if (node instanceof Text) isMerged = false;
}
public void add(BasedSequence nodeChars) {
if (!nodeChars.isEmpty()) {
add(new Text(nodeChars));
}
}
public void addChildrenOf(Node parent) {
Node child = parent.getFirstChild();
while (child != null) {
Node nextChild = child.getNext();
child.unlink();
add(child);
child = nextChild;
}
}
public void appendMergedTo(Node parent) {
mergeList();
for (Node child : list) {
parent.appendChild(child);
}
}
public void clear() {
list.clear();
isMerged = true;
}
// insert and clear list
public void insertMergedBefore(Node sibling) {
mergeList();
for (Node node : list) {
sibling.insertBefore(node);
}
clear();
}
// insert and clear list
public void insertMergedAfter(Node sibling) {
mergeList();
for (Node node : list) {
sibling.insertAfter(node);
sibling = node;
}
clear();
}
private void mergeList() {<FILL_FUNCTION_BODY>}
public List<Node> getMergedList() {
mergeList();
return list;
}
}
|
if (!isMerged) {
// go through and see if some can be combined
ArrayList<Node> mergedList = null;
Node lastText = null;
for (Node child : list) {
if (child instanceof Text) {
if (!child.getChars().isEmpty()) {
if (lastText == null) {
lastText = child;
} else if (lastText.getChars().isContinuedBy(child.getChars())) {
// merge their text
lastText.setChars(lastText.getChars().spliceAtEnd(child.getChars()));
} else {
if (mergedList == null) mergedList = new ArrayList<>();
mergedList.add(lastText);
lastText = child;
}
}
} else {
if (mergedList == null) mergedList = new ArrayList<>();
if (lastText != null) {
mergedList.add(lastText);
lastText = null;
}
mergedList.add(child);
}
}
if (lastText != null) {
if (mergedList == null) {
list.clear();
list.add(lastText);
} else {
mergedList.add(lastText);
}
}
if (mergedList != null) {
list = mergedList;
}
}
| 428
| 352
| 780
|
<no_super_class>
|
vsch_flexmark-java
|
flexmark-java/flexmark/src/main/java/com/vladsch/flexmark/formatter/MarkdownWriter.java
|
MarkdownWriter
|
lastBlockQuoteChildPrefix
|
class MarkdownWriter extends MarkdownWriterBase<MarkdownWriter, Node, NodeFormatterContext> {
public MarkdownWriter() {
this(null, 0);
}
public MarkdownWriter(int formatOptions) {
this(null, formatOptions);
}
public MarkdownWriter(@Nullable Appendable appendable, int formatOptions) {
super(appendable, formatOptions);
}
@NotNull
@Override
public MarkdownWriter getEmptyAppendable() {
return new MarkdownWriter(appendable, appendable.getOptions());
}
@Override
public @NotNull BasedSequence lastBlockQuoteChildPrefix(BasedSequence prefix) {<FILL_FUNCTION_BODY>}
public @NotNull MarkdownWriter appendNonTranslating(@NotNull CharSequence csq) {
return appendNonTranslating(null, csq, null, null);
}
public @NotNull MarkdownWriter appendNonTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq) {
return appendNonTranslating(prefix, csq, null, null);
}
public @NotNull MarkdownWriter appendNonTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq, @Nullable CharSequence suffix) {
return appendNonTranslating(prefix, csq, suffix, null);
}
public @NotNull MarkdownWriter appendNonTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq, @Nullable CharSequence suffix, @Nullable CharSequence suffix2) {
if (context.isTransformingText()) {
append(context.transformNonTranslating(prefix, csq, suffix, suffix2));
} else {
append(csq);
}
return this;
}
public @NotNull MarkdownWriter appendTranslating(@NotNull CharSequence csq) {
return appendTranslating(null, csq, null, null);
}
public @NotNull MarkdownWriter appendTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq) {
return appendTranslating(prefix, csq, null, null);
}
public @NotNull MarkdownWriter appendTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq, @Nullable CharSequence suffix) {
return appendTranslating(prefix, csq, suffix, null);
}
public @NotNull MarkdownWriter appendTranslating(@Nullable CharSequence prefix, @NotNull CharSequence csq, @Nullable CharSequence suffix, @Nullable CharSequence suffix2) {
if (context.isTransformingText()) {
append(context.transformTranslating(prefix, csq, suffix, suffix2));
} else {
if (prefix != null) append(prefix);
append(csq);
if (suffix != null) append(suffix);
if (suffix2 != null) append(suffix2);
}
return this;
}
}
|
Node node = context.getCurrentNode();
while (node != null && node.getNextAnyNot(BlankLine.class) == null) {
Node parent = node.getParent();
if (parent == null || parent instanceof Document) break;
if (parent instanceof BlockQuoteLike) {
int pos = prefix.lastIndexOfAny(context.getBlockQuoteLikePrefixPredicate());
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
}
}
node = parent;
}
return prefix;
| 707
| 187
| 894
|
<methods>public void <init>() ,public void <init>(int) ,public void <init>(@Nullable Appendable, int) ,public @NotNull MarkdownWriter addIndentOnFirstEOL(@NotNull Runnable) ,public @NotNull MarkdownWriter addPrefix(@NotNull CharSequence) ,public @NotNull MarkdownWriter addPrefix(@NotNull CharSequence, boolean) ,public @NotNull MarkdownWriter append(char) ,public @NotNull MarkdownWriter append(@NotNull CharSequence) ,public @NotNull MarkdownWriter append(@NotNull CharSequence, int, int) ,public @NotNull MarkdownWriter append(@NotNull LineAppendable, int, int, boolean) ,public @NotNull MarkdownWriter append(char, int) ,public T appendTo(@NotNull T, boolean, int, int, int, int) throws java.io.IOException,public @NotNull MarkdownWriter blankLine() ,public @NotNull MarkdownWriter blankLine(int) ,public @NotNull MarkdownWriter blankLineIf(boolean) ,public @NotNull MarkdownWriter changeOptions(int, int) ,public @NotNull MarkdownWriter closePreFormatted() ,public int column() ,public boolean endsWithEOL() ,public int getAfterEolPrefixDelta() ,public @NotNull BasedSequence getBeforeEolPrefix() ,public @NotNull ISequenceBuilder<?,?> getBuilder() ,public com.vladsch.flexmark.formatter.NodeFormatterContext 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 MarkdownWriter 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 MarkdownWriter line() ,public @NotNull MarkdownWriter lineIf(boolean) ,public @NotNull MarkdownWriter lineOnFirstText(boolean) ,public @NotNull MarkdownWriter lineWithTrailingSpaces(int) ,public int offset() ,public int offsetWithPending() ,public @NotNull MarkdownWriter openPreFormatted(boolean) ,public @NotNull MarkdownWriter popOptions() ,public @NotNull MarkdownWriter popPrefix() ,public @NotNull MarkdownWriter popPrefix(boolean) ,public @NotNull MarkdownWriter pushOptions() ,public @NotNull MarkdownWriter pushPrefix() ,public @NotNull MarkdownWriter removeExtraBlankLines(int, int, int, int) ,public @NotNull MarkdownWriter removeIndentOnFirstEOL(@NotNull Runnable) ,public @NotNull MarkdownWriter removeLines(int, int) ,public void setContext(com.vladsch.flexmark.formatter.NodeFormatterContext) ,public @NotNull MarkdownWriter setIndentPrefix(@Nullable CharSequence) ,public void setLine(int, @NotNull CharSequence, @NotNull CharSequence) ,public @NotNull MarkdownWriter setOptions(int) ,public @NotNull MarkdownWriter setPrefix(@NotNull CharSequence) ,public @NotNull MarkdownWriter setPrefix(@Nullable CharSequence, boolean) ,public void setPrefixLength(int, int) ,public @NotNull MarkdownWriter tailBlankLine() ,public @NotNull MarkdownWriter tailBlankLine(int) ,public @NotNull CharSequence toSequence(int, int, boolean) ,public java.lang.String toString() ,public @NotNull String toString(int, int, boolean) ,public @NotNull MarkdownWriter unIndent() ,public @NotNull MarkdownWriter unIndentNoEol() <variables>protected final non-sealed com.vladsch.flexmark.util.sequence.LineAppendableImpl appendable,protected com.vladsch.flexmark.formatter.NodeFormatterContext context
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.