文件编译系统升级
This commit is contained in:
parent
5d4f078664
commit
61cf34c513
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -20,6 +20,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.WhichButton
|
import com.afollestad.materialdialogs.WhichButton
|
||||||
import com.afollestad.materialdialogs.actions.setActionButtonEnabled
|
import com.afollestad.materialdialogs.actions.setActionButtonEnabled
|
||||||
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
import com.afollestad.materialdialogs.input.getInputField
|
import com.afollestad.materialdialogs.input.getInputField
|
||||||
import com.afollestad.materialdialogs.input.input
|
import com.afollestad.materialdialogs.input.input
|
||||||
import com.afollestad.materialdialogs.list.ItemListener
|
import com.afollestad.materialdialogs.list.ItemListener
|
||||||
|
@ -1180,6 +1181,13 @@ class EditActivity : BaseActivity<ActivityEditBinding>() {
|
||||||
goIntent.putExtra("filePath", filePath)
|
goIntent.putExtra("filePath", filePath)
|
||||||
startActivity(goIntent)
|
startActivity(goIntent)
|
||||||
}
|
}
|
||||||
|
R.id.display_source_code -> {
|
||||||
|
val file = File(viewModel.getNowOpenFilePath())
|
||||||
|
val code = FileOperator.readFile(file)
|
||||||
|
MaterialDialog(this, BottomSheet()).show {
|
||||||
|
title(text = file.name).message(text = code).negativeButton(R.string.dialog_ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
R.id.clear_code_cache -> {
|
R.id.clear_code_cache -> {
|
||||||
viewModel.codeCompiler2.clearCache()
|
viewModel.codeCompiler2.clearCache()
|
||||||
Snackbar.make(
|
Snackbar.make(
|
||||||
|
|
|
@ -94,6 +94,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
||||||
}
|
}
|
||||||
modId = temId
|
modId = temId
|
||||||
if (targetFile.exists()) {
|
if (targetFile.exists()) {
|
||||||
|
viewBinding.button.isEnabled = false
|
||||||
viewBinding.button.text = getString(R.string.installated)
|
viewBinding.button.text = getString(R.string.installated)
|
||||||
}
|
}
|
||||||
viewBinding.modCommentRecyclerView.layoutManager =
|
viewBinding.modCommentRecyclerView.layoutManager =
|
||||||
|
@ -375,6 +376,7 @@ class WebModInfoActivity : BaseActivity<ActivityWebModInfoBinding>() {
|
||||||
if (materialDialog.isShowing) {
|
if (materialDialog.isShowing) {
|
||||||
materialDialog.dismiss()
|
materialDialog.dismiss()
|
||||||
}
|
}
|
||||||
|
viewBinding.button.isEnabled = false
|
||||||
viewBinding.button.setText(R.string.installated)
|
viewBinding.button.setText(R.string.installated)
|
||||||
WebMod.instance.addDownloadNum(modId)
|
WebMod.instance.addDownloadNum(modId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.coldmint.rust.core.database.code.CodeDataBase
|
||||||
import com.coldmint.rust.core.database.code.SectionInfo
|
import com.coldmint.rust.core.database.code.SectionInfo
|
||||||
import com.coldmint.rust.core.database.file.FileDataBase
|
import com.coldmint.rust.core.database.file.FileDataBase
|
||||||
import com.coldmint.rust.core.interfaces.EnglishMode
|
import com.coldmint.rust.core.interfaces.EnglishMode
|
||||||
|
import com.coldmint.rust.core.tool.DebugHelper
|
||||||
import com.coldmint.rust.core.tool.LineParser
|
import com.coldmint.rust.core.tool.LineParser
|
||||||
import com.coldmint.rust.pro.tool.AppSettings
|
import com.coldmint.rust.pro.tool.AppSettings
|
||||||
import com.coldmint.rust.pro.tool.CompletionItemConverter
|
import com.coldmint.rust.pro.tool.CompletionItemConverter
|
||||||
|
@ -27,6 +28,7 @@ class RustAutoComplete2(val context: Context) : AutoCompleteProvider, EnglishMod
|
||||||
private val result: ArrayList<CompletionItem> by lazy {
|
private val result: ArrayList<CompletionItem> by lazy {
|
||||||
ArrayList()
|
ArrayList()
|
||||||
}
|
}
|
||||||
|
private val debugKey = "自动完成器"
|
||||||
private var codeDataBase: CodeDataBase? = null
|
private var codeDataBase: CodeDataBase? = null
|
||||||
private val executorService = Executors.newCachedThreadPool()
|
private val executorService = Executors.newCachedThreadPool()
|
||||||
private var fileDataBase: FileDataBase? = null
|
private var fileDataBase: FileDataBase? = null
|
||||||
|
@ -63,6 +65,7 @@ class RustAutoComplete2(val context: Context) : AutoCompleteProvider, EnglishMod
|
||||||
* @param sourceFolder String
|
* @param sourceFolder String
|
||||||
*/
|
*/
|
||||||
fun setSourceFolder(sourceFolder: String) {
|
fun setSourceFolder(sourceFolder: String) {
|
||||||
|
DebugHelper.printLog(debugKey, "已设置源文件目录" + sourceFolder, "设置源文件目录")
|
||||||
completionItemConverter.setSourceFilePath(sourceFolder)
|
completionItemConverter.setSourceFilePath(sourceFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,33 +217,55 @@ class RustAutoComplete2(val context: Context) : AutoCompleteProvider, EnglishMod
|
||||||
} else {
|
} else {
|
||||||
lineData.subSequence(0, keyIndex)
|
lineData.subSequence(0, keyIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
val codeInfo =
|
val codeInfo =
|
||||||
if (isEnglishMode) {
|
if (isEnglishMode) {
|
||||||
codeDataBase!!.getCodeDao().findCodeByCode(keyValue.toString())
|
codeDataBase!!.getCodeDao().findCodeByCode(keyValue.toString())
|
||||||
} else {
|
} else {
|
||||||
codeDataBase!!.getCodeDao().findCodeByTranslate(keyValue.toString())
|
codeDataBase!!.getCodeDao().findCodeByTranslate(keyValue.toString())
|
||||||
}
|
}
|
||||||
|
DebugHelper.printLog(
|
||||||
|
debugKey,
|
||||||
|
"值[" + keyValue + "]英文模式[" + isEnglishMode + "]代码信息[" + codeInfo + "]关键字[" + prefix + "]",
|
||||||
|
"值检查"
|
||||||
|
)
|
||||||
if (codeInfo != null) {
|
if (codeInfo != null) {
|
||||||
val typeInfo = completionItemConverter.getValueType(codeInfo.type)
|
val typeInfo = completionItemConverter.getValueType(codeInfo.type)
|
||||||
//获取代码的关联列表
|
//获取代码的关联列表
|
||||||
if (typeInfo != null && typeInfo.list.isNotBlank()) {
|
if (typeInfo != null && typeInfo.list.isNotBlank()) {
|
||||||
|
DebugHelper.printLog(
|
||||||
|
debugKey,
|
||||||
|
"值类型[" + codeInfo.type + "]自动提示列表[" + typeInfo.list + "]", "关联提示"
|
||||||
|
)
|
||||||
lineParser.text = typeInfo.list
|
lineParser.text = typeInfo.list
|
||||||
lineParser.analyse { lineNum, lineData, isEnd ->
|
lineParser.analyse { lineNum, lineData, isEnd ->
|
||||||
//分析关联提示项目
|
//分析关联提示项目
|
||||||
val temCodeInfo =
|
val temCodeInfo =
|
||||||
codeDataBase!!.getCodeDao().findCodeByCode(lineData)
|
codeDataBase!!.getCodeDao().findCodeByCode(lineData)
|
||||||
|
DebugHelper.printLog(
|
||||||
|
debugKey,
|
||||||
|
"值类型[" + codeInfo.type + "]项目[" + lineData + "]是代码[" + (temCodeInfo != null) + "]",
|
||||||
|
"关联提示列表分析"
|
||||||
|
)
|
||||||
if (temCodeInfo == null) {
|
if (temCodeInfo == null) {
|
||||||
if (lineData.startsWith("@file(") && lineData.endsWith(")")) {
|
if (lineData.startsWith("@file(") && lineData.endsWith(")")) {
|
||||||
val fileType = lineData.subSequence(
|
val fileType = lineData.subSequence(
|
||||||
lineData.indexOf('(') + 1,
|
lineData.indexOf('(') + 1,
|
||||||
lineData.indexOf(')')
|
lineData.indexOf(')')
|
||||||
)
|
)
|
||||||
|
|
||||||
val fileInfo = fileDataBase!!.getFileInfoDao()
|
val fileInfo = fileDataBase!!.getFileInfoDao()
|
||||||
.searchFileInfoByNameAndType(
|
.searchFileInfoByNameAndType(
|
||||||
prefix,
|
prefix,
|
||||||
fileType.toString(),
|
fileType.toString(),
|
||||||
identifiersPromptNumber
|
identifiersPromptNumber
|
||||||
)
|
)
|
||||||
|
DebugHelper.printLog(
|
||||||
|
debugKey,
|
||||||
|
"值类型[" + codeInfo.type + "]项目[" + lineData + "]搜索了[" + fileType + "]类型的文件,返回了[" + (fileInfo?.size
|
||||||
|
?: -1) + "]个结果",
|
||||||
|
"关联提示列表分析"
|
||||||
|
)
|
||||||
if (fileInfo != null && fileInfo.isNotEmpty()) {
|
if (fileInfo != null && fileInfo.isNotEmpty()) {
|
||||||
for (fileTable in fileInfo) {
|
for (fileTable in fileInfo) {
|
||||||
result.add(
|
result.add(
|
||||||
|
@ -277,17 +302,34 @@ class RustAutoComplete2(val context: Context) : AutoCompleteProvider, EnglishMod
|
||||||
lineData.indexOf('(') + 1,
|
lineData.indexOf('(') + 1,
|
||||||
lineData.indexOf(')')
|
lineData.indexOf(')')
|
||||||
).toString()
|
).toString()
|
||||||
codeDataBase!!.getCodeDao().findCodeByKeyInType(
|
val list = if (isEnglishMode
|
||||||
|
) {
|
||||||
|
codeDataBase!!.getCodeDao().findCodeByCodeInType(
|
||||||
prefix,
|
prefix,
|
||||||
type,
|
type,
|
||||||
identifiersPromptNumber
|
identifiersPromptNumber
|
||||||
)?.forEach {
|
)
|
||||||
|
} else {
|
||||||
|
codeDataBase!!.getCodeDao().findCodeByTranslateInType(
|
||||||
|
prefix,
|
||||||
|
type,
|
||||||
|
identifiersPromptNumber
|
||||||
|
)
|
||||||
|
}
|
||||||
|
DebugHelper.printLog(
|
||||||
|
debugKey,
|
||||||
|
"关联了值类型[" + type + "]获取[" + (list?.size ?: -1) + "]个结果",
|
||||||
|
"值类型引用"
|
||||||
|
)
|
||||||
|
if (!list.isNullOrEmpty()) {
|
||||||
|
list.forEach {
|
||||||
result.add(
|
result.add(
|
||||||
completionItemConverter.codeInfoToCompletionItem(
|
completionItemConverter.codeInfoToCompletionItem(
|
||||||
it
|
it
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (lineData.startsWith("@section") && lineData.endsWith(
|
} else if (lineData.startsWith("@section") && lineData.endsWith(
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
@ -318,7 +360,18 @@ class RustAutoComplete2(val context: Context) : AutoCompleteProvider, EnglishMod
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (temCodeInfo.translate.contains(prefix)) {
|
|
||||||
|
val show = if (isEnglishMode) {
|
||||||
|
temCodeInfo.code.contains(prefix)
|
||||||
|
} else {
|
||||||
|
temCodeInfo.translate.contains(prefix)
|
||||||
|
}
|
||||||
|
DebugHelper.printLog(
|
||||||
|
debugKey,
|
||||||
|
"值类型[" + codeInfo.type + "]项目[" + lineData + "]是否包含" + prefix + "关键字[" + show + "]",
|
||||||
|
"关联提示列表分析"
|
||||||
|
)
|
||||||
|
if (show) {
|
||||||
result.add(
|
result.add(
|
||||||
completionItemConverter.codeInfoToCompletionItem(
|
completionItemConverter.codeInfoToCompletionItem(
|
||||||
temCodeInfo
|
temCodeInfo
|
||||||
|
|
|
@ -39,9 +39,9 @@
|
||||||
android:title="@string/word_wrap" />
|
android:title="@string/word_wrap" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:visible="false"
|
|
||||||
android:id="@+id/turret_design"
|
android:id="@+id/turret_design"
|
||||||
android:title="@string/turret_design" />
|
android:title="@string/turret_design"
|
||||||
|
android:visible="false" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/search_view"
|
android:id="@+id/search_view"
|
||||||
|
@ -54,6 +54,9 @@
|
||||||
<item
|
<item
|
||||||
android:id="@+id/clear_code_cache"
|
android:id="@+id/clear_code_cache"
|
||||||
android:title="@string/clear_code_cache" />
|
android:title="@string/clear_code_cache" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/display_source_code"
|
||||||
|
android:title="@string/display_source_code" />
|
||||||
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
|
@ -827,4 +827,5 @@
|
||||||
<string name="email_fill_complete">邮箱地址填充完成。</string>
|
<string name="email_fill_complete">邮箱地址填充完成。</string>
|
||||||
<string name="confirm_password">确认密码</string>
|
<string name="confirm_password">确认密码</string>
|
||||||
<string name="confirm_password_error">两次密码不一致。</string>
|
<string name="confirm_password_error">两次密码不一致。</string>
|
||||||
|
<string name="display_source_code">显示源代码</string>
|
||||||
</resources>
|
</resources>
|
|
@ -4,11 +4,14 @@ import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.os.Message
|
||||||
|
import android.util.Log
|
||||||
import com.coldmint.rust.core.dataBean.CompileConfiguration
|
import com.coldmint.rust.core.dataBean.CompileConfiguration
|
||||||
import com.coldmint.rust.core.database.code.CodeDataBase
|
import com.coldmint.rust.core.database.code.CodeDataBase
|
||||||
import com.coldmint.rust.core.database.code.SectionInfo
|
import com.coldmint.rust.core.database.code.SectionInfo
|
||||||
import com.coldmint.rust.core.database.code.ValueTypeInfo
|
import com.coldmint.rust.core.database.code.ValueTypeInfo
|
||||||
import com.coldmint.rust.core.interfaces.*
|
import com.coldmint.rust.core.interfaces.*
|
||||||
|
import com.coldmint.rust.core.tool.DebugHelper
|
||||||
import com.coldmint.rust.core.tool.FileOperator
|
import com.coldmint.rust.core.tool.FileOperator
|
||||||
import com.coldmint.rust.core.tool.LineParser
|
import com.coldmint.rust.core.tool.LineParser
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -70,6 +73,7 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val split = "\n ,:()=%{}+*/\r"
|
const val split = "\n ,:()=%{}+*/\r"
|
||||||
|
val debugKey = "代码编译器"
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private var instance: CodeCompiler2? = null
|
private var instance: CodeCompiler2? = null
|
||||||
|
@ -175,7 +179,7 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
||||||
if (translationMap.containsKey(code)) {
|
if (translationMap.containsKey(code)) {
|
||||||
translationResult.append(translationMap[code])
|
translationResult.append(translationMap[code])
|
||||||
} else {
|
} else {
|
||||||
codeResult.delete(0, codeResult.length)
|
codeResult.clear()
|
||||||
when (code) {
|
when (code) {
|
||||||
"\n" -> {
|
"\n" -> {
|
||||||
if (codeBlockType == CompileConfiguration.CodeBlockType.Reference) {
|
if (codeBlockType == CompileConfiguration.CodeBlockType.Reference) {
|
||||||
|
@ -184,9 +188,10 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
||||||
codeDataBase.getCodeDao().findCodeByCode(referenceValue)
|
codeDataBase.getCodeDao().findCodeByCode(referenceValue)
|
||||||
if (codeInfo == null) {
|
if (codeInfo == null) {
|
||||||
translationResult.append(referenceResult)
|
translationResult.append(referenceResult)
|
||||||
}else{
|
} else {
|
||||||
// tr
|
translationResult.append(codeInfo.translate)
|
||||||
}
|
}
|
||||||
|
referenceResult.clear()
|
||||||
}
|
}
|
||||||
codeBlockType = CompileConfiguration.CodeBlockType.Key
|
codeBlockType = CompileConfiguration.CodeBlockType.Key
|
||||||
codeResult.append(code)
|
codeResult.append(code)
|
||||||
|
@ -295,6 +300,11 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
||||||
translationMap[code] = codeResult.toString()
|
translationMap[code] = codeResult.toString()
|
||||||
}
|
}
|
||||||
translationResult.append(codeResult.toString())
|
translationResult.append(codeResult.toString())
|
||||||
|
DebugHelper.printLog(
|
||||||
|
debugKey,
|
||||||
|
"代码[" + code + "]译文[" + codeResult.toString() + "]是否翻译[" + (code != codeResult.toString()) + "]",
|
||||||
|
"翻译"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handler.post {
|
handler.post {
|
||||||
|
@ -323,6 +333,11 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
||||||
val codeResult = StringBuilder()
|
val codeResult = StringBuilder()
|
||||||
//保存完整的翻译结果
|
//保存完整的翻译结果
|
||||||
val compileResult = StringBuilder()
|
val compileResult = StringBuilder()
|
||||||
|
//是否为首次引用冒号值(首次值会直接附加到结果集合内)
|
||||||
|
var isFirstReference = false
|
||||||
|
|
||||||
|
//保存资源引用值(应该看做整体处理)
|
||||||
|
val referenceResult = StringBuilder()
|
||||||
val context = compileConfiguration.context
|
val context = compileConfiguration.context
|
||||||
handler.post {
|
handler.post {
|
||||||
compilerListener?.beforeCompilation()
|
compilerListener?.beforeCompilation()
|
||||||
|
@ -330,7 +345,7 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
||||||
val startTime = System.currentTimeMillis()
|
val startTime = System.currentTimeMillis()
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
val translation = tokenizer.nextToken()
|
val translation = tokenizer.nextToken()
|
||||||
codeResult.delete(0, codeResult.length)
|
codeResult.clear()
|
||||||
if (compileMap.containsKey(translation)) {
|
if (compileMap.containsKey(translation)) {
|
||||||
//此处仅读取字段缓存,不涉及错误缓存的读取
|
//此处仅读取字段缓存,不涉及错误缓存的读取
|
||||||
val code = compileMap[translation]
|
val code = compileMap[translation]
|
||||||
|
@ -351,32 +366,67 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
||||||
} else {
|
} else {
|
||||||
when (translation) {
|
when (translation) {
|
||||||
"\n" -> {
|
"\n" -> {
|
||||||
analysisLineCode(compileConfiguration, compilerListener)
|
if (compileConfiguration.codeBlockType == CompileConfiguration.CodeBlockType.Reference) {
|
||||||
|
//此段代码将临时引用数据referenceValue 附加到编译结果内,并附加到 值 数据内(附加值数据用于检查)
|
||||||
|
val referenceValue = referenceResult.toString()
|
||||||
|
compileConfiguration.appendValue(referenceResult.toString())
|
||||||
|
val codeInfo = codeDataBase.getCodeDao()
|
||||||
|
.findCodeByTranslate(referenceResult.toString())
|
||||||
|
if (codeInfo == null) {
|
||||||
|
compileResult.append(referenceValue)
|
||||||
|
} else {
|
||||||
|
compileResult.append(codeInfo.code)
|
||||||
|
}
|
||||||
|
DebugHelper.printLog(
|
||||||
|
debugKey,
|
||||||
|
"引用数据[" + referenceValue + "]代码信息存在状态[" + (codeInfo != null) + "]",
|
||||||
|
"行引用附加"
|
||||||
|
)
|
||||||
|
referenceResult.clear()
|
||||||
|
}
|
||||||
|
isFirstReference = true
|
||||||
|
checkLineCode(compileConfiguration, compilerListener)
|
||||||
compileConfiguration.nextLine()
|
compileConfiguration.nextLine()
|
||||||
codeResult.append(translation)
|
codeResult.append(translation)
|
||||||
}
|
}
|
||||||
"\r" -> {
|
"\r" -> {
|
||||||
}
|
}
|
||||||
" ", ",", "(", ")", "=", "%", "{", "}", "+", "*", "/" -> {
|
" ", ",", "(", ")", "=", "%", "{", "}", "+", "*", "/" -> {
|
||||||
|
if (compileConfiguration.codeBlockType == CompileConfiguration.CodeBlockType.Reference) {
|
||||||
|
referenceResult.append(translation)
|
||||||
|
} else {
|
||||||
codeResult.append(
|
codeResult.append(
|
||||||
translation
|
translation
|
||||||
)
|
)
|
||||||
compileConfiguration.appendResult(translation)
|
compileConfiguration.appendResult(translation)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
":" -> {
|
":" -> {
|
||||||
when (compileConfiguration.codeBlockType) {
|
when (compileConfiguration.codeBlockType) {
|
||||||
CompileConfiguration.CodeBlockType.Value -> {
|
CompileConfiguration.CodeBlockType.Value -> {
|
||||||
compileConfiguration.appendResult(translation)
|
compileConfiguration.appendResult(translation)
|
||||||
|
codeResult.append(translation)
|
||||||
}
|
}
|
||||||
CompileConfiguration.CodeBlockType.Key -> {
|
CompileConfiguration.CodeBlockType.Key -> {
|
||||||
compileConfiguration.codeBlockType =
|
compileConfiguration.codeBlockType =
|
||||||
CompileConfiguration.CodeBlockType.Value
|
CompileConfiguration.CodeBlockType.Value
|
||||||
}
|
|
||||||
}
|
|
||||||
codeResult.append(translation)
|
codeResult.append(translation)
|
||||||
}
|
}
|
||||||
|
CompileConfiguration.CodeBlockType.Reference -> {
|
||||||
|
if (isFirstReference) {
|
||||||
|
codeResult.append(translation)
|
||||||
|
isFirstReference = false
|
||||||
|
} else {
|
||||||
|
referenceResult.append(translation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else -> if (compileConfiguration.codeBlockType == CompileConfiguration.CodeBlockType.Note) {
|
else -> if (compileConfiguration.codeBlockType == CompileConfiguration.CodeBlockType.Note) {
|
||||||
codeResult.append(translation)
|
codeResult.append(translation)
|
||||||
|
} else if (compileConfiguration.codeBlockType == CompileConfiguration.CodeBlockType.Reference) {
|
||||||
|
//资源引用值应该被整体处理
|
||||||
|
referenceResult.append(translation)
|
||||||
} else {
|
} else {
|
||||||
if (translation.startsWith("#") && compileConfiguration.codeBlockType ==
|
if (translation.startsWith("#") && compileConfiguration.codeBlockType ==
|
||||||
CompileConfiguration.CodeBlockType.Key
|
CompileConfiguration.CodeBlockType.Key
|
||||||
|
@ -430,7 +480,7 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
||||||
if (!tag.isNullOrBlank()) {
|
if (!tag.isNullOrBlank()) {
|
||||||
//如果此类型为特殊标注,那么设置为注释
|
//如果此类型为特殊标注,那么设置为注释
|
||||||
compileConfiguration.codeBlockType =
|
compileConfiguration.codeBlockType =
|
||||||
CompileConfiguration.CodeBlockType.Note
|
CompileConfiguration.CodeBlockType.Reference
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codeResult.append(codeInfo.code)
|
codeResult.append(codeInfo.code)
|
||||||
|
@ -465,15 +515,21 @@ class CodeCompiler2 private constructor(val context: Context) : CodeCompilerInte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析行数据
|
* 检查行数据,此函数不修改结果集。
|
||||||
* @param compileConfiguration CompileConfiguration 代码配置
|
* @param compileConfiguration CompileConfiguration 代码配置
|
||||||
* @param compilerListener CodeCompilerListener? 代码监听器
|
* @param compilerListener CodeCompilerListener? 代码监听器
|
||||||
*/
|
*/
|
||||||
fun analysisLineCode(
|
fun checkLineCode(
|
||||||
compileConfiguration: CompileConfiguration,
|
compileConfiguration: CompileConfiguration,
|
||||||
compilerListener: CodeCompilerListener? = null
|
compilerListener: CodeCompilerListener? = null
|
||||||
) {
|
) {
|
||||||
|
DebugHelper.printLog(
|
||||||
|
debugKey,
|
||||||
|
"键[" + compileConfiguration.getKey() + "]值[" + compileConfiguration.getValue() + "]",
|
||||||
|
"行处理"
|
||||||
|
)
|
||||||
compileConfiguration.setCanAddError(true)
|
compileConfiguration.setCanAddError(true)
|
||||||
val key = compileConfiguration.getKey()
|
val key = compileConfiguration.getKey()
|
||||||
//设置了监听器并且key不为空
|
//设置了监听器并且key不为空
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.text.SpannableString
|
||||||
import android.text.Spanned
|
import android.text.Spanned
|
||||||
import android.text.style.ClickableSpan
|
import android.text.style.ClickableSpan
|
||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.coldmint.rust.core.*
|
import com.coldmint.rust.core.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -40,6 +41,18 @@ data class CompileConfiguration(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加值
|
||||||
|
* @param string String
|
||||||
|
*/
|
||||||
|
fun appendValue(string: String) {
|
||||||
|
if (codeBlockType == CodeBlockType.Reference) {
|
||||||
|
valueBuilder.append(string)
|
||||||
|
} else {
|
||||||
|
Log.e(CodeCompiler2.debugKey, "只能在引用语句块设置值。")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置是否可以添加错误(只能在特定的函数内添加错误)
|
* 设置是否可以添加错误(只能在特定的函数内添加错误)
|
||||||
* @param canAddError Boolean
|
* @param canAddError Boolean
|
||||||
|
|
|
@ -1,19 +1,35 @@
|
||||||
package com.coldmint.rust.core.dataBean.dataset
|
package com.coldmint.rust.core.dataBean.dataset
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
data class DataBaseManifest(
|
data class DataBaseManifest(
|
||||||
val id: String,
|
@SerializedName("author")
|
||||||
val author: String,
|
val author: String,
|
||||||
|
@SerializedName("describe")
|
||||||
val describe: String,
|
val describe: String,
|
||||||
|
@SerializedName("id")
|
||||||
|
val id: String,
|
||||||
|
@SerializedName("name")
|
||||||
val name: String,
|
val name: String,
|
||||||
val versionNumber: Int,
|
@SerializedName("tables")
|
||||||
|
val tables: Tables,
|
||||||
|
@SerializedName("updateLog")
|
||||||
|
val updateLog: List<String>,
|
||||||
|
@SerializedName("versionName")
|
||||||
val versionName: String,
|
val versionName: String,
|
||||||
val tables: Tables
|
@SerializedName("versionNumber")
|
||||||
|
val versionNumber: Int
|
||||||
) {
|
) {
|
||||||
data class Tables(
|
data class Tables(
|
||||||
val chain_inspection: String,
|
@SerializedName("chain_inspection")
|
||||||
|
val chainInspection: String,
|
||||||
|
@SerializedName("code")
|
||||||
val code: String,
|
val code: String,
|
||||||
val game_version: String,
|
@SerializedName("game_version")
|
||||||
|
val gameVersion: String,
|
||||||
|
@SerializedName("section")
|
||||||
val section: String,
|
val section: String,
|
||||||
val value_type: String
|
@SerializedName("value_type")
|
||||||
|
val valueType: String
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -37,8 +37,24 @@ interface CodeDao {
|
||||||
@Query("SELECT * FROM code WHERE translate LIKE '%'||:key||'%' AND (section=:section OR section='all') LIMIT :limitNum")
|
@Query("SELECT * FROM code WHERE translate LIKE '%'||:key||'%' AND (section=:section OR section='all') LIMIT :limitNum")
|
||||||
fun findCodeByKeyInSection(key: String, section: String, limitNum: Int): List<CodeInfo>?
|
fun findCodeByKeyInSection(key: String, section: String, limitNum: Int): List<CodeInfo>?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在类型内通过翻译查找代码
|
||||||
|
* @param key String
|
||||||
|
* @param type String
|
||||||
|
* @param limitNum Int
|
||||||
|
* @return List<CodeInfo>?
|
||||||
|
*/
|
||||||
@Query("SELECT * FROM code WHERE translate LIKE '%'||:key||'%' AND type=:type LIMIT :limitNum")
|
@Query("SELECT * FROM code WHERE translate LIKE '%'||:key||'%' AND type=:type LIMIT :limitNum")
|
||||||
fun findCodeByKeyInType(key: String, type: String, limitNum: Int): List<CodeInfo>?
|
fun findCodeByTranslateInType(key: String, type: String, limitNum: Int): List<CodeInfo>?
|
||||||
|
/**
|
||||||
|
* 在类型内通过Code查找代码
|
||||||
|
* @param key String
|
||||||
|
* @param type String
|
||||||
|
* @param limitNum Int
|
||||||
|
* @return List<CodeInfo>?
|
||||||
|
*/
|
||||||
|
@Query("SELECT * FROM code WHERE code LIKE '%'||:key||'%' AND type=:type LIMIT :limitNum")
|
||||||
|
fun findCodeByCodeInType(key: String, type: String, limitNum: Int): List<CodeInfo>?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搜索代码
|
* 搜索代码
|
||||||
|
|
|
@ -9,12 +9,8 @@ import androidx.room.RoomDatabase
|
||||||
import com.coldmint.rust.core.DataSet
|
import com.coldmint.rust.core.DataSet
|
||||||
import com.coldmint.rust.core.dataBean.dataset.*
|
import com.coldmint.rust.core.dataBean.dataset.*
|
||||||
import com.coldmint.rust.core.database.file.FileDataBase
|
import com.coldmint.rust.core.database.file.FileDataBase
|
||||||
import com.coldmint.rust.core.database.file.FileTable
|
|
||||||
import com.coldmint.rust.core.database.file.HistoryRecord
|
|
||||||
import com.coldmint.rust.core.database.file.ValueTable
|
|
||||||
import com.coldmint.rust.core.tool.FileOperator
|
import com.coldmint.rust.core.tool.FileOperator
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import java.io.File
|
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,7 +222,7 @@ abstract class CodeDataBase : RoomDatabase() {
|
||||||
try {
|
try {
|
||||||
Log.d("数据集加载", "加载值表...")
|
Log.d("数据集加载", "加载值表...")
|
||||||
val valueTypeData =
|
val valueTypeData =
|
||||||
FileOperator.readFile(dataSet.getAbsolutePath(manifest.tables.value_type))
|
FileOperator.readFile(dataSet.getAbsolutePath(manifest.tables.valueType))
|
||||||
if (valueTypeData != null) {
|
if (valueTypeData != null) {
|
||||||
val valueTypeDataBean =
|
val valueTypeDataBean =
|
||||||
gson.fromJson<ValueTypeDataBean>(
|
gson.fromJson<ValueTypeDataBean>(
|
||||||
|
@ -286,7 +282,7 @@ abstract class CodeDataBase : RoomDatabase() {
|
||||||
try {
|
try {
|
||||||
Log.d(datasetTag, "加载链式检查表...")
|
Log.d(datasetTag, "加载链式检查表...")
|
||||||
val chainInspectionData =
|
val chainInspectionData =
|
||||||
FileOperator.readFile(dataSet.getAbsolutePath(manifest.tables.chain_inspection))
|
FileOperator.readFile(dataSet.getAbsolutePath(manifest.tables.chainInspection))
|
||||||
if (chainInspectionData != null) {
|
if (chainInspectionData != null) {
|
||||||
val chainInspectionDataBean = gson.fromJson<ChainInspectionDataBean>(
|
val chainInspectionDataBean = gson.fromJson<ChainInspectionDataBean>(
|
||||||
chainInspectionData,
|
chainInspectionData,
|
||||||
|
@ -345,7 +341,7 @@ abstract class CodeDataBase : RoomDatabase() {
|
||||||
try {
|
try {
|
||||||
Log.d("数据集加载", "加载版本表...")
|
Log.d("数据集加载", "加载版本表...")
|
||||||
val versionData =
|
val versionData =
|
||||||
FileOperator.readFile(dataSet.getAbsolutePath(manifest.tables.game_version))
|
FileOperator.readFile(dataSet.getAbsolutePath(manifest.tables.gameVersion))
|
||||||
if (versionData != null) {
|
if (versionData != null) {
|
||||||
val versionDataBean =
|
val versionDataBean =
|
||||||
gson.fromJson<GameVersionDataBean>(
|
gson.fromJson<GameVersionDataBean>(
|
||||||
|
|
|
@ -27,6 +27,7 @@ interface CodeCompilerListener {
|
||||||
* @param code String 代码
|
* @param code String 代码
|
||||||
* @param section String 节
|
* @param section String 节
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun onClickKeyNotFoundItem(
|
fun onClickKeyNotFoundItem(
|
||||||
lineNum: Int,
|
lineNum: Int,
|
||||||
columnNum: Int,
|
columnNum: Int,
|
||||||
|
@ -42,6 +43,7 @@ interface CodeCompilerListener {
|
||||||
* @param view View 视图
|
* @param view View 视图
|
||||||
* @param valueType ValueTypeInfo 值类型
|
* @param valueType ValueTypeInfo 值类型
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun onClickValueTypeErrorItem(
|
fun onClickValueTypeErrorItem(
|
||||||
lineNum: Int,
|
lineNum: Int,
|
||||||
columnNum: Int,
|
columnNum: Int,
|
||||||
|
@ -57,6 +59,7 @@ interface CodeCompilerListener {
|
||||||
* @param view View
|
* @param view View
|
||||||
* @param sectionName String
|
* @param sectionName String
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun onClickSectionIndexError(lineNum: Int, columnNum: Int, view: View, sectionName: String)
|
fun onClickSectionIndexError(lineNum: Int, columnNum: Int, view: View, sectionName: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,6 +95,7 @@ interface CodeCompilerListener {
|
||||||
* @param sectionName String 节名
|
* @param sectionName String 节名
|
||||||
* @param needName Boolean 是否需要附加名
|
* @param needName Boolean 是否需要附加名
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun onClickSectionNameErrorItem(
|
fun onClickSectionNameErrorItem(
|
||||||
lineNum: Int,
|
lineNum: Int,
|
||||||
columnNum: Int,
|
columnNum: Int,
|
||||||
|
@ -107,6 +111,7 @@ interface CodeCompilerListener {
|
||||||
* @param view View 视图
|
* @param view View 视图
|
||||||
* @param sectionName String 节名
|
* @param sectionName String 节名
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun onClickCodeIndexErrorItem(lineNum: Int, view: View, sectionName: String)
|
fun onClickCodeIndexErrorItem(lineNum: Int, view: View, sectionName: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.coldmint.rust.core.tool
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import com.coldmint.rust.core.CodeCompiler2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调试帮助器
|
||||||
|
*/
|
||||||
|
object DebugHelper {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志打印
|
||||||
|
* @param message String 消息
|
||||||
|
* @param module String? 模块名
|
||||||
|
* @param isError Boolean 是否为错误
|
||||||
|
*/
|
||||||
|
fun printLog(keyValue: String, message: String, module: String? = null, isError: Boolean = false) {
|
||||||
|
val key = if (module == null) {
|
||||||
|
keyValue
|
||||||
|
} else {
|
||||||
|
"$keyValue-$module"
|
||||||
|
}
|
||||||
|
if (isError) {
|
||||||
|
Log.e(key, message)
|
||||||
|
} else {
|
||||||
|
Log.d(key, message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,5 +4,5 @@
|
||||||
# Location of the SDK. This is only used by Gradle.
|
# Location of the SDK. This is only used by Gradle.
|
||||||
# For customization when using a Version Control System, please read the
|
# For customization when using a Version Control System, please read the
|
||||||
# header note.
|
# header note.
|
||||||
#Sat Apr 23 18:41:07 CST 2022
|
#Sun Apr 24 15:32:29 CST 2022
|
||||||
sdk.dir=D\:\\Android_SDK
|
sdk.dir=D\:\\Document\\AndroidSdk
|
||||||
|
|
Loading…
Reference in New Issue
Block a user