diff options
author | Araq <rumpf_a@web.de> | 2015-02-07 13:15:30 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-02-07 13:15:30 +0100 |
commit | dc85c2498b2d555125510fe91905cd1beffb6d10 (patch) | |
tree | 31e48696e52de31a429c0194953ff34c5202f997 /compiler | |
parent | 0b5c42f4050da85905c25633573617b91cd05229 (diff) | |
download | Nim-dc85c2498b2d555125510fe91905cd1beffb6d10.tar.gz |
nimsuggest knows how to deal with files not belonging to the project
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/msgs.nim | 7 | ||||
-rw-r--r-- | compiler/nimsuggest/nimsuggest.nim | 8 |
2 files changed, 12 insertions, 3 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 35a121769..62e6d5281 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -522,7 +522,7 @@ proc newFileInfo(fullPath, projPath: string): TFileInfo = if optEmbedOrigSrc in gGlobalOptions or true: result.lines = @[] -proc fileInfoIdx*(filename: string): int32 = +proc fileInfoIdx*(filename: string; isKnownFile: var bool): int32 = var canon: string pseudoPath = false @@ -539,11 +539,16 @@ proc fileInfoIdx*(filename: string): int32 = if filenameToIndexTbl.hasKey(canon): result = filenameToIndexTbl[canon] else: + isKnownFile = false result = fileInfos.len.int32 fileInfos.add(newFileInfo(canon, if pseudoPath: filename else: canon.shortenDir)) filenameToIndexTbl[canon] = result +proc fileInfoIdx*(filename: string): int32 = + var dummy: bool + result = fileInfoIdx(filename, dummy) + proc newLineInfo*(fileInfoIdx: int32, line, col: int): TLineInfo = result.fileIndex = fileInfoIdx result.line = int16(line) diff --git a/compiler/nimsuggest/nimsuggest.nim b/compiler/nimsuggest/nimsuggest.nim index 6edea06e5..cac078127 100644 --- a/compiler/nimsuggest/nimsuggest.nim +++ b/compiler/nimsuggest/nimsuggest.nim @@ -87,8 +87,9 @@ proc action(cmd: string) = i += skipWhile(cmd, seps, i) i += parseInt(cmd, col, i) + var isKnownFile = true if orig.len == 0: err() - let dirtyIdx = orig.fileInfoIdx + let dirtyIdx = orig.fileInfoIdx(isKnownFile) if dirtyfile.len != 0: msgs.setDirtyFile(dirtyIdx, dirtyfile) else: msgs.setDirtyFile(dirtyIdx, nil) @@ -99,7 +100,10 @@ proc action(cmd: string) = gTrackPos = newLineInfo(dirtyIdx, line, col) #echo dirtyfile, gDirtyBufferIdx, " project ", gProjectMainIdx gErrorCounter = 0 - compileProject() + if not isKnownFile: + compileProject(dirtyIdx) + else: + compileProject() proc serve() = # do not stop after the first error: |