This repository was archived by the owner on Oct 18, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
android-tree-sitter/src/main/java/com/itsaky/androidide/treesitter Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1717
1818package com .itsaky .androidide .treesitter ;
1919
20+ import android .text .TextUtils ;
2021import java .util .Objects ;
2122
2223public class TSQuery implements AutoCloseable {
@@ -157,6 +158,21 @@ private void validatePatternIndex(int pattern) {
157158 }
158159 }
159160
161+ /**
162+ * Creates a new {@link TSQuery} with the given {@link TSLanguage} and query source. If the
163+ * language or the query source is invalid, {@link TSQuery#EMPTY} is returned.
164+ *
165+ * @param language The {@link TSLanguage} for the query.
166+ * @param query The query source.
167+ * @return The {@link TSQuery} object.
168+ */
169+ public static TSQuery create (TSLanguage language , String query ) {
170+ if (language == null || query == null || TextUtils .getTrimmedLength (query ) == 0 ) {
171+ return EMPTY ;
172+ }
173+ return new TSQuery (language , query );
174+ }
175+
160176 /**
161177 * An empty query. Instances of this class are invalid queries and does not have any patterns,
162178 * capture names, etc. The <code>get*Count()</code> methods always return <code>0</code>, the
You can’t perform that action at this time.
0 commit comments