(sourceFile)
| 129074 | } |
| 129075 | ts.positionIsASICandidate = positionIsASICandidate; |
| 129076 | function probablyUsesSemicolons(sourceFile) { |
| 129077 | var withSemicolon = 0; |
| 129078 | var withoutSemicolon = 0; |
| 129079 | var nStatementsToObserve = 5; |
| 129080 | ts.forEachChild(sourceFile, function visit(node) { |
| 129081 | if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { |
| 129082 | var lastToken = node.getLastToken(sourceFile); |
| 129083 | if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { |
| 129084 | withSemicolon++; |
| 129085 | } |
| 129086 | else { |
| 129087 | withoutSemicolon++; |
| 129088 | } |
| 129089 | } |
| 129090 | else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { |
| 129091 | var lastToken = node.getLastToken(sourceFile); |
| 129092 | if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { |
| 129093 | withSemicolon++; |
| 129094 | } |
| 129095 | else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) { |
| 129096 | var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line; |
| 129097 | var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line; |
| 129098 | // Avoid counting missing semicolon in single-line objects: |
| 129099 | // `function f(p: { x: string /*no semicolon here is insignificant*/ }) {` |
| 129100 | if (lastTokenLine !== nextTokenLine) { |
| 129101 | withoutSemicolon++; |
| 129102 | } |
| 129103 | } |
| 129104 | } |
| 129105 | if (withSemicolon + withoutSemicolon >= nStatementsToObserve) { |
| 129106 | return true; |
| 129107 | } |
| 129108 | return ts.forEachChild(node, visit); |
| 129109 | }); |
| 129110 | // One statement missing a semicolon isn't sufficient evidence to say the user |
| 129111 | // doesn’t want semicolons, because they may not even be done writing that statement. |
| 129112 | if (withSemicolon === 0 && withoutSemicolon <= 1) { |
| 129113 | return true; |
| 129114 | } |
| 129115 | // If even 2/5 places have a semicolon, the user probably wants semicolons |
| 129116 | return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; |
| 129117 | } |
| 129118 | ts.probablyUsesSemicolons = probablyUsesSemicolons; |
| 129119 | function tryGetDirectories(host, directoryName) { |
| 129120 | return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; |
no test coverage detected