fix: UI Bug
This commit is contained in:
parent
3460f3133d
commit
0e461e1419
3 changed files with 61 additions and 35 deletions
|
@ -4,6 +4,9 @@
|
|||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="PWA">
|
||||
<option name="wasEnabledAtLeastOnce" value="true" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
|
|
|
@ -21,6 +21,10 @@ import androidx.compose.ui.window.Dialog
|
|||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.application
|
||||
import core.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import ui.TextfieldWithLineNumber
|
||||
import utils.*
|
||||
|
||||
|
@ -47,6 +51,8 @@ fun App() {
|
|||
}) {
|
||||
AlertDialog(
|
||||
title = {
|
||||
Column(modifier = Modifier.fillMaxWidth(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Text(
|
||||
text = when (page) {
|
||||
0 -> "函数定义的变量"
|
||||
|
@ -58,11 +64,13 @@ fun App() {
|
|||
color = Color.Black,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 24.sp,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.padding(top = 10.dp)
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
},
|
||||
text = {
|
||||
Box(modifier = Modifier.fillMaxWidth()
|
||||
.fillMaxHeight(0.8f)) {
|
||||
Text(
|
||||
text = when (page) {
|
||||
0 -> defineList
|
||||
|
@ -73,13 +81,13 @@ fun App() {
|
|||
},
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.wrapContentHeight(),
|
||||
.verticalScroll(rememberScrollState()),
|
||||
textAlign = TextAlign.Start,
|
||||
color = Color.Black,
|
||||
fontSize = 18.sp,
|
||||
fontFamily = FontFamily("monospace")
|
||||
)
|
||||
}
|
||||
},
|
||||
onDismissRequest = {
|
||||
showResult.value = false
|
||||
|
@ -157,6 +165,7 @@ fun App() {
|
|||
val def = getDefineList(sf.getDef())
|
||||
def.ifEmpty {
|
||||
"分析失败:可能输入有错误!"
|
||||
return@TextfieldWithLineNumber
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace().toString()
|
||||
|
@ -166,12 +175,26 @@ fun App() {
|
|||
} catch (e: Exception) {
|
||||
e.printStackTrace().toString()
|
||||
}
|
||||
|
||||
// 异步获取 traceTree
|
||||
val relations = mutableMapOf<String, List<Relation>>()
|
||||
val traceTreeStr = StringBuilder()
|
||||
sf.functions.forEach { func ->
|
||||
traceTreeStr.append(getTraceTreeString(func.getTraceTree().getStringRepr(),func.name))
|
||||
relations.putAll(parseRelation(func.name,func.getTraceTree().getStringRepr()))
|
||||
runBlocking {
|
||||
val deferredResults = sf.functions.map { func ->
|
||||
async(Dispatchers.Default) {
|
||||
val traceStr = getTraceTreeString(func.getTraceTree().getStringRepr(), func.name)
|
||||
val parsedRelations = parseRelation(func.name, func.getTraceTree().getStringRepr())
|
||||
Pair(traceStr, parsedRelations)
|
||||
}
|
||||
}
|
||||
|
||||
// 等待所有协程结束
|
||||
deferredResults.awaitAll().forEach { (traceStr, parsedRelations) ->
|
||||
traceTreeStr.append(traceStr)
|
||||
relations.putAll(parsedRelations)
|
||||
}
|
||||
}
|
||||
|
||||
traceTree = traceTreeStr.toString()
|
||||
|
||||
funcTraceTree =
|
||||
|
|
|
@ -182,7 +182,7 @@ class SourceFile {
|
|||
}
|
||||
|
||||
/**
|
||||
* 任务1:获取使用的值的情况
|
||||
* 获取使用的值的情况
|
||||
* @return Map of<函数 to List<使用值的情况>>
|
||||
* @see utils.getUseList 获取要求的格式
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue