? = null,
36 | val extraData: Any? = null
37 | )
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/lang/styling/inlayHint/InlayHintLayoutType.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.lang.styling.inlayHint
26 |
27 | enum class InlayHintLayoutType {
28 | IN_LINE,
29 | ABOVE_LINE,
30 | BELOW_LINE
31 | }
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/lang/styling/line/LineSideIcon.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.lang.styling.line
26 |
27 | import android.graphics.drawable.Drawable
28 |
29 | /**
30 | * A small icon shown at the left of line.
31 | * Note that the bounds of the drawable is specified every time the drawable is drawn on screen.
32 | *
33 | * @author Rosemoe
34 | */
35 | data class LineSideIcon(override var line: Int, val drawable: Drawable) : LineAnchorStyle(line)
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/lang/styling/span/SpanExt.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.lang.styling.span
26 |
27 | import io.github.rosemoe.sora.lang.styling.Span
28 |
29 | /**
30 | * Extended attribute for [Span]. These attributes are uncommonly-used, and will be stored in
31 | * a lazily initialized map to save memory.
32 | */
33 | interface SpanExt
34 |
35 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/lang/styling/span/SpanInteractionInfo.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.lang.styling.span
26 |
27 | /**
28 | * Interaction attributes for a [Span].
29 | */
30 | interface SpanInteractionInfo : SpanExt {
31 |
32 | fun isClickable(): Boolean
33 |
34 | fun isLongClickable(): Boolean
35 |
36 | fun isDoubleClickable(): Boolean
37 |
38 | fun getData(): Any?
39 |
40 | }
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/text/Content.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.text
26 |
27 | /**
28 | * A delegate method.
29 | * Notify the UndoManager to batch edit.
30 | * @see Content.beginBatchEdit
31 | * @see Content.endBatchEdit
32 | */
33 | fun Content.batchEdit(block: (Content) -> Unit): Content {
34 | this.beginBatchEdit()
35 | block(this)
36 | this.endBatchEdit()
37 | return this
38 | }
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/text/bidi/BidiRequirementChecker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.text.bidi;
25 |
26 | public interface BidiRequirementChecker {
27 |
28 | boolean mayNeedBidi();
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/util/ArrayList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.util;
25 |
26 | /**
27 | * Expose {@link java.util.ArrayList#removeRange(int, int)} to public.
28 | *
29 | * {@inheritDoc}
30 | */
31 | public class ArrayList extends java.util.ArrayList {
32 |
33 | public ArrayList() {
34 | super();
35 | }
36 |
37 | public ArrayList(int initialCapacity) {
38 | super(initialCapacity);
39 | }
40 |
41 | @Override
42 | public void removeRange(int fromIndex, int toIndex) {
43 | super.removeRange(fromIndex, toIndex);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/util/EditorHandler.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.util
26 |
27 | import android.os.Handler
28 | import android.os.Looper
29 |
30 | object EditorHandler : Handler(Looper.getMainLooper())
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/util/Floats.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.util;
25 |
26 | public class Floats {
27 |
28 | public static boolean withinDelta(float a, float b, float delta) {
29 | return Math.abs(a - b) < Math.abs(delta);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/util/MutableInt.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.util;
25 |
26 | public class MutableInt {
27 |
28 | public int value;
29 |
30 | public MutableInt(int v) {
31 | value = v;
32 | }
33 |
34 | public int decreaseAndGet() {
35 | return --value;
36 | }
37 |
38 | public void increase() {
39 | value++;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/util/ThemeUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.util;
25 |
26 | import android.util.TypedValue;
27 | import android.view.ContextThemeWrapper;
28 |
29 | public class ThemeUtils {
30 |
31 | public static int getColorPrimary(ContextThemeWrapper context) {
32 | TypedValue typedValue = new TypedValue();
33 | context.getTheme().resolveAttribute(android.R.attr.colorPrimary, typedValue, true);
34 | return typedValue.data;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/util/regex/RegexBackrefGrammar.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2025 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.util.regex;
25 |
26 | public class RegexBackrefGrammar {
27 |
28 | public final static RegexBackrefGrammar DEFAULT = new RegexBackrefGrammar('$', '\\');
29 |
30 | public final char backrefStartChar;
31 |
32 | public final char escapeChar;
33 |
34 | public RegexBackrefGrammar(char backrefStartChar, char escapeChar) {
35 | this.backrefStartChar = backrefStartChar;
36 | this.escapeChar = escapeChar;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/widget/rendering/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 |
25 |
26 | /**
27 | * This package contains classes related to editor rendering.
28 | */
29 | package io.github.rosemoe.sora.widget.rendering;
30 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/widget/snippet/variable/FileBasedSnippetVariableResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.widget.snippet.variable;
25 |
26 | import androidx.annotation.NonNull;
27 |
28 | public abstract class FileBasedSnippetVariableResolver implements ISnippetVariableResolver {
29 |
30 | @NonNull
31 | @Override
32 | public String[] getResolvableNames() {
33 | return new String[]{
34 | "TM_FILENAME", "TM_FILENAME_BASE", "TM_DIRECTORY", "TM_FILEPATH", "RELATIVE_PATH"
35 | };
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/widget/snippet/variable/WorkspaceBasedSnippetVariableResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.widget.snippet.variable;
25 |
26 | import androidx.annotation.NonNull;
27 |
28 | public abstract class WorkspaceBasedSnippetVariableResolver implements ISnippetVariableResolver {
29 |
30 | @NonNull
31 | @Override
32 | public String[] getResolvableNames() {
33 | return new String[]{
34 | "WORKSPACE_NAME", "WORKSPACE_FOLDER"
35 | };
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/widget/style/DiagnosticIndicatorStyle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.widget.style;
25 |
26 | /**
27 | * Style for diagnostic displaying
28 | *
29 | * @author Rosemoe
30 | */
31 | public enum DiagnosticIndicatorStyle {
32 | NONE,
33 | LINE,
34 | DOUBLE_LINE,
35 | WAVY_LINE
36 | }
37 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/widget/style/LineInfoPanelPosition.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.widget.style;
25 |
26 | public class LineInfoPanelPosition {
27 | public static final int LEFT = 1;
28 | public static final int TOP = 2;
29 | public static final int RIGHT = 4;
30 | public static final int BOTTOM = 8;
31 | public static final int CENTER = 15;
32 | }
33 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/widget/style/LineInfoPanelPositionMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.widget.style;
25 |
26 | public class LineInfoPanelPositionMode {
27 | public static final int FIXED = 0;
28 | public static final int FOLLOW = 1;
29 | }
30 |
--------------------------------------------------------------------------------
/editor/src/main/java/io/github/rosemoe/sora/widget/style/builtin/DefaultLineNumberTip.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.widget.style.builtin
26 |
27 | import io.github.rosemoe.sora.widget.CodeEditor
28 | import io.github.rosemoe.sora.widget.style.LineNumberTipTextProvider
29 |
30 | object DefaultLineNumberTip : LineNumberTipTextProvider {
31 |
32 | override fun getCurrentText(editor: CodeEditor) = "L${editor.firstVisibleLine + 1}"
33 |
34 | }
--------------------------------------------------------------------------------
/editor/src/main/res/anim/anim_text_action_popup_enter.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 |
32 |
33 |
--------------------------------------------------------------------------------
/editor/src/main/res/anim/anim_text_action_popup_exit.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 |
32 |
33 |
--------------------------------------------------------------------------------
/editor/src/main/res/drawable/magnifier_background.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/editor/src/main/res/layout/magnifier_popup.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
--------------------------------------------------------------------------------
/editor/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 | @android:color/background_dark
27 | @android:color/white
28 |
--------------------------------------------------------------------------------
/editor/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 | @android:color/tertiary_text_light
27 | @android:color/background_light
28 | @android:color/black
29 |
--------------------------------------------------------------------------------
/editor/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Aug 03 16:05:07 CST 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
5 | networkTimeout=10000
6 | validateDistributionUrl=true
7 | zipStoreBase=GRADLE_USER_HOME
8 | zipStorePath=wrapper/dists
9 |
--------------------------------------------------------------------------------
/images/editor_banner.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/images/editor_banner.jpg
--------------------------------------------------------------------------------
/images/general.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/images/general.jpg
--------------------------------------------------------------------------------
/images/problem_indicators.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/images/problem_indicators.jpg
--------------------------------------------------------------------------------
/language-java/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/language-java/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/language-java/consumer-rules.pro
--------------------------------------------------------------------------------
/language-java/gradle.properties:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # sora-editor - the awesome code editor for Android
3 | # https://github.com/Rosemoe/sora-editor
4 | # Copyright (C) 2020-2024 Rosemoe
5 | #
6 | # This library is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU Lesser General Public
8 | # License as published by the Free Software Foundation; either
9 | # version 2.1 of the License, or (at your option) any later version.
10 | #
11 | # This library is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # Lesser General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU Lesser General Public
17 | # License along with this library; if not, write to the Free Software
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | # USA
20 | #
21 | # Please contact Rosemoe by email 2073412493@qq.com if you need
22 | # additional information or have any questions
23 | ################################################################################
24 |
25 | POM_ARTIFACT_ID=language-java
26 | POM_NAME=language-java
27 | POM_DESCRIPTION=An awesome code editor library on Android
28 | POM_PACKAGING=aar
29 |
--------------------------------------------------------------------------------
/language-java/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/language-java/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/language-java/src/test/java/io/github/rosemoe/langs/java/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.langs.java;
25 |
26 | import static org.junit.Assert.assertEquals;
27 |
28 | import org.junit.Test;
29 |
30 | /**
31 | * Example local unit test, which will execute on the development machine (host).
32 | *
33 | * @see Testing documentation
34 | */
35 | public class ExampleUnitTest {
36 | @Test
37 | public void addition_isCorrect() {
38 | assertEquals(4, 2 + 2);
39 | }
40 | }
--------------------------------------------------------------------------------
/language-monarch/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/language-monarch/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/language-monarch/consumer-rules.pro
--------------------------------------------------------------------------------
/language-monarch/gradle.properties:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # sora-editor - the awesome code editor for Android
3 | # https://github.com/Rosemoe/sora-editor
4 | # Copyright (C) 2020-2024 Rosemoe
5 | #
6 | # This library is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU Lesser General Public
8 | # License as published by the Free Software Foundation; either
9 | # version 2.1 of the License, or (at your option) any later version.
10 | #
11 | # This library is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # Lesser General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU Lesser General Public
17 | # License along with this library; if not, write to the Free Software
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | # USA
20 | #
21 | # Please contact Rosemoe by email 2073412493@qq.com if you need
22 | # additional information or have any questions
23 | ################################################################################
24 |
25 | POM_ARTIFACT_ID=language-monarch
26 | POM_NAME=language-monarch
27 | POM_DESCRIPTION=An awesome code editor library on Android
28 | POM_PACKAGING=aar
29 |
--------------------------------------------------------------------------------
/language-monarch/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/language-monarch/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/MonarchState.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.langs.monarch
26 |
27 | import io.github.dingyi222666.monarch.types.TokenizeState
28 | import io.github.dingyi222666.regex.MatchResult
29 |
30 | data class MonarchState(
31 | val tokenizeState: TokenizeState,
32 | val foldingCache: MatchResult?,
33 | val indent: Int,
34 | val identifiers: List?
35 | )
36 |
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/folding/FoldingHelper.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.langs.monarch.folding
26 |
27 | import io.github.dingyi222666.regex.MatchResult
28 |
29 | interface FoldingHelper {
30 | fun getResultFor(line: Int): MatchResult?
31 |
32 | fun getIndentFor(line: Int): Int
33 | }
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/folding/FoldingRegion.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.langs.monarch.folding
25 |
26 | class FoldingRegion(private val ranges: FoldingRegions, private val regionIndex: Int) {
27 | val startLineNumber: Int
28 | get() = ranges.getStartLineNumber(this.regionIndex)
29 |
30 | val endLineNumber: Int
31 | get() = ranges.getEndLineNumber(this.regionIndex)
32 |
33 | @get:Throws(Exception::class)
34 | val parentIndex: Int
35 | get() = ranges.getParentIndex(this.regionIndex)
36 | }
37 |
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/folding/PreviousRegion.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.langs.monarch.folding
25 |
26 | data class PreviousRegion(// indent or -2 if a marker
27 | var indent: Int, // end line number for the region above
28 | var endAbove: Int, // start line of the region. Only used for marker regions.
29 | var line: Int
30 | )
31 |
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/AutoClosingPair.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model
16 |
17 | interface BaseAutoClosingPair {
18 | val open: String
19 | val close: String
20 | val isSurroundingPair: Boolean
21 | }
22 |
23 | data class AutoClosingPair(
24 | override val open: String,
25 | override val close: String,
26 | override val isSurroundingPair: Boolean = false
27 | ): BaseAutoClosingPair
28 |
29 | data class AutoClosingPairConditional(
30 | override val open: String,
31 | override val close: String,
32 | val notIn: List,
33 | override val isSurroundingPair: Boolean = false
34 | ): BaseAutoClosingPair
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/CommentRule.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model
16 |
17 | data class CommentRule (
18 | val lineComment: String? = null,
19 | val blockComment: CharacterPair? = null
20 | )
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/CompleteEnterAction.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model
16 |
17 | data class CompleteEnterAction(
18 | /**
19 | * Describe what to do with the indentation.
20 | */
21 | val indentAction: Int,
22 | /**
23 | * Describes text to be appended after the new line and after the indentation.
24 | */
25 | val appendText: String,
26 | /**
27 | * Describes the number of characters to remove from the new line's indentation.
28 | */
29 | val removeText: Int?,
30 | /**
31 | * The line's indentation minus removeText
32 | */
33 | val indentation: String
34 | )
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/EnterAction.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model
16 |
17 | data class EnterAction(
18 | val indentAction: Int,
19 | val appendText: String? = null,
20 | val removeText: Int? = null
21 | )
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/FoldingMarkers.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model
16 |
17 | import io.github.dingyi222666.regex.Regex
18 |
19 | data class FoldingMarkers(
20 | val start: Regex,
21 | val end: Regex
22 | )
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/FoldingRules.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model
16 |
17 | data class FoldingRules(
18 | val offSide: Boolean? = null,
19 | val markers: FoldingMarkers? = null
20 | )
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/IndentAction.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model
16 |
17 | object IndentAction {
18 | const val None = 0
19 | const val Indent = 1
20 | const val IndentOutdent = 2
21 | const val Outdent = 3
22 | }
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/IndentationRule.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model
16 |
17 | import io.github.dingyi222666.regex.Regex
18 |
19 | data class IndentationRule(
20 | val decreaseIndentPattern: Regex,
21 | val increaseIndentPattern: Regex,
22 | val indentNextLinePattern: Regex? = null,
23 | val unIndentedLinePattern: Regex? = null
24 | )
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/languageconfiguration/model/OnEnterRule.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.languageconfiguration.model
16 |
17 | import io.github.dingyi222666.regex.Regex
18 |
19 | data class OnEnterRule(
20 | val beforeText: Regex,
21 | val afterText: Regex? = null,
22 | val previousLineText: Regex? = null,
23 | val action: EnterAction
24 | )
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/registry/model/GrammarDefinition.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.langs.monarch.registry.model;
25 |
26 | import io.github.rosemoe.sora.langs.monarch.languageconfiguration.model.LanguageConfiguration
27 |
28 |
29 | data class GrammarDefinition(
30 | val name: String,
31 | val grammar: T,
32 | val embeddedLanguages: Map,
33 | val languageConfiguration: LanguageConfiguration? = null,
34 | var scopeName: String,
35 | )
36 |
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/registry/provider/AssetsFileResolver.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.langs.monarch.registry.provider
25 |
26 | import android.content.res.AssetManager
27 | import java.io.InputStream
28 |
29 | class AssetsFileResolver(private var assetManager: AssetManager?) : FileResolver {
30 | override fun resolve(path: String): InputStream? {
31 | return assetManager?.open(path)
32 | }
33 |
34 | override fun dispose() {
35 | // assetManager?.close()
36 | assetManager = null
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/theme/ColorMap.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.theme
16 |
17 | class ColorMap {
18 |
19 | private var lastColorId: Int = -1
20 | private val id2color = mutableListOf()
21 | private val color2id = mutableMapOf()
22 |
23 | fun getId(color: String?): Int {
24 | if (color == null) {
25 | return 0
26 | }
27 | return color2id.getOrPut(color) {
28 | lastColorId++
29 | id2color.add(lastColorId, color)
30 | lastColorId
31 | }
32 | }
33 |
34 | fun getColor(id: Int): String? {
35 | return id2color.getOrNull(id)
36 | }
37 |
38 | val colorMap: List
39 | get() = id2color.toList()
40 |
41 | override fun toString(): String {
42 | return "ColorMap(lastColorId=$lastColorId, id2color=$id2color, color2id=$color2id)"
43 | }
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/theme/ExternalThemeTrieElement.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.theme
16 |
17 | class ExternalThemeTrieElement(
18 | val mainRule: ThemeTrieElementRule,
19 | children: Map = mapOf()
20 | ) {
21 | val children = children.toMutableMap()
22 | }
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/theme/ThemeDefaultColors.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.theme
16 |
17 | class ThemeDefaultColors(
18 | defaultColors: Map,
19 | val oldTextMateStyle: Boolean = false
20 | ) {
21 | private val colors = mutableMapOf()
22 |
23 | init {
24 | colors.putAll(defaultColors)
25 | }
26 |
27 | constructor() : this(emptyMap())
28 |
29 | operator fun get(key: String): String? {
30 | return colors[key]
31 | }
32 |
33 | fun putColors(map: Map) {
34 | colors.putAll(map)
35 | }
36 |
37 | fun getColor(key: String): String? {
38 | return colors[key]
39 | }
40 |
41 | fun getColors(): Map {
42 | return colors
43 | }
44 |
45 | override fun toString(): String {
46 | return "ThemeDefaultColors(colors=$colors)"
47 | }
48 |
49 | companion object {
50 | val EMPTY = ThemeDefaultColors()
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/language-monarch/src/main/java/io/github/rosemoe/sora/langs/monarch/theme/types.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | * Sebastian Thomschke (Vegard IT GmbH) - add previousLineText support
12 | *
13 | ******************************************************************************/
14 |
15 | package io.github.rosemoe.sora.langs.monarch.theme
16 |
17 |
18 | interface ITokenThemeRule {
19 | var token: String
20 | var foreground: String?
21 | var background: String?
22 | var fontStyle: String?
23 | }
24 |
25 | class ParsedTokenThemeRule(
26 | val token: String,
27 | val index: Int,
28 | val fontStyle: Int,
29 | val foreground: String?,
30 | val background: String?
31 | )
--------------------------------------------------------------------------------
/language-textmate/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/language-textmate/README.md:
--------------------------------------------------------------------------------
1 | ## About
2 |
3 | **Work In Progress** `language-textmate` module is a module that performs syntax highlighting and other functions dynamically. To use it, you need to introduce several other `textmate-*` modules.Our goal is to achieve the effect of VSCode. However, for many reasons, this may be difficult to achieve in the short term.
4 |
5 | ## Features(already available)
6 |
7 | 1. Highlighting of files based on syntax rules
8 | 2. Load color theme from file
9 | 3. Code block line based on indent and rule
10 |
11 | ## How to get syntax and theme files
12 | If many people use this module, they may collect the available configuration files into a repository later.
13 | - You can obtain relevant documents from [Textmate](https://github.com/textmate).
14 | - Eclipse also uses Textmate, and you can also get files from its related repository。
15 | - Textmate is also used in [vscode](https://github.com/microsoft/vscode/tree/main/extensions), but its version is ahead of the version used in this module. You can get the configuration file from its source code, but not all of them can be used normally
--------------------------------------------------------------------------------
/language-textmate/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/language-textmate/consumer-rules.pro
--------------------------------------------------------------------------------
/language-textmate/gradle.properties:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # sora-editor - the awesome code editor for Android
3 | # https://github.com/Rosemoe/sora-editor
4 | # Copyright (C) 2020-2024 Rosemoe
5 | #
6 | # This library is free software; you can redistribute it and/or
7 | # modify it under the terms of the GNU Lesser General Public
8 | # License as published by the Free Software Foundation; either
9 | # version 2.1 of the License, or (at your option) any later version.
10 | #
11 | # This library is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | # Lesser General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU Lesser General Public
17 | # License along with this library; if not, write to the Free Software
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | # USA
20 | #
21 | # Please contact Rosemoe by email 2073412493@qq.com if you need
22 | # additional information or have any questions
23 | ################################################################################
24 |
25 | POM_ARTIFACT_ID=language-textmate
26 | POM_NAME=language-textmate
27 | POM_DESCRIPTION=An awesome code editor library on Android
28 | POM_PACKAGING=aar
29 |
--------------------------------------------------------------------------------
/language-textmate/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/language-textmate/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/io/github/rosemoe/sora/langs/textmate/folding/FoldingHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.langs.textmate.folding;
25 |
26 | import org.eclipse.tm4e.core.internal.oniguruma.OnigResult;
27 |
28 | public interface FoldingHelper {
29 |
30 | OnigResult getResultFor(int line);
31 |
32 | int getIndentFor(int line);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/io/github/rosemoe/sora/langs/textmate/folding/PreviousRegion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | */
24 | package io.github.rosemoe.sora.langs.textmate.folding;
25 |
26 | public class PreviousRegion {
27 | // indent or -2 if a marker
28 | public int indent;
29 | // end line number for the region above
30 | public int endAbove;
31 | // start line of the region. Only used for marker regions.
32 | public int line;
33 |
34 | public PreviousRegion(int indent, int endAbove, int line) {
35 | this.indent = indent;
36 | this.endAbove = endAbove;
37 | this.line = line;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/TMException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | */
12 | package org.eclipse.tm4e.core;
13 |
14 | /**
15 | * TextMate exception.
16 | *
17 | */
18 | public class TMException extends RuntimeException {
19 |
20 | private static final long serialVersionUID = 1L;
21 |
22 | public TMException(final String message) {
23 | super(message);
24 | }
25 |
26 | public TMException(final String message, final Throwable cause) {
27 | super(message, cause);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/grammar/IStateStack.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.grammar;
18 |
19 | /**
20 | * Represents a "pushed" state on the stack (as a linked list element).
21 | *
22 | * @see
23 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts
24 | */
25 | public interface IStateStack {
26 | int getDepth();
27 | }
28 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/grammar/IToken.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.grammar;
18 |
19 | import java.util.List;
20 |
21 | /**
22 | * @see
23 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts
24 | */
25 | public interface IToken {
26 |
27 | /**
28 | * 0-based start-index, inclusive
29 | */
30 | int getStartIndex();
31 |
32 | void setStartIndex(int startIndex);
33 |
34 | /**
35 | * 0-based end-index, exclusive
36 | */
37 | int getEndIndex();
38 |
39 | List getScopes();
40 | }
41 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/grammar/ITokenizeLineResult.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.grammar;
18 |
19 | /**
20 | * Result of the line tokenization API.
21 | *
22 | * @see
23 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts
24 | */
25 | public interface ITokenizeLineResult {
26 |
27 | T getTokens();
28 |
29 | /**
30 | * Returns the `prevState` to be passed on to the next line tokenization.
31 | *
32 | * @return the `prevState` to be passed on to the next line tokenization.
33 | */
34 | IStateStack getRuleStack();
35 |
36 | /**
37 | * Did tokenization stop early due to reaching the time limit.
38 | */
39 | boolean isStoppedEarly();
40 | }
41 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/BasicScopeAttributes.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * Angelo Zerr - initial API and implementation
15 | */
16 | package org.eclipse.tm4e.core.internal.grammar;
17 |
18 | /**
19 | * @see
21 | * github.com/microsoft/vscode-textmate/blob/main/src/basicScopesAttributeProvider.ts
22 | */
23 | final class BasicScopeAttributes {
24 |
25 | final int languageId;
26 | final int /*OptionalStandardTokenType*/ tokenType;
27 |
28 | BasicScopeAttributes(final int languageId, final int /*OptionalStandardTokenType*/ tokenType) {
29 | this.languageId = languageId;
30 | this.tokenType = tokenType;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/TokenTypeMatcher.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Sebastian Thomschke and others.
3 | *
4 | * This program and the accompanying materials are made
5 | * available under the terms of the Eclipse Public License 2.0
6 | * which is available at https://www.eclipse.org/legal/epl-2.0/
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | *
10 | * Initial code from https://github.com/microsoft/vscode-textmate/
11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
12 | * Initial license: MIT
13 | *
14 | * Contributors:
15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
16 | * - Sebastian Thomschke - translation and adaptation to Java
17 | */
18 | package org.eclipse.tm4e.core.internal.grammar;
19 |
20 | import java.util.List;
21 |
22 | import org.eclipse.tm4e.core.internal.matcher.Matcher;
23 |
24 | /**
25 | * @see
27 | * github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammar.ts
28 | */
29 | final class TokenTypeMatcher {
30 |
31 | final Matcher> matcher;
32 | final int /*StandardTokenType*/ type;
33 |
34 | TokenTypeMatcher(final Matcher> matcher, final int type) {
35 | this.matcher = matcher;
36 | this.type = type;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/TokenizeLineResult.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.grammar;
18 |
19 | import org.eclipse.tm4e.core.grammar.ITokenizeLineResult;
20 |
21 | /**
22 | * Result of the line tokenization implementation.
23 | */
24 | final class TokenizeLineResult implements ITokenizeLineResult {
25 |
26 | private final T tokens;
27 | private final StateStack ruleStack;
28 | private final boolean stoppedEarly;
29 |
30 | TokenizeLineResult(final T tokens, final StateStack ruleStack, final boolean stoppedEarly) {
31 | this.tokens = tokens;
32 | this.ruleStack = ruleStack;
33 | this.stoppedEarly = stoppedEarly;
34 | }
35 |
36 | @Override
37 | public T getTokens() {
38 | return tokens;
39 | }
40 |
41 | @Override
42 | public StateStack getRuleStack() {
43 | return ruleStack;
44 | }
45 |
46 | @Override
47 | public boolean isStoppedEarly() {
48 | return stoppedEarly;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/IRawCaptures.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.grammar.raw;
18 |
19 | /**
20 | * @see
22 | * github.com/microsoft/vscode-textmate/blob/main/src/rawGrammar.ts
23 | */
24 | public interface IRawCaptures {
25 |
26 | IRawRule getCapture(String captureId);
27 |
28 | Iterable getCaptureIds();
29 | }
30 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/IRawGrammar.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.grammar.raw;
18 |
19 | import java.util.Collection;
20 | import java.util.Map;
21 |
22 | import org.eclipse.jdt.annotation.Nullable;
23 |
24 | /**
25 | * @see
27 | * github.com/microsoft/vscode-textmate/blob/main/src/rawGrammar.ts
28 | */
29 | public interface IRawGrammar {
30 |
31 | IRawRepository getRepository();
32 |
33 | String getScopeName();
34 |
35 | @Nullable // TODO non-null in upstream project
36 | Collection getPatterns();
37 |
38 | @Nullable
39 | Map getInjections();
40 |
41 | @Nullable
42 | String getInjectionSelector();
43 |
44 | Collection getFileTypes();
45 |
46 | @Nullable
47 | String getName();
48 |
49 | @Nullable
50 | String getFirstLineMatch();
51 |
52 | void setRepository(IRawRepository repository);
53 |
54 | IRawRule toRawRule();
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawCaptures.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Sebastian Thomschke and others.
3 | *
4 | * This program and the accompanying materials are made
5 | * available under the terms of the Eclipse Public License 2.0
6 | * which is available at https://www.eclipse.org/legal/epl-2.0/
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | */
10 | package org.eclipse.tm4e.core.internal.grammar.raw;
11 |
12 | import org.eclipse.tm4e.core.internal.parser.PropertySettable;
13 |
14 | public final class RawCaptures extends PropertySettable.HashMap implements IRawCaptures {
15 |
16 | private static final long serialVersionUID = 1L;
17 |
18 | @Override
19 | public IRawRule getCapture(final String captureId) {
20 | return get(captureId);
21 | }
22 |
23 | @Override
24 | public Iterable getCaptureIds() {
25 | return keySet();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/tokenattrs/OptionalStandardTokenType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Sebastian Thomschke and others.
3 | *
4 | * This program and the accompanying materials are made
5 | * available under the terms of the Eclipse Public License 2.0
6 | * which is available at https://www.eclipse.org/legal/epl-2.0/
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | *
10 | * Initial code from https://github.com/microsoft/vscode-textmate/
11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
12 | * Initial license: MIT
13 | *
14 | * Contributors:
15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
16 | * - Sebastian Thomschke - translation and adaptation to Java
17 | */
18 | package org.eclipse.tm4e.core.internal.grammar.tokenattrs;
19 |
20 | /**
21 | * @see
23 | * github.com/microsoft/vscode-textmate/blob/main/src/encodedTokenAttributes.ts
24 | */
25 | public final class OptionalStandardTokenType {
26 |
27 | // Must have the same values as `StandardTokenType`!
28 | public static final int Other = StandardTokenType.Other;
29 | public static final int Comment = StandardTokenType.Comment;
30 | public static final int String = StandardTokenType.String;
31 | public static final int RegEx = StandardTokenType.RegEx;
32 |
33 | /**
34 | * Indicates that no token type is set.
35 | */
36 | public static final int NotSet = 8;
37 |
38 | /**
39 | * Content should be accessed statically
40 | */
41 | private OptionalStandardTokenType() {
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/grammar/tokenattrs/StandardTokenType.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | */
12 | package org.eclipse.tm4e.core.internal.grammar.tokenattrs;
13 |
14 | /**
15 | * Standard TextMate token type.
16 | *
17 | * @see
19 | * github.com/microsoft/vscode-textmate/blob/main/src/encodedTokenAttributes.ts
20 | */
21 | public final class StandardTokenType {
22 |
23 | public static final int Other = 0;
24 | public static final int Comment = 1;
25 | public static final int String = 2;
26 | public static final int RegEx = 3;
27 |
28 | /**
29 | * Content should be accessed statically
30 | */
31 | private StandardTokenType() {
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/matcher/Matcher.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.matcher;
18 |
19 | import java.util.List;
20 |
21 | @FunctionalInterface
22 | public interface Matcher {
23 |
24 | static List>> createMatchers(final String selector) {
25 | return createMatchers(selector, NameMatcher.DEFAULT);
26 | }
27 |
28 | static List>> createMatchers(final String selector,
29 | final NameMatcher> matchesName) {
30 | return new MatcherBuilder<>(selector, matchesName).results;
31 | }
32 |
33 | boolean matches(T t);
34 | }
35 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/matcher/MatcherWithPriority.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.matcher;
18 |
19 | public final class MatcherWithPriority {
20 |
21 | public final Matcher matcher;
22 | public final int priority;
23 |
24 | MatcherWithPriority(final Matcher matcher, final int priority) {
25 | this.matcher = matcher;
26 | this.priority = priority;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/oniguruma/OnigScanner.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/atom/node-oniguruma
10 | * Initial copyright Copyright (c) 2013 GitHub Inc.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - GitHub Inc.: Initial code, written in JavaScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.oniguruma;
18 |
19 | import java.util.List;
20 |
21 | import org.eclipse.jdt.annotation.Nullable;
22 |
23 | /**
24 | * @see
25 | * github.com/atom/node-oniguruma/blob/master/src/onig-scanner.cc
26 | */
27 | public final class OnigScanner {
28 |
29 | private final OnigSearcher searcher;
30 |
31 | public OnigScanner(final List regexps) {
32 | searcher = new OnigSearcher(regexps);
33 | }
34 |
35 | @Nullable
36 | public OnigScannerMatch findNextMatch(final OnigString source, final int startPosition) {
37 | final OnigResult bestResult = searcher.search(source, startPosition);
38 | if (bestResult != null) {
39 | return new OnigScannerMatch(bestResult, source);
40 | }
41 | return null;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/parser/PropertySettable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Sebastian Thomschke and others.
3 | *
4 | * This program and the accompanying materials are made
5 | * available under the terms of the Eclipse Public License 2.0
6 | * which is available at https://www.eclipse.org/legal/epl-2.0/
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | *
10 | * Contributors:
11 | * Sebastian Thomschke - initial implementation
12 | */
13 | package org.eclipse.tm4e.core.internal.parser;
14 |
15 | public interface PropertySettable {
16 |
17 | public class ArrayList extends java.util.ArrayList implements PropertySettable {
18 |
19 | private static final long serialVersionUID = 1L;
20 |
21 | @Override
22 | public void setProperty(final String name, final T value) {
23 | final var idx = Integer.parseInt(name);
24 | if (idx == size())
25 | add(value);
26 | else
27 | set(idx, value);
28 | }
29 | }
30 |
31 | public class HashMap extends java.util.HashMap implements PropertySettable {
32 |
33 | private static final long serialVersionUID = 1L;
34 |
35 | @Override
36 | public void setProperty(final String name, final T value) {
37 | put(name, value);
38 | }
39 | }
40 |
41 | void setProperty(String name, V value);
42 | }
43 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/parser/TMParserYAML.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2023 Vegard IT GmbH and others.
3 | *
4 | * This program and the accompanying materials are made
5 | * available under the terms of the Eclipse Public License 2.0
6 | * which is available at https://www.eclipse.org/legal/epl-2.0/
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | *
10 | * Contributors:
11 | * Sebastian Thomschke (Vegard IT) - initial implementation
12 | */
13 | package org.eclipse.tm4e.core.internal.parser;
14 |
15 | import java.io.Reader;
16 | import java.util.ArrayList;
17 | import java.util.HashMap;
18 | import java.util.HashSet;
19 | import java.util.Map;
20 |
21 | import org.snakeyaml.engine.v2.api.Load;
22 | import org.snakeyaml.engine.v2.api.LoadSettings;
23 |
24 | public final class TMParserYAML extends TMParserJSON {
25 |
26 | public static final TMParserYAML INSTANCE = new TMParserYAML();
27 |
28 | private static final LoadSettings LOAD_SETTINGS = LoadSettings.builder()
29 | .setDefaultList(ArrayList::new)
30 | .setDefaultMap(HashMap::new)
31 | .setDefaultSet(HashSet::new)
32 | .build();
33 |
34 | @Override
35 | @SuppressWarnings({ "null", "unchecked" })
36 | protected Map loadRaw(final Reader source) {
37 | return (Map) new Load(LOAD_SETTINGS).loadFromReader(source);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/registry/IGrammarRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.registry;
18 |
19 | import java.util.Collection;
20 |
21 | import org.eclipse.jdt.annotation.Nullable;
22 | import org.eclipse.tm4e.core.internal.grammar.raw.IRawGrammar;
23 |
24 | /**
25 | * TextMate grammar repository API.
26 | *
27 | * @see
29 | * github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammar.ts
30 | */
31 | public interface IGrammarRepository {
32 |
33 | /**
34 | * Lookup a raw grammar.
35 | */
36 | @Nullable
37 | IRawGrammar lookup(String scopeName);
38 |
39 | /**
40 | * Returns the injections for the given grammar
41 | */
42 | @Nullable
43 | Collection injections(String targetScope);
44 | }
45 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/registry/IThemeProvider.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | */
12 | package org.eclipse.tm4e.core.internal.registry;
13 |
14 | import org.eclipse.jdt.annotation.Nullable;
15 | import org.eclipse.tm4e.core.internal.grammar.ScopeStack;
16 | import org.eclipse.tm4e.core.internal.theme.StyleAttributes;
17 |
18 | /**
19 | * @see
21 | * github.com/microsoft/vscode-textmate/blob/main/src/grammar/grammar.ts
22 | */
23 | public interface IThemeProvider {
24 |
25 | @Nullable
26 | StyleAttributes themeMatch(ScopeStack scopePath);
27 |
28 | StyleAttributes getDefaults();
29 | }
30 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/CompilePatternsResult.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.rule;
18 |
19 | /**
20 | * @see
22 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts
23 | */
24 | final class CompilePatternsResult {
25 |
26 | final RuleId[] patterns;
27 | final boolean hasMissingPatterns;
28 |
29 | CompilePatternsResult(final RuleId[] patterns, final boolean hasMissingPatterns) {
30 | this.hasMissingPatterns = hasMissingPatterns;
31 | this.patterns = patterns;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/CompiledRule.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.rule;
18 |
19 | import java.util.List;
20 |
21 | import org.eclipse.tm4e.core.internal.oniguruma.OnigScanner;
22 |
23 | /**
24 | * @see
26 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts
27 | */
28 | public final class CompiledRule {
29 |
30 | public final List debugRegExps;
31 | public final OnigScanner scanner;
32 | public final RuleId[] rules;
33 |
34 | CompiledRule(final List regExps, final RuleId[] rules) {
35 | this.debugRegExps = regExps;
36 | this.rules = rules;
37 | this.scanner = new OnigScanner(regExps);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/IGrammarRegistry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.rule;
18 |
19 | import org.eclipse.jdt.annotation.Nullable;
20 | import org.eclipse.tm4e.core.internal.grammar.raw.IRawGrammar;
21 | import org.eclipse.tm4e.core.internal.grammar.raw.IRawRepository;
22 |
23 | /**
24 | * @see
26 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts
27 | */
28 | interface IGrammarRegistry {
29 |
30 | @Nullable
31 | IRawGrammar getExternalGrammar(String scopeName, IRawRepository repository);
32 | }
33 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/IRuleFactoryHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.rule;
18 |
19 | /**
20 | * @see
22 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts
23 | */
24 | public interface IRuleFactoryHelper extends IRuleRegistry, IGrammarRegistry {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/rule/IRuleRegistry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.internal.rule;
18 |
19 | import java.util.function.Function;
20 |
21 | /**
22 | * @see
24 | * github.com/microsoft/vscode-textmate/blob/main/src/rule.ts
25 | */
26 | public interface IRuleRegistry {
27 |
28 | /**
29 | * @throws IndexOutOfBoundsException if no rule with the given id was found.
30 | */
31 | Rule getRule(RuleId ruleId);
32 |
33 | T registerRule(Function factory);
34 | }
35 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/theme/IThemeSetting.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | */
12 | package org.eclipse.tm4e.core.internal.theme;
13 |
14 | import org.eclipse.jdt.annotation.Nullable;
15 |
16 | public interface IThemeSetting {
17 |
18 | @Nullable
19 | Object getFontStyle();
20 |
21 | @Nullable
22 | String getBackground();
23 |
24 | @Nullable
25 | String getForeground();
26 | }
27 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/theme/raw/IRawTheme.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | */
12 | package org.eclipse.tm4e.core.internal.theme.raw;
13 |
14 | import java.util.Collection;
15 |
16 | import org.eclipse.jdt.annotation.Nullable;
17 |
18 | public interface IRawTheme {
19 |
20 | @Nullable
21 | String getName();
22 |
23 | @Nullable
24 | Collection getSettings();
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/theme/raw/IRawThemeSetting.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | */
12 | package org.eclipse.tm4e.core.internal.theme.raw;
13 |
14 | import org.eclipse.jdt.annotation.Nullable;
15 | import org.eclipse.tm4e.core.internal.theme.IThemeSetting;
16 |
17 | /**
18 | * A single theme setting.
19 | *
20 | * @see
21 | * github.com/microsoft/vscode-textmate/blob/main/src/theme.ts
22 | */
23 | public interface IRawThemeSetting {
24 |
25 | @Nullable
26 | String getName();
27 |
28 | @Nullable
29 | Object getScope();
30 |
31 | @Nullable
32 | IThemeSetting getSetting();
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/internal/utils/ScopeNames.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2024 Sebastian Thomschke and others.
3 | *
4 | * This program and the accompanying materials are made
5 | * available under the terms of the Eclipse Public License 2.0
6 | * which is available at https://www.eclipse.org/legal/epl-2.0/
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | *
10 | * Contributors:
11 | * - Sebastian Thomschke - initial API and implementation
12 | */
13 | package org.eclipse.tm4e.core.internal.utils;
14 |
15 | import org.eclipse.jdt.annotation.Nullable;
16 |
17 | /**
18 | * Utility class to deal with plugin scoped TextMate Scope Names, e.g. "source.batchfile@com.example.myplugin"
19 | */
20 | public final class ScopeNames {
21 |
22 | public static final char CONTRIBUTOR_SEPARATOR = '@';
23 |
24 | public static @Nullable String getContributor(final String scopeName) {
25 | final int separatorAt = scopeName.indexOf(CONTRIBUTOR_SEPARATOR);
26 | if (separatorAt == -1) {
27 | return "";
28 | }
29 | return scopeName.substring(separatorAt + 1);
30 | }
31 |
32 | /**
33 | * @return true if a scope name is suffixed by the contributing plugin id, e.g. "source.batchfile@com.example.myplugin"
34 | */
35 | public static boolean hasContributor(final String scopeName) {
36 | return scopeName.indexOf(CONTRIBUTOR_SEPARATOR) > -1;
37 | }
38 |
39 | public static String withoutContributor(final String scopeName) {
40 | final int separatorAt = scopeName.indexOf(CONTRIBUTOR_SEPARATOR);
41 | if (separatorAt == -1) {
42 | return scopeName;
43 | }
44 | return scopeName.substring(0, separatorAt);
45 | }
46 |
47 | private ScopeNames() {
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/registry/IGrammarConfiguration.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Sebastian Thomschke and others.
3 | *
4 | * This program and the accompanying materials are made
5 | * available under the terms of the Eclipse Public License 2.0
6 | * which is available at https://www.eclipse.org/legal/epl-2.0/
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | *
10 | * Initial code from https://github.com/microsoft/vscode-textmate/
11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
12 | * Initial license: MIT
13 | *
14 | * Contributors:
15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
16 | * - Sebastian Thomschke - translation and adaptation to Java
17 | */
18 | package org.eclipse.tm4e.core.registry;
19 |
20 | import java.util.List;
21 | import java.util.Map;
22 |
23 | import org.eclipse.jdt.annotation.Nullable;
24 |
25 | /**
26 | * @see
28 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts
29 | */
30 | public interface IGrammarConfiguration {
31 |
32 | @Nullable
33 | default Map getEmbeddedLanguages() {
34 | return null;
35 | }
36 |
37 | @Nullable
38 | default Map getTokenTypes() {
39 | return null;
40 | }
41 |
42 | @Nullable
43 | default List getBalancedBracketSelectors() {
44 | return null;
45 | }
46 |
47 | @Nullable
48 | default List getUnbalancedBracketSelectors() {
49 | return null;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/core/registry/IRegistryOptions.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Initial code from https://github.com/microsoft/vscode-textmate/
10 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
11 | * Initial license: MIT
12 | *
13 | * Contributors:
14 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
15 | * - Angelo Zerr - translation and adaptation to Java
16 | */
17 | package org.eclipse.tm4e.core.registry;
18 |
19 | import java.util.Collection;
20 | import java.util.List;
21 |
22 | import org.eclipse.jdt.annotation.Nullable;
23 | import org.eclipse.tm4e.core.internal.theme.raw.IRawTheme;
24 |
25 | /**
26 | * @see
28 | * github.com/microsoft/vscode-textmate/blob/main/src/main.ts
29 | */
30 | public interface IRegistryOptions {
31 |
32 | @Nullable
33 | default IRawTheme getTheme() {
34 | return null;
35 | }
36 |
37 | @Nullable
38 | default List getColorMap() {
39 | return null;
40 | }
41 |
42 | @Nullable
43 | default IGrammarSource getGrammarSource(@SuppressWarnings("unused") final String scopeName) {
44 | return null;
45 | }
46 |
47 | @Nullable
48 | default Collection getInjections(@SuppressWarnings("unused") final String scopeName) {
49 | return null;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/model/AutoClosingPair.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2022 Sebastian Thomschke and others.
3 | *
4 | * This program and the accompanying materials are made
5 | * available under the terms of the Eclipse Public License 2.0
6 | * which is available at https://www.eclipse.org/legal/epl-2.0/
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | *
10 | * Initial code from https://github.com/microsoft/vscode-textmate/
11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
12 | * Initial license: MIT
13 | *
14 | * Contributors:
15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
16 | * - Sebastian Thomschke - translation and adaptation to Java
17 | */
18 | package org.eclipse.tm4e.languageconfiguration.internal.model;
19 |
20 | /**
21 | * @see
23 | * github.com/microsoft/vscode/blob/main/src/vs/editor/common/languages/languageConfiguration.ts#L196
24 | */
25 | public class AutoClosingPair extends CharacterPair {
26 |
27 | public AutoClosingPair(final String open, final String close) {
28 | super(open, close);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/model/AutoClosingPairConditional.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | */
12 | package org.eclipse.tm4e.languageconfiguration.internal.model;
13 |
14 | import androidx.annotation.NonNull;
15 |
16 | import java.util.List;
17 |
18 | import org.eclipse.tm4e.core.internal.utils.StringUtils;
19 |
20 | /**
21 | * @see
23 | * github.com/microsoft/vscode/blob/main/src/vs/editor/common/languages/languageConfiguration.ts#L201
24 | */
25 | public final class AutoClosingPairConditional extends AutoClosingPair {
26 |
27 | public final List notIn;
28 |
29 | public AutoClosingPairConditional(final String open, final String close, final List notIn) {
30 | super(open, close);
31 | this.notIn = notIn;
32 | }
33 |
34 | @NonNull
35 | @Override
36 | public String toString() {
37 | return StringUtils.toString(this, sb -> sb
38 | .append("open=").append(open).append(", ")
39 | .append("close=").append(close).append(", ")
40 | .append("notIn=").append(notIn));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/model/IndentForEnter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2024 Vegard IT GmbH and others.
3 | *
4 | * This program and the accompanying materials are made
5 | * available under the terms of the Eclipse Public License 2.0
6 | * which is available at https://www.eclipse.org/legal/epl-2.0/
7 | *
8 | * SPDX-License-Identifier: EPL-2.0
9 | *
10 | * Initial code from https://github.com/microsoft/vscode/
11 | * Initial copyright Copyright (C) Microsoft Corporation. All rights reserved.
12 | * Initial license: MIT
13 | *
14 | * Contributors:
15 | * - Microsoft Corporation: Initial code, written in TypeScript, licensed under MIT license
16 | * - Sebastian Thomschke - translation and adaptation to Java
17 | */
18 | package org.eclipse.tm4e.languageconfiguration.internal.model;
19 |
20 | import org.eclipse.tm4e.core.internal.utils.StringUtils;
21 |
22 | /**
23 | * Describes indentation rules for a language.
24 | *
25 | * @see
27 | * github.com/microsoft/vscode/blob/main/src/vs/editor/common/languages/autoIndent.ts#L278
28 | */
29 | public class IndentForEnter {
30 |
31 | public final String beforeEnter;
32 | public final String afterEnter;
33 |
34 | public IndentForEnter(final String beforeEnter, final String afterEnter) {
35 | this.beforeEnter = beforeEnter;
36 | this.afterEnter = afterEnter;
37 | }
38 |
39 | @Override
40 | public String toString() {
41 | return StringUtils.toString(this, sb -> sb
42 | .append("beforeEnter=").append(beforeEnter).append(", ")
43 | .append("afterEnter=").append(afterEnter));
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/language-textmate/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/utils/RegExpUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-2017 Angelo ZERR.
3 | * This program and the accompanying materials are made
4 | * available under the terms of the Eclipse Public License 2.0
5 | * which is available at https://www.eclipse.org/legal/epl-2.0/
6 | *
7 | * SPDX-License-Identifier: EPL-2.0
8 | *
9 | * Contributors:
10 | * Angelo Zerr - initial API and implementation
11 | */
12 | package org.eclipse.tm4e.languageconfiguration.internal.utils;
13 |
14 |
15 | import java.util.regex.Pattern;
16 |
17 | import org.eclipse.jdt.annotation.Nullable;
18 |
19 | import io.github.rosemoe.sora.util.Logger;
20 |
21 | /**
22 | * Regex utilities.
23 | */
24 | public final class RegExpUtils {
25 |
26 | private static final Logger log = Logger.instance(RegExpUtils.class.getName());
27 |
28 | /**
29 | * Escapes regular expression characters in a given string
30 | */
31 | public static String escapeRegExpCharacters(final String value) {
32 | return value.replaceAll("[\\-\\\\\\{\\}\\*\\+\\?\\|\\^\\$\\.\\[\\]\\(\\)\\#]", "\\\\$0"); //$NON-NLS-1$ //$NON-NLS-2$
33 | }
34 |
35 | /**
36 | * Create Java Regexp and null otherwise.
37 | *
38 | * @return Java Regexp and null otherwise.
39 | */
40 | @Nullable
41 | public static Pattern create(final String regex) {
42 | try {
43 | return Pattern.compile(regex);
44 | } catch (final Exception ex) {
45 | log.e("Failed to parse pattern: " + regex, ex);
46 | return null;
47 | }
48 | }
49 |
50 | private RegExpUtils() {
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/language-treesitter/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/language-treesitter/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rosemoe/sora-editor/0d363ed5301870cf234f5636600067404bd5eb3f/language-treesitter/consumer-rules.pro
--------------------------------------------------------------------------------
/language-treesitter/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/language-treesitter/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/language-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/multilang/LanguagePriorityCheck.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.editor.ts.multilang
26 |
27 | interface LanguagePriorityCheck {
28 |
29 | companion object {
30 | val PRIORITY_NEVER = 0
31 | val PRIORITY_AS_FALLBACK = 1
32 | val PRIORITY_ALWAYS = 1000
33 | }
34 |
35 | fun getPriorityByName(name: String) : Int
36 |
37 | }
--------------------------------------------------------------------------------
/language-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/multilang/TsIndentHelper.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.editor.ts.multilang
26 |
27 | interface TsIndentHelper {
28 | }
--------------------------------------------------------------------------------
/language-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/predicate/TsClientPredicateStep.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.editor.ts.predicate
26 |
27 | import com.itsaky.androidide.treesitter.TSQueryPredicateStep
28 |
29 | data class TsClientPredicateStep(
30 | val predicateType: TSQueryPredicateStep.Type,
31 | val content: String
32 | )
33 |
--------------------------------------------------------------------------------
/language-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/predicate/TsSyntheticCapture.kt:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * sora-editor - the awesome code editor for Android
3 | * https://github.com/Rosemoe/sora-editor
4 | * Copyright (C) 2020-2024 Rosemoe
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | *
21 | * Please contact Rosemoe by email 2073412493@qq.com if you need
22 | * additional information or have any questions
23 | ******************************************************************************/
24 |
25 | package io.github.rosemoe.sora.editor.ts.predicate
26 |
27 | import com.itsaky.androidide.treesitter.TSNode
28 |
29 | data class TsSyntheticCapture(
30 | val captureName: String,
31 | val captureText: String? = null,
32 | val captureNode: TSNode? = null
33 | )
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:base", ":disableDependencyDashboard"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------