Skip to content

Commit

Permalink
Updated Kotlin syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
romainguy committed May 17, 2024
1 parent 30651b1 commit 3afea72
Show file tree
Hide file tree
Showing 12 changed files with 6,639 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ kotlin {
implementation(libs.skiko.mac)
implementation(libs.rsyntaxtextarea)
implementation(libs.rstaui)
implementation(project(":token-markers"))
implementation(project(":token-makers"))
runtimeOnly(libs.skiko.linux)
}
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ plugins {
rootProject.name = "kotlin-explorer"

include("tests")
include("token-markers")
include("token-makers")
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.Key.Companion.A
import androidx.compose.ui.input.key.Key.Companion.B
import androidx.compose.ui.input.key.Key.Companion.C
import androidx.compose.ui.input.key.Key.Companion.Comma
import androidx.compose.ui.input.key.Key.Companion.D
import androidx.compose.ui.input.key.Key.Companion.F
import androidx.compose.ui.input.key.Key.Companion.G
Expand Down Expand Up @@ -378,7 +377,7 @@ private fun Title(text: String) {

private fun sourceTextArea(focusTracker: FocusListener, explorerState: ExplorerState): SourceTextArea {
return SourceTextArea(explorerState.syncLines).apply {
configureSyntaxTextArea(SyntaxConstants.SYNTAX_STYLE_KOTLIN, focusTracker)
configureSyntaxTextArea(SyntaxStyle.Kotlin, focusTracker)
SwingUtilities.invokeLater { requestFocusInWindow() }
document.addDocumentListener(DocumentChangeListener { explorerState.sourceCode = text })
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (C) 2023 Romain Guy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.romainguy.kotlin.explorer.code

import org.fife.ui.rsyntaxtextarea.AbstractTokenMakerFactory
Expand All @@ -6,14 +22,16 @@ import org.fife.ui.rsyntaxtextarea.TokenMakerFactory
class SyntaxStyle private constructor() {
companion object {
val Dex: String get() = "text/dex-bytecode"
val Oat: String get() = "text/oat-assembly"
val ByteCode: String get() = "text/java-bytecode"
val Kotlin: String get() = "text/modified-kotlin"
val Oat: String get() = "text/oat-assembly"

init {
val factory = TokenMakerFactory.getDefaultInstance() as AbstractTokenMakerFactory
factory.putMapping(ByteCode, DexTokenMarker::class.java.canonicalName)
factory.putMapping(Dex, DexTokenMarker::class.java.canonicalName)
factory.putMapping(Oat, OatTokenMarker::class.java.canonicalName)
factory.putMapping(ByteCode, DexTokenMaker::class.java.canonicalName)
factory.putMapping(Dex, DexTokenMaker::class.java.canonicalName)
factory.putMapping(Kotlin, KotlinTokenMaker::class.java.canonicalName)
factory.putMapping(Oat, OatTokenMaker::class.java.canonicalName)
}
}
}
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3afea72

Please sign in to comment.