Skip to content

Commit

Permalink
Add @NonNull annotations (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw authored Dec 9, 2024
1 parent bb20e3a commit 83cdfea
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public MarkdownFormatter(@NonNull AssetManager assetManager) {
mAssetManager = assetManager;
}

public void format(SpannableStringBuilder ssb, List<MarkdownRange> markdownRanges, @NonNull MarkdownStyle markdownStyle) {
public void format(@NonNull SpannableStringBuilder ssb, @NonNull List<MarkdownRange> markdownRanges, @NonNull MarkdownStyle markdownStyle) {
try {
Systrace.beginSection(0, "format");
Objects.requireNonNull(markdownStyle, "mMarkdownStyle is null");
Expand All @@ -31,7 +31,7 @@ public void format(SpannableStringBuilder ssb, List<MarkdownRange> markdownRange
}
}

private void removeSpans(SpannableStringBuilder ssb) {
private void removeSpans(@NonNull SpannableStringBuilder ssb) {
try {
Systrace.beginSection(0, "removeSpans");
// We shouldn't use `removeSpans()` because it also removes SpellcheckSpan, SuggestionSpan etc.
Expand All @@ -44,7 +44,7 @@ private void removeSpans(SpannableStringBuilder ssb) {
}
}

private void applyRanges(SpannableStringBuilder ssb, List<MarkdownRange> markdownRanges, @NonNull MarkdownStyle markdownStyle) {
private void applyRanges(@NonNull SpannableStringBuilder ssb, @NonNull List<MarkdownRange> markdownRanges, @NonNull MarkdownStyle markdownStyle) {
try {
Systrace.beginSection(0, "applyRanges");
for (MarkdownRange markdownRange : markdownRanges) {
Expand All @@ -55,7 +55,7 @@ private void applyRanges(SpannableStringBuilder ssb, List<MarkdownRange> markdow
}
}

private void applyRange(SpannableStringBuilder ssb, MarkdownRange markdownRange, MarkdownStyle markdownStyle) {
private void applyRange(@NonNull SpannableStringBuilder ssb, @NonNull MarkdownRange markdownRange, @NonNull MarkdownStyle markdownStyle) {
String type = markdownRange.getType();
int start = markdownRange.getStart();
int end = start + markdownRange.getLength();
Expand Down Expand Up @@ -126,7 +126,7 @@ private void applyRange(SpannableStringBuilder ssb, MarkdownRange markdownRange,
}
}

private void setSpan(SpannableStringBuilder ssb, MarkdownSpan span, int start, int end) {
private void setSpan(@NonNull SpannableStringBuilder ssb, @NonNull MarkdownSpan span, int start, int end) {
ssb.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public MarkdownParser(@NonNull ReactContext reactContext) {
mReactContext = reactContext;
}

private native String nativeParse(String text, int parserId);
private native String nativeParse(@NonNull String text, int parserId);

public synchronized List<MarkdownRange> parse(String text, int parserId) {
public synchronized List<MarkdownRange> parse(@NonNull String text, int parserId) {
try {
Systrace.beginSection(0, "parse");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.expensify.livemarkdown;

import androidx.annotation.NonNull;

public class MarkdownRange {
private final String mType;
private final @NonNull String mType;
private final int mStart;
private final int mLength;
private final int mDepth;

public MarkdownRange(String type, int start, int length, int depth) {
public MarkdownRange(@NonNull String type, int start, int length, int depth) {
mType = type;
mStart = start;
mLength = length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class MarkdownStyle {

private final float mBlockquotePaddingLeft;

@NonNull
private final String mCodeFontFamily;

private final float mCodeFontSize;
Expand All @@ -42,6 +43,7 @@ public class MarkdownStyle {
@ColorInt
private final int mCodeBackgroundColor;

@NonNull
private final String mPreFontFamily;

private final float mPreFontSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import androidx.annotation.NonNull;

public class MarkdownTextWatcher implements TextWatcher {
private final MarkdownUtils mMarkdownUtils;
private final @NonNull MarkdownUtils mMarkdownUtils;

public MarkdownTextWatcher(@NonNull MarkdownUtils markdownUtils) {
mMarkdownUtils = markdownUtils;
Expand Down

0 comments on commit 83cdfea

Please sign in to comment.