** * Start of the original range might fall inside the comment - scanner will not yield appropriate results * This function will look for token that is located before the start of target range * and return its end as start position for the scanner. */
(enclosingNode *ast.Node, originalRange core.TextRange, sourceFile *ast.SourceFile)
| 49 | * and return its end as start position for the scanner. |
| 50 | */ |
| 51 | func getScanStartPosition(enclosingNode *ast.Node, originalRange core.TextRange, sourceFile *ast.SourceFile) int { |
| 52 | adjusted := withTokenStart(enclosingNode, sourceFile) |
| 53 | start := adjusted.Pos() |
| 54 | if start == originalRange.Pos() && enclosingNode.End() == originalRange.End() { |
| 55 | return start |
| 56 | } |
| 57 | |
| 58 | precedingToken := astnav.FindPrecedingToken(sourceFile, originalRange.Pos()) |
| 59 | if precedingToken == nil { |
| 60 | // no preceding token found - start from the beginning of enclosing node |
| 61 | return enclosingNode.Pos() |
| 62 | } |
| 63 | |
| 64 | // preceding token ends after the start of original range (i.e when originalRange.pos falls in the middle of literal) |
| 65 | // start from the beginning of enclosingNode to handle the entire 'originalRange' |
| 66 | if precedingToken.End() >= originalRange.Pos() { |
| 67 | return enclosingNode.Pos() |
| 68 | } |
| 69 | |
| 70 | return precedingToken.End() |
| 71 | } |
| 72 | |
| 73 | /* |
| 74 | * For cases like |
no test coverage detected