Skip to content

Commit 8e46a8a

Browse files
committed
fix(devins-lang): Improve token type string representation and handle whitespace in agent ID regex #101
The `DevInTokenType` class now correctly formats its string representation, and the `DevInLexer.flex` file has been updated to allow whitespace in agent IDs. Additionally, unnecessary code has been removed from the `DevInTypedHandler.kt` and `DevInFile.kt` files.
1 parent 98e92c9 commit 8e46a8a

File tree

5 files changed

+4
-28
lines changed

5 files changed

+4
-28
lines changed

exts/devins-lang/src/grammar/DevInLexer.flex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import com.intellij.psi.TokenType;
3737
IDENTIFIER=[a-zA-Z0-9][_\-a-zA-Z0-9]*
3838

3939
VARIABLE_ID=[a-zA-Z0-9][_\-a-zA-Z0-9]*
40-
AGENT_ID=[a-zA-Z0-9][_\-a-zA-Z0-9]*
40+
AGENT_ID=[a-zA-Z0-9][_\-a-zA-Z0-9\s]*
4141
COMMAND_ID=[a-zA-Z0-9][_\-a-zA-Z0-9]*
4242
LANGUAGE_ID=[a-zA-Z][_\-a-zA-Z0-9 .]*
4343
SYSTEM_ID=[a-zA-Z][_\-a-zA-Z0-9]*

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/DevInTypedHandler.kt

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ class DevInTypedHandler : TypedHandlerDelegate() {
2020
return when (charTyped) {
2121
'`' -> {
2222
val offset = editor.caretModel.primaryCaret.offset
23-
if (offset == 0) {
24-
return Result.CONTINUE
25-
}
23+
if (offset == 0) return Result.CONTINUE
2624

2725
val element = file.findElementAt(offset - 1)
2826
if (element?.elementType == DevInTypes.CODE_CONTENT || element?.elementType == DevInTypes.CODE_BLOCK_END) {
@@ -34,25 +32,7 @@ class DevInTypedHandler : TypedHandlerDelegate() {
3432
return Result.STOP
3533
}
3634

37-
'@' -> {
38-
PsiDocumentManager.getInstance(project).commitDocument(editor.document)
39-
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null)
40-
Result.STOP
41-
}
42-
43-
'/' -> {
44-
PsiDocumentManager.getInstance(project).commitDocument(editor.document)
45-
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null)
46-
Result.STOP
47-
}
48-
49-
'$' -> {
50-
PsiDocumentManager.getInstance(project).commitDocument(editor.document)
51-
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null)
52-
Result.STOP
53-
}
54-
55-
':' -> {
35+
'@', '/', '$', ':' -> {
5636
PsiDocumentManager.getInstance(project).commitDocument(editor.document)
5737
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null)
5838
Result.STOP

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/lexer/DevInTokenType.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ import com.intellij.psi.tree.IElementType
55
import org.jetbrains.annotations.NonNls
66

77
class DevInTokenType(debugName: @NonNls String) : IElementType(debugName, DevInLanguage) {
8-
override fun toString(): String {
9-
return "DevInTokenType." + super.toString()
10-
}
8+
override fun toString(): String = "DevInTokenType." + super.toString()
119
}

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/provider/DevInsCustomAgentResponse.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class DevInsCustomAgentResponse : AgentResponseProvider {
2424
val result = devInsCompiler.compile()
2525

2626
AutoDevNotifications.notify(project, result.output)
27-
2827
return result.output
2928
}
3029
}

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/psi/DevInFile.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class DevInFile(viewProvider: FileViewProvider) : PsiFileBase(viewProvider, DevI
2121
}
2222

2323
class DevInFileStub(file: DevInFile?, private val flags: Int) : PsiFileStubImpl<DevInFile>(file) {
24-
2524
override fun getType() = Type
2625

2726
object Type : IStubFileElementType<DevInFileStub>(DevInLanguage) {

0 commit comments

Comments
 (0)