Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @NonNull annotations #569

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading