summary refs log tree commit diff stats
path: root/nimsuggest
Commit message (Expand)AuthorAgeFilesLines
* fix bugs with dot & call operators [backport] (#20931)metagn2022-11-281-2/+0
* rename `std/threads` to `std/typedthreads` (#20850)ringabout2022-11-161-1/+1
* Fix typo in nimsuggest.nim (#20767)Ikko Ashimine2022-11-051-1/+1
* fixes #20526; use `nimPreviewSlimSystem` for documentation build (#20714)ringabout2022-11-011-0/+3
* put std/threads under the umbrella of nimPreviewSlimSystem (#20711)ringabout2022-10-311-0/+2
* fixes #19162; enable `strictEffects` for v2 (#19380)ringabout2022-10-151-1/+1
* 'lock levels' are deprecated, now a noop (#20539)ringabout2022-10-118-24/+24
* Fix/improve handling of forward declarations in nimsuggest (#20493)Ivan Yonchovski2022-10-063-9/+114
* moderate system cleanup & refactor (#20355)metagn2022-09-282-4/+4
* defaults to ORC (#19972)ringabout2022-09-231-12/+2
* Partially Revert "Change nim's nimble files to make it installable" (#20296)ringabout2022-09-021-0/+8
* Change nim's nimble files to make it installable (#20179)Ivan Yonchovski2022-08-311-8/+0
* [nimsuggest] fix def call on identifier 2 times on the line (#20228)Ivan Yonchovski2022-08-303-38/+49
* Use module actual file instead of PSym.info (#19956)Ivan Yonchovski2022-07-151-0/+7
* Implement type command (#19944)Ivan Yonchovski2022-07-153-2/+44
* Initial implementation of nimsuggest v3 (#19826)Ivan Yonchovski2022-06-133-15/+257
* Make sure that field usage preserves the original line info (#19751)Ivan Yonchovski2022-04-291-0/+15
* [nimsuggest] return the type when on symbol in let/var (#19639)Ivan Yonchovski2022-04-071-0/+7
* fix stricteffects (nimsuggest/sexp) (#19405)flywind2022-01-181-1/+1
* [backport] use old style hints in .cfg files (#18917)Miran2021-09-291-1/+1
* improvements to `addInt` and `$` for integer types (#18592)Timothee Cour2021-08-191-1/+1
* fix #18385 followup, by building nimsuggest with -d:release during testing (#...Timothee Cour2021-07-291-4/+11
* improvements to hint:processing: show import stack, distinguish nims, show in...Timothee Cour2021-06-303-3/+3
* change `--hint[X] => --hint:X` in nim repo (avoids shell quoting issues) (#18...Timothee Cour2021-05-261-1/+1
* disable tmacro_highlight on i386, refs #17945 (#17949)Timothee Cour2021-05-061-0/+4
* improve nimsuggest/tester, minor improvements to koch.nim (#17879)Timothee Cour2021-04-291-10/+12
* add `--processing:dots|filenames|off` to customize `hintProcessing` (#17817)Timothee Cour2021-04-235-6/+11
* fixed dot operator recursive loop & macro suggest (#16922)Saem Ghani2021-02-152-12/+1
* tables module uses runnableExamples (#16994)flywind2021-02-131-0/+2
* compilesettings: add libpath (#16997)Timothee Cour2021-02-121-2/+4
* nimsuggest prioritize non-deprecated suggestions (#16816)Saem Ghani2021-01-292-10/+12
* regression test for nim-lang/nimsuggest#58 (#16817)Saem Ghani2021-01-251-0/+22
* fixed nim-lang/nimsuggest#48 type aware sug (#16814)Saem Ghani2021-01-252-3/+29
* Deprecate TaintedString (#15423)Juan Carlos2021-01-151-1/+1
* fixes nim-lang/nimsuggest#103 con dot exprs (#16657)Saem Ghani2021-01-121-2/+32
* fixed nim-lang/nimsuggest#82 pure enum field sug (#16676)Saem Ghani2021-01-111-0/+18
* IC: next steps (#16550)Andreas Rumpf2021-01-071-1/+1
* fixes nim-lang/nimsuggest#119 outline includes (#16608)Saem Ghani2021-01-061-2/+8
* nimsuggest: fix and re-enable old tests (#16401)Saem Ghani2020-12-2719-376/+292
* use hexchar in stdlib (#16290)flywind2020-12-171-8/+2
* cmdline: improve command processing (#16056)Timothee Cour2020-11-261-2/+2
* rename loadConfigsAndRunMainCommand => loadConfigsAndProcessCmdLine, reflect ...Timothee Cour2020-11-201-2/+2
* suggest: try to find the implementation of a symbol when def is used (#15555)alaviss2020-10-141-0/+13
* refactoring: removed cmdlinehelper.mainCommand callbackAndreas Rumpf2020-10-111-6/+8
* * honor --errorMax even for tools (eg drnim, nim doc) (#14546)Timothee Cour2020-06-021-4/+2
* Change severity of template instantiation message [backport] (#14526)Danil Yarantsev2020-06-011-0/+13
* Fix `compiles` for nimsuggest [backport] (#14527)Danil Yarantsev2020-06-011-0/+8
* Remove the uses of {.procvar.} pragma (#14359)Kaushal Modi2020-05-151-7/+7
* compiler/suggest: highlight squashed operators (#11796)alaviss2020-04-201-0/+11
* fix deprecations and other warnings (#13748)Miran2020-03-251-3/+3
x">-1) if name != "": # Make name be index into names list segment.name = info.names.find(name) if segment.name == -1: segment.name = info.names.len info.names &= name assert info.mappings[^1].inSource, "Current line isn't in Nim source" info.mappings[^1].segments &= segment func newLine(info: var SourceInfo) {.raises: [].} = ## Add new mapping which doesn't appear in the Nim source info.mappings &= Mapping(inSource: false) func newLine(info: var SourceInfo, file: string, line: int) {.raises: [].} = ## Starts a new line in the mappings. Call addSegment after this to add ## segments into the line var mapping = Mapping(inSource: true, line: line) # Set file to file position. Add in if needed mapping.file = info.files.find(file) if mapping.file == -1: mapping.file = info.files.len info.files &= file info.mappings &= mapping # base64_VLQ func encode*(values: seq[int]): string {.raises: [].} = ## Encodes a series of integers into a VLQ base64 encoded string # References: # - https://www.lucidchart.com/techblog/2019/08/22/decode-encoding-base64-vlqs-source-maps/ # - https://github.com/rails/sprockets/blob/main/guides/source_maps.md#source-map-file const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" shift = 5 continueBit = 1 shl 5 mask = continueBit - 1 for val in values: # Sign is stored in first bit var newVal = abs(val) shl 1 if val < 0: newVal = newVal or 1 # Now comes the variable length part # This is how we are able to store large numbers while true: # We only encode 5 bits. var masked = newVal and mask newVal = newVal shr shift # If there is still something left # then signify with the continue bit that the # decoder should keep decoding if newVal > 0: masked = masked or continueBit result &= alphabet[masked] # If the value is zero then we have nothing left to encode if newVal == 0: break iterator tokenize*(line: string): (int, string) = ## Goes through a line and splits it into Nim identifiers and ## normal JS code. This allows us to map mangled names back to Nim names. ## Yields (column, name). Doesn't yield anything but identifiers. ## See mangleName in compiler/jsgen.nim for how name mangling is done var col = 0 token = "" while col < line.len: var token: string name: string # First we find the next identifier col += line.skipWhitespace(col) col += line.skipUntil(IdentStartChars, col) let identStart = col col += line.parseIdent(token, col) # Idents will either be originalName_randomInt or HEXhexCode_randomInt if token.startsWith("HEX"): var hex: int # 3 = "HEX".len and we only want to parse the two integers after it discard token[3 ..< 5].parseHex(hex) name = $chr(hex) elif not token.endsWith("_Idx"): # Ignore address indexes # It might be in the form originalName_randomInt let lastUnderscore = token.rfind('_') if lastUnderscore != -1: name = token[0..<lastUnderscore] if name != "": yield (identStart, name) func parse*(source: string): SourceInfo = ## Parses the JS output for embedded line info ## So it can convert those into a series of mappings var skipFirstLine = true currColumn = 0 currLine = 0 currFile = "" # Add each line as a node into the output for line in source.splitLines(): var lineNumber: int linePath: string column: int if line.strip().scanf("/* line $i:$i \"$+\" */", lineNumber, column, linePath): # When we reach the first line mappinsegmentg then we can assume # we can map the rest of the JS lines to Nim lines currColumn = column # Column is already zero indexed currLine = lineNumber - 1 currFile = linePath # Lines are zero indexed result.newLine(currFile, currLine) # Skip whitespace to find the starting column result.addSegment(currColumn, line.skipWhitespace()) elif currFile != "": result.newLine(currFile, currLine) # There mightn't be any tokens so add a starting segment result.addSegment(currColumn, line.skipWhitespace()) for jsColumn, token in line.tokenize: result.addSegment(currColumn, jsColumn, token) else: result.newLine() func toSourceMap*(info: SourceInfo, file: string): SourceMap {.raises: [].} = ## Convert from high level SourceInfo into the required SourceMap object # Add basic info result.version = 3 result.file = file result.sources = info.files result.names = info.names # Convert nodes into mappings. # Mappings are split into blocks where each block referes to a line in the outputted JS. # Blocks can be seperated into statements which refere to tokens on the line. # Since the mappings depend on previous values we need to # keep track of previous file, name, etc var prevFile = 0 prevLine = 0 prevName = 0 prevNimCol = 0 for mapping in info.mappings: # We know need to encode segments with the following fields # All these fields are relative to their previous values # - 0: Column in generated code # - 1: Index of Nim file in source list # - 2: Line in Nim source # - 3: Column in Nim source # - 4: Index in names list if mapping.inSource: # JS Column is special in that it is reset after every line var prevJSCol = 0 for segment in mapping.segments: var values = @[segment.generated - prevJSCol, mapping.file - prevFile, mapping.line - prevLine, segment.original - prevNimCol] # Add name field if needed if segment.name != -1: values &= segment.name - prevName prevName = segment.name prevJSCol = segment.generated prevNimCol = segment.original prevFile = mapping.file prevLine = mapping.line result.mappings &= encode(values) & "," # Remove trailing , if mapping.segments.len > 0: result.mappings.setLen(result.mappings.len - 1) result.mappings &= ";" proc genSourceMap*(source: string, outFile: string): SourceMap = let node = parse(source) result = node.toSourceMap(outFile)