mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix: migrate to SLF4J and Logback logging implementations
This commit is contained in:
@@ -56,36 +56,51 @@
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @err.tag
|
||||
(date) @err.date
|
||||
(time) @err.time
|
||||
(priority) @err.priority
|
||||
(thread_name) @err.thread_name
|
||||
(tag) @err.tag
|
||||
(message) @err.msg
|
||||
(#match? @err.priority "E")
|
||||
(#match? @err.priority "ERROR")
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @warn.tag
|
||||
(date) @warn.date
|
||||
(time) @warn.time
|
||||
(priority) @warn.priority
|
||||
(thread_name) @warn.thread_name
|
||||
(tag) @warn.tag
|
||||
(message) @warn.msg
|
||||
(#match? @warn.priority "W")
|
||||
(#match? @warn.priority "WARN")
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @info.tag
|
||||
(date) @info.date
|
||||
(time) @info.time
|
||||
(priority) @info.priority
|
||||
(thread_name) @info.thread_name
|
||||
(tag) @info.tag
|
||||
(message) @info.msg
|
||||
(#match? @info.priority "I")
|
||||
(#match? @info.priority "INFO")
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @debug.tag
|
||||
(date) @debug.date
|
||||
(time) @debug.time
|
||||
(priority) @debug.priority
|
||||
(thread_name) @debug.thread_name
|
||||
(tag) @debug.tag
|
||||
(message) @debug.msg
|
||||
(#match? @debug.priority "D")
|
||||
(#match? @debug.priority "DEBUG")
|
||||
)
|
||||
|
||||
(ide_log_line
|
||||
(ide_tag) @verbose.tag
|
||||
(date) @verbose.date
|
||||
(time) @verbose.time
|
||||
(priority) @verbose.priority
|
||||
(thread_name) @verbose.thread_name
|
||||
(tag) @verbose.tag
|
||||
(message) @verbose.msg
|
||||
(#match? @verbose.priority "V")
|
||||
)
|
||||
(#match? @verbose.priority "TRACE")
|
||||
)
|
||||
|
||||
+2
-2
@@ -25,10 +25,10 @@ import com.itsaky.androidide.lsp.models.FailureType.COMPLETION
|
||||
import com.itsaky.androidide.lsp.models.LSPFailure
|
||||
import com.itsaky.androidide.lsp.util.setupLookupForCompletion
|
||||
import com.itsaky.androidide.models.Position
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionCancelledException
|
||||
import io.github.rosemoe.sora.text.CharPosition
|
||||
import io.github.rosemoe.sora.text.ContentReference
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.nio.file.Path
|
||||
import java.util.concurrent.CancellationException
|
||||
|
||||
@@ -45,7 +45,7 @@ internal class CommonCompletionProvider(
|
||||
|
||||
companion object {
|
||||
|
||||
private val log = ILogger.newInstance("CommonCompletionProvider")
|
||||
private val log = LoggerFactory.getLogger(CommonCompletionProvider::class.java)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,13 +24,13 @@ import com.itsaky.androidide.lsp.api.ILanguageServer
|
||||
import com.itsaky.androidide.preferences.internal.tabSize
|
||||
import com.itsaky.androidide.preferences.internal.useSoftTab
|
||||
import com.itsaky.androidide.progress.ICancelChecker
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import io.github.rosemoe.sora.lang.Language
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionCancelledException
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionPublisher
|
||||
import io.github.rosemoe.sora.lang.format.Formatter
|
||||
import io.github.rosemoe.sora.text.CharPosition
|
||||
import io.github.rosemoe.sora.text.ContentReference
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.nio.file.Paths
|
||||
|
||||
/**
|
||||
@@ -76,13 +76,14 @@ abstract class IDELanguage : Language {
|
||||
val server = languageServer ?: return
|
||||
val path = extraArguments.getString(IEditor.KEY_FILE, null)
|
||||
if (path == null) {
|
||||
LOG.warn("Cannot provide completions. No file provided.")
|
||||
log.warn("Cannot provide completions. No file provided.")
|
||||
return
|
||||
}
|
||||
|
||||
val completionProvider = CommonCompletionProvider(server, cancelChecker)
|
||||
val file = Paths.get(path)
|
||||
val completionItems = completionProvider.complete(content, file, position) { checkIsCompletionChar(it) }
|
||||
val completionItems = completionProvider.complete(content, file,
|
||||
position) { checkIsCompletionChar(it) }
|
||||
publisher.setUpdateThreshold(1)
|
||||
(publisher as IDECompletionPublisher).addLSPItems(completionItems)
|
||||
}
|
||||
@@ -116,6 +117,6 @@ abstract class IDELanguage : Language {
|
||||
|
||||
companion object {
|
||||
|
||||
private val LOG = ILogger.newInstance("IDELanguage")
|
||||
private val log = LoggerFactory.getLogger(IDELanguage::class.java)
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import com.itsaky.androidide.lsp.models.CodeFormatResult
|
||||
import com.itsaky.androidide.lsp.models.FormatCodeParams
|
||||
import com.itsaky.androidide.models.Position
|
||||
import com.itsaky.androidide.models.Range
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import io.github.rosemoe.sora.lang.format.AsyncFormatter
|
||||
import io.github.rosemoe.sora.text.CharPosition
|
||||
import io.github.rosemoe.sora.text.Content
|
||||
|
||||
@@ -26,31 +26,25 @@ import static com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE.forKeyw
|
||||
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.IncrementalToken;
|
||||
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 io.github.rosemoe.sora.lang.styling.Span;
|
||||
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};
|
||||
final var start = new int[]{CPP14Lexer.Div, CPP14Lexer.Star};
|
||||
final var end = new int[]{CPP14Lexer.Star, CPP14Lexer.Div};
|
||||
return new int[][]{start, end};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,6 +222,6 @@ public class CppAnalyzer extends BaseIncrementalAnalyzeManager {
|
||||
|
||||
@Override
|
||||
protected int[] getCodeBlockTokens() {
|
||||
return new int[] {CPP14Lexer.LeftBrace, CPP14Lexer.RightBrace};
|
||||
return new int[]{CPP14Lexer.LeftBrace, CPP14Lexer.RightBrace};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.itsaky.androidide.editor.language.IDELanguage;
|
||||
import com.itsaky.androidide.editor.language.newline.BracketsNewlineHandler;
|
||||
import com.itsaky.androidide.editor.language.utils.CommonSymbolPairs;
|
||||
import com.itsaky.androidide.lexers.cpp.CPP14Lexer;
|
||||
import com.itsaky.androidide.utils.ILogger;
|
||||
import io.github.rosemoe.sora.lang.analysis.AnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionCancelledException;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionPublisher;
|
||||
@@ -33,12 +32,14 @@ import io.github.rosemoe.sora.widget.SymbolPairMatch;
|
||||
import java.io.StringReader;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CppLanguage extends IDELanguage {
|
||||
|
||||
private static final ILogger LOG = ILogger.newInstance("CppLanguage");
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CppLanguage.class);
|
||||
private final NewlineHandler[] newlineHandlers =
|
||||
new NewlineHandler[] {new BracketsNewlineHandler(this::getIndentAdvance, this::useTab)};
|
||||
new NewlineHandler[]{new BracketsNewlineHandler(this::getIndentAdvance, this::useTab)};
|
||||
private final CommonSymbolPairs symbolPairs = new CommonSymbolPairs();
|
||||
private CppAnalyzer analyzer;
|
||||
|
||||
|
||||
+3
-2
@@ -23,7 +23,6 @@ import com.itsaky.androidide.editor.language.newline.BracketsNewlineHandler;
|
||||
import com.itsaky.androidide.editor.language.utils.CommonSymbolPairs;
|
||||
import com.itsaky.androidide.lexers.groovy.GroovyLexer;
|
||||
import com.itsaky.androidide.utils.CharSequenceReader;
|
||||
import com.itsaky.androidide.utils.ILogger;
|
||||
import io.github.rosemoe.sora.lang.analysis.AnalyzeManager;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionCancelledException;
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionPublisher;
|
||||
@@ -34,10 +33,12 @@ import io.github.rosemoe.sora.widget.SymbolPairMatch;
|
||||
import java.io.StringReader;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class GroovyLanguage extends IDELanguage {
|
||||
|
||||
private static final ILogger LOG = ILogger.newInstance("GroovyLanguage");
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GroovyLanguage.class);
|
||||
private final GroovyAnalyzer analyzer;
|
||||
private final GroovyAutoComplete completer;
|
||||
private final NewlineHandler[] newlineHandlers =
|
||||
|
||||
-1
@@ -22,7 +22,6 @@ import io.github.rosemoe.sora.lang.smartEnter.NewlineHandleResult
|
||||
import io.github.rosemoe.sora.lang.styling.Styles
|
||||
import io.github.rosemoe.sora.text.CharPosition
|
||||
import io.github.rosemoe.sora.text.Content
|
||||
import io.github.rosemoe.sora.text.ContentReference
|
||||
import io.github.rosemoe.sora.text.TextUtils
|
||||
|
||||
/**
|
||||
|
||||
-1
@@ -20,7 +20,6 @@ package com.itsaky.androidide.editor.language.treesitter
|
||||
import android.content.Context
|
||||
import com.itsaky.androidide.editor.language.treesitter.TreeSitterLanguage.Factory
|
||||
import com.itsaky.androidide.treesitter.kotlin.TSLanguageKotlin
|
||||
import com.itsaky.androidide.utils.withStopWatch
|
||||
import io.github.rosemoe.sora.lang.Language.INTERRUPTION_LEVEL_STRONG
|
||||
|
||||
/**
|
||||
|
||||
-1
@@ -30,7 +30,6 @@ import com.itsaky.androidide.treesitter.TSParser
|
||||
import com.itsaky.androidide.treesitter.TSQueryCapture
|
||||
import com.itsaky.androidide.treesitter.TSQueryCursor
|
||||
import com.itsaky.androidide.treesitter.TSQueryMatch
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import io.github.rosemoe.sora.editor.ts.TsTheme
|
||||
import io.github.rosemoe.sora.lang.Language.INTERRUPTION_LEVEL_STRONG
|
||||
import io.github.rosemoe.sora.lang.analysis.AnalyzeManager
|
||||
|
||||
+3
-5
@@ -22,18 +22,16 @@ import androidx.core.graphics.ColorUtils
|
||||
import com.itsaky.androidide.editor.schemes.LanguageScheme
|
||||
import com.itsaky.androidide.treesitter.TSQuery
|
||||
import com.itsaky.androidide.treesitter.TSQueryCapture
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import com.itsaky.androidide.utils.parseHexColor
|
||||
import io.github.rosemoe.sora.editor.ts.spans.DefaultSpanFactory
|
||||
import io.github.rosemoe.sora.editor.ts.spans.TsSpanFactory
|
||||
import io.github.rosemoe.sora.lang.styling.Span
|
||||
import io.github.rosemoe.sora.lang.styling.SpanFactory
|
||||
import io.github.rosemoe.sora.lang.styling.Styles
|
||||
import io.github.rosemoe.sora.lang.styling.span.SpanColorResolver
|
||||
import io.github.rosemoe.sora.lang.styling.span.SpanConstColorResolver
|
||||
import io.github.rosemoe.sora.lang.styling.span.SpanExt
|
||||
import io.github.rosemoe.sora.lang.styling.span.SpanExtAttrs
|
||||
import io.github.rosemoe.sora.text.ContentReference
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
/**
|
||||
* [TsSpanFactory] for tree sitter languages.
|
||||
@@ -49,7 +47,7 @@ class TreeSitterSpanFactory(
|
||||
|
||||
companion object {
|
||||
|
||||
private val log = ILogger.newInstance("TreeSitterSpanFactory")
|
||||
private val log = LoggerFactory.getLogger(TreeSitterSpanFactory::class.java)
|
||||
|
||||
@JvmStatic
|
||||
private val HEX_REGEX = "#\\b([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\\b".toRegex()
|
||||
@@ -103,7 +101,7 @@ class TreeSitterSpanFactory(
|
||||
val color = try {
|
||||
parseHexColor(result.groupValues[1]).toInt()
|
||||
} catch (e: Exception) {
|
||||
log.error("An error occurred parsing hex color. text=$text", e)
|
||||
log.error("An error occurred parsing hex color. text={}", text, e)
|
||||
return@forEach
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ import com.itsaky.androidide.preferences.internal.DEFAULT_COLOR_SCHEME
|
||||
import com.itsaky.androidide.preferences.internal.colorScheme
|
||||
import com.itsaky.androidide.syntax.colorschemes.SchemeAndroidIDE
|
||||
import com.itsaky.androidide.utils.Environment
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import com.itsaky.androidide.utils.isSystemInDarkMode
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
import java.util.Properties
|
||||
@@ -40,7 +40,7 @@ import kotlin.coroutines.CoroutineContext
|
||||
/** @author Akash Yadav */
|
||||
object IDEColorSchemeProvider {
|
||||
|
||||
private val log = ILogger.newInstance("IDEColorSchemeProvider")
|
||||
private val log = LoggerFactory.getLogger(IDEColorSchemeProvider::class.java)
|
||||
private val schemesDir = File(Environment.ANDROIDIDE_UI, "editor/schemes")
|
||||
|
||||
private val schemes = ConcurrentHashMap<String, IDEColorScheme>()
|
||||
@@ -99,7 +99,7 @@ object IDEColorSchemeProvider {
|
||||
scheme.darkVariant?.load()
|
||||
scheme
|
||||
} catch (err: Exception) {
|
||||
log.error("An error occurred while loading color scheme '$colorScheme'", err)
|
||||
log.error("An error occurred while loading color scheme '{}'", colorScheme, err)
|
||||
null
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ object IDEColorSchemeProvider {
|
||||
Properties().apply { load(reader) }
|
||||
}
|
||||
} catch (err: Exception) {
|
||||
log.error("Failed to read properties for scheme '${schemeDir.name}'")
|
||||
log.error("Failed to read properties for scheme '{}'", schemeDir.name)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ object IDEColorSchemeProvider {
|
||||
}
|
||||
|
||||
if (version <= 0) {
|
||||
log.warn("Version code of color scheme '$schemeDir' must be set to >= 1")
|
||||
log.warn("Version code of color scheme '{}' must be set to >= 1", schemeDir)
|
||||
}
|
||||
|
||||
if (file.isBlank()) {
|
||||
@@ -258,7 +258,7 @@ object IDEColorSchemeProvider {
|
||||
|
||||
return currentScheme?.let { scheme ->
|
||||
return@let if (scheme.getLanguageScheme(type) == null) {
|
||||
log.warn("Color scheme '${scheme.name}' does not support '$type'")
|
||||
log.warn("Color scheme '{}' does not support '{}'", scheme.name, type)
|
||||
log.warn("Falling back to default color scheme")
|
||||
null
|
||||
} else {
|
||||
|
||||
@@ -25,9 +25,9 @@ import com.itsaky.androidide.editor.language.treesitter.predicates.MatchPredicat
|
||||
import com.itsaky.androidide.editor.language.treesitter.predicates.NotEqualPredicate
|
||||
import com.itsaky.androidide.editor.language.treesitter.predicates.NotMatchPredicate
|
||||
import com.itsaky.androidide.treesitter.TSLanguage
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import io.github.rosemoe.sora.editor.ts.LocalsCaptureSpec
|
||||
import io.github.rosemoe.sora.editor.ts.TsLanguageSpec
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.FileNotFoundException
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ import java.io.FileNotFoundException
|
||||
object LanguageSpecProvider {
|
||||
|
||||
private const val BASE_SPEC_PATH = "editor/treesitter"
|
||||
private val log = ILogger.newInstance("LanguageSpecProvider")
|
||||
private val log = LoggerFactory.getLogger(LanguageSpecProvider::class.java)
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
@@ -57,13 +57,13 @@ object LanguageSpecProvider {
|
||||
bracketsScmSource = readScheme(context, type, "brackets"),
|
||||
localsCaptureSpec = localsCaptureSpec,
|
||||
predicates =
|
||||
listOf(
|
||||
MatchPredicate,
|
||||
NotMatchPredicate,
|
||||
EqualPredicate,
|
||||
NotEqualPredicate,
|
||||
AnyOfPredicate
|
||||
)
|
||||
listOf(
|
||||
MatchPredicate,
|
||||
NotMatchPredicate,
|
||||
EqualPredicate,
|
||||
NotEqualPredicate,
|
||||
AnyOfPredicate
|
||||
)
|
||||
)
|
||||
return TreeSitterLanguageSpec(
|
||||
spec = editorLangSpec,
|
||||
@@ -77,7 +77,7 @@ object LanguageSpecProvider {
|
||||
} catch (e: Exception) {
|
||||
if (e !is FileNotFoundException) {
|
||||
// log everything except FileNotFoundException
|
||||
log.error("Failed to read scheme file $name for type $type", e)
|
||||
log.error("Failed to read scheme file {} for type {}", name, type, e)
|
||||
}
|
||||
""
|
||||
}
|
||||
|
||||
+6
-8
@@ -17,8 +17,8 @@
|
||||
|
||||
package com.itsaky.androidide.editor.schemes
|
||||
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import io.github.rosemoe.sora.editor.ts.LocalsCaptureSpec
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
/**
|
||||
* Provides local
|
||||
@@ -27,7 +27,7 @@ import io.github.rosemoe.sora.editor.ts.LocalsCaptureSpec
|
||||
*/
|
||||
object LocalCaptureSpecProvider {
|
||||
|
||||
private val log = ILogger.newInstance("LocalCaptureSpecProvider")
|
||||
private val log = LoggerFactory.getLogger(LocalCaptureSpecProvider::class.java)
|
||||
|
||||
@JvmStatic
|
||||
fun newLocalCaptureSpec(type: String): LocalsCaptureSpec {
|
||||
@@ -35,9 +35,7 @@ object LocalCaptureSpecProvider {
|
||||
IDEColorSchemeProvider.getColorSchemeForType(type)?.languages?.get(type)
|
||||
?: run {
|
||||
log.error(
|
||||
"Cannot create LocalsCaptureSpec",
|
||||
"Failed to load current color scheme.",
|
||||
"Falling back to default implementation"
|
||||
"Cannot create LocalsCaptureSpec. Failed to load current color scheme. Falling back to default implementation"
|
||||
)
|
||||
return LocalsCaptureSpec.DEFAULT
|
||||
}
|
||||
@@ -46,7 +44,7 @@ object LocalCaptureSpecProvider {
|
||||
override fun isDefinitionCapture(captureName: String): Boolean {
|
||||
return lang.isLocalDef(captureName)
|
||||
}
|
||||
|
||||
|
||||
override fun isDefinitionValueCapture(captureName: String): Boolean {
|
||||
return lang.isLocalDefVal(captureName)
|
||||
}
|
||||
@@ -54,11 +52,11 @@ object LocalCaptureSpecProvider {
|
||||
override fun isReferenceCapture(captureName: String): Boolean {
|
||||
return lang.isLocalRef(captureName)
|
||||
}
|
||||
|
||||
|
||||
override fun isScopeCapture(captureName: String): Boolean {
|
||||
return lang.isLocalScope(captureName)
|
||||
}
|
||||
|
||||
|
||||
override fun isMembersScopeCapture(captureName: String): Boolean {
|
||||
return lang.isMembersScope(captureName)
|
||||
}
|
||||
|
||||
-1
@@ -17,7 +17,6 @@
|
||||
|
||||
package com.itsaky.androidide.editor.schemes.internal.parser
|
||||
|
||||
import androidx.core.util.set
|
||||
import com.google.gson.stream.JsonReader
|
||||
import com.itsaky.androidide.editor.schemes.IDEColorScheme
|
||||
import com.itsaky.androidide.editor.schemes.internal.parser.SchemeParser.EditorColors
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
package com.itsaky.androidide.editor.ui
|
||||
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import io.github.rosemoe.sora.widget.CodeEditor
|
||||
import io.github.rosemoe.sora.widget.base.EditorPopupWindow
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
/**
|
||||
* Abstract class for all [IDEEditor] popup windows.
|
||||
@@ -30,13 +30,15 @@ abstract class AbstractPopupWindow(editor: CodeEditor, features: Int) :
|
||||
EditorPopupWindow(editor, features) {
|
||||
|
||||
companion object {
|
||||
private val log = ILogger.newInstance("AbstractPopupWindow")
|
||||
|
||||
private val log = LoggerFactory.getLogger(AbstractPopupWindow::class.java)
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
(editor as? IDEEditor)?.ensureWindowsDismissed()
|
||||
if (!editor.isAttachedToWindow) {
|
||||
log.error("Trying to show popup window '${javaClass.name}' when editor is not attached to window")
|
||||
log.error("Trying to show popup window '{}' when editor is not attached to window",
|
||||
javaClass.name)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import com.itsaky.androidide.actions.ActionsRegistry
|
||||
import com.itsaky.androidide.actions.ActionsRegistry.Companion.getInstance
|
||||
import com.itsaky.androidide.actions.EditorActionItem
|
||||
import com.itsaky.androidide.actions.FillMenuParams
|
||||
import com.itsaky.androidide.editor.R.*
|
||||
import com.itsaky.androidide.editor.R.layout
|
||||
import com.itsaky.androidide.editor.databinding.LayoutPopupMenuItemBinding
|
||||
import com.itsaky.androidide.editor.ui.EditorActionsMenu.ActionsListAdapter.VH
|
||||
import com.itsaky.androidide.lsp.api.ILanguageServerRegistry
|
||||
|
||||
@@ -22,11 +22,11 @@ import android.net.Uri
|
||||
import android.widget.ListView
|
||||
import com.itsaky.androidide.lsp.util.DocumentationReferenceProvider
|
||||
import com.itsaky.androidide.progress.ProgressManager
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import com.itsaky.androidide.utils.KeyboardUtils
|
||||
import io.github.rosemoe.sora.lang.completion.CompletionItem
|
||||
import io.github.rosemoe.sora.widget.component.CompletionLayout
|
||||
import io.github.rosemoe.sora.widget.component.EditorAutoCompletion
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.lang.ref.WeakReference
|
||||
import kotlin.math.min
|
||||
|
||||
@@ -39,7 +39,11 @@ class EditorCompletionWindow(val editor: IDEEditor) : EditorAutoCompletion(edito
|
||||
|
||||
private var listView: ListView? = null
|
||||
private val items: MutableList<CompletionItem> = mutableListOf()
|
||||
private val log = ILogger.newInstance(javaClass.simpleName)
|
||||
|
||||
companion object {
|
||||
|
||||
private val log = LoggerFactory.getLogger(EditorCompletionWindow::class.java)
|
||||
}
|
||||
|
||||
init {
|
||||
setLayout(EditorCompletionLayout())
|
||||
@@ -80,7 +84,7 @@ class EditorCompletionWindow(val editor: IDEEditor) : EditorAutoCompletion(edito
|
||||
return try {
|
||||
super.select(pos)
|
||||
} catch (e: Throwable) {
|
||||
log.warn("Unable to select completion item at $pos", e)
|
||||
log.warn("Unable to select completion item at {}", pos, e)
|
||||
false
|
||||
}
|
||||
}
|
||||
@@ -153,8 +157,8 @@ class EditorCompletionWindow(val editor: IDEEditor) : EditorAutoCompletion(edito
|
||||
}
|
||||
|
||||
if (adapter!!.count >= 1
|
||||
&& KeyboardUtils.isHardKeyboardConnected(context)
|
||||
) {
|
||||
&& KeyboardUtils.isHardKeyboardConnected(context)
|
||||
) {
|
||||
currentSelection = 0
|
||||
}
|
||||
},
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.itsaky.androidide.eventbus.events.editor.DocumentSelectedEvent
|
||||
import com.itsaky.androidide.projects.FileManager.onDocumentClose
|
||||
import com.itsaky.androidide.projects.FileManager.onDocumentContentChange
|
||||
import com.itsaky.androidide.projects.FileManager.onDocumentOpen
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -34,6 +33,7 @@ import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.concurrent.CancellationException
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
|
||||
@@ -51,7 +51,7 @@ class EditorEventDispatcher(
|
||||
|
||||
companion object {
|
||||
|
||||
private val log = ILogger.newInstance("EditorEventDispatcher")
|
||||
private val log = LoggerFactory.getLogger(EditorEventDispatcher::class.java)
|
||||
}
|
||||
|
||||
fun init(scope: CoroutineScope) {
|
||||
|
||||
@@ -46,7 +46,7 @@ class EditorFeatures(
|
||||
override fun setSelection(start: Position, end: Position) {
|
||||
withEditor {
|
||||
if (!isValidPosition(start, true) || !isValidPosition(end, true)) {
|
||||
log.warn("Invalid selection range: start=$start end=$end")
|
||||
log.warn("Invalid selection range: start={} end={}", start, end)
|
||||
return@withEditor
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ import com.itsaky.androidide.tasks.JobCancelChecker
|
||||
import com.itsaky.androidide.tasks.cancelIfActive
|
||||
import com.itsaky.androidide.tasks.launchAsyncWithProgress
|
||||
import com.itsaky.androidide.utils.DocumentUtils
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import com.itsaky.androidide.utils.flashError
|
||||
import io.github.rosemoe.sora.event.ContentChangeEvent
|
||||
import io.github.rosemoe.sora.event.SelectionChangeEvent
|
||||
@@ -95,6 +94,7 @@ import kotlinx.coroutines.withContext
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
@@ -177,7 +177,7 @@ open class IDEEditor @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
|
||||
private const val SELECTION_CHANGE_DELAY = 500L
|
||||
|
||||
internal val log = ILogger.newInstance("IDEEditor")
|
||||
internal val log = LoggerFactory.getLogger(IDEEditor::class.java)
|
||||
|
||||
/**
|
||||
* Create input type flags for the editor.
|
||||
@@ -596,7 +596,7 @@ open class IDEEditor @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
language.setupWith(finalScheme)
|
||||
|
||||
if (finalScheme.getLanguageScheme(type) == null) {
|
||||
log.warn("Color scheme does not support file type '$type'")
|
||||
log.warn("Color scheme does not support file type '{}'", type)
|
||||
finalScheme = SchemeAndroidIDE.newInstance(context)
|
||||
}
|
||||
}
|
||||
@@ -626,7 +626,7 @@ open class IDEEditor @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
}.also { job ->
|
||||
job.invokeOnCompletion { err ->
|
||||
if (err != null) {
|
||||
log.error("Failed to setup tree sitter language for file: $file", err)
|
||||
log.error("Failed to setup tree sitter language for file: {}", file, err)
|
||||
}
|
||||
|
||||
setupTsLanguageJob = null
|
||||
@@ -888,7 +888,7 @@ open class IDEEditor @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <T> safeGet(name: String, action: () -> T) : T? {
|
||||
private inline fun <T> safeGet(name: String, action: () -> T): T? {
|
||||
return try {
|
||||
action()
|
||||
} catch (err: Throwable) {
|
||||
@@ -897,16 +897,16 @@ open class IDEEditor @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
}
|
||||
}
|
||||
|
||||
private fun Job.logError(action: String) : Job = apply {
|
||||
private fun Job.logError(action: String): Job = apply {
|
||||
invokeOnCompletion { err -> logError(err, action) }
|
||||
}
|
||||
|
||||
private fun logError(err: Throwable?, action: String) {
|
||||
err ?: return
|
||||
if (CancelChecker.isCancelled(err)) {
|
||||
log.warn("$action has been cancelled")
|
||||
log.warn("{} has been cancelled", action)
|
||||
} else {
|
||||
log.error("$action failed")
|
||||
log.error("{} failed", action)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import android.view.LayoutInflater
|
||||
import com.itsaky.androidide.editor.databinding.LayoutEditorFindReplaceBinding
|
||||
import com.itsaky.androidide.resources.R
|
||||
import com.itsaky.androidide.utils.DialogUtils
|
||||
import com.itsaky.androidide.utils.ILogger
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
/**
|
||||
* Handles the replace action while searching in file.
|
||||
@@ -30,7 +30,7 @@ import com.itsaky.androidide.utils.ILogger
|
||||
*/
|
||||
object ReplaceAction {
|
||||
|
||||
private val log = ILogger.newInstance("ReplaceAction")
|
||||
private val log = LoggerFactory.getLogger(ReplaceAction::class.java)
|
||||
|
||||
@JvmStatic
|
||||
fun doReplace(editor: IDEEditor) {
|
||||
|
||||
@@ -25,10 +25,11 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.itsaky.androidide.lsp.models.SignatureHelp;
|
||||
import com.itsaky.androidide.lsp.models.SignatureInformation;
|
||||
import com.itsaky.androidide.utils.ILogger;
|
||||
import com.itsaky.androidide.utils.ResourceUtilsKt;
|
||||
import io.github.rosemoe.sora.event.SelectionChangeEvent;
|
||||
import io.github.rosemoe.sora.widget.base.EditorPopupWindow;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* An {@link EditorPopupWindow} used to show signature help.
|
||||
@@ -37,7 +38,7 @@ import io.github.rosemoe.sora.widget.base.EditorPopupWindow;
|
||||
*/
|
||||
public class SignatureHelpWindow extends BaseEditorWindow {
|
||||
|
||||
private static final ILogger LOG = ILogger.newInstance("SignatureHelpWindow");
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SignatureHelpWindow.class);
|
||||
|
||||
/**
|
||||
* Create a signature help popup window for editor
|
||||
@@ -48,12 +49,12 @@ public class SignatureHelpWindow extends BaseEditorWindow {
|
||||
super(editor);
|
||||
|
||||
editor.subscribeEvent(
|
||||
SelectionChangeEvent.class,
|
||||
(event, unsubscribe) -> {
|
||||
if (isShowing()) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
SelectionChangeEvent.class,
|
||||
(event, unsubscribe) -> {
|
||||
if (isShowing()) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setupAndDisplay(SignatureHelp signature) {
|
||||
@@ -83,29 +84,26 @@ public class SignatureHelpWindow extends BaseEditorWindow {
|
||||
final SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||
|
||||
if (activeSignature < 0 || activeParameter < 0) {
|
||||
LOG.debug("activeSignature:", activeSignature, "activeParameter:", activeParameter);
|
||||
LOG.debug("activeSignature: {}, activeParameter: {}", activeSignature, activeParameter);
|
||||
return null;
|
||||
}
|
||||
|
||||
var count = signatures.size();
|
||||
if (activeSignature >= count) {
|
||||
LOG.debug("Active signature is invalid", "Size is " + count);
|
||||
LOG.debug("Active signature is invalid. Size is {}", count);
|
||||
return null;
|
||||
}
|
||||
|
||||
// remove all with non-applicable signatures
|
||||
signatures.removeIf(
|
||||
info -> {
|
||||
final var remove = activeParameter >= info.getParameters().size();
|
||||
if (remove) {
|
||||
LOG.debug(
|
||||
"Removing",
|
||||
info,
|
||||
"params=" + info.getParameters().size(),
|
||||
"active=" + activeParameter);
|
||||
}
|
||||
return remove;
|
||||
});
|
||||
info -> {
|
||||
final var remove = activeParameter >= info.getParameters().size();
|
||||
if (remove) {
|
||||
LOG.debug("Removing {} params={} active={}", info, info.getParameters().size(),
|
||||
activeParameter);
|
||||
}
|
||||
return remove;
|
||||
});
|
||||
|
||||
count = signatures.size();
|
||||
for (var i = 0; i < count; i++) {
|
||||
@@ -127,22 +125,22 @@ public class SignatureHelpWindow extends BaseEditorWindow {
|
||||
* @param result The builder to append spanned text to.
|
||||
*/
|
||||
private void formatSignature(
|
||||
@NonNull SignatureInformation signature,
|
||||
int paramIndex,
|
||||
SpannableStringBuilder result) {
|
||||
@NonNull SignatureInformation signature,
|
||||
int paramIndex,
|
||||
SpannableStringBuilder result) {
|
||||
|
||||
String name = signature.getLabel();
|
||||
name = name.substring(0, name.indexOf("("));
|
||||
|
||||
final var foreground = ResourceUtilsKt.resolveAttr(getEditor().getContext(),
|
||||
attr.colorOnSecondaryContainer);
|
||||
attr.colorOnSecondaryContainer);
|
||||
final var paramSelected = 0xffff6060;
|
||||
final var operators = 0xff4fc3f7;
|
||||
|
||||
result.append(
|
||||
name, new ForegroundColorSpan(foreground), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
name, new ForegroundColorSpan(foreground), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
result.append(
|
||||
"(", new ForegroundColorSpan(operators), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
"(", new ForegroundColorSpan(operators), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
var params = signature.getParameters();
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
@@ -150,22 +148,22 @@ public class SignatureHelpWindow extends BaseEditorWindow {
|
||||
final var info = params.get(i);
|
||||
if (i == params.size() - 1) {
|
||||
result.append(
|
||||
info.getLabel() + "",
|
||||
new ForegroundColorSpan(color),
|
||||
SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
info.getLabel(),
|
||||
new ForegroundColorSpan(color),
|
||||
SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
} else {
|
||||
result.append(
|
||||
info.getLabel() + "",
|
||||
new ForegroundColorSpan(color),
|
||||
SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
info.getLabel(),
|
||||
new ForegroundColorSpan(color),
|
||||
SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
result.append(
|
||||
",",
|
||||
new ForegroundColorSpan(operators),
|
||||
SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
",",
|
||||
new ForegroundColorSpan(operators),
|
||||
SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
result.append(" ");
|
||||
}
|
||||
}
|
||||
result.append(
|
||||
")", new ForegroundColorSpan(0xff4fc3f7), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
")", new ForegroundColorSpan(0xff4fc3f7), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user