decaffeinate-parser
Advanced tools
Comparing version 22.4.0 to 22.4.1
@@ -13,2 +13,3 @@ "use strict"; | ||
var nodes_1 = require("decaffeinate-coffeescript2/lib/coffeescript/nodes"); | ||
var expandToIncludeParens_1 = require("./expandToIncludeParens"); | ||
var fixInvalidLocationData_1 = require("./fixInvalidLocationData"); | ||
@@ -140,2 +141,6 @@ var locationWithLastPosition_1 = require("./locationWithLastPosition"); | ||
} | ||
// The CS2 AST doesn't include the surrounding parens in a block, which can cause trouble with | ||
// things like postfix loops with parenthesized bodies. Expand every block to include any | ||
// surrounding parens. | ||
node.locationData = expandToIncludeParens_1["default"](context, node.locationData); | ||
} | ||
@@ -142,0 +147,0 @@ if (node instanceof nodes_1.If) { |
@@ -0,1 +1,2 @@ | ||
import SourceToken from 'coffee-lex/dist/SourceToken'; | ||
import { Base } from 'decaffeinate-coffeescript2/lib/coffeescript/nodes'; | ||
@@ -11,1 +12,3 @@ import ParseContext from './ParseContext'; | ||
export default function getLocation(context: ParseContext, node: Base): NodeLocation; | ||
export declare function firstSemanticTokenAfter(context: ParseContext, index: number): SourceToken | null; | ||
export declare function firstSemanticTokenBefore(context: ParseContext, index: number): SourceToken | null; |
@@ -22,4 +22,4 @@ "use strict"; | ||
} | ||
var firstTokenOfNode = firstSemanticTokenAfter(context, start, node); | ||
var lastTokenOfNode = firstSemanticTokenBefore(context, end, node); | ||
var firstTokenOfNode = requireToken(firstSemanticTokenAfter(context, start), node); | ||
var lastTokenOfNode = requireToken(firstSemanticTokenBefore(context, end), node); | ||
start = firstTokenOfNode.start; | ||
@@ -31,3 +31,3 @@ end = lastTokenOfNode.end; | ||
exports["default"] = getLocation; | ||
function firstSemanticTokenAfter(context, index, node) { | ||
function firstSemanticTokenAfter(context, index) { | ||
var tokenIndex = context.sourceTokens.indexOfTokenMatchingPredicate(function (token) { | ||
@@ -38,5 +38,6 @@ return (token.start >= index && | ||
}, context.sourceTokens.indexOfTokenNearSourceIndex(index)); | ||
return tokenFromIndex(context, tokenIndex, node); | ||
return tokenIndex === null ? null : context.sourceTokens.tokenAtIndex(tokenIndex); | ||
} | ||
function firstSemanticTokenBefore(context, index, node) { | ||
exports.firstSemanticTokenAfter = firstSemanticTokenAfter; | ||
function firstSemanticTokenBefore(context, index) { | ||
var tokenIndex = context.sourceTokens.lastIndexOfTokenMatchingPredicate(function (token) { | ||
@@ -47,9 +48,6 @@ return (token.end <= index && | ||
}, context.sourceTokens.indexOfTokenNearSourceIndex(index)); | ||
return tokenFromIndex(context, tokenIndex, node); | ||
return tokenIndex === null ? null : context.sourceTokens.tokenAtIndex(tokenIndex); | ||
} | ||
function tokenFromIndex(context, tokenIndex, node) { | ||
if (tokenIndex === null) { | ||
throw new Error("unable to find token index for node: " + util_1.inspect(node)); | ||
} | ||
var token = context.sourceTokens.tokenAtIndex(tokenIndex); | ||
exports.firstSemanticTokenBefore = firstSemanticTokenBefore; | ||
function requireToken(token, node) { | ||
if (token === null) { | ||
@@ -56,0 +54,0 @@ throw new Error("unable to find token for node: " + util_1.inspect(node)); |
{ | ||
"name": "decaffeinate-parser", | ||
"description": "A better AST for CoffeeScript, inspired by CoffeeScriptRedux.", | ||
"version": "22.4.0", | ||
"version": "22.4.1", | ||
"main": "dist/parser.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/parser.mjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
395436
198
8880