MCPcopy Create free account
hub / github.com/nodejs/node / isInsideJsxElementOrAttribute

Function isInsideJsxElementOrAttribute

test/fixtures/snapshot/typescript.js:127661–127688  ·  view source on GitHub ↗

* returns true if the position is in between the open and close elements of an JSX expression.

(sourceFile, position)

Source from the content-addressed store, hash-verified

127659 * returns true if the position is in between the open and close elements of an JSX expression.
127660 */
127661 function isInsideJsxElementOrAttribute(sourceFile, position) {
127662 var token = getTokenAtPosition(sourceFile, position);
127663 if (!token) {
127664 return false;
127665 }
127666 if (token.kind === 11 /* SyntaxKind.JsxText */) {
127667 return true;
127668 }
127669 // <div>Hello |</div>
127670 if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) {
127671 return true;
127672 }
127673 // <div> { | </div> or <div a={| </div>
127674 if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) {
127675 return true;
127676 }
127677 // <div> {
127678 // |
127679 // } < /div>
127680 if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) {
127681 return true;
127682 }
127683 // <div>|</div>
127684 if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) {
127685 return true;
127686 }
127687 return false;
127688 }
127689 ts.isInsideJsxElementOrAttribute = isInsideJsxElementOrAttribute;
127690 function isWhiteSpaceOnlyJsxText(node) {
127691 return ts.isJsxText(node) && node.containsOnlyTriviaWhiteSpaces;

Callers

nothing calls this directly

Calls 1

getTokenAtPositionFunction · 0.85

Tested by

no test coverage detected