Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filename#L1-L2的問題 #172

Closed
ymli0215 opened this issue May 2, 2024 · 6 comments
Closed

filename#L1-L2的問題 #172

ymli0215 opened this issue May 2, 2024 · 6 comments
Assignees

Comments

@ymli0215
Copy link
Contributor

ymli0215 commented May 2, 2024

原本 檔案名稱後面加上 #L1-L2 會針對指定的行數範圍去寫入內容,但是現在沒有作用
經過測試WriteInsCommand去呼叫LineInfo.fromString(argument)時
這個argument就沒有傳遞 #L1-L2,只有傳入filename而已

@phodal
Copy link
Member

phodal commented May 2, 2024

看上去像是解析出问题了,有更全的 /write 我试试?

@ymli0215
Copy link
Contributor Author

ymli0215 commented May 2, 2024

測試起來是在DevInsCompiler 的 val propElement = id.nextSibling?.nextSibling
propElement 的 text 就只有 src/test/java/org/example/service/SpringRestServiceTest.java

例如下面這段

/write:src/test/java/org/example/service/SpringRestServiceTest.java#L3-L4
```java
package org.example.service;

import org.example.GradleProjectApplication;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
public class SpringRestServiceTest {

}
```

@phodal
Copy link
Member

phodal commented May 2, 2024

应该是之前支持 #L2C0-L3C12 的时候,引入了 bug:

d524095

@phodal phodal self-assigned this May 2, 2024
@phodal phodal closed this as completed in 7bb3d77 May 2, 2024
@phodal
Copy link
Member

phodal commented May 2, 2024

提交上去了,等 buidl:https://github.com/unit-mesh/auto-dev/actions/runs/8918256806

@ymli0215
Copy link
Contributor Author

ymli0215 commented May 2, 2024

請問一下 DevInUsed 得用途是什麼呢??
因為沒看到他的原始碼,不太理解它的作用...
有看到一個txt檔案 : CommandAndSymbol.txt ,好像就定義了好幾種type
但是又不知道是哪何時parse過來的

@phodal
Copy link
Member

phodal commented May 2, 2024

  1. DevIns 的 parser 的定义的

DevInsFile ::= (used | code | TEXT_SEGMENT | NEWLINE | COMMENTS)*
used ::= (
AGENT_START AGENT_ID
| COMMAND_START COMMAND_ID (COLON COMMAND_PROP (SHARP LINE_INFO)?)?
| VARIABLE_START VARIABLE_ID
| SYSTEM_START SYSTEM_ID COLON NUMBER
)
code ::= CODE_BLOCK_START LANGUAGE_ID? NEWLINE? code_contents? CODE_BLOCK_END?
code_contents ::= (NEWLINE | CODE_CONTENT)*

其中的 DevInUsed 指的就是 used ,包含了 command,variable 、 agent 等类型的语法

  1. 在 Gradle 编译时,会根据 bnf 和 flex 生成对应的解析器代码:

auto-dev/build.gradle.kts

Lines 644 to 662 in 7bb3d77

tasks {
generateLexer {
sourceFile.set(file("src/grammar/DevInLexer.flex"))
targetOutputDir.set(file("src/gen/cc/unitmesh/devti/language/lexer"))
purgeOldFiles.set(true)
}
generateParser {
sourceFile.set(file("src/grammar/DevInParser.bnf"))
targetRootOutputDir.set(file("src/gen"))
pathToParser.set("cc/unitmesh/devti/language/parser/DevInParser.java")
pathToPsiRoot.set("cc/unitmesh/devti/language/psi")
purgeOldFiles.set(true)
}
withType<KotlinCompile> {
dependsOn(generateLexer, generateParser)
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants