unit-mesh / auto-dev

🧙‍AutoDev: The AI-powered coding wizard(AI 驱动编程助手) with multilingual support 🌐, auto code generation 🏗️, and a helpful bug-slaying assistant 🐞! Customizable prompts 🎨 and a magic Auto Dev/Testing/Document/Agent feature 🧪 included! 🚀
https://ide.unitmesh.cc/
Mozilla Public License 2.0
2.76k stars 317 forks source link

filename#L1-L2的問題 #172

Closed ymli0215 closed 5 months ago

ymli0215 commented 5 months ago

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

phodal commented 5 months ago

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

ymli0215 commented 5 months ago

測試起來是在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 commented 5 months ago

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

https://github.com/unit-mesh/auto-dev/commit/d524095392ac70cf1d47bda378baffcaa3ed86b8

phodal commented 5 months ago

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

ymli0215 commented 5 months ago

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

phodal commented 5 months ago
  1. DevIns 的 parser 的定义的

https://github.com/unit-mesh/auto-dev/blob/7bb3d776f82f54c4d376859b0a68386e86f12b12/exts/devins-lang/src/grammar/DevInParser.bnf#L39-L50

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

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

https://github.com/unit-mesh/auto-dev/blob/7bb3d776f82f54c4d376859b0a68386e86f12b12/build.gradle.kts#L644-L662