support suggest after compile in caas mode
This commit is contained in:
parent
5a2720e990
commit
f52ea04d22
9 changed files with 72 additions and 7 deletions
|
|
@ -275,6 +275,7 @@ const
|
||||||
|
|
||||||
sfDirty* = sfPure
|
sfDirty* = sfPure
|
||||||
# template is not hygienic (old styled template)
|
# template is not hygienic (old styled template)
|
||||||
|
# module, compiled from a dirty-buffer
|
||||||
|
|
||||||
sfAnon* = sfDiscardable
|
sfAnon* = sfDiscardable
|
||||||
# symbol name that was generated by the compiler
|
# symbol name that was generated by the compiler
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,22 @@ proc processPath(path: string, notRelativeToProj = false): string =
|
||||||
"projectname", options.gProjectName,
|
"projectname", options.gProjectName,
|
||||||
"projectpath", options.gProjectPath])
|
"projectpath", options.gProjectPath])
|
||||||
|
|
||||||
|
proc trackDirty(arg: string, info: TLineInfo) =
|
||||||
|
var a = arg.split(',')
|
||||||
|
if a.len != 4: LocalError(info, errTokenExpected,
|
||||||
|
"DIRTY_BUFFER,ORIGINAL_FILE,LINE,COLUMN")
|
||||||
|
var line, column: int
|
||||||
|
if parseUtils.parseInt(a[2], line) <= 0:
|
||||||
|
LocalError(info, errInvalidNumber, a[1])
|
||||||
|
if parseUtils.parseInt(a[3], column) <= 0:
|
||||||
|
LocalError(info, errInvalidNumber, a[2])
|
||||||
|
|
||||||
|
gDirtyBufferIdx = a[0].fileInfoIdx
|
||||||
|
gDirtyOriginalIdx = a[1].fileInfoIdx
|
||||||
|
|
||||||
|
optTrackPos = newLineInfo(gDirtyBufferIdx, line, column)
|
||||||
|
msgs.addCheckpoint(optTrackPos)
|
||||||
|
|
||||||
proc track(arg: string, info: TLineInfo) =
|
proc track(arg: string, info: TLineInfo) =
|
||||||
var a = arg.split(',')
|
var a = arg.split(',')
|
||||||
if a.len != 3: LocalError(info, errTokenExpected, "FILE,LINE,COLUMN")
|
if a.len != 3: LocalError(info, errTokenExpected, "FILE,LINE,COLUMN")
|
||||||
|
|
@ -470,6 +486,9 @@ proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
|
||||||
of "track":
|
of "track":
|
||||||
expectArg(switch, arg, pass, info)
|
expectArg(switch, arg, pass, info)
|
||||||
track(arg, info)
|
track(arg, info)
|
||||||
|
of "trackdirty":
|
||||||
|
expectArg(switch, arg, pass, info)
|
||||||
|
trackDirty(arg, info)
|
||||||
of "suggest":
|
of "suggest":
|
||||||
expectNoArg(switch, arg, pass, info)
|
expectNoArg(switch, arg, pass, info)
|
||||||
incl(gGlobalOptions, optSuggest)
|
incl(gGlobalOptions, optSuggest)
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,12 @@ proc newModule(fileIdx: int32): PSym =
|
||||||
initStrTable(result.tab)
|
initStrTable(result.tab)
|
||||||
StrTableAdd(result.tab, result) # a module knows itself
|
StrTableAdd(result.tab, result) # a module knows itself
|
||||||
|
|
||||||
proc compileModule(fileIdx: int32, flags: TSymFlags): PSym =
|
proc compileModule(fileIdxArg: int32, flagsArg: TSymFlags): PSym =
|
||||||
|
let (fileIdx, flags) = if fileIdxArg == gDirtyOriginalIdx:
|
||||||
|
(gDirtyBufferIdx, flagsArg + {sfDirty})
|
||||||
|
else:
|
||||||
|
(fileIdxArg, flagsArg)
|
||||||
|
|
||||||
result = getModule(fileIdx)
|
result = getModule(fileIdx)
|
||||||
if result == nil:
|
if result == nil:
|
||||||
growCache gMemCacheData, fileIdx
|
growCache gMemCacheData, fileIdx
|
||||||
|
|
|
||||||
|
|
@ -526,13 +526,17 @@ proc SuggestWriteln*(s: string) =
|
||||||
else:
|
else:
|
||||||
Writeln(stdout, s)
|
Writeln(stdout, s)
|
||||||
stdoutSocket.send(s & "\c\L")
|
stdoutSocket.send(s & "\c\L")
|
||||||
|
|
||||||
proc SuggestQuit*() =
|
proc SuggestQuit*() =
|
||||||
if not isServing: quit(0)
|
if not isServing:
|
||||||
elif not isNil(stdoutSocket):
|
quit(0)
|
||||||
stdoutSocket.send("\c\L")
|
elif isWorkingWithDirtyBuffer:
|
||||||
|
# No need to compile the rest if we are working with a
|
||||||
|
# throw-away buffer. Incomplete dot expressions frequently
|
||||||
|
# found in dirty buffers will result in errors few steps
|
||||||
|
# from now anyway.
|
||||||
raise newException(ESuggestDone, "suggest done")
|
raise newException(ESuggestDone, "suggest done")
|
||||||
|
|
||||||
# this format is understood by many text editors: it is the same that
|
# this format is understood by many text editors: it is the same that
|
||||||
# Borland and Freepascal use
|
# Borland and Freepascal use
|
||||||
const
|
const
|
||||||
|
|
|
||||||
|
|
@ -106,10 +106,16 @@ var
|
||||||
gLastCmdTime*: float # when caas is enabled, we measure each command
|
gLastCmdTime*: float # when caas is enabled, we measure each command
|
||||||
gListFullPaths*: bool
|
gListFullPaths*: bool
|
||||||
isServing*: bool = false
|
isServing*: bool = false
|
||||||
|
gDirtyBufferIdx* = 0'i32 # indicates the fileIdx of the dirty version of
|
||||||
|
# the tracked source X, saved by the CAAS client.
|
||||||
|
gDirtyOriginalIdx* = 0'i32 # the original source file of the dirtified buffer.
|
||||||
|
|
||||||
proc importantComments*(): bool {.inline.} = gCmd in {cmdDoc, cmdIdeTools}
|
proc importantComments*(): bool {.inline.} = gCmd in {cmdDoc, cmdIdeTools}
|
||||||
proc usesNativeGC*(): bool {.inline.} = gSelectedGC >= gcRefc
|
proc usesNativeGC*(): bool {.inline.} = gSelectedGC >= gcRefc
|
||||||
|
|
||||||
|
template isWorkingWithDirtyBuffer*: expr =
|
||||||
|
gDirtyBufferIdx != 0
|
||||||
|
|
||||||
template compilationCachePresent*: expr =
|
template compilationCachePresent*: expr =
|
||||||
{optCaasEnabled, optSymbolFiles} * gGlobalOptions != {}
|
{optCaasEnabled, optSymbolFiles} * gGlobalOptions != {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,9 @@ proc serve*(action: proc (){.nimcall.}) =
|
||||||
curCaasCmd = cmd
|
curCaasCmd = cmd
|
||||||
processCmdLine(passCmd2, cmd)
|
processCmdLine(passCmd2, cmd)
|
||||||
action()
|
action()
|
||||||
|
gDirtyBufferIdx = 0
|
||||||
|
gDirtyOriginalIdx = 0
|
||||||
|
|
||||||
let typ = getConfigVar("server.type")
|
let typ = getConfigVar("server.type")
|
||||||
case typ
|
case typ
|
||||||
of "stdin":
|
of "stdin":
|
||||||
|
|
|
||||||
7
tests/caas/compile-suggest.txt
Normal file
7
tests/caas/compile-suggest.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
main.nim
|
||||||
|
> c
|
||||||
|
SuccessX
|
||||||
|
> idetools --trackDirty:main_dirty.nim,main.nim,12,7 --suggest main.nim
|
||||||
|
skField\tx
|
||||||
|
skField\ty
|
||||||
|
|
||||||
14
tests/caas/main_dirty.nim
Normal file
14
tests/caas/main_dirty.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import imported, strutils
|
||||||
|
|
||||||
|
type
|
||||||
|
TFoo = object
|
||||||
|
x: int
|
||||||
|
y: string
|
||||||
|
|
||||||
|
proc main =
|
||||||
|
var t1 = "text"
|
||||||
|
var t2 = t1.toUpper
|
||||||
|
var foo = TFoo(x: 10, y: "test")
|
||||||
|
foo.
|
||||||
|
echo(t1 +++ t2)
|
||||||
|
|
||||||
7
tests/caas/suggest-compile.txt
Normal file
7
tests/caas/suggest-compile.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
main.nim
|
||||||
|
> idetools --trackDirty:main_dirty.nim,main.nim,12,7 --suggest main.nim
|
||||||
|
skField\tx
|
||||||
|
skField\ty
|
||||||
|
> c
|
||||||
|
SuccessX
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue