@tslite/services 0.0.0-stage → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/NOTICE +13 -0
- package/dist/_namespaces/edit.d.ts +8 -0
- package/dist/_namespaces/edit.js +11 -0
- package/dist/_namespaces/ts.Completions.StringCompletions.d.ts +1 -0
- package/dist/_namespaces/ts.Completions.StringCompletions.js +2 -0
- package/dist/_namespaces/ts.Completions.d.ts +2 -0
- package/dist/_namespaces/ts.Completions.js +3 -0
- package/dist/_namespaces/ts.FindAllReferences.d.ts +2 -0
- package/dist/_namespaces/ts.FindAllReferences.js +3 -0
- package/dist/_namespaces/ts.GoToDefinition.d.ts +1 -0
- package/dist/_namespaces/ts.GoToDefinition.js +2 -0
- package/dist/_namespaces/ts.NavigationBar.d.ts +1 -0
- package/dist/_namespaces/ts.NavigationBar.js +2 -0
- package/dist/_namespaces/ts.OrganizeImports.d.ts +1 -0
- package/dist/_namespaces/ts.OrganizeImports.js +2 -0
- package/dist/_namespaces/ts.OutliningElementsCollector.d.ts +1 -0
- package/dist/_namespaces/ts.OutliningElementsCollector.js +2 -0
- package/dist/_namespaces/ts.Rename.d.ts +1 -0
- package/dist/_namespaces/ts.Rename.js +2 -0
- package/dist/_namespaces/ts.SignatureHelp.d.ts +1 -0
- package/dist/_namespaces/ts.SignatureHelp.js +2 -0
- package/dist/_namespaces/ts.SmartSelectionRange.d.ts +1 -0
- package/dist/_namespaces/ts.SmartSelectionRange.js +2 -0
- package/dist/_namespaces/ts.SymbolDisplay.d.ts +1 -0
- package/dist/_namespaces/ts.SymbolDisplay.js +2 -0
- package/dist/_namespaces/ts.codefix.d.ts +26 -0
- package/dist/_namespaces/ts.codefix.js +27 -0
- package/dist/_namespaces/ts.d.ts +17 -0
- package/dist/_namespaces/ts.formatting.d.ts +7 -0
- package/dist/_namespaces/ts.formatting.js +8 -0
- package/dist/_namespaces/ts.js +20 -0
- package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.d.ts +1 -0
- package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.js +2 -0
- package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.d.ts +1 -0
- package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.js +2 -0
- package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.d.ts +1 -0
- package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.js +2 -0
- package/dist/_namespaces/ts.refactor.d.ts +9 -0
- package/dist/_namespaces/ts.refactor.extractSymbol.d.ts +1 -0
- package/dist/_namespaces/ts.refactor.extractSymbol.js +2 -0
- package/dist/_namespaces/ts.refactor.js +10 -0
- package/dist/_namespaces/ts.textChanges.d.ts +1 -0
- package/dist/_namespaces/ts.textChanges.js +2 -0
- package/dist/classifier.d.ts +5 -0
- package/dist/classifier.js +439 -0
- package/dist/codeFixProvider.d.ts +13 -0
- package/dist/codeFixProvider.js +84 -0
- package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.d.ts +1 -0
- package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.js +21 -0
- package/dist/codefixes/addEmptyExportDeclaration.d.ts +1 -0
- package/dist/codefixes/addEmptyExportDeclaration.js +17 -0
- package/dist/codefixes/addMissingAsync.d.ts +1 -0
- package/dist/codefixes/addMissingAsync.js +75 -0
- package/dist/codefixes/addMissingAwait.d.ts +1 -0
- package/dist/codefixes/addMissingAwait.js +236 -0
- package/dist/codefixes/addMissingConst.d.ts +1 -0
- package/dist/codefixes/addMissingConst.js +91 -0
- package/dist/codefixes/addNameToNamelessParameter.d.ts +1 -0
- package/dist/codefixes/addNameToNamelessParameter.js +29 -0
- package/dist/codefixes/convertConstToLet.d.ts +1 -0
- package/dist/codefixes/convertConstToLet.js +30 -0
- package/dist/codefixes/convertToAsyncFunction.d.ts +1 -0
- package/dist/codefixes/convertToAsyncFunction.js +495 -0
- package/dist/codefixes/convertToMappedObjectType.d.ts +1 -0
- package/dist/codefixes/convertToMappedObjectType.js +48 -0
- package/dist/codefixes/correctQualifiedNameToIndexedAccessType.d.ts +1 -0
- package/dist/codefixes/correctQualifiedNameToIndexedAccessType.js +33 -0
- package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.d.ts +1 -0
- package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.js +27 -0
- package/dist/codefixes/fixAwaitInSyncFunction.d.ts +1 -0
- package/dist/codefixes/fixAwaitInSyncFunction.js +69 -0
- package/dist/codefixes/fixExpectedComma.d.ts +1 -0
- package/dist/codefixes/fixExpectedComma.js +35 -0
- package/dist/codefixes/fixInvalidJsxCharacters.d.ts +1 -0
- package/dist/codefixes/fixInvalidJsxCharacters.js +41 -0
- package/dist/codefixes/fixMissingCallParentheses.d.ts +1 -0
- package/dist/codefixes/fixMissingCallParentheses.js +42 -0
- package/dist/codefixes/fixSpelling.d.ts +1 -0
- package/dist/codefixes/fixSpelling.js +94 -0
- package/dist/codefixes/fixUnreachableCode.d.ts +1 -0
- package/dist/codefixes/fixUnreachableCode.js +65 -0
- package/dist/codefixes/fixUnusedIdentifier.d.ts +1 -0
- package/dist/codefixes/fixUnusedIdentifier.js +224 -0
- package/dist/codefixes/helpers.d.ts +8 -0
- package/dist/codefixes/helpers.js +53 -0
- package/dist/codefixes/importFixes.d.ts +14 -0
- package/dist/codefixes/importFixes.js +441 -0
- package/dist/codefixes/inferFromUsage.d.ts +1 -0
- package/dist/codefixes/inferFromUsage.js +742 -0
- package/dist/codefixes/removeUnnecessaryAwait.d.ts +1 -0
- package/dist/codefixes/removeUnnecessaryAwait.js +41 -0
- package/dist/codefixes/returnValueCorrect.d.ts +1 -0
- package/dist/codefixes/returnValueCorrect.js +132 -0
- package/dist/codefixes/splitTypeOnlyImport.d.ts +1 -0
- package/dist/codefixes/splitTypeOnlyImport.js +32 -0
- package/dist/codefixes/useBigintLiteral.d.ts +1 -0
- package/dist/codefixes/useBigintLiteral.js +29 -0
- package/dist/completions.d.ts +83 -0
- package/dist/completions.js +1720 -0
- package/dist/documentHighlights.d.ts +8 -0
- package/dist/documentHighlights.js +367 -0
- package/dist/documentRegistry.d.ts +36 -0
- package/dist/documentRegistry.js +63 -0
- package/dist/editingServices.d.ts +1 -0
- package/dist/editingServices.js +4 -0
- package/dist/findAllReferences.d.ts +113 -0
- package/dist/findAllReferences.js +1366 -0
- package/dist/formatting/formatting.d.ts +26 -0
- package/dist/formatting/formatting.js +1021 -0
- package/dist/formatting/formattingContext.d.ts +34 -0
- package/dist/formatting/formattingContext.js +78 -0
- package/dist/formatting/formattingScanner.d.ts +14 -0
- package/dist/formatting/formattingScanner.js +228 -0
- package/dist/formatting/rule.d.ts +31 -0
- package/dist/formatting/rule.js +22 -0
- package/dist/formatting/rules.d.ts +7 -0
- package/dist/formatting/rules.js +610 -0
- package/dist/formatting/rulesMap.d.ts +5 -0
- package/dist/formatting/rulesMap.js +127 -0
- package/dist/formatting/smartIndenter.d.ts +44 -0
- package/dist/formatting/smartIndenter.js +518 -0
- package/dist/getEditsForFileRename.d.ts +6 -0
- package/dist/getEditsForFileRename.js +86 -0
- package/dist/goToDefinition.d.ts +8 -0
- package/dist/goToDefinition.js +246 -0
- package/dist/importTracker.d.ts +50 -0
- package/dist/importTracker.js +422 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/navigationBar.d.ts +3 -0
- package/dist/navigationBar.js +549 -0
- package/dist/organizeImports.d.ts +18 -0
- package/dist/organizeImports.js +290 -0
- package/dist/outliningElementsCollector.d.ts +2 -0
- package/dist/outliningElementsCollector.js +261 -0
- package/dist/refactorProvider.d.ts +5 -0
- package/dist/refactorProvider.js +16 -0
- package/dist/refactors/addOrRemoveBracesToArrowFunction.d.ts +1 -0
- package/dist/refactors/addOrRemoveBracesToArrowFunction.js +86 -0
- package/dist/refactors/convertExport.d.ts +1 -0
- package/dist/refactors/convertExport.js +126 -0
- package/dist/refactors/convertImport.d.ts +1 -0
- package/dist/refactors/convertImport.js +116 -0
- package/dist/refactors/convertParamsToDestructuredObject.d.ts +1 -0
- package/dist/refactors/convertParamsToDestructuredObject.js +282 -0
- package/dist/refactors/convertStringOrTemplateLiteral.d.ts +1 -0
- package/dist/refactors/convertStringOrTemplateLiteral.js +148 -0
- package/dist/refactors/extractSymbol.d.ts +60 -0
- package/dist/refactors/extractSymbol.js +1281 -0
- package/dist/refactors/extractType.d.ts +1 -0
- package/dist/refactors/extractType.js +102 -0
- package/dist/refactors/moveToNewFile.d.ts +1 -0
- package/dist/refactors/moveToNewFile.js +477 -0
- package/dist/rename.d.ts +2 -0
- package/dist/rename.js +100 -0
- package/dist/services.d.ts +48 -0
- package/dist/services.js +1480 -0
- package/dist/signatureHelp.d.ts +8 -0
- package/dist/signatureHelp.js +414 -0
- package/dist/smartSelection.d.ts +2 -0
- package/dist/smartSelection.js +243 -0
- package/dist/stringCompletions.d.ts +4 -0
- package/dist/stringCompletions.js +220 -0
- package/dist/suggestionDiagnostics.d.ts +6 -0
- package/dist/suggestionDiagnostics.js +92 -0
- package/dist/symbolDisplay.d.ts +16 -0
- package/dist/symbolDisplay.js +400 -0
- package/dist/textChanges.d.ts +161 -0
- package/dist/textChanges.js +1163 -0
- package/dist/types.d.ts +908 -0
- package/dist/types.js +263 -0
- package/dist/utilities.d.ts +283 -0
- package/dist/utilities.js +1981 -0
- package/package.json +45 -3
- package/README.md +0 -3
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Modificado de microsoft/TypeScript v3.9.10, src/services/refactors/convertStringOrTemplateLiteral.ts: o namespace virou módulo ES, com os imports explícitos.
|
|
2
|
+
import { Debug, Diagnostics, SyntaxKind, copyTrailingAsLeadingComments, copyTrailingComments, createNoSubstitutionTemplateLiteral, createTemplateExpression, createTemplateHead, createTemplateMiddle, createTemplateSpan, createTemplateTail, emptyArray, getLocaleSpecificMessage, getTokenAtPosition, getTrailingCommentRanges, isBinaryExpression, isParenthesizedExpression, isStringLiteral, textChanges, } from "../_namespaces/edit.js";
|
|
3
|
+
import { registerRefactor, } from "../_namespaces/ts.refactor.js";
|
|
4
|
+
const refactorName = "Convert to template string";
|
|
5
|
+
const refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
|
|
6
|
+
registerRefactor(refactorName, { getEditsForAction, getAvailableActions });
|
|
7
|
+
function getAvailableActions(context) {
|
|
8
|
+
const { file, startPosition } = context;
|
|
9
|
+
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
10
|
+
const maybeBinary = getParentBinaryExpression(node);
|
|
11
|
+
const refactorInfo = { name: refactorName, description: refactorDescription, actions: [] };
|
|
12
|
+
if (isBinaryExpression(maybeBinary) && isStringConcatenationValid(maybeBinary)) {
|
|
13
|
+
refactorInfo.actions.push({ name: refactorName, description: refactorDescription });
|
|
14
|
+
return [refactorInfo];
|
|
15
|
+
}
|
|
16
|
+
return emptyArray;
|
|
17
|
+
}
|
|
18
|
+
function getNodeOrParentOfParentheses(file, startPosition) {
|
|
19
|
+
const node = getTokenAtPosition(file, startPosition);
|
|
20
|
+
const nestedBinary = getParentBinaryExpression(node);
|
|
21
|
+
const isNonStringBinary = !isStringConcatenationValid(nestedBinary);
|
|
22
|
+
if (isNonStringBinary &&
|
|
23
|
+
isParenthesizedExpression(nestedBinary.parent) &&
|
|
24
|
+
isBinaryExpression(nestedBinary.parent.parent)) {
|
|
25
|
+
return nestedBinary.parent.parent;
|
|
26
|
+
}
|
|
27
|
+
return node;
|
|
28
|
+
}
|
|
29
|
+
function getEditsForAction(context, actionName) {
|
|
30
|
+
const { file, startPosition } = context;
|
|
31
|
+
const node = getNodeOrParentOfParentheses(file, startPosition);
|
|
32
|
+
switch (actionName) {
|
|
33
|
+
case refactorDescription:
|
|
34
|
+
return { edits: getEditsForToTemplateLiteral(context, node) };
|
|
35
|
+
default:
|
|
36
|
+
return Debug.fail("invalid action");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function getEditsForToTemplateLiteral(context, node) {
|
|
40
|
+
const maybeBinary = getParentBinaryExpression(node);
|
|
41
|
+
const file = context.file;
|
|
42
|
+
const templateLiteral = nodesToTemplate(treeToArray(maybeBinary), file);
|
|
43
|
+
const trailingCommentRanges = getTrailingCommentRanges(file.text, maybeBinary.end);
|
|
44
|
+
if (trailingCommentRanges) {
|
|
45
|
+
const lastComment = trailingCommentRanges[trailingCommentRanges.length - 1];
|
|
46
|
+
const trailingRange = { pos: trailingCommentRanges[0].pos, end: lastComment.end };
|
|
47
|
+
// since suppressTrailingTrivia(maybeBinary) does not work, the trailing comment is removed manually
|
|
48
|
+
// otherwise it would have the trailing comment twice
|
|
49
|
+
return textChanges.ChangeTracker.with(context, t => {
|
|
50
|
+
t.deleteRange(file, trailingRange);
|
|
51
|
+
t.replaceNode(file, maybeBinary, templateLiteral);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return textChanges.ChangeTracker.with(context, t => t.replaceNode(file, maybeBinary, templateLiteral));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function isNotEqualsOperator(node) {
|
|
59
|
+
return node.operatorToken.kind !== SyntaxKind.EqualsToken;
|
|
60
|
+
}
|
|
61
|
+
function getParentBinaryExpression(expr) {
|
|
62
|
+
while (isBinaryExpression(expr.parent) && isNotEqualsOperator(expr.parent)) {
|
|
63
|
+
expr = expr.parent;
|
|
64
|
+
}
|
|
65
|
+
return expr;
|
|
66
|
+
}
|
|
67
|
+
function isStringConcatenationValid(node) {
|
|
68
|
+
const { containsString, areOperatorsValid } = treeToArray(node);
|
|
69
|
+
return containsString && areOperatorsValid;
|
|
70
|
+
}
|
|
71
|
+
function treeToArray(current) {
|
|
72
|
+
if (isBinaryExpression(current)) {
|
|
73
|
+
const { nodes, operators, containsString: leftHasString, areOperatorsValid: leftOperatorValid } = treeToArray(current.left);
|
|
74
|
+
if (!leftHasString && !isStringLiteral(current.right)) {
|
|
75
|
+
return { nodes: [current], operators: [], containsString: false, areOperatorsValid: true };
|
|
76
|
+
}
|
|
77
|
+
const currentOperatorValid = current.operatorToken.kind === SyntaxKind.PlusToken;
|
|
78
|
+
const areOperatorsValid = leftOperatorValid && currentOperatorValid;
|
|
79
|
+
nodes.push(current.right);
|
|
80
|
+
operators.push(current.operatorToken);
|
|
81
|
+
return { nodes, operators, containsString: true, areOperatorsValid };
|
|
82
|
+
}
|
|
83
|
+
return { nodes: [current], operators: [], containsString: isStringLiteral(current), areOperatorsValid: true };
|
|
84
|
+
}
|
|
85
|
+
// to copy comments following the operator
|
|
86
|
+
// "foo" + /* comment */ "bar"
|
|
87
|
+
const copyTrailingOperatorComments = (operators, file) => (index, targetNode) => {
|
|
88
|
+
if (index < operators.length) {
|
|
89
|
+
copyTrailingComments(operators[index], targetNode, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
// to copy comments following the string
|
|
93
|
+
// "foo" /* comment */ + "bar" /* comment */ + "bar2"
|
|
94
|
+
const copyCommentFromMultiNode = (nodes, file, copyOperatorComments) => (indexes, targetNode) => {
|
|
95
|
+
while (indexes.length > 0) {
|
|
96
|
+
const index = indexes.shift();
|
|
97
|
+
copyTrailingComments(nodes[index], targetNode, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
|
98
|
+
copyOperatorComments(index, targetNode);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
function concatConsecutiveString(index, nodes) {
|
|
102
|
+
let text = "";
|
|
103
|
+
const indexes = [];
|
|
104
|
+
while (index < nodes.length && isStringLiteral(nodes[index])) {
|
|
105
|
+
const stringNode = nodes[index];
|
|
106
|
+
text = text + stringNode.text;
|
|
107
|
+
indexes.push(index);
|
|
108
|
+
index++;
|
|
109
|
+
}
|
|
110
|
+
return [index, text, indexes];
|
|
111
|
+
}
|
|
112
|
+
function nodesToTemplate({ nodes, operators }, file) {
|
|
113
|
+
const copyOperatorComments = copyTrailingOperatorComments(operators, file);
|
|
114
|
+
const copyCommentFromStringLiterals = copyCommentFromMultiNode(nodes, file, copyOperatorComments);
|
|
115
|
+
const [begin, headText, headIndexes] = concatConsecutiveString(0, nodes);
|
|
116
|
+
if (begin === nodes.length) {
|
|
117
|
+
const noSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral(headText);
|
|
118
|
+
copyCommentFromStringLiterals(headIndexes, noSubstitutionTemplateLiteral);
|
|
119
|
+
return noSubstitutionTemplateLiteral;
|
|
120
|
+
}
|
|
121
|
+
const templateSpans = [];
|
|
122
|
+
const templateHead = createTemplateHead(headText);
|
|
123
|
+
copyCommentFromStringLiterals(headIndexes, templateHead);
|
|
124
|
+
for (let i = begin; i < nodes.length; i++) {
|
|
125
|
+
const currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
|
|
126
|
+
copyOperatorComments(i, currentNode);
|
|
127
|
+
const [newIndex, subsequentText, stringIndexes] = concatConsecutiveString(i + 1, nodes);
|
|
128
|
+
i = newIndex - 1;
|
|
129
|
+
const templatePart = i === nodes.length - 1 ? createTemplateTail(subsequentText) : createTemplateMiddle(subsequentText);
|
|
130
|
+
copyCommentFromStringLiterals(stringIndexes, templatePart);
|
|
131
|
+
templateSpans.push(createTemplateSpan(currentNode, templatePart));
|
|
132
|
+
}
|
|
133
|
+
return createTemplateExpression(templateHead, templateSpans);
|
|
134
|
+
}
|
|
135
|
+
// to copy comments following the opening & closing parentheses
|
|
136
|
+
// "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar"
|
|
137
|
+
function copyCommentsWhenParenthesized(node) {
|
|
138
|
+
const file = node.getSourceFile();
|
|
139
|
+
copyTrailingComments(node, node.expression, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
|
140
|
+
copyTrailingAsLeadingComments(node.expression, node.expression, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false);
|
|
141
|
+
}
|
|
142
|
+
function getExpressionFromParenthesesOrExpression(node) {
|
|
143
|
+
if (isParenthesizedExpression(node)) {
|
|
144
|
+
copyCommentsWhenParenthesized(node);
|
|
145
|
+
node = node.expression;
|
|
146
|
+
}
|
|
147
|
+
return node;
|
|
148
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ApplicableRefactorInfo, Diagnostic, DiagnosticMessage, Expression, RefactorContext, RefactorEditInfo, SourceFile, Statement, Symbol, TextSpan } from "../_namespaces/edit.js";
|
|
2
|
+
/**
|
|
3
|
+
* Compute the associated code actions
|
|
4
|
+
* Exported for tests.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getAvailableActions(context: RefactorContext): readonly ApplicableRefactorInfo[];
|
|
7
|
+
export declare function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined;
|
|
8
|
+
export declare namespace Messages {
|
|
9
|
+
const cannotExtractRange: DiagnosticMessage;
|
|
10
|
+
const cannotExtractImport: DiagnosticMessage;
|
|
11
|
+
const cannotExtractEmpty: DiagnosticMessage;
|
|
12
|
+
const expressionExpected: DiagnosticMessage;
|
|
13
|
+
const uselessConstantType: DiagnosticMessage;
|
|
14
|
+
const statementOrExpressionExpected: DiagnosticMessage;
|
|
15
|
+
const cannotExtractRangeContainingConditionalBreakOrContinueStatements: DiagnosticMessage;
|
|
16
|
+
const cannotExtractRangeContainingConditionalReturnStatement: DiagnosticMessage;
|
|
17
|
+
const typeWillNotBeVisibleInTheNewScope: DiagnosticMessage;
|
|
18
|
+
const cannotExtractIdentifier: DiagnosticMessage;
|
|
19
|
+
const cannotExtractExportedEntity: DiagnosticMessage;
|
|
20
|
+
const cannotWriteInExpression: DiagnosticMessage;
|
|
21
|
+
const cannotExtractAmbientBlock: DiagnosticMessage;
|
|
22
|
+
const cannotAccessVariablesFromNestedScopes: DiagnosticMessage;
|
|
23
|
+
const cannotExtractToOtherFunctionLike: DiagnosticMessage;
|
|
24
|
+
const cannotExtractToExpressionArrowFunction: DiagnosticMessage;
|
|
25
|
+
}
|
|
26
|
+
declare enum RangeFacts {
|
|
27
|
+
None = 0,
|
|
28
|
+
HasReturn = 1,
|
|
29
|
+
IsAsyncFunction = 4
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents an expression or a list of statements that should be extracted with some extra information
|
|
33
|
+
*/
|
|
34
|
+
interface TargetRange {
|
|
35
|
+
readonly range: Expression | Statement[];
|
|
36
|
+
readonly facts: RangeFacts;
|
|
37
|
+
/**
|
|
38
|
+
* A list of symbols that are declared in the selected range which are visible in the containing lexical scope
|
|
39
|
+
* Used to ensure we don't turn something used outside the range free (or worse, resolve to a different entity).
|
|
40
|
+
*/
|
|
41
|
+
readonly declarations: Symbol[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Result of 'getRangeToExtract' operation: contains either a range or a list of errors
|
|
45
|
+
*/
|
|
46
|
+
type RangeToExtract = {
|
|
47
|
+
readonly targetRange?: never;
|
|
48
|
+
readonly errors: readonly Diagnostic[];
|
|
49
|
+
} | {
|
|
50
|
+
readonly targetRange: TargetRange;
|
|
51
|
+
readonly errors?: never;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* getRangeToExtract takes a span inside a text file and returns either an expression or an array
|
|
55
|
+
* of statements representing the minimum set of nodes needed to extract the entire span. This
|
|
56
|
+
* process may fail, in which case a set of errors is returned instead (these are currently
|
|
57
|
+
* not shown to the user, but can be used by us diagnostically)
|
|
58
|
+
*/
|
|
59
|
+
export declare function getRangeToExtract(sourceFile: SourceFile, span: TextSpan): RangeToExtract;
|
|
60
|
+
export {};
|