1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-05 09:34:03 +02:00

Fix tests

This commit is contained in:
filipp 2023-05-12 20:49:00 +03:00
parent 2716255e22
commit f456e0a8dd
15 changed files with 190 additions and 17 deletions
annotation-processors/src/main/kotlin/com/intellij/vim/processors
build.gradle.kts
src
main
java/com/maddyhome/idea/vim/vimscript
resources
test/resources
vim-engine
build.gradle.kts
src
main
kotlin/com/maddyhome/idea/vim/vimscript/model/commands
resources
test/resources

View File

@ -34,8 +34,13 @@ class ExCommandProcessor(private val environment: SymbolProcessorEnvironment): S
override fun process(resolver: Resolver): List<KSAnnotated> {
resolver.getAllFiles().forEach { it.accept(visitor, Unit) }
val fileContent = writer.getYAML(comment, commandToClass)
val filePath = Path(environment.options["generated_directory"]!!, environment.options["ex_commands_file"]!!)
writer.writeFile(filePath, writer.getYAML(comment, commandToClass))
writer.writeFile(filePath, fileContent)
val testFilePath = Path(environment.options["generated_test_directory"]!!, environment.options["ex_commands_file"]!!)
writer.writeFile(testFilePath, fileContent)
return emptyList()
}

View File

@ -37,8 +37,13 @@ class VimscriptFunctionProcessor(private val environment: SymbolProcessorEnviron
override fun process(resolver: Resolver): List<KSAnnotated> {
resolver.getAllFiles().forEach { it.accept(visitor, Unit) }
val fileContent = writer.getYAML(comment, nameToClass)
val filePath = Path(environment.options["generated_directory"]!!, environment.options["vimscript_functions_file"]!!)
writer.writeFile(filePath, writer.getYAML(comment, nameToClass))
writer.writeFile(filePath, fileContent)
val testFilePath = Path(environment.options["generated_test_directory"]!!, environment.options["vimscript_functions_file"]!!)
writer.writeFile(testFilePath, fileContent)
return emptyList()
}

View File

@ -80,6 +80,7 @@ plugins {
ksp {
arg("generated_directory", "$projectDir/src/main/resources")
arg("generated_test_directory", "$projectDir/src/test/resources")
arg("vimscript_functions_file", "intellij_vimscript_functions.yaml")
arg("ex_commands_file", "intellij_ex_commands.yaml")
}

View File

@ -32,7 +32,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :global" / "h :vglobal"
*/
@ExCommand(command = "g[lobal],vg[lobal]")
@ExCommand(command = "g[lobal],v[global]")
internal data class GlobalCommand(val ranges: Ranges, val argument: String, val invert: Boolean) : Command.SingleExecution(ranges, argument) {
override val argFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.SELF_SYNCHRONIZED)

View File

@ -11,6 +11,7 @@ package com.maddyhome.idea.vim.vimscript.model.functions.handlers
import com.intellij.vim.annotations.VimscriptFunction
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.vimscript.model.VimLContext
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
@ -41,7 +42,7 @@ internal class SubmatchFunctionHandler : FunctionHandler() {
companion object {
fun getInstance(): SubmatchFunctionHandler {
return FunctionStorage.getFunctionOfType<SubmatchFunctionHandler>()
return injector.functionService.getBuiltInFunction("submatch") as SubmatchFunctionHandler
}
}
}

View File

@ -18,6 +18,7 @@ import com.maddyhome.idea.vim.vimscript.model.Script
import com.maddyhome.idea.vim.vimscript.model.VimLContext
import com.maddyhome.idea.vim.vimscript.model.expressions.Scope
import com.maddyhome.idea.vim.vimscript.model.functions.DefinedFunctionHandler
import com.maddyhome.idea.vim.vimscript.model.functions.EngineFunctionProvider
import com.maddyhome.idea.vim.vimscript.model.functions.FunctionBeanClass
import com.maddyhome.idea.vim.vimscript.model.functions.FunctionHandler
import com.maddyhome.idea.vim.vimscript.model.functions.IntellijFunctionProvider
@ -166,6 +167,9 @@ internal class FunctionStorage : VimscriptFunctionService {
}
override fun registerHandlers() {
val engineFunctions = EngineFunctionProvider.getFunctions()
engineFunctions.forEach { addHandler(it) }
val intellijFunctions = IntellijFunctionProvider.getFunctions()
intellijFunctions.forEach { addHandler(it) }
}
@ -173,14 +177,4 @@ internal class FunctionStorage : VimscriptFunctionService {
override fun addHandler(handler: LazyVimscriptFunction) {
builtInFunctions[handler.name] = handler
}
companion object {
private val extensionPoint = ExtensionPointName.create<FunctionBeanClass>("IdeaVIM.vimLibraryFunction")
inline fun <reified T : FunctionHandler> getFunctionOfType(): T {
val point = extensionPoint.getExtensionList(ApplicationManager.getApplication())
.single { it.implementation == T::class.java.name }
return point.instance as T
}
}
}

View File

@ -8,5 +8,5 @@ files: com.maddyhome.idea.vim.vimscript.model.commands.BufferListCommand
buffers: com.maddyhome.idea.vim.vimscript.model.commands.BufferListCommand
'!': com.maddyhome.idea.vim.vimscript.model.commands.CmdFilterCommand
g[lobal]: com.maddyhome.idea.vim.vimscript.model.commands.GlobalCommand
vg[lobal]: com.maddyhome.idea.vim.vimscript.model.commands.GlobalCommand
v[global]: com.maddyhome.idea.vim.vimscript.model.commands.GlobalCommand
h[elp]: com.maddyhome.idea.vim.vimscript.model.commands.HelpCommand

View File

@ -0,0 +1,12 @@
# This file was automatically generated by [com.intellij.vim.processor.EXCommandProcessor].
# If you are going to change it, you are probably doing something wrong, as your changes will be overridden by the next `gradle kspKotlin` run.
actionl[ist]: com.maddyhome.idea.vim.vimscript.model.commands.ActionListCommand
b[uffer]: com.maddyhome.idea.vim.vimscript.model.commands.BufferCommand
ls: com.maddyhome.idea.vim.vimscript.model.commands.BufferListCommand
files: com.maddyhome.idea.vim.vimscript.model.commands.BufferListCommand
buffers: com.maddyhome.idea.vim.vimscript.model.commands.BufferListCommand
'!': com.maddyhome.idea.vim.vimscript.model.commands.CmdFilterCommand
g[lobal]: com.maddyhome.idea.vim.vimscript.model.commands.GlobalCommand
v[global]: com.maddyhome.idea.vim.vimscript.model.commands.GlobalCommand
h[elp]: com.maddyhome.idea.vim.vimscript.model.commands.HelpCommand

View File

@ -0,0 +1,7 @@
# This file was automatically generated by [com.intellij.vim.processor.VimscriptFunctionProcessor].
# If you are going to change it, you are probably doing something wrong, as your changes will be overridden by the next `gradle kspKotlin` run.
line: com.maddyhome.idea.vim.vimscript.model.functions.handlers.LineFunctionHandler
col: com.maddyhome.idea.vim.vimscript.model.functions.handlers.ColFunctionHandler
has: com.maddyhome.idea.vim.vimscript.model.functions.handlers.HasFunctionHandler
submatch: com.maddyhome.idea.vim.vimscript.model.functions.handlers.SubmatchFunctionHandler

View File

@ -22,6 +22,7 @@ repositories {
ksp {
arg("generated_directory", "$projectDir/src/main/resources")
arg("generated_test_directory", "$projectDir/src/test/resources")
arg("vimscript_functions_file", "engine_vimscript_functions.yaml")
arg("ex_commands_file", "engine_ex_commands.yaml")
}

View File

@ -20,7 +20,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :mark"
*/
@ExCommand(command = "k,ma[rks]")
@ExCommand(command = "k,ma[rk]")
public data class MarkCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_REQUIRED, Access.READ_ONLY)

View File

@ -8,6 +8,7 @@
package com.maddyhome.idea.vim.vimscript.model.commands
import com.intellij.vim.annotations.ExCommand
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
@ -20,6 +21,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :marks"
*/
@ExCommand(command = "marks")
public data class MarksCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)

View File

@ -35,7 +35,8 @@ let: com.maddyhome.idea.vim.vimscript.model.commands.LetCommand
lockv[ar]: com.maddyhome.idea.vim.vimscript.model.commands.LockVarCommand
unlo[ckvar]: com.maddyhome.idea.vim.vimscript.model.commands.UnlockVarCommand
k: com.maddyhome.idea.vim.vimscript.model.commands.MarkCommand
ma[rks]: com.maddyhome.idea.vim.vimscript.model.commands.MarkCommand
ma[rk]: com.maddyhome.idea.vim.vimscript.model.commands.MarkCommand
marks: com.maddyhome.idea.vim.vimscript.model.commands.MarksCommand
m[ove]: com.maddyhome.idea.vim.vimscript.model.commands.MoveTextCommand
n[ext]: com.maddyhome.idea.vim.vimscript.model.commands.NextFileCommand
bn[ext]: com.maddyhome.idea.vim.vimscript.model.commands.NextFileCommand

View File

@ -0,0 +1,129 @@
# This file was automatically generated by [com.intellij.vim.processor.EXCommandProcessor].
# If you are going to change it, you are probably doing something wrong, as your changes will be overridden by the next `gradle kspKotlin` run.
action: com.maddyhome.idea.vim.vimscript.model.commands.ActionCommand
as[cii]: com.maddyhome.idea.vim.vimscript.model.commands.AsciiCommand
bd[elete]: com.maddyhome.idea.vim.vimscript.model.commands.BufferCloseCommand
cal[l]: com.maddyhome.idea.vim.vimscript.model.commands.CallCommand
comc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.CmdClearCommand
com[mand]: com.maddyhome.idea.vim.vimscript.model.commands.CmdCommand
t: com.maddyhome.idea.vim.vimscript.model.commands.CopyTextCommand
co[py]: com.maddyhome.idea.vim.vimscript.model.commands.CopyTextCommand
delc[ommand]: com.maddyhome.idea.vim.vimscript.model.commands.DelCmdCommand
d[elete]: com.maddyhome.idea.vim.vimscript.model.commands.DeleteLinesCommand
delm[arks]: com.maddyhome.idea.vim.vimscript.model.commands.DeleteMarksCommand
delf[unction]: com.maddyhome.idea.vim.vimscript.model.commands.DelfunctionCommand
dig[raphs]: com.maddyhome.idea.vim.vimscript.model.commands.DigraphCommand
dump[line]: com.maddyhome.idea.vim.vimscript.model.commands.DumpLineCommand
ec[ho]: com.maddyhome.idea.vim.vimscript.model.commands.EchoCommand
e[dit]: com.maddyhome.idea.vim.vimscript.model.commands.EditFileCommand
bro[wse]: com.maddyhome.idea.vim.vimscript.model.commands.EditFileCommand
exe[cute]: com.maddyhome.idea.vim.vimscript.model.commands.ExecuteCommand
qa[ll]: com.maddyhome.idea.vim.vimscript.model.commands.ExitCommand
xa[ll]: com.maddyhome.idea.vim.vimscript.model.commands.ExitCommand
wqa[ll]: com.maddyhome.idea.vim.vimscript.model.commands.ExitCommand
quita[ll]: com.maddyhome.idea.vim.vimscript.model.commands.ExitCommand
f[ile]: com.maddyhome.idea.vim.vimscript.model.commands.FileCommand
cla[ss]: com.maddyhome.idea.vim.vimscript.model.commands.FindClassCommand
fin[d]: com.maddyhome.idea.vim.vimscript.model.commands.FindFileCommand
sym[bol]: com.maddyhome.idea.vim.vimscript.model.commands.FindSymbolCommand
go[to]: com.maddyhome.idea.vim.vimscript.model.commands.GotoCharacterCommand
his[tory]: com.maddyhome.idea.vim.vimscript.model.commands.HistoryCommand
j[oin]: com.maddyhome.idea.vim.vimscript.model.commands.JoinLinesCommand
ju[mps]: com.maddyhome.idea.vim.vimscript.model.commands.JumpsCommand
let: com.maddyhome.idea.vim.vimscript.model.commands.LetCommand
lockv[ar]: com.maddyhome.idea.vim.vimscript.model.commands.LockVarCommand
unlo[ckvar]: com.maddyhome.idea.vim.vimscript.model.commands.UnlockVarCommand
k: com.maddyhome.idea.vim.vimscript.model.commands.MarkCommand
ma[rk]: com.maddyhome.idea.vim.vimscript.model.commands.MarkCommand
marks: com.maddyhome.idea.vim.vimscript.model.commands.MarksCommand
m[ove]: com.maddyhome.idea.vim.vimscript.model.commands.MoveTextCommand
n[ext]: com.maddyhome.idea.vim.vimscript.model.commands.NextFileCommand
bn[ext]: com.maddyhome.idea.vim.vimscript.model.commands.NextFileCommand
tabn[ext]: com.maddyhome.idea.vim.vimscript.model.commands.NextTabCommand
noh[lsearch]: com.maddyhome.idea.vim.vimscript.model.commands.NoHLSearchCommand
norm[al]: com.maddyhome.idea.vim.vimscript.model.commands.NormalCommand
on[ly]: com.maddyhome.idea.vim.vimscript.model.commands.OnlyCommand
pa[ckadd]: com.maddyhome.idea.vim.vimscript.model.commands.PackaddCommand
Plug[in]: com.maddyhome.idea.vim.vimscript.model.commands.PlugCommand
prev[ious]: com.maddyhome.idea.vim.vimscript.model.commands.PreviousFileCommand
bp[revious]: com.maddyhome.idea.vim.vimscript.model.commands.PreviousFileCommand
N[ext]: com.maddyhome.idea.vim.vimscript.model.commands.PreviousFileCommand
tabp[previous]: com.maddyhome.idea.vim.vimscript.model.commands.PreviousTabCommand
tabN[ext]: com.maddyhome.idea.vim.vimscript.model.commands.PreviousTabCommand
p[rint]: com.maddyhome.idea.vim.vimscript.model.commands.PrintCommand
P[rint]: com.maddyhome.idea.vim.vimscript.model.commands.PrintCommand
pro[mptfind]: com.maddyhome.idea.vim.vimscript.model.commands.PromptFindCommand
promptr[eplace]: com.maddyhome.idea.vim.vimscript.model.commands.PromptReplaceCommand
pu[t]: com.maddyhome.idea.vim.vimscript.model.commands.PutLinesCommand
q[uit]: com.maddyhome.idea.vim.vimscript.model.commands.QuitCommand
clo[se]: com.maddyhome.idea.vim.vimscript.model.commands.QuitCommand
hi[de]: com.maddyhome.idea.vim.vimscript.model.commands.QuitCommand
red[o]: com.maddyhome.idea.vim.vimscript.model.commands.RedoCommand
dis[play]: com.maddyhome.idea.vim.vimscript.model.commands.RegistersCommand
reg[isters]: com.maddyhome.idea.vim.vimscript.model.commands.RegistersCommand
'@': com.maddyhome.idea.vim.vimscript.model.commands.RepeatCommand
argu[ment]: com.maddyhome.idea.vim.vimscript.model.commands.SelectFileCommand
fir[st]: com.maddyhome.idea.vim.vimscript.model.commands.SelectFirstFileCommand
la[st]: com.maddyhome.idea.vim.vimscript.model.commands.SelectLastFileCommand
se[t]: com.maddyhome.idea.vim.vimscript.model.commands.SetCommand
setl[ocal]: com.maddyhome.idea.vim.vimscript.model.commands.SetLocalCommand
sethandler: com.maddyhome.idea.vim.vimscript.model.commands.SetHandlerCommand
sh[ell]: com.maddyhome.idea.vim.vimscript.model.commands.ShellCommand
sor[t]: com.maddyhome.idea.vim.vimscript.model.commands.SortCommand
so[urce]: com.maddyhome.idea.vim.vimscript.model.commands.SourceCommand
sp[lit]: com.maddyhome.idea.vim.vimscript.model.commands.SplitCommand
vs[plit]: com.maddyhome.idea.vim.vimscript.model.commands.SplitCommand
'~': com.maddyhome.idea.vim.vimscript.model.commands.SubstituteCommand
'&': com.maddyhome.idea.vim.vimscript.model.commands.SubstituteCommand
s[ubstitute]: com.maddyhome.idea.vim.vimscript.model.commands.SubstituteCommand
tabc[lose]: com.maddyhome.idea.vim.vimscript.model.commands.TabCloseCommand
tabm[ove]: com.maddyhome.idea.vim.vimscript.model.commands.TabMoveCommand
tabo[nly]: com.maddyhome.idea.vim.vimscript.model.commands.TabOnlyCommand
u[ndo]: com.maddyhome.idea.vim.vimscript.model.commands.UndoCommand
wa[ll]: com.maddyhome.idea.vim.vimscript.model.commands.WriteAllCommand
w[rite]: com.maddyhome.idea.vim.vimscript.model.commands.WriteCommand
wn[ext]: com.maddyhome.idea.vim.vimscript.model.commands.WriteNextFileCommand
wp[revious]: com.maddyhome.idea.vim.vimscript.model.commands.WritePreviousFileCommand
wN[ext]: com.maddyhome.idea.vim.vimscript.model.commands.WritePreviousFileCommand
wq: com.maddyhome.idea.vim.vimscript.model.commands.WriteQuitCommand
x[it]: com.maddyhome.idea.vim.vimscript.model.commands.WriteQuitCommand
exi[t]: com.maddyhome.idea.vim.vimscript.model.commands.WriteQuitCommand
y[ank]: com.maddyhome.idea.vim.vimscript.model.commands.YankLinesCommand
mapc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapClearCommand
nmapc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapClearCommand
vmapc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapClearCommand
xmapc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapClearCommand
smapc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapClearCommand
omapc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapClearCommand
imapc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapClearCommand
lmapc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapClearCommand
cmapc[lear]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapClearCommand
map: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
nm[ap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
vm[ap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
xm[ap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
smap: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
om[ap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
im[ap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
lm[ap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
cm[ap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
no[map]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
nn[oremap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
vn[oremap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
xn[oremap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
snor[emap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
ono[remap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
no[remap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
ino[remap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
ln[oremap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
cno[remap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand
unm[ap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.UnMapCommand
nun[map]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.UnMapCommand
vu[nmap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.UnMapCommand
xu[nmap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.UnMapCommand
sunm[ap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.UnMapCommand
ou[nmap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.UnMapCommand
iu[nmap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.UnMapCommand
lu[nmap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.UnMapCommand
cu[nmap]: com.maddyhome.idea.vim.vimscript.model.commands.mapping.UnMapCommand

View File

@ -0,0 +1,15 @@
# This file was automatically generated by [com.intellij.vim.processor.VimscriptFunctionProcessor].
# If you are going to change it, you are probably doing something wrong, as your changes will be overridden by the next `gradle kspKotlin` run.
abs: com.maddyhome.idea.vim.vimscript.model.functions.handlers.AbsFunctionHandler
empty: com.maddyhome.idea.vim.vimscript.model.functions.handlers.EmptyFunctionHandler
exists: com.maddyhome.idea.vim.vimscript.model.functions.handlers.ExistsFunctionHandler
function: com.maddyhome.idea.vim.vimscript.model.functions.handlers.FunctionFunctionHandler
funcref: com.maddyhome.idea.vim.vimscript.model.functions.handlers.FuncrefFunctionHandler
get: com.maddyhome.idea.vim.vimscript.model.functions.handlers.GetFunctionHandler
join: com.maddyhome.idea.vim.vimscript.model.functions.handlers.JoinFunctionHandler
len: com.maddyhome.idea.vim.vimscript.model.functions.handlers.LenFunctionHandler
sin: com.maddyhome.idea.vim.vimscript.model.functions.handlers.SinFunctionHandler
split: com.maddyhome.idea.vim.vimscript.model.functions.handlers.SplitFunctionHandler
tolower: com.maddyhome.idea.vim.vimscript.model.functions.handlers.TolowerFunctionHandler
toupper: com.maddyhome.idea.vim.vimscript.model.functions.handlers.ToupperFunctionHandler