-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Remove KAPT #16018
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
Open
tobiasKaminsky
wants to merge
1
commit into
master
Choose a base branch
from
removeKAPT
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Remove KAPT #16018
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 209 additions & 0 deletions
209
app/src/main/java/third_parties/io/noties/prism4j/languages/MarkwonGrammarLocator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,209 @@ | ||
| /* | ||
| * Nextcloud - Android Client | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Your Name <[email protected]> | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| package third_parties.io.noties.prism4j.languages; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import io.noties.prism4j.GrammarLocator; | ||
| import io.noties.prism4j.Prism4j; | ||
|
|
||
| public class MarkwonGrammarLocator implements GrammarLocator { | ||
|
|
||
| @SuppressWarnings("ConstantConditions") | ||
| private static final Prism4j.Grammar NULL = | ||
| new Prism4j.Grammar() { | ||
| @NotNull | ||
| @Override | ||
| public String name() { | ||
| return null; | ||
| } | ||
|
|
||
| @NotNull | ||
| @Override | ||
| public List<Prism4j.Token> tokens() { | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| private final Map<String, Prism4j.Grammar> cache = new HashMap<>(3); | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public Prism4j.Grammar grammar(@NotNull Prism4j prism4j, @NotNull String language) { | ||
|
|
||
| final String name = realLanguageName(language); | ||
|
|
||
| Prism4j.Grammar grammar = cache.get(name); | ||
| if (grammar != null) { | ||
| if (NULL == grammar) { | ||
| grammar = null; | ||
| } | ||
| return grammar; | ||
| } | ||
|
|
||
| grammar = obtainGrammar(prism4j, name); | ||
| if (grammar == null) { | ||
| cache.put(name, NULL); | ||
| } else { | ||
| cache.put(name, grammar); | ||
| triggerModify(prism4j, name); | ||
| } | ||
|
|
||
| return grammar; | ||
| } | ||
|
|
||
| @NotNull | ||
| protected String realLanguageName(@NotNull String name) { | ||
| final String out; | ||
| switch (name) { | ||
| case "dotnet": | ||
| out = "csharp"; | ||
| break; | ||
| case "js": | ||
| out = "javascript"; | ||
| break; | ||
| case "jsonp": | ||
| out = "json"; | ||
| break; | ||
| case "xml": | ||
| case "html": | ||
| case "mathml": | ||
| case "svg": | ||
| out = "markup"; | ||
| break; | ||
| default: | ||
| out = name; | ||
| } | ||
| return out; | ||
| } | ||
|
|
||
| @Nullable | ||
| protected Prism4j.Grammar obtainGrammar(@NotNull Prism4j prism4j, @NotNull String name) { | ||
| final Prism4j.Grammar grammar; | ||
| switch (name) { | ||
| case "c": | ||
| grammar = Prism_c.create(prism4j); | ||
| break; | ||
| case "clike": | ||
| grammar = Prism_clike.create(prism4j); | ||
| break; | ||
| case "clojure": | ||
| grammar = Prism_clojure.create(prism4j); | ||
| break; | ||
| case "cpp": | ||
| grammar = Prism_cpp.create(prism4j); | ||
| break; | ||
| case "csharp": | ||
| grammar = Prism_csharp.create(prism4j); | ||
| break; | ||
| case "css": | ||
| grammar = Prism_css.create(prism4j); | ||
| break; | ||
| case "dart": | ||
| grammar = Prism_dart.create(prism4j); | ||
| break; | ||
| case "git": | ||
| grammar = Prism_git.create(prism4j); | ||
| break; | ||
| case "go": | ||
| grammar = Prism_go.create(prism4j); | ||
| break; | ||
| case "groovy": | ||
| grammar = Prism_groovy.create(prism4j); | ||
| break; | ||
| case "java": | ||
| grammar = Prism_java.create(prism4j); | ||
| break; | ||
| case "javascript": | ||
| grammar = Prism_javascript.create(prism4j); | ||
| break; | ||
| case "json": | ||
| grammar = Prism_json.create(prism4j); | ||
| break; | ||
| case "kotlin": | ||
| grammar = Prism_kotlin.create(prism4j); | ||
| break; | ||
| case "latex": | ||
| grammar = Prism_latex.create(prism4j); | ||
| break; | ||
| case "makefile": | ||
| grammar = Prism_makefile.create(prism4j); | ||
| break; | ||
| case "markdown": | ||
| grammar = Prism_markdown.create(prism4j); | ||
| break; | ||
| case "markup": | ||
| grammar = Prism_markup.create(prism4j); | ||
| break; | ||
| case "python": | ||
| grammar = Prism_python.create(prism4j); | ||
| break; | ||
| case "scala": | ||
| grammar = Prism_scala.create(prism4j); | ||
| break; | ||
| case "sql": | ||
| grammar = Prism_sql.create(prism4j); | ||
| break; | ||
| case "swift": | ||
| grammar = Prism_swift.create(prism4j); | ||
| break; | ||
| case "yaml": | ||
| grammar = Prism_yaml.create(prism4j); | ||
| break; | ||
| default: | ||
| grammar = null; | ||
| } | ||
| return grammar; | ||
| } | ||
|
|
||
| protected void triggerModify(@NotNull Prism4j prism4j, @NotNull String name) { | ||
| switch (name) { | ||
| case "markup": | ||
| prism4j.grammar("css"); | ||
| prism4j.grammar("javascript"); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| @NotNull | ||
| public Set<String> languages() { | ||
| final Set<String> set = new HashSet<String>(23); | ||
| set.add("c"); | ||
| set.add("clike"); | ||
| set.add("clojure"); | ||
| set.add("cpp"); | ||
| set.add("csharp"); | ||
| set.add("css"); | ||
| set.add("dart"); | ||
| set.add("git"); | ||
| set.add("go"); | ||
| set.add("groovy"); | ||
| set.add("java"); | ||
| set.add("javascript"); | ||
| set.add("json"); | ||
| set.add("kotlin"); | ||
| set.add("latex"); | ||
| set.add("makefile"); | ||
| set.add("markdown"); | ||
| set.add("markup"); | ||
| set.add("python"); | ||
| set.add("scala"); | ||
| set.add("sql"); | ||
| set.add("swift"); | ||
| set.add("yaml"); | ||
| return set; | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
app/src/main/java/third_parties/io/noties/prism4j/languages/Prism_c.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * Nextcloud - Android Client | ||
| * | ||
| * SPDX-FileCopyrightText: 2025 Your Name <[email protected]> | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| package third_parties.io.noties.prism4j.languages; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| import io.noties.prism4j.GrammarUtils; | ||
| import io.noties.prism4j.Prism4j; | ||
| import io.noties.prism4j.annotations.Extend; | ||
|
|
||
| import static io.noties.prism4j.Prism4j.grammar; | ||
| import static io.noties.prism4j.Prism4j.pattern; | ||
| import static io.noties.prism4j.Prism4j.token; | ||
| import static java.util.regex.Pattern.CASE_INSENSITIVE; | ||
| import static java.util.regex.Pattern.MULTILINE; | ||
| import static java.util.regex.Pattern.compile; | ||
|
|
||
| @SuppressWarnings("unused") | ||
| @Extend("clike") | ||
| public class Prism_c { | ||
|
|
||
| @NotNull | ||
| public static Prism4j.Grammar create(@NotNull Prism4j prism4j) { | ||
|
|
||
| final Prism4j.Grammar c = GrammarUtils.extend( | ||
| GrammarUtils.require(prism4j, "clike"), | ||
| "c", | ||
| new GrammarUtils.TokenFilter() { | ||
| @Override | ||
| public boolean test(@NotNull Prism4j.Token token) { | ||
| final String name = token.name(); | ||
| return !"class-name".equals(name) && !"boolean".equals(name); | ||
| } | ||
| }, | ||
| token("keyword", pattern(compile("\\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\\b"))), | ||
| token("operator", pattern(compile("-[>-]?|\\+\\+?|!=?|<<?=?|>>?=?|==?|&&?|\\|\\|?|[~^%?*\\/]"))), | ||
| token("number", pattern(compile("(?:\\b0x[\\da-f]+|(?:\\b\\d+\\.?\\d*|\\B\\.\\d+)(?:e[+-]?\\d+)?)[ful]*", CASE_INSENSITIVE))) | ||
| ); | ||
|
|
||
| GrammarUtils.insertBeforeToken(c, "string", | ||
| token("macro", pattern( | ||
| compile("(^\\s*)#\\s*[a-z]+(?:[^\\r\\n\\\\]|\\\\(?:\\r\\n|[\\s\\S]))*", CASE_INSENSITIVE | MULTILINE), | ||
| true, | ||
| false, | ||
| "property", | ||
| grammar("inside", | ||
| token("string", pattern(compile("(#\\s*include\\s*)(?:<.+?>|(\"|')(?:\\\\?.)+?\\2)"), true)), | ||
| token("directive", pattern( | ||
| compile("(#\\s*)\\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\\b"), | ||
| true, | ||
| false, | ||
| "keyword" | ||
| )) | ||
| ) | ||
| )), | ||
| token("constant", pattern(compile("\\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\\b"))) | ||
| ); | ||
|
|
||
| return c; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Inefficient regular expression High