refactor: move IDEEditor to :editor module (fixes #672)

This commit is contained in:
Akash Yadav
2022-12-20 07:46:43 +05:30
parent 19f947c537
commit fb9096013f
73 changed files with 528 additions and 676 deletions
+1
View File
@@ -40,6 +40,7 @@
<module name="AndroidIDE.build-tools.tools-common" target="11" />
<module name="AndroidIDE.colorschemes" target="11" />
<module name="AndroidIDE.colorschemes.main" target="11" />
<module name="AndroidIDE.editor-languages" target="11" />
<module name="AndroidIDE.google-java-format" target="1.8" />
<module name="AndroidIDE.gradle-tooling" target="1.8" />
<module name="AndroidIDE.gradle-tooling.plugin" target="1.8" />
-1
View File
@@ -140,7 +140,6 @@ dependencies {
implementation project (':actions')
implementation project (':common')
implementation project (':editor')
implementation project (':editor-languages')
implementation project (':emulatorview')
implementation project (':eventbus')
implementation project (':eventbus-android')
@@ -115,7 +115,7 @@ import com.itsaky.androidide.shell.ShellServer;
import com.itsaky.androidide.ui.EditorBottomSheet;
import com.itsaky.androidide.ui.MaterialBanner;
import com.itsaky.androidide.ui.editor.CodeEditorView;
import com.itsaky.androidide.ui.editor.IDEEditor;
import com.itsaky.androidide.editor.ui.IDEEditor;
import com.itsaky.androidide.uidesigner.UIDesignerActivity;
import com.itsaky.androidide.utils.ActionMenuUtils;
import com.itsaky.androidide.utils.DialogUtils;
@@ -20,7 +20,7 @@ package com.itsaky.androidide.actions
import android.content.Context
import android.graphics.drawable.Drawable
import androidx.core.content.ContextCompat
import com.itsaky.androidide.ui.editor.IDEEditor
import com.itsaky.androidide.editor.ui.IDEEditor
/** @author Akash Yadav */
abstract class BaseEditorAction : EditorActionItem {
@@ -18,7 +18,7 @@
package com.itsaky.androidide.actions
import com.itsaky.androidide.ui.editor.CodeEditorView
import com.itsaky.androidide.ui.editor.IDEEditor
import com.itsaky.androidide.editor.ui.IDEEditor
/** @author Akash Yadav */
abstract class EditorRelatedAction : EditorActivityAction(), EditorActionItem {
@@ -27,9 +27,8 @@ import com.blankj.utilcode.util.KeyboardUtils
import com.itsaky.androidide.EditorActivity
import com.itsaky.androidide.actions.ActionData
import com.itsaky.androidide.actions.EditorRelatedAction
import com.itsaky.androidide.actions.markInvisible
import com.itsaky.androidide.resources.R
import com.itsaky.androidide.ui.editor.IDEEditor
import com.itsaky.androidide.editor.ui.IDEEditor
import com.itsaky.androidide.uidesigner.UIDesignerActivity
import java.io.File
@@ -29,7 +29,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.itsaky.androidide.R;
import com.itsaky.androidide.databinding.LayoutSymbolItemBinding;
import com.itsaky.androidide.ui.SymbolInputView.Symbol;
import com.itsaky.androidide.ui.editor.IDEEditor;
import com.itsaky.androidide.editor.ui.IDEEditor;
import java.util.ArrayList;
import java.util.List;
@@ -23,13 +23,10 @@ import android.net.Uri;
import com.blankj.utilcode.util.ThrowableUtils;
import com.itsaky.androidide.BuildConfig;
import com.itsaky.androidide.CrashHandlerActivity;
import com.itsaky.androidide.editor.IEditorProvider;
import com.itsaky.androidide.events.AppEventsIndex;
import com.itsaky.androidide.events.LspApiEventsIndex;
import com.itsaky.androidide.events.LspJavaEventsIndex;
import com.itsaky.androidide.events.ProjectsApiEventsIndex;
import com.itsaky.androidide.lookup.Lookup;
import com.itsaky.androidide.utils.IDEEditorInstanceProvider;
import com.itsaky.androidide.utils.ILogger;
import com.itsaky.toaster.ToastUtilsKt;
import com.itsaky.toaster.Toaster;
@@ -59,8 +56,6 @@ public class IDEApplication extends BaseApplication {
.addIndex(new LspApiEventsIndex())
.addIndex(new LspJavaEventsIndex())
.installDefaultEventBus();
Lookup.DEFAULT.register(IEditorProvider.class, new IDEEditorInstanceProvider());
}
private void handleCrash(Thread thread, Throwable th) {
@@ -24,7 +24,7 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.blankj.utilcode.util.ThreadUtils
import com.itsaky.androidide.databinding.FragmentLogBinding
import com.itsaky.androidide.language.log.LogLanguage
import com.itsaky.androidide.editor.language.log.LogLanguage
import com.itsaky.androidide.models.LogLine
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE
import com.itsaky.androidide.utils.ILogger.Priority
@@ -88,7 +88,7 @@ abstract class LogViewFragment : Fragment(), ShareableOutputFragment {
editor.setTextSize(12f)
editor.typefaceText = jetbrainsMono()
editor.colorScheme = SchemeAndroidIDE.newInstance(requireContext())
editor.setEditorLanguage(com.itsaky.androidide.language.log.LogLanguage())
editor.setEditorLanguage(LogLanguage())
}
override fun onDestroy() {
@@ -29,7 +29,7 @@ import androidx.fragment.app.Fragment;
import com.itsaky.androidide.databinding.FragmentNonEditableEditorBinding;
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE;
import com.itsaky.androidide.utils.TypefaceUtilsKt;
import com.itsaky.androidide.ui.editor.IDEEditor;
import com.itsaky.androidide.editor.ui.IDEEditor;
import io.github.rosemoe.sora.lang.EmptyLanguage;
@@ -25,10 +25,8 @@ import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import com.itsaky.androidide.editor.IEditorProvider;
import com.itsaky.androidide.lookup.Lookup;
import com.itsaky.androidide.editor.ui.IDEEditor;
import com.itsaky.androidide.resources.R;
import com.itsaky.androidide.ui.editor.IDEEditor;
import com.itsaky.androidide.utils.TypefaceUtilsKt;
import io.github.rosemoe.sora.lang.EmptyLanguage;
@@ -118,8 +116,7 @@ public class TextSheetFragment extends BaseBottomSheetFragment {
}
private IDEEditor createEditor() {
//noinspection ConstantConditions
editor = (IDEEditor) Lookup.DEFAULT.lookup(IEditorProvider.class).createEditor(getContext());
editor = new IDEEditor(getContext());
editor.setEditable(false);
editor.setDividerWidth(0);
editor.setEditorLanguage(new EmptyLanguage());
@@ -48,7 +48,7 @@ import com.itsaky.androidide.tasks.TaskExecutor;
import com.itsaky.androidide.utils.ILogger;
import com.itsaky.androidide.utils.LSPUtils;
import com.itsaky.androidide.ui.editor.CodeEditorView;
import com.itsaky.androidide.ui.editor.IDEEditor;
import com.itsaky.androidide.editor.ui.IDEEditor;
import com.itsaky.toaster.ToastUtilsKt;
import com.itsaky.toaster.Toaster;
@@ -383,6 +383,7 @@ public class IDELanguageClientImpl implements ILanguageClient {
}
/** Called by {@link IDEEditor IDEEditor} to show locations in EditorActivity */
@Override
public void showLocations(List<Location> locations) {
// Cannot show anything if the activity() is null
@@ -20,7 +20,6 @@ package com.itsaky.androidide.ui
import android.app.Activity
import android.app.ProgressDialog
import android.content.Context
import android.content.res.ColorStateList
import android.text.TextUtils
import android.util.AttributeSet
import android.view.Gravity
@@ -30,7 +29,6 @@ import android.view.ViewTreeObserver
import android.widget.RelativeLayout
import androidx.annotation.GravityInt
import androidx.appcompat.widget.TooltipCompat
import androidx.core.view.ViewCompat
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment
@@ -41,9 +39,6 @@ import com.blankj.utilcode.util.KeyboardUtils
import com.blankj.utilcode.util.SizeUtils
import com.blankj.utilcode.util.ThreadUtils.runOnUiThread
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.shape.CornerFamily
import com.google.android.material.shape.MaterialShapeDrawable
import com.google.android.material.shape.ShapeAppearanceModel
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
import com.google.android.material.tabs.TabLayout.Tab
import com.google.android.material.tabs.TabLayoutMediator
@@ -63,7 +58,6 @@ import com.itsaky.androidide.ui.editor.CodeEditorView
import com.itsaky.androidide.utils.ILogger
import com.itsaky.androidide.utils.IntentUtils.shareFile
import com.itsaky.androidide.utils.Symbols.forFile
import com.itsaky.androidide.utils.resolveAttr
import com.itsaky.toaster.Toaster.Type.ERROR
import com.itsaky.toaster.toast
import java.io.File
@@ -25,9 +25,8 @@ import android.util.AttributeSet;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.itsaky.androidide.R;
import com.itsaky.androidide.adapters.SymbolInputAdapter;
import com.itsaky.androidide.ui.editor.IDEEditor;
import com.itsaky.androidide.editor.ui.IDEEditor;
public class SymbolInputView extends RecyclerView {
@@ -51,14 +51,16 @@ import androidx.annotation.Nullable;
import com.blankj.utilcode.util.FileIOUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.SizeUtils;
import com.itsaky.androidide.app.IDEApplication;
import com.itsaky.androidide.databinding.LayoutCodeEditorBinding;
import com.itsaky.androidide.app.BaseApplication;
import com.itsaky.androidide.editor.databinding.LayoutCodeEditorBinding;
import com.itsaky.androidide.editor.ui.EditorSearchLayout;
import com.itsaky.androidide.editor.ui.IDEEditor;
import com.itsaky.androidide.eventbus.events.preferences.PreferenceChangeEvent;
import com.itsaky.androidide.language.cpp.CppLanguage;
import com.itsaky.androidide.language.groovy.GroovyLanguage;
import com.itsaky.androidide.language.java.JavaLanguage;
import com.itsaky.androidide.language.kotlin.KotlinLanguage;
import com.itsaky.androidide.language.xml.XMLLanguage;
import com.itsaky.androidide.editor.language.cpp.CppLanguage;
import com.itsaky.androidide.editor.language.groovy.GroovyLanguage;
import com.itsaky.androidide.editor.language.java.JavaLanguage;
import com.itsaky.androidide.editor.language.kotlin.KotlinLanguage;
import com.itsaky.androidide.editor.language.xml.XMLLanguage;
import com.itsaky.androidide.lsp.api.ILanguageServer;
import com.itsaky.androidide.lsp.api.ILanguageServerRegistry;
import com.itsaky.androidide.lsp.java.JavaLanguageServer;
@@ -319,7 +321,7 @@ public class CodeEditorView extends LinearLayout {
return;
}
final var prefs = IDEApplication.getInstance().getPrefManager();
final var prefs = BaseApplication.getBaseInstance().getPrefManager();
switch (event.getKey()) {
case FONT_SIZE:
onFontSizePrefChanged();
@@ -1,31 +0,0 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.utils
import android.content.Context
import com.itsaky.androidide.editor.IEditor
import com.itsaky.androidide.editor.IEditorProvider
import com.itsaky.androidide.ui.editor.IDEEditor
/** @author Akash Yadav */
class IDEEditorInstanceProvider : IEditorProvider {
override fun createEditor(context: Context): IEditor {
return IDEEditor(context)
}
}
+1 -1
View File
@@ -14,7 +14,7 @@
~ You should have received a copy of the GNU General Public License
~ along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
-->
<com.itsaky.androidide.ui.editor.IDEEditor xmlns:android="http://schemas.android.com/apk/res/android"
<com.itsaky.androidide.editor.ui.IDEEditor xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/editor"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@@ -15,7 +15,7 @@
~ along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
-->
<com.itsaky.androidide.ui.editor.IDEEditor xmlns:android="http://schemas.android.com/apk/res/android"
<com.itsaky.androidide.editor.ui.IDEEditor xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/editor"
android:layout_width="match_parent"
android:layout_height="match_parent" />
-1
View File
@@ -1 +0,0 @@
/build
-69
View File
@@ -1,69 +0,0 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}
android {
namespace "com.itsaky.androidide.language"
compileSdkVersion rootProject.ext.compileSdk
buildToolsVersion rootProject.ext.buildTools
defaultConfig {
minSdkVersion rootProject.ext.minSdk
targetSdkVersion rootProject.ext.targetSdk
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile ('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility rootProject.ext.javaSourceVersion
targetCompatibility rootProject.ext.javaTargetVersion
}
kotlinOptions {
jvmTarget = "11"
}
}
dependencies {
implementation project(path: ':common')
implementation project(path: ':editor')
implementation project(path: ':logger')
implementation project(path: ':lookup')
implementation project(path: ':lexers')
implementation project(path: ':lsp:api')
implementation project(path: ':lsp:java')
implementation project(path: ':lsp:xml')
implementation common.editor
implementation common.utilcode
implementation common.kotlin
implementation google.guava
testImplementation common.editor
testImplementation tests.junit
testImplementation tests.google_truth
testImplementation tests.robolectric
}
View File
-21
View File
@@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ This file is part of AndroidIDE.
~
~ AndroidIDE is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ AndroidIDE is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
@@ -1,225 +0,0 @@
package com.itsaky.androidide.language.cpp;
import static com.itsaky.androidide.lexers.cpp.CPP14Lexer.Class;
import static com.itsaky.androidide.lexers.cpp.CPP14Lexer.Double;
import static com.itsaky.androidide.lexers.cpp.CPP14Lexer.Enum;
import static com.itsaky.androidide.lexers.cpp.CPP14Lexer.Float;
import static com.itsaky.androidide.lexers.cpp.CPP14Lexer.Long;
import static com.itsaky.androidide.lexers.cpp.CPP14Lexer.Override;
import static com.itsaky.androidide.lexers.cpp.CPP14Lexer.Short;
import static com.itsaky.androidide.lexers.cpp.CPP14Lexer.Void;
import static com.itsaky.androidide.lexers.cpp.CPP14Lexer.*;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.LITERAL;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.OPERATOR;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.TEXT_NORMAL;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.TYPE_NAME;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.forComment;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.forKeyword;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.forString;
import static io.github.rosemoe.sora.lang.styling.TextStyle.makeStyle;
import com.itsaky.androidide.language.incremental.BaseIncrementalAnalyzeManager;
import com.itsaky.androidide.language.incremental.IncrementalToken;
import com.itsaky.androidide.language.incremental.LineState;
import com.itsaky.androidide.lexers.cpp.CPP14Lexer;
import com.itsaky.androidide.utils.ILogger;
import java.lang.Override;
import java.util.ArrayList;
import java.util.List;
import io.github.rosemoe.sora.lang.styling.Span;
public class CppAnalyzer extends BaseIncrementalAnalyzeManager {
private static final ILogger LOG = ILogger.newInstance("CppAnalyzer");
public CppAnalyzer() {
super(CPP14Lexer.class);
}
@Override
protected int[][] getMultilineTokenStartEndTypes() {
final var start = new int[] {Div, Star};
final var end = new int[] {Star, Div};
return new int[][] {start, end};
}
@Override
protected List<Span> generateSpans(final LineTokenizeResult<LineState, IncrementalToken> tokens) {
final var spans = new ArrayList<Span>();
spans.add(Span.obtain(0, makeStyle(TEXT_NORMAL)));
for (int i = 0; i < tokens.tokens.size(); i++) {
final var token = tokens.tokens.get(i);
final var type = token.getType();
final var offset = token.getStartIndex();
switch (type) {
case Alignas:
case Alignof:
case Asm:
case Auto:
case Break:
case Class:
case Const:
case Catch:
case Case:
case Constexpr:
case Const_cast:
case Continue:
case Decltype:
case Default:
case Delete:
case Do:
case Dynamic_cast:
case Else:
case Enum:
case Explicit:
case Export:
case Extern:
case Final:
case For:
case Friend:
case Goto:
case If:
case Inline:
case Mutable:
case Namespace:
case New:
case Noexcept:
case Operator:
case Override:
case Private:
case Protected:
case Public:
case Register:
case Reinterpret_cast:
case Return:
case Sizeof:
case Signed:
case Static:
case Static_cast:
case Static_assert:
case Struct:
case Switch:
case Template:
case This:
case Throw:
case Thread_local:
case Try:
case Typedef:
case Typeid_:
case Typename_:
case Unsigned:
case Union:
case Using:
case Virtual:
case Volatile:
case While:
case Void:
spans.add(Span.obtain(offset, forKeyword()));
break;
case Bool:
case Char:
case Char16:
case Char32:
case Double:
case Float:
case Int:
case Long:
case Short:
case Wchar:
spans.add(Span.obtain(offset, makeStyle(TYPE_NAME)));
break;
case LeftParen:
case LeftBracket:
case LeftBrace:
case Dot:
case RightParen:
case RightBracket:
case RightBrace:
case Semi:
case Comma:
case Plus:
case Minus:
case Star:
case Div:
case Mod:
case Caret:
case And:
case Or:
case Tilde:
case Not:
case Assign:
case Less:
case Greater:
case PlusAssign:
case MinusAssign:
case StarAssign:
case DivAssign:
case ModAssign:
case XorAssign:
case AndAssign:
case OrAssign:
case RightShiftAssign:
case LeftShiftAssign:
case Equal:
case NotEqual:
case LessEqual:
case GreaterEqual:
case AndAnd:
case OrOr:
case PlusPlus:
case MinusMinus:
case Arrow:
case ArrowStar:
case Question:
case Colon:
case Doublecolon:
case DotStar:
case Ellipsis:
spans.add(Span.obtain(offset, makeStyle(OPERATOR)));
break;
case IntegerLiteral:
case DecimalLiteral:
case OctalLiteral:
case HexadecimalLiteral:
case BinaryLiteral:
case Integersuffix:
case CharacterLiteral:
case FloatingLiteral:
case BooleanLiteral:
case Nullptr:
case True_:
case False_:
spans.add(Span.obtain(offset, makeStyle(LITERAL)));
break;
case StringLiteral:
case MultiLineMacro:
case Directive:
spans.add(Span.obtain(offset, forString()));
break;
case BlockComment:
spans.add(Span.obtain(offset, forComment()));
break;
case LineComment:
handleLineCommentSpan(token, spans, offset);
break;
default:
spans.add(Span.obtain(offset, makeStyle(TEXT_NORMAL)));
break;
}
}
return spans;
}
@Override
protected void handleIncompleteToken(final IncrementalToken token) {
token.type = BlockComment;
}
@Override
protected int[] getCodeBlockTokens() {
return new int[] {LeftBrace, RightBrace};
}
}
+60
View File
@@ -0,0 +1,60 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
}
android {
namespace "com.itsaky.androidide.editor"
compileSdkVersion rootProject.ext.compileSdk
buildToolsVersion rootProject.ext.buildTools
defaultConfig {
minSdkVersion rootProject.ext.minSdk
targetSdkVersion rootProject.ext.targetSdk
}
buildFeatures.viewBinding true
compileOptions {
sourceCompatibility rootProject.ext.javaSourceVersion
targetCompatibility rootProject.ext.javaTargetVersion
}
kotlinOptions {
jvmTarget = "11"
}
buildTypes {
release {
minifyEnabled true
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
dependencies {
implementation androidx.annotation
implementation androidx.appcompat
implementation androidx.constraintlayout
implementation common.editor
implementation common.utilcode
implementation google.material
implementation project (path: ":actions")
implementation project (path: ":common")
implementation project (path: ":lexers")
implementation project (path: ":shared")
implementation project (path: ":resources")
implementation project (path: ":lsp:api")
implementation project (path: ":lsp:java")
implementation project (path: ":lsp:xml")
}
-39
View File
@@ -1,39 +0,0 @@
import com.itsaky.androidide.Versions
plugins {
id("com.android.library")
id("kotlin-android")
}
android {
namespace = "com.itsaky.androidide.editor"
compileSdk = Versions.compileSdk
buildToolsVersion = Versions.buildTools
defaultConfig {
minSdk = Versions.minSdk
targetSdk = Versions.targetSdk
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = Versions.javaVersion
targetCompatibility = Versions.javaVersion
}
kotlinOptions {
jvmTarget = "11"
}
}
dependencies {
implementation(project(path = ":common"))
implementation(project(path = ":shared"))
implementation(project(path = ":lsp:api"))
}
@@ -19,6 +19,7 @@ package com.itsaky.androidide.editor;
import androidx.annotation.NonNull;
import com.itsaky.androidide.lsp.api.ILanguageClient;
import com.itsaky.androidide.lsp.api.ILanguageServer;
import com.itsaky.androidide.lsp.models.SignatureHelp;
import com.itsaky.androidide.models.Position;
@@ -32,9 +33,8 @@ import java.io.File;
* @author Akash Yadav
*/
public interface IEditor {
String KEY_FILE = "ide.editor.file";
/**
* Get the file that this editor is currently editing.
@@ -172,7 +172,7 @@ public interface IEditor {
/**
* Set the language server that this editor will connect with. If the language client is not set,
* it'll be set to {@link IDELanguageClientImpl}.
* it'll be set to {@link ILanguageClient} from the language server.
*
* @param server The server to set. Provide <code>null</code> to disable all the language server
* features.
@@ -1,36 +0,0 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.editor
import android.content.Context
/**
* Provides instance of [IEditor]. An instance of this class can be retrieved with the help of the
* Lookup API.
*
* @author Akash Yadav
*/
interface IEditorProvider {
/**
* Creates a new instance of editor with the given [context].
*
* @param context The context to use for editor instance creation.
*/
fun createEditor(context: Context) : IEditor
}
@@ -1,21 +1,20 @@
/*
* This file is part of AndroidIDE.
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.adapters
package com.itsaky.androidide.editor.adapters
import android.content.res.Resources
import android.graphics.Typeface
@@ -25,7 +24,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.itsaky.androidide.databinding.LayoutCompletionItemBinding
import com.itsaky.androidide.editor.databinding.LayoutCompletionItemBinding
import com.itsaky.androidide.lookup.Lookup
import com.itsaky.androidide.lsp.models.ClassCompletionData
import com.itsaky.androidide.lsp.models.CompletionItem as LspCompletionItem
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language
package com.itsaky.androidide.editor.language
import io.github.rosemoe.sora.lang.smartEnter.NewlineHandleResult
import io.github.rosemoe.sora.lang.smartEnter.NewlineHandler
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language
package com.itsaky.androidide.editor.language
import com.itsaky.androidide.lsp.api.ILanguageServer
import com.itsaky.androidide.lsp.models.CompletionItem
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language
package com.itsaky.androidide.editor.language
import io.github.rosemoe.sora.text.Content
import io.github.rosemoe.sora.widget.SymbolPairMatch
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language
package com.itsaky.androidide.editor.language
import com.itsaky.androidide.lsp.api.ICompletionCancelChecker
import io.github.rosemoe.sora.lang.completion.CompletionCancelledException
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language;
package com.itsaky.androidide.editor.language;
import android.os.Bundle;
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language
package com.itsaky.androidide.editor.language
import com.itsaky.androidide.lsp.api.ILanguageServer
import com.itsaky.androidide.lsp.models.CodeFormatResult
@@ -0,0 +1,233 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.editor.language.cpp;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.LITERAL;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.OPERATOR;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.TEXT_NORMAL;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.TYPE_NAME;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.forComment;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.forKeyword;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.forString;
import static io.github.rosemoe.sora.lang.styling.TextStyle.makeStyle;
import com.itsaky.androidide.editor.language.incremental.IncrementalToken;
import com.itsaky.androidide.editor.language.incremental.BaseIncrementalAnalyzeManager;
import com.itsaky.androidide.editor.language.incremental.LineState;
import com.itsaky.androidide.lexers.cpp.CPP14Lexer;
import com.itsaky.androidide.utils.ILogger;
import java.lang.Override;
import java.util.ArrayList;
import java.util.List;
import io.github.rosemoe.sora.lang.styling.Span;
public class CppAnalyzer extends BaseIncrementalAnalyzeManager {
private static final ILogger LOG = ILogger.newInstance("CppAnalyzer");
public CppAnalyzer() {
super(CPP14Lexer.class);
}
@Override
protected int[][] getMultilineTokenStartEndTypes() {
final var start = new int[] {CPP14Lexer.Div, CPP14Lexer.Star};
final var end = new int[] {CPP14Lexer.Star, CPP14Lexer.Div};
return new int[][] {start, end};
}
@Override
protected List<Span> generateSpans(final LineTokenizeResult<LineState, IncrementalToken> tokens) {
final var spans = new ArrayList<Span>();
spans.add(Span.obtain(0, makeStyle(TEXT_NORMAL)));
for (int i = 0; i < tokens.tokens.size(); i++) {
final var token = tokens.tokens.get(i);
final var type = token.getType();
final var offset = token.getStartIndex();
switch (type) {
case CPP14Lexer.Alignas:
case CPP14Lexer.Alignof:
case CPP14Lexer.Asm:
case CPP14Lexer.Auto:
case CPP14Lexer.Break:
case CPP14Lexer.Class:
case CPP14Lexer.Const:
case CPP14Lexer.Catch:
case CPP14Lexer.Case:
case CPP14Lexer.Constexpr:
case CPP14Lexer.Const_cast:
case CPP14Lexer.Continue:
case CPP14Lexer.Decltype:
case CPP14Lexer.Default:
case CPP14Lexer.Delete:
case CPP14Lexer.Do:
case CPP14Lexer.Dynamic_cast:
case CPP14Lexer.Else:
case CPP14Lexer.Enum:
case CPP14Lexer.Explicit:
case CPP14Lexer.Export:
case CPP14Lexer.Extern:
case CPP14Lexer.Final:
case CPP14Lexer.For:
case CPP14Lexer.Friend:
case CPP14Lexer.Goto:
case CPP14Lexer.If:
case CPP14Lexer.Inline:
case CPP14Lexer.Mutable:
case CPP14Lexer.Namespace:
case CPP14Lexer.New:
case CPP14Lexer.Noexcept:
case CPP14Lexer.Operator:
case CPP14Lexer.Override:
case CPP14Lexer.Private:
case CPP14Lexer.Protected:
case CPP14Lexer.Public:
case CPP14Lexer.Register:
case CPP14Lexer.Reinterpret_cast:
case CPP14Lexer.Return:
case CPP14Lexer.Sizeof:
case CPP14Lexer.Signed:
case CPP14Lexer.Static:
case CPP14Lexer.Static_cast:
case CPP14Lexer.Static_assert:
case CPP14Lexer.Struct:
case CPP14Lexer.Switch:
case CPP14Lexer.Template:
case CPP14Lexer.This:
case CPP14Lexer.Throw:
case CPP14Lexer.Thread_local:
case CPP14Lexer.Try:
case CPP14Lexer.Typedef:
case CPP14Lexer.Typeid_:
case CPP14Lexer.Typename_:
case CPP14Lexer.Unsigned:
case CPP14Lexer.Union:
case CPP14Lexer.Using:
case CPP14Lexer.Virtual:
case CPP14Lexer.Volatile:
case CPP14Lexer.While:
case CPP14Lexer.Void:
spans.add(Span.obtain(offset, forKeyword()));
break;
case CPP14Lexer.Bool:
case CPP14Lexer.Char:
case CPP14Lexer.Char16:
case CPP14Lexer.Char32:
case CPP14Lexer.Double:
case CPP14Lexer.Float:
case CPP14Lexer.Int:
case CPP14Lexer.Long:
case CPP14Lexer.Short:
case CPP14Lexer.Wchar:
spans.add(Span.obtain(offset, makeStyle(TYPE_NAME)));
break;
case CPP14Lexer.LeftParen:
case CPP14Lexer.LeftBracket:
case CPP14Lexer.LeftBrace:
case CPP14Lexer.Dot:
case CPP14Lexer.RightParen:
case CPP14Lexer.RightBracket:
case CPP14Lexer.RightBrace:
case CPP14Lexer.Semi:
case CPP14Lexer.Comma:
case CPP14Lexer.Plus:
case CPP14Lexer.Minus:
case CPP14Lexer.Star:
case CPP14Lexer.Div:
case CPP14Lexer.Mod:
case CPP14Lexer.Caret:
case CPP14Lexer.And:
case CPP14Lexer.Or:
case CPP14Lexer.Tilde:
case CPP14Lexer.Not:
case CPP14Lexer.Assign:
case CPP14Lexer.Less:
case CPP14Lexer.Greater:
case CPP14Lexer.PlusAssign:
case CPP14Lexer.MinusAssign:
case CPP14Lexer.StarAssign:
case CPP14Lexer.DivAssign:
case CPP14Lexer.ModAssign:
case CPP14Lexer.XorAssign:
case CPP14Lexer.AndAssign:
case CPP14Lexer.OrAssign:
case CPP14Lexer.RightShiftAssign:
case CPP14Lexer.LeftShiftAssign:
case CPP14Lexer.Equal:
case CPP14Lexer.NotEqual:
case CPP14Lexer.LessEqual:
case CPP14Lexer.GreaterEqual:
case CPP14Lexer.AndAnd:
case CPP14Lexer.OrOr:
case CPP14Lexer.PlusPlus:
case CPP14Lexer.MinusMinus:
case CPP14Lexer.Arrow:
case CPP14Lexer.ArrowStar:
case CPP14Lexer.Question:
case CPP14Lexer.Colon:
case CPP14Lexer.Doublecolon:
case CPP14Lexer.DotStar:
case CPP14Lexer.Ellipsis:
spans.add(Span.obtain(offset, makeStyle(OPERATOR)));
break;
case CPP14Lexer.IntegerLiteral:
case CPP14Lexer.DecimalLiteral:
case CPP14Lexer.OctalLiteral:
case CPP14Lexer.HexadecimalLiteral:
case CPP14Lexer.BinaryLiteral:
case CPP14Lexer.Integersuffix:
case CPP14Lexer.CharacterLiteral:
case CPP14Lexer.FloatingLiteral:
case CPP14Lexer.BooleanLiteral:
case CPP14Lexer.Nullptr:
case CPP14Lexer.True_:
case CPP14Lexer.False_:
spans.add(Span.obtain(offset, makeStyle(LITERAL)));
break;
case CPP14Lexer.StringLiteral:
case CPP14Lexer.MultiLineMacro:
case CPP14Lexer.Directive:
spans.add(Span.obtain(offset, forString()));
break;
case CPP14Lexer.BlockComment:
spans.add(Span.obtain(offset, forComment()));
break;
case CPP14Lexer.LineComment:
handleLineCommentSpan(token, spans, offset);
break;
default:
spans.add(Span.obtain(offset, makeStyle(TEXT_NORMAL)));
break;
}
}
return spans;
}
@Override
protected void handleIncompleteToken(final IncrementalToken token) {
token.type = CPP14Lexer.BlockComment;
}
@Override
protected int[] getCodeBlockTokens() {
return new int[] {CPP14Lexer.LeftBrace, CPP14Lexer.RightBrace};
}
}
@@ -1,29 +1,28 @@
/************************************************************************************
* This file is part of AndroidIDE.
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.language.cpp;
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.editor.language.cpp;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.itsaky.androidide.language.BraceHandler;
import com.itsaky.androidide.language.CommonSymbolPairs;
import com.itsaky.androidide.language.IDELanguage;
import com.itsaky.androidide.editor.language.BraceHandler;
import com.itsaky.androidide.editor.language.CommonSymbolPairs;
import com.itsaky.androidide.editor.language.IDELanguage;
import com.itsaky.androidide.lexers.cpp.CPP14Lexer;
import com.itsaky.androidide.utils.ILogger;
@@ -15,11 +15,11 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.groovy
package com.itsaky.androidide.editor.language.groovy
import com.itsaky.androidide.language.incremental.BaseIncrementalAnalyzeManager
import com.itsaky.androidide.language.incremental.IncrementalToken
import com.itsaky.androidide.language.incremental.LineState
import com.itsaky.androidide.editor.language.incremental.BaseIncrementalAnalyzeManager
import com.itsaky.androidide.editor.language.incremental.IncrementalToken
import com.itsaky.androidide.editor.language.incremental.LineState
import com.itsaky.androidide.lexers.groovy.GroovyLexer
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE
import io.github.rosemoe.sora.lang.analysis.IncrementalAnalyzeManager.LineTokenizeResult
@@ -1,23 +1,20 @@
/************************************************************************************
* This file is part of AndroidIDE.
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.language.groovy;
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.editor.language.groovy;
import android.os.Bundle;
@@ -1,29 +1,28 @@
/************************************************************************************
* This file is part of AndroidIDE.
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.language.groovy;
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.editor.language.groovy;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.itsaky.androidide.language.BraceHandler;
import com.itsaky.androidide.language.CommonSymbolPairs;
import com.itsaky.androidide.language.IDELanguage;
import com.itsaky.androidide.editor.language.CommonSymbolPairs;
import com.itsaky.androidide.editor.language.IDELanguage;
import com.itsaky.androidide.editor.language.BraceHandler;
import com.itsaky.androidide.lexers.groovy.GroovyLexer;
import com.itsaky.androidide.utils.CharSequenceReader;
import com.itsaky.androidide.utils.ILogger;
@@ -15,10 +15,10 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.incremental;
package com.itsaky.androidide.editor.language.incremental;
import static com.itsaky.androidide.language.incremental.LineState.INCOMPLETE;
import static com.itsaky.androidide.language.incremental.LineState.NORMAL;
import static com.itsaky.androidide.editor.language.incremental.LineState.INCOMPLETE;
import static com.itsaky.androidide.editor.language.incremental.LineState.NORMAL;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.FIXME_COMMENT;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.TODO_COMMENT;
import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.withoutCompletion;
@@ -28,7 +28,7 @@ import androidx.annotation.NonNull;
import com.blankj.utilcode.util.ArrayUtils;
import com.google.common.base.Preconditions;
import com.google.common.collect.EvictingQueue;
import com.itsaky.androidide.language.java.JavaAnalyzer;
import com.itsaky.androidide.editor.language.java.JavaAnalyzer;
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE;
import com.itsaky.androidide.utils.CharSequenceReader;
import com.itsaky.androidide.utils.ILogger;
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.incremental
package com.itsaky.androidide.editor.language.incremental
import org.antlr.v4.runtime.CharStream
import org.antlr.v4.runtime.Token
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.incremental
package com.itsaky.androidide.editor.language.incremental
import org.antlr.v4.runtime.Lexer
@@ -14,11 +14,11 @@
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.java
package com.itsaky.androidide.editor.language.java
import com.itsaky.androidide.language.incremental.BaseIncrementalAnalyzeManager
import com.itsaky.androidide.language.incremental.IncrementalToken
import com.itsaky.androidide.language.incremental.LineState
import com.itsaky.androidide.editor.language.incremental.BaseIncrementalAnalyzeManager
import com.itsaky.androidide.editor.language.incremental.IncrementalToken
import com.itsaky.androidide.editor.language.incremental.LineState
import com.itsaky.androidide.lexers.java.JavaLexer
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.ANNOTATION
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.LITERAL
@@ -14,14 +14,14 @@
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.java;
package com.itsaky.androidide.editor.language.java;
import androidx.annotation.NonNull;
import com.itsaky.androidide.language.BraceHandler;
import com.itsaky.androidide.language.CommonCompletionProvider;
import com.itsaky.androidide.language.CommonSymbolPairs;
import com.itsaky.androidide.language.IDELanguage;
import com.itsaky.androidide.editor.language.CommonSymbolPairs;
import com.itsaky.androidide.editor.language.IDELanguage;
import com.itsaky.androidide.editor.language.BraceHandler;
import com.itsaky.androidide.editor.language.CommonCompletionProvider;
import com.itsaky.androidide.lexers.java.JavaLexer;
import com.itsaky.androidide.lexers.java.JavaParser;
import com.itsaky.androidide.lsp.api.ILanguageServer;
@@ -15,11 +15,11 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.kotlin
package com.itsaky.androidide.editor.language.kotlin
import com.itsaky.androidide.language.incremental.BaseIncrementalAnalyzeManager
import com.itsaky.androidide.language.incremental.IncrementalToken
import com.itsaky.androidide.language.incremental.LineState
import com.itsaky.androidide.editor.language.incremental.BaseIncrementalAnalyzeManager
import com.itsaky.androidide.editor.language.incremental.IncrementalToken
import com.itsaky.androidide.editor.language.incremental.LineState
import com.itsaky.androidide.lexers.kotlin.KotlinLexer
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.ANNOTATION
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.LITERAL
@@ -1,30 +1,29 @@
/************************************************************************************
* This file is part of AndroidIDE.
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*
**************************************************************************************/
package com.itsaky.androidide.language.kotlin;
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.editor.language.kotlin;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.itsaky.androidide.language.BraceHandler;
import com.itsaky.androidide.language.CommonSymbolPairs;
import com.itsaky.androidide.language.IDELanguage;
import com.itsaky.androidide.language.java.JavaLanguage;
import com.itsaky.androidide.editor.language.BraceHandler;
import com.itsaky.androidide.editor.language.CommonSymbolPairs;
import com.itsaky.androidide.editor.language.IDELanguage;
import com.itsaky.androidide.editor.language.java.JavaLanguage;
import com.itsaky.androidide.lexers.kotlin.KotlinLexer;
import com.itsaky.androidide.lexers.kotlin.KotlinParser;
import com.itsaky.androidide.utils.ILogger;
@@ -15,10 +15,10 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.log
package com.itsaky.androidide.editor.language.log
import android.os.Bundle
import com.itsaky.androidide.language.IDELanguage
import com.itsaky.androidide.editor.language.IDELanguage
import io.github.rosemoe.sora.lang.completion.CompletionPublisher
import io.github.rosemoe.sora.lang.smartEnter.NewlineHandler
import io.github.rosemoe.sora.text.CharPosition
@@ -15,9 +15,9 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.log
package com.itsaky.androidide.editor.language.log
import com.itsaky.androidide.language.log.LogLineAnalyzer.LogLineState
import com.itsaky.androidide.editor.language.log.LogLineAnalyzer.LogLineState
import com.itsaky.androidide.lexers.log.LogLineTokenizer
import com.itsaky.androidide.lexers.log.LogToken
import com.itsaky.androidide.lexers.log.LogToken.PRIORITY
@@ -15,14 +15,14 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.xml
package com.itsaky.androidide.editor.language.xml
import android.graphics.Color
import android.graphics.Color.parseColor
import com.google.common.collect.EvictingQueue
import com.itsaky.androidide.language.incremental.BaseIncrementalAnalyzeManager
import com.itsaky.androidide.language.incremental.IncrementalToken
import com.itsaky.androidide.language.incremental.LineState
import com.itsaky.androidide.editor.language.incremental.BaseIncrementalAnalyzeManager
import com.itsaky.androidide.editor.language.incremental.IncrementalToken
import com.itsaky.androidide.editor.language.incremental.LineState
import com.itsaky.androidide.lexers.xml.XMLLexer
import com.itsaky.androidide.lexers.xml.XMLLexer.CLOSE
import com.itsaky.androidide.lexers.xml.XMLLexer.COLON
@@ -1,26 +1,25 @@
/*
* This file is part of AndroidIDE.
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.language.xml;
package com.itsaky.androidide.editor.language.xml;
import androidx.annotation.NonNull;
import com.itsaky.androidide.language.CommonSymbolPairs;
import com.itsaky.androidide.language.IDELanguage;
import com.itsaky.androidide.editor.language.CommonSymbolPairs;
import com.itsaky.androidide.editor.language.IDELanguage;
import com.itsaky.androidide.lexers.xml.XMLLexer;
import com.itsaky.androidide.lsp.api.ILanguageServer;
import com.itsaky.androidide.lsp.api.ILanguageServerRegistry;
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.ui.editor
package com.itsaky.androidide.editor.ui
import io.github.rosemoe.sora.widget.CodeEditor
import io.github.rosemoe.sora.widget.base.EditorPopupWindow
@@ -15,11 +15,10 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.ui.editor;
package com.itsaky.androidide.editor.ui;
import static android.view.View.MeasureSpec.AT_MOST;
import static android.view.View.MeasureSpec.makeMeasureSpec;
import static com.itsaky.androidide.utils.ResourceUtilsKt.resolveAttr;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.ui.editor
package com.itsaky.androidide.editor.ui
import com.itsaky.androidide.lsp.models.DiagnosticItem
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.ui.editor
package com.itsaky.androidide.editor.ui
import android.annotation.SuppressLint
import android.content.Context
@@ -42,12 +42,14 @@ import com.itsaky.androidide.actions.ActionItem
import com.itsaky.androidide.actions.ActionsRegistry
import com.itsaky.androidide.actions.ActionsRegistry.Companion.getInstance
import com.itsaky.androidide.actions.EditorActionItem
import com.itsaky.androidide.databinding.LayoutPopupMenuItemBinding
import com.itsaky.androidide.editor.R.*
import com.itsaky.androidide.editor.databinding.LayoutPopupMenuItemBinding
import com.itsaky.androidide.lsp.api.ILanguageServerRegistry
import com.itsaky.androidide.lsp.java.JavaLanguageServer
import com.itsaky.androidide.lsp.models.DiagnosticItem
import com.itsaky.androidide.lsp.xml.XMLLanguageServer
import com.itsaky.androidide.resources.R
import com.itsaky.androidide.editor.ui.EditorActionsMenu.ActionsListAdapter.VH
import com.itsaky.androidide.utils.resolveAttr
import io.github.rosemoe.sora.event.HandleStateChangeEvent
import io.github.rosemoe.sora.event.ScrollEvent
@@ -349,8 +351,8 @@ open class EditorActionsMenu constructor(val editor: IDEEditor) :
private fun findWidestItem(): Int {
var widest = 0
val text =
LayoutInflater.from(editor.context)
.inflate(com.itsaky.androidide.R.layout.layout_popup_menu_item, null) as MaterialButton
LayoutInflater.from(editor.context).inflate(layout.layout_popup_menu_item, null)
as MaterialButton
val dp30 = SizeUtils.dp2px(30f)
val paddingHorizontal = text.paddingStart + text.paddingEnd
val drawablePadding = text.iconPadding
@@ -372,7 +374,7 @@ open class EditorActionsMenu constructor(val editor: IDEEditor) :
}
private class ActionsListAdapter(val menu: Menu?, val forceShowTitle: Boolean = false) :
RecyclerView.Adapter<ActionsListAdapter.VH>() {
RecyclerView.Adapter<VH>() {
override fun getItemCount(): Int {
return menu?.size() ?: 0
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.ui.editor
package com.itsaky.androidide.editor.ui
import android.content.Intent
import android.net.Uri
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.ui.editor
package com.itsaky.androidide.editor.ui
import android.annotation.SuppressLint
import android.content.Context
@@ -27,10 +27,10 @@ import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.FrameLayout
import android.widget.PopupMenu
import com.itsaky.androidide.editor.databinding.LayoutFindInFileBinding
import com.itsaky.androidide.resources.R
import com.itsaky.androidide.databinding.LayoutFindInFileBinding
import com.itsaky.androidide.editor.ui.ReplaceAction.doReplace
import com.itsaky.androidide.utils.SingleTextWatcher
import com.itsaky.androidide.ui.editor.ReplaceAction.doReplace
import io.github.rosemoe.sora.widget.EditorSearcher.SearchOptions
import java.util.regex.Pattern
@@ -68,7 +68,7 @@ class EditorSearchLayout(context: Context, val editor: IDEEditor) : FrameLayout(
optionsMenu.setOnMenuItemClickListener {
return@setOnMenuItemClickListener if (it.isCheckable) {
it.isChecked = !it.isChecked
val ignoreCase = searchOptions.ignoreCase
val regex = searchOptions.useRegex
searchOptions =
@@ -78,7 +78,7 @@ class EditorSearchLayout(context: Context, val editor: IDEEditor) : FrameLayout(
else -> searchOptions
}
editor.searcher?.updateSearchOptions(searchOptions)
true
} else false
}
@@ -1,20 +1,20 @@
/*
* This file is part of AndroidIDE.
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.ui.editor;
package com.itsaky.androidide.editor.ui;
import static com.itsaky.androidide.preferences.internal.EditorPreferencesKt.getVisiblePasswordFlag;
import static com.itsaky.androidide.resources.R.string;
@@ -32,15 +32,15 @@ import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import com.blankj.utilcode.util.ThreadUtils;
import com.itsaky.androidide.adapters.CompletionListAdapter;
import com.itsaky.androidide.editor.adapters.CompletionListAdapter;
import com.itsaky.androidide.editor.language.IDELanguage;
import com.itsaky.androidide.eventbus.events.editor.ChangeType;
import com.itsaky.androidide.eventbus.events.editor.DocumentChangeEvent;
import com.itsaky.androidide.eventbus.events.editor.DocumentCloseEvent;
import com.itsaky.androidide.eventbus.events.editor.DocumentOpenEvent;
import com.itsaky.androidide.eventbus.events.editor.DocumentSaveEvent;
import com.itsaky.androidide.eventbus.events.editor.DocumentSelectedEvent;
import com.itsaky.androidide.language.IDELanguage;
import com.itsaky.androidide.lsp.IDELanguageClientImpl;
import com.itsaky.androidide.lsp.api.ILanguageClient;
import com.itsaky.androidide.lsp.api.ILanguageServer;
import com.itsaky.androidide.lsp.models.Command;
import com.itsaky.androidide.lsp.models.DefinitionResult;
@@ -71,7 +71,7 @@ import io.github.rosemoe.sora.widget.component.EditorAutoCompletion;
import io.github.rosemoe.sora.widget.component.EditorTextActionWindow;
public class IDEEditor extends CodeEditor implements com.itsaky.androidide.editor.IEditor {
private static final ILogger LOG = ILogger.newInstance("IDEEditor");
private final EditorActionsMenu actionsMenu;
private IDEEditorSearcher searcher;
@@ -81,7 +81,7 @@ public class IDEEditor extends CodeEditor implements com.itsaky.androidide.edito
private ILanguageServer languageServer;
private SignatureHelpWindow signatureHelpWindow;
private DiagnosticWindow diagnosticWindow;
IDELanguageClientImpl languageClient;
ILanguageClient languageClient;
public IDEEditor(Context context) {
this(context, null);
@@ -404,7 +404,7 @@ public class IDEEditor extends CodeEditor implements com.itsaky.androidide.edito
/**
* Set the language server that this editor will connect with. If the language client is not set,
* it'll be set to {@link IDELanguageClientImpl}.
* it'll be set to {@link ILanguageClient} set in the language server.
*
* @param server The server to set. Provide <code>null</code> to disable all the language server
* features.
@@ -412,10 +412,7 @@ public class IDEEditor extends CodeEditor implements com.itsaky.androidide.edito
@Override
public void setLanguageServer(ILanguageServer server) {
this.languageServer = server;
if (languageClient == null && IDELanguageClientImpl.isInitialized()) {
languageClient = IDELanguageClientImpl.getInstance();
}
this.languageClient = server.getClient();
}
/**
@@ -549,7 +546,7 @@ public class IDEEditor extends CodeEditor implements com.itsaky.androidide.edito
* cursor position.
*
* <p>If the server returns a valid response, that response is forwarded to the {@link
* IDELanguageClientImpl}.
* ILanguageClient}.
*/
@Override
@SuppressWarnings("unused")
@@ -875,7 +872,7 @@ public class IDEEditor extends CodeEditor implements com.itsaky.androidide.edito
"Search ActionMode is not supported. Use CodeEditorView.beginSearch() instead.");
}
protected void dispatchDocumentSaveEvent() {
public void dispatchDocumentSaveEvent() {
if (getFile() == null) {
return;
}
@@ -15,11 +15,11 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.ui.editor
package com.itsaky.androidide.editor.ui
import android.view.LayoutInflater
import com.itsaky.androidide.editor.databinding.LayoutEditorFindReplaceBinding
import com.itsaky.androidide.resources.R
import com.itsaky.androidide.databinding.LayoutEditorFindReplaceBinding
import com.itsaky.androidide.utils.DialogUtils
import com.itsaky.androidide.utils.ILogger
@@ -15,7 +15,7 @@
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.ui.editor;
package com.itsaky.androidide.editor.ui;
import android.text.SpannableStringBuilder;
import android.text.style.BackgroundColorSpan;
@@ -23,7 +23,7 @@ import android.app.ProgressDialog
import android.widget.Toast
import com.itsaky.androidide.resources.R.string
import com.itsaky.androidide.utils.ILogger
import com.itsaky.androidide.ui.editor.IDEEditor
import com.itsaky.androidide.editor.ui.IDEEditor
import io.github.rosemoe.sora.text.TextUtils
import io.github.rosemoe.sora.util.IntPair
import java.util.concurrent.CompletableFuture
@@ -1,10 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ This file is part of AndroidIDE.
~
~ AndroidIDE is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ AndroidIDE is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.itsaky.androidide.ui.editor.IDEEditor
<com.itsaky.androidide.editor.ui.IDEEditor
android:id="@+id/editor"
android:layout_width="match_parent"
android:layout_height="0dp"
@@ -18,7 +18,9 @@
package com.itsaky.androidide.language.incremental
import com.google.common.truth.Truth.assertThat
import com.itsaky.androidide.language.java.JavaAnalyzer
import com.itsaky.androidide.editor.language.incremental.IncrementalToken
import com.itsaky.androidide.editor.language.incremental.LineState
import com.itsaky.androidide.editor.language.java.JavaAnalyzer
import com.itsaky.androidide.lexers.java.JavaLexer
import io.github.rosemoe.sora.lang.analysis.IncrementalAnalyzeManager.LineTokenizeResult
import org.junit.Test
@@ -24,8 +24,10 @@ import com.itsaky.androidide.lsp.models.DiagnosticItem;
import com.itsaky.androidide.lsp.models.DiagnosticResult;
import com.itsaky.androidide.lsp.models.ShowDocumentParams;
import com.itsaky.androidide.lsp.models.ShowDocumentResult;
import com.itsaky.androidide.models.Location;
import java.io.File;
import java.util.List;
/**
* A language client handles notifications and events from a {@link ILanguageServer}.
@@ -69,4 +71,12 @@ public interface ILanguageClient {
* action.
*/
ShowDocumentResult showDocument(ShowDocumentParams params);
/**
* Notification sent by the language server to tell teh client client to show the given locations
* to the user.
*
* @param locations The location to show.
*/
void showLocations(List<Location> locations);
}
-1
View File
@@ -48,4 +48,3 @@ include ':preferences'
include ':resources'
include ':uidesigner'
include ':xml-inflater'
include ':editor-languages'
Binary file not shown.
+1 -2
View File
@@ -54,7 +54,6 @@ dependencies {
implementation project(path: ':actions')
implementation project(path: ':common')
implementation project(path: ':editor')
implementation project(path: ':editor-languages')
implementation project(path: ':logger')
implementation project(path: ':lookup')
implementation project(path: ':lsp:api')
@@ -66,4 +65,4 @@ dependencies {
testImplementation tests.google_truth
testImplementation tests.robolectric
testImplementation tests.mockito_kotlin
}
}
@@ -22,9 +22,8 @@ import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import com.itsaky.androidide.app.BaseIDEActivity
import com.itsaky.androidide.editor.IEditorProvider
import com.itsaky.androidide.language.xml.XMLLanguage
import com.itsaky.androidide.lookup.Lookup
import com.itsaky.androidide.editor.language.xml.XMLLanguage
import com.itsaky.androidide.editor.ui.IDEEditor
import com.itsaky.androidide.preferences.internal.fontSize
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE
import com.itsaky.androidide.uidesigner.databinding.ActivityShowXmlBinding
@@ -50,8 +49,7 @@ class ShowXmlActivity : BaseIDEActivity() {
override fun bindLayout(): View {
this.binding = ActivityShowXmlBinding.inflate(layoutInflater)
this.editor =
Lookup.DEFAULT.lookup(IEditorProvider::class.java)!!.createEditor(this) as CodeEditor
this.editor = IDEEditor(this)
setSupportActionBar(this.binding!!.toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)