generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(autoin-lang): add basic infrastructure for AutoDev input languag…
…e support #101 AutoDev input language support is a new feature added to the project. The following files have been modified or created to support this new language:
- Loading branch information
Showing
11 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/gen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. | ||
package org.intellij.sdk.language; | ||
|
||
import com.intellij.lexer.FlexLexer; | ||
import com.intellij.psi.tree.IElementType; | ||
import cc.unitmesh.language.psi.DevInTypes; | ||
import com.intellij.psi.TokenType; | ||
|
||
%% | ||
|
||
%class DevInLexer | ||
%implements FlexLexer | ||
%unicode | ||
%function advance | ||
%type IElementType | ||
%eof{ return; | ||
%eof} | ||
|
||
CRLF=\R | ||
WHITE_SPACE=[\ \n\t\f] | ||
FIRST_VALUE_CHARACTER=[^ \n\f\\] | "\\"{CRLF} | "\\". | ||
VALUE_CHARACTER=[^\n\f\\] | "\\"{CRLF} | "\\". | ||
END_OF_LINE_COMMENT=("#"|"!")[^\r\n]* | ||
SEPARATOR=[:=] | ||
KEY_CHARACTER=[^:=\ \n\t\f\\] | "\\ " | ||
|
||
%state WAITING_VALUE | ||
|
||
%% | ||
|
||
({CRLF}|{WHITE_SPACE})+ { yybegin(YYINITIAL); return TokenType.WHITE_SPACE; } | ||
|
||
[^] { return TokenType.BAD_CHARACTER; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// should similar to markdown syntax | ||
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. | ||
{ | ||
parserClass="cc.unitmesh.language.parser.DevInParser" | ||
|
||
extends="com.intellij.extapi.psi.ASTWrapperPsiElement" | ||
|
||
psiClassPrefix="DevIn" | ||
psiImplClassSuffix="Impl" | ||
psiPackage="cc.unitmesh.language.psi" | ||
psiImplPackage="cc.unitmesh.language.psi.impl" | ||
|
||
elementTypeHolderClass="cc.unitmesh.language.psi.DevInTypes" | ||
elementTypeClass="cc.unitmesh.language.psi.DevInElementType" | ||
tokenTypeClass="cc.unitmesh.language.psi.DevInTokenType" | ||
} | ||
|
||
DevInFile ::= item_* | ||
|
||
private item_ ::= (CRLF) |
18 changes: 18 additions & 0 deletions
18
exts/autoin-lang/src/main/kotlin/cc/unitmesh/language/DevInFileType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cc.unitmesh.language | ||
|
||
import cc.unitmesh.devti.AutoDevIcons | ||
import com.intellij.openapi.fileTypes.LanguageFileType | ||
import com.intellij.openapi.vfs.VirtualFile | ||
import javax.swing.Icon | ||
|
||
object DevInFileType : LanguageFileType(DevInLanguage) { | ||
override fun getName(): String = "DevIn File" | ||
|
||
override fun getIcon(): Icon = AutoDevIcons.AI_COPILOT | ||
|
||
override fun getDefaultExtension(): String = "devin" | ||
|
||
override fun getCharset(file: VirtualFile, content: ByteArray): String = "UTF-8" | ||
|
||
override fun getDescription(): String = "DevIn file" | ||
} |
10 changes: 10 additions & 0 deletions
10
exts/autoin-lang/src/main/kotlin/cc/unitmesh/language/DevInLanguage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cc.unitmesh.language | ||
|
||
import com.intellij.lang.Language | ||
|
||
object DevInLanguage : Language("DevIn", "text/devin", "text/x-devin", "application/x-devin") { | ||
val INSTANCE: Language = DevInLanguage | ||
|
||
override fun isCaseSensitive() = true | ||
override fun getDisplayName() = "DevIn" | ||
} |
51 changes: 51 additions & 0 deletions
51
exts/autoin-lang/src/main/kotlin/cc/unitmesh/language/DevInParserDefinition.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cc.unitmesh.language | ||
|
||
import com.intellij.lang.ASTNode | ||
import com.intellij.lang.ParserDefinition | ||
import com.intellij.lang.PsiParser | ||
import com.intellij.lexer.Lexer | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.psi.FileViewProvider | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.PsiFile | ||
import com.intellij.psi.tree.IFileElementType | ||
import com.intellij.psi.tree.TokenSet | ||
import org.jetbrains.annotations.NotNull | ||
|
||
|
||
internal class DevInParserDefinition : ParserDefinition { | ||
@NotNull | ||
override fun createLexer(project: Project?): Lexer { | ||
TODO() | ||
} | ||
|
||
@NotNull | ||
override fun getCommentTokens(): TokenSet = TokenSet.EMPTY | ||
|
||
@NotNull | ||
override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY | ||
|
||
@NotNull | ||
override fun createParser(project: Project?): PsiParser { | ||
TODO() | ||
} | ||
|
||
@NotNull | ||
override fun getFileNodeType(): IFileElementType { | ||
return FILE | ||
} | ||
|
||
@NotNull | ||
override fun createFile(@NotNull viewProvider: FileViewProvider): PsiFile { | ||
TODO() | ||
} | ||
|
||
@NotNull | ||
override fun createElement(node: ASTNode?): PsiElement { | ||
TODO() | ||
} | ||
|
||
companion object { | ||
val FILE: IFileElementType = IFileElementType(DevInLanguage.INSTANCE) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
exts/autoin-lang/src/main/kotlin/cc/unitmesh/language/DevInSyntaxHighlighterFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package cc.unitmesh.language | ||
|
||
import com.intellij.openapi.fileTypes.SyntaxHighlighter | ||
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vfs.VirtualFile | ||
|
||
class DevInSyntaxHighlighterFactory : SyntaxHighlighterFactory() { | ||
override fun getSyntaxHighlighter(project: Project?, virtualFile: VirtualFile?): SyntaxHighlighter { | ||
TODO("Not yet implemented") | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
exts/autoin-lang/src/main/kotlin/cc/unitmesh/language/psi/DevInTokenType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cc.unitmesh.language.psi | ||
|
||
import com.intellij.psi.tree.IElementType | ||
import org.jetbrains.annotations.NonNls | ||
import org.jetbrains.annotations.NotNull | ||
|
||
class DevInTokenType( | ||
@NotNull @NonNls debugName: String | ||
): IElementType(debugName, cc.unitmesh.language.DevInLanguage.INSTANCE) { | ||
override fun toString(): String { | ||
return "DevInTokenType." + super.toString() | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
exts/autoin-lang/src/main/resources/cc.unitmesh.language.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<idea-plugin package="cc.unitmesh.language"> | ||
<extensions defaultExtensionNs="com.intellij"> | ||
<!-- refs: https://github.com/JetBrains/intellij-sdk-code-samples/blob/main/simple_language_plugin/src/main/resources/META-INF/plugin.xml--> | ||
<fileType name="AutoinFile" implementationClass="cc.unitmesh.language.DevInFileType" fieldName="INSTANCE" | ||
language="AutoIn" extensions="autoin"/> | ||
|
||
<lang.parserDefinition language="AutoIn" implementationClass="cc.unitmesh.language.DevInParserDefinition"/> | ||
<lang.syntaxHighlighterFactory language="AutoIn" | ||
implementationClass="cc.unitmesh.language.DevInSyntaxHighlighterFactory"/> | ||
</extensions> | ||
</idea-plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters