From f4236ec5c8a0db4de5506e198b6a827288d1f11d Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 31 Oct 2017 08:05:39 -0700 Subject: [PATCH] Rename "isPartOfExpression" (#18469) --- src/compiler/checker.ts | 10 +++++----- src/compiler/utilities.ts | 6 +++--- src/harness/typeWriter.ts | 2 +- src/services/breakpoints.ts | 2 +- src/services/codefixes/inferFromUsage.ts | 2 +- src/services/formatting/rules.ts | 2 +- src/services/refactors/extractSymbol.ts | 4 ++-- src/services/utilities.ts | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bcb35cefd53..1bc5fafdbc7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6576,7 +6576,7 @@ namespace ts { if (!node) return false; switch (node.kind) { case SyntaxKind.Identifier: - return (node).escapedText === "arguments" && isPartOfExpression(node); + return (node).escapedText === "arguments" && isExpressionNode(node); case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: @@ -12522,7 +12522,7 @@ namespace ts { if (isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (isPartOfExpression(location) && !isAssignmentTarget(location)) { + if (isExpressionNode(location) && !isAssignmentTarget(location)) { const type = getTypeOfExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; @@ -15211,7 +15211,7 @@ namespace ts { // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: - return isPartOfExpression(node) ? false : "quit"; + return isExpressionNode(node) ? false : "quit"; } }); } @@ -23482,7 +23482,7 @@ namespace ts { return typeParameter && typeParameter.symbol; } - if (isPartOfExpression(entityName)) { + if (isExpressionNode(entityName)) { if (nodeIsMissing(entityName)) { // Missing entity name. return undefined; @@ -23656,7 +23656,7 @@ namespace ts { return typeFromTypeNode; } - if (isPartOfExpression(node)) { + if (isExpressionNode(node)) { return getRegularTypeOfExpression(node); } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 01bb36e9065..277683af281 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1228,7 +1228,7 @@ namespace ts { return false; } - export function isPartOfExpression(node: Node): boolean { + export function isExpressionNode(node: Node): boolean { switch (node.kind) { case SyntaxKind.SuperKeyword: case SyntaxKind.NullKeyword: @@ -1331,7 +1331,7 @@ namespace ts { case SyntaxKind.ExpressionWithTypeArguments: return (parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: - return isPartOfExpression(parent); + return isExpressionNode(parent); } } @@ -5381,7 +5381,7 @@ namespace ts { /* @internal */ /** * Determines whether a node is an expression based only on its kind. - * Use `isPartOfExpression` if not in transforms. + * Use `isExpressionNode` if not in transforms. */ export function isExpression(node: Node): node is Expression { return isExpressionKind(skipPartiallyEmittedExpressions(node).kind); diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index af626f1e548..17eda776bda 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -52,7 +52,7 @@ class TypeWriterWalker { } private *visitNode(node: ts.Node, isSymbolWalk: boolean): IterableIterator { - if (ts.isPartOfExpression(node) || node.kind === ts.SyntaxKind.Identifier) { + if (ts.isExpressionNode(node) || node.kind === ts.SyntaxKind.Identifier) { const result = this.writeTypeOrSymbol(node, isSymbolWalk); if (result) { yield result; diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index 37aa8df0ca1..73176aa4b5f 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -297,7 +297,7 @@ namespace ts.BreakpointResolver { } } - if (isPartOfExpression(node)) { + if (isExpressionNode(node)) { switch (node.parent.kind) { case SyntaxKind.DoStatement: // Set span as if on while keyword diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index b952cc5a98d..378c73f2f75 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -368,7 +368,7 @@ namespace ts.codefix { } function inferTypeFromContextualType(node: Expression, checker: TypeChecker, usageContext: UsageContext): void { - if (isPartOfExpression(node)) { + if (isExpressionNode(node)) { addCandidateType(usageContext, checker.getContextualType(node)); } } diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index d41d9dfbfd8..32d01eb1a16 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -849,7 +849,7 @@ namespace ts.formatting { } static NodeIsInDecoratorContext(node: Node): boolean { - while (isPartOfExpression(node)) { + while (isExpressionNode(node)) { node = node.parent; } return node.kind === SyntaxKind.Decorator; diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 5013acafc52..3106ea9576c 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -331,7 +331,7 @@ namespace ts.refactor.extractSymbol { Continue = 1 << 1, Return = 1 << 2 } - if (!isStatement(nodeToCheck) && !(isPartOfExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + if (!isStatement(nodeToCheck) && !(isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; } @@ -491,7 +491,7 @@ namespace ts.refactor.extractSymbol { if (isStatement(node)) { return [node]; } - else if (isPartOfExpression(node)) { + else if (isExpressionNode(node)) { // If our selection is the expression in an ExpressionStatement, expand // the selection to include the enclosing Statement (this stops us // from trying to care about the return value of the extracted function diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 2b116eb1cd0..2580ff18410 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -178,7 +178,7 @@ namespace ts { switch (node.kind) { case SyntaxKind.ThisKeyword: - return !isPartOfExpression(node); + return !isExpressionNode(node); case SyntaxKind.ThisType: return true; }