@@ -139,6 +139,24 @@ export function getTokenBefore(
139139}
140140/* oxlint-enable no-unused-vars */
141141
142+ /**
143+ * Get the token that precedes a given node or token.
144+ *
145+ * @deprecated Use `sourceCode.getTokenAfter` with `includeComments: true` instead.
146+ *
147+ * @param nodeOrToken The AST node or token.
148+ * @param skip - Number of tokens to skip.
149+ * @returns `Token`, or `null` if all were skipped.
150+ */
151+ /* oxlint-disable no-unused-vars */
152+ export function getTokenOrCommentBefore ( nodeOrToken : NodeOrToken | Comment , skip ?: number ) : Token | null {
153+ // TODO: Implement equivalent of:
154+ // `return getTokenBefore(nodeOrToken, { includeComments: true, skip });`
155+ // But could use a const object at top level for options object, to avoid creating temporary object on each call.
156+ throw new Error ( '`sourceCode.getTokenOrCommentBefore` not implemented yet' ) ;
157+ }
158+ /* oxlint-enable no-unused-vars */
159+
142160/**
143161 * Get the tokens that precede a given node or token.
144162 * @param nodeOrToken - The AST node or token.
@@ -169,6 +187,24 @@ export function getTokenAfter(
169187}
170188/* oxlint-enable no-unused-vars */
171189
190+ /**
191+ * Get the token that follows a given node or token.
192+ *
193+ * @deprecated Use `sourceCode.getTokenAfter` with `includeComments: true` instead.
194+ *
195+ * @param nodeOrToken The AST node or token.
196+ * @param skip - Number of tokens to skip.
197+ * @returns `Token`, or `null` if all were skipped.
198+ */
199+ /* oxlint-disable no-unused-vars */
200+ export function getTokenOrCommentAfter ( nodeOrToken : NodeOrToken | Comment , skip ?: number ) : Token | null {
201+ // TODO: Implement equivalent of:
202+ // `return getTokenAfter(nodeOrToken, { includeComments: true, skip });`
203+ // But could use a const object at top level for options object, to avoid creating temporary object on each call.
204+ throw new Error ( '`sourceCode.getTokenOrCommentAfter` not implemented yet' ) ;
205+ }
206+ /* oxlint-enable no-unused-vars */
207+
172208/**
173209 * Get the tokens that follow a given node or token.
174210 * @param nodeOrToken - The AST node or token.
@@ -346,3 +382,29 @@ export function isSpaceBetween(nodeOrToken1: NodeOrToken, nodeOrToken2: NodeOrTo
346382
347383 return WHITESPACE_REGEXP . test ( sourceText . slice ( gapStart , gapEnd ) ) ;
348384}
385+
386+ /**
387+ * Determine if two nodes or tokens have at least one whitespace character between them.
388+ * Order does not matter.
389+ *
390+ * Returns `false` if the given nodes or tokens overlap.
391+ *
392+ * Checks for whitespace *between tokens*, not including whitespace *inside tokens*.
393+ * e.g. Returns `false` for `isSpaceBetween(x, y)` in `x+" "+y`.
394+ *
395+ * Unlike `SourceCode#isSpaceBetween`, this function does return `true` if there is a `JSText` token between the two
396+ * input tokens, and it contains whitespace.
397+ * e.g. Returns `true` for `isSpaceBetweenTokens(x, slash)` in `<X>a b</X>`.
398+ *
399+ * @deprecated Use `sourceCode.isSpaceBetween` instead.
400+ *
401+ * TODO: Implementation is not quite right at present, for same reasons as `SourceCode#isSpaceBetween`.
402+ *
403+ * @param nodeOrToken1 - The first node or token to check between.
404+ * @param nodeOrToken2 - The second node or token to check between.
405+ * @returns `true` if there is a whitespace character between
406+ * any of the tokens found between the two given nodes or tokens.
407+ */
408+ export function isSpaceBetweenTokens ( token1 : Token , token2 : Token ) : boolean {
409+ return isSpaceBetween ( token1 , token2 ) ;
410+ }
0 commit comments