From 74139186ed6db214dcae39b019f5d29fc245a77a Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Fri, 15 Sep 2017 10:28:20 -0700 Subject: [PATCH] Re-enable extraction of single tokens Now that we explicitly prevent extraction of empty spans. --- src/services/refactors/extractMethod.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 9ea3d9d11bd..3b8ea19a9f0 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -92,7 +92,7 @@ namespace ts.refactor.extractMethod { export const CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators: DiagnosticMessage = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); export const TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); export const FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); - export const InsufficientSelection = createMessage("Select more than a single token."); + export const InsufficientSelection = createMessage("Select more than a single identifier."); export const CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); export const CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); export const CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); @@ -231,7 +231,7 @@ namespace ts.refactor.extractMethod { } function checkRootNode(node: Node): Diagnostic[] | undefined { - if (isToken(isExpressionStatement(node) ? node.expression : node)) { + if (isIdentifier(isExpressionStatement(node) ? node.expression : node)) { return [createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined;