@microsoft/powerquery-language-services 0.6.12 → 0.9.2
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/lib/powerquery-language-services/analysis/analysis.d.ts +12 -11
- package/lib/powerquery-language-services/analysis/analysisBase.d.ts +31 -25
- package/lib/powerquery-language-services/analysis/analysisBase.js +210 -169
- package/lib/powerquery-language-services/analysis/analysisBase.js.map +1 -1
- package/lib/powerquery-language-services/analysis/analysisUtils.d.ts +1 -1
- package/lib/powerquery-language-services/analysis/analysisUtils.js +3 -3
- package/lib/powerquery-language-services/analysis/analysisUtils.js.map +1 -1
- package/lib/powerquery-language-services/analysis/memoizedAnalysis.d.ts +6 -6
- package/lib/powerquery-language-services/analysis/memoizedAnalysis.js.map +1 -1
- package/lib/powerquery-language-services/documentSymbols.js +4 -4
- package/lib/powerquery-language-services/documentSymbols.js.map +1 -1
- package/lib/powerquery-language-services/externalType/externalTypeUtils.d.ts +2 -2
- package/lib/powerquery-language-services/externalType/externalTypeUtils.js +5 -5
- package/lib/powerquery-language-services/externalType/externalTypeUtils.js.map +1 -1
- package/lib/powerquery-language-services/index.d.ts +2 -1
- package/lib/powerquery-language-services/index.js +4 -3
- package/lib/powerquery-language-services/index.js.map +1 -1
- package/lib/powerquery-language-services/inspection/activeNode/activeNode.d.ts +5 -6
- package/lib/powerquery-language-services/inspection/activeNode/activeNode.js +3 -4
- package/lib/powerquery-language-services/inspection/activeNode/activeNode.js.map +1 -1
- package/lib/powerquery-language-services/inspection/activeNode/activeNodeUtils.d.ts +1 -1
- package/lib/powerquery-language-services/inspection/activeNode/activeNodeUtils.js +212 -179
- package/lib/powerquery-language-services/inspection/activeNode/activeNodeUtils.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteFieldAccess.js +6 -6
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteFieldAccess.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteItem/autocompleteItemUtils.d.ts +4 -5
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteItem/autocompleteItemUtils.js +10 -20
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteItem/autocompleteItemUtils.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeyword.d.ts +2 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeyword.js +22 -23
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeyword.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordDefault.js +3 -3
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordDefault.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordErrorHandlingExpression.js +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordErrorHandlingExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordIdentifierPairedExpression.js +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordIdentifierPairedExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordLetExpression.js +5 -5
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordLetExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordListExpression.js +3 -3
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordListExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordSectionMember.js +5 -7
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordSectionMember.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordTrailingText.d.ts +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordTrailingText.js +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/autocompleteKeywordTrailingText.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/common.js +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/common.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteKeyword/commonTypes.d.ts +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteLanguageConstant.d.ts +2 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteLanguageConstant.js +14 -14
- package/lib/powerquery-language-services/inspection/autocomplete/autocompleteLanguageConstant.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/autocompletePrimitiveType.d.ts +5 -3
- package/lib/powerquery-language-services/inspection/autocomplete/autocompletePrimitiveType.js +302 -52
- package/lib/powerquery-language-services/inspection/autocomplete/autocompletePrimitiveType.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/commonTypes.d.ts +0 -3
- package/lib/powerquery-language-services/inspection/autocomplete/task.js +3 -3
- package/lib/powerquery-language-services/inspection/autocomplete/task.js.map +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/trailingToken.d.ts +8 -0
- package/lib/powerquery-language-services/inspection/autocomplete/trailingToken.js +5 -0
- package/lib/powerquery-language-services/inspection/autocomplete/trailingToken.js.map +1 -0
- package/lib/powerquery-language-services/inspection/autocomplete/{common.d.ts → trailingTokenUtils.d.ts} +1 -1
- package/lib/powerquery-language-services/inspection/autocomplete/trailingTokenUtils.js +19 -0
- package/lib/powerquery-language-services/inspection/autocomplete/trailingTokenUtils.js.map +1 -0
- package/lib/powerquery-language-services/inspection/deferenceIdentifier.js +7 -7
- package/lib/powerquery-language-services/inspection/deferenceIdentifier.js.map +1 -1
- package/lib/powerquery-language-services/inspection/expectedType.js +2 -2
- package/lib/powerquery-language-services/inspection/expectedType.js.map +1 -1
- package/lib/powerquery-language-services/inspection/invokeExpression/currentInvokeExpression.js +8 -8
- package/lib/powerquery-language-services/inspection/invokeExpression/currentInvokeExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/invokeExpression/invokeExpression.js +5 -5
- package/lib/powerquery-language-services/inspection/invokeExpression/invokeExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/pseudoFunctionExpressionType.js +5 -5
- package/lib/powerquery-language-services/inspection/pseudoFunctionExpressionType.js.map +1 -1
- package/lib/powerquery-language-services/inspection/scope/scopeInspection.js +4 -4
- package/lib/powerquery-language-services/inspection/scope/scopeInspection.js.map +1 -1
- package/lib/powerquery-language-services/inspection/task.js +8 -8
- package/lib/powerquery-language-services/inspection/task.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/common.d.ts +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/common.js +8 -8
- package/lib/powerquery-language-services/inspection/type/inspectType/common.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/examineFieldSpecificationList.js +2 -2
- package/lib/powerquery-language-services/inspection/type/inspectType/examineFieldSpecificationList.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeConstant.js +18 -18
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeConstant.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeEachExpression.js +3 -3
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeEachExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeErrorHandlingExpression.js +5 -5
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeErrorHandlingExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeField/common.js +2 -2
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeField/common.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeField/inspectTypeFieldProjection.js +5 -5
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeField/inspectTypeFieldProjection.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeField/inspectTypeFieldSelector.js +5 -5
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeField/inspectTypeFieldSelector.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeFieldSpecification.js +3 -3
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeFieldSpecification.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeFunctionExpression.js +3 -3
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeFunctionExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeFunctionType.js +7 -7
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeFunctionType.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeIdentifier.js +3 -3
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeIdentifier.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeIdentifierExpression.js +3 -3
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeIdentifierExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeIfExpression.js +4 -4
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeIfExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeInvokeExpression.js +6 -6
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeInvokeExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeList.js +2 -2
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeList.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeListType.js +3 -3
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeListType.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeLiteralExpression.js +5 -5
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeLiteralExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeNullCoalescingExpression.js +7 -4
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeNullCoalescingExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeParameter.js +3 -3
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeParameter.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypePrimitiveType.js +4 -4
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypePrimitiveType.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeRangeExpression.js +2 -2
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeRangeExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeRecord.js +2 -2
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeRecord.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeRecordType.js +3 -3
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeRecordType.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeRecursivePrimaryExpression.js +8 -8
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeRecursivePrimaryExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeTBinOpExpression.js +46 -46
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeTBinOpExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeTableType.js +3 -3
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeTableType.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeUnaryExpression.js +5 -5
- package/lib/powerquery-language-services/inspection/type/inspectType/inspectTypeUnaryExpression.js.map +1 -1
- package/lib/powerquery-language-services/inspection/type/task.js +3 -3
- package/lib/powerquery-language-services/inspection/type/task.js.map +1 -1
- package/lib/powerquery-language-services/inspection/typeCache/typeCacheUtils.d.ts +1 -1
- package/lib/powerquery-language-services/inspection/typeCache/typeCacheUtils.js +3 -3
- package/lib/powerquery-language-services/inspection/typeCache/typeCacheUtils.js.map +1 -1
- package/lib/powerquery-language-services/inspectionUtils.d.ts +3 -3
- package/lib/powerquery-language-services/inspectionUtils.js +29 -31
- package/lib/powerquery-language-services/inspectionUtils.js.map +1 -1
- package/lib/powerquery-language-services/library/librarySymbolUtils.d.ts +10 -2
- package/lib/powerquery-language-services/library/librarySymbolUtils.js +18 -12
- package/lib/powerquery-language-services/library/librarySymbolUtils.js.map +1 -1
- package/lib/powerquery-language-services/library/libraryUtils.d.ts +5 -5
- package/lib/powerquery-language-services/library/libraryUtils.js +12 -12
- package/lib/powerquery-language-services/library/libraryUtils.js.map +1 -1
- package/lib/powerquery-language-services/positionUtils.d.ts +8 -4
- package/lib/powerquery-language-services/positionUtils.js +40 -13
- package/lib/powerquery-language-services/positionUtils.js.map +1 -1
- package/lib/powerquery-language-services/providers/libraryProvider.js +2 -2
- package/lib/powerquery-language-services/providers/libraryProvider.js.map +1 -1
- package/lib/powerquery-language-services/providers/localDocumentProvider/foldingRanges.js +1 -1
- package/lib/powerquery-language-services/providers/localDocumentProvider/foldingRanges.js.map +1 -1
- package/lib/powerquery-language-services/providers/localDocumentProvider/localDocumentProvider.js +3 -3
- package/lib/powerquery-language-services/providers/localDocumentProvider/localDocumentProvider.js.map +1 -1
- package/lib/powerquery-language-services/providers/localDocumentProvider/partialSemanticToken.js +12 -12
- package/lib/powerquery-language-services/providers/localDocumentProvider/partialSemanticToken.js.map +1 -1
- package/lib/powerquery-language-services/providers/nullSymbolProvider.js +6 -6
- package/lib/powerquery-language-services/providers/nullSymbolProvider.js.map +1 -1
- package/lib/powerquery-language-services/tokenPositionComparison.d.ts +5 -0
- package/lib/powerquery-language-services/tokenPositionComparison.js +13 -0
- package/lib/powerquery-language-services/tokenPositionComparison.js.map +1 -0
- package/lib/powerquery-language-services/traceUtils.d.ts +2 -2
- package/lib/powerquery-language-services/traceUtils.js +5 -5
- package/lib/powerquery-language-services/traceUtils.js.map +1 -1
- package/lib/powerquery-language-services/validate/validate.js +4 -4
- package/lib/powerquery-language-services/validate/validate.js.map +1 -1
- package/lib/powerquery-language-services/validate/validateDuplicateIdentifiers.js +3 -3
- package/lib/powerquery-language-services/validate/validateDuplicateIdentifiers.js.map +1 -1
- package/lib/powerquery-language-services/validate/validateFunctionExpression.js +2 -2
- package/lib/powerquery-language-services/validate/validateFunctionExpression.js.map +1 -1
- package/lib/powerquery-language-services/validate/validateInvokeExpression.js +2 -2
- package/lib/powerquery-language-services/validate/validateInvokeExpression.js.map +1 -1
- package/lib/powerquery-language-services/validate/validateUnknownIdentifiers.js +1 -1
- package/lib/powerquery-language-services/validate/validateUnknownIdentifiers.js.map +1 -1
- package/package.json +9 -7
- package/lib/powerquery-language-services/inspection/autocomplete/common.js +0 -11
- package/lib/powerquery-language-services/inspection/autocomplete/common.js.map +0 -1
|
@@ -1,75 +1,127 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
+
/* eslint-disable max-len */
|
|
2
4
|
// Copyright (c) Microsoft Corporation.
|
|
3
5
|
// Licensed under the MIT license.
|
|
4
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
6
|
-
const PQP = require("@microsoft/powerquery-parser");
|
|
7
|
+
exports.findNodeKind = exports.isPositionInBounds = exports.assertPositionInBounds = exports.assertGetLeaf = exports.assertActiveNode = exports.createOutOfBoundPosition = exports.activeNode = void 0;
|
|
7
8
|
const parser_1 = require("@microsoft/powerquery-parser/lib/powerquery-parser/parser");
|
|
9
|
+
const powerquery_parser_1 = require("@microsoft/powerquery-parser");
|
|
8
10
|
const language_1 = require("@microsoft/powerquery-parser/lib/powerquery-parser/language");
|
|
9
11
|
const __1 = require("../..");
|
|
10
|
-
// Searches all leaf Ast.TNodes and all Context nodes to find the "active" node.
|
|
11
|
-
// ' 1 + |' -> the second operand, a Context node, in an ArithmeticExpression.
|
|
12
|
-
// 'let x=|1 in x' -> the value part of the key-value-pair.
|
|
13
|
-
// 'foo(|)' -> the zero length ArrayWrapper of an InvokeExpression
|
|
14
|
-
//
|
|
15
|
-
// The naive approach is to find the closest Ast or Context node either to the left of or ends on the cursor.
|
|
16
|
-
// This approach breaks under several edge cases.
|
|
17
|
-
//
|
|
18
|
-
// Take a look at the ArithmeticExpression example above,
|
|
19
|
-
// it doesn't make sense for the ActiveNode to be the '+' Constant.
|
|
20
|
-
// When the position is on a constant the selected Ast.TNode might need to be shifted one to the right.
|
|
21
|
-
// This happens with atomic constants such as '+', '=>', '[', '(' etc.
|
|
22
|
-
// However if you shifted right on '(' for 'foo(|)' then the ActiveNode would be ')' instead of the ArrayWrapper.
|
|
23
|
-
//
|
|
24
|
-
// Sometimes we don't want to shift at all.
|
|
25
|
-
// Nodes that prevent shifting are called anchor nodes.
|
|
26
|
-
// '[foo = bar|' should be anchored on the identifier 'bar' and not the context node for the ']' Constant.
|
|
27
12
|
function activeNode(nodeIdMapCollection, position) {
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const contextNode = findContext(nodeIdMapCollection, astSearch);
|
|
13
|
+
const astSearched = leafSearch(nodeIdMapCollection, position);
|
|
14
|
+
const { nodeClosestBeforePosition, nodeOnPosition, nodeClosestAfterPosition } = leafSearch(nodeIdMapCollection, position);
|
|
15
|
+
const contextClosestOnOrAfterPosition = findContext(nodeIdMapCollection, astSearched);
|
|
32
16
|
let leaf;
|
|
33
17
|
let leafKind;
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (astSearch.shiftedRightNode !== undefined) {
|
|
40
|
-
leaf = parser_1.XorNodeUtils.boxAst(astSearch.shiftedRightNode);
|
|
41
|
-
leafKind = "ShiftedRight" /* ShiftedRight */;
|
|
18
|
+
// Case 1: empty document
|
|
19
|
+
if (nodeClosestBeforePosition === undefined &&
|
|
20
|
+
nodeOnPosition === undefined &&
|
|
21
|
+
nodeClosestAfterPosition === undefined) {
|
|
22
|
+
return createOutOfBoundPosition(position);
|
|
42
23
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
// Case 2: There's only 1 leaf
|
|
25
|
+
// Case 2a: truthy left
|
|
26
|
+
// `not |`
|
|
27
|
+
// `foo |`
|
|
28
|
+
else if (nodeClosestBeforePosition !== undefined &&
|
|
29
|
+
nodeOnPosition === undefined &&
|
|
30
|
+
nodeClosestAfterPosition === undefined) {
|
|
31
|
+
// With context
|
|
32
|
+
// `not |`
|
|
33
|
+
if (contextClosestOnOrAfterPosition !== undefined) {
|
|
34
|
+
leaf = parser_1.XorNodeUtils.boxContext(contextClosestOnOrAfterPosition);
|
|
35
|
+
leafKind = "Context" /* ContextNode */;
|
|
36
|
+
}
|
|
37
|
+
// Without context
|
|
38
|
+
// `foo |`
|
|
39
|
+
else {
|
|
40
|
+
leaf = parser_1.XorNodeUtils.boxAst(nodeClosestBeforePosition);
|
|
41
|
+
leafKind = "IsBeforePosition" /* IsBeforePosition */;
|
|
42
|
+
}
|
|
46
43
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
// Case 2b: truthy center
|
|
45
|
+
// `|not`
|
|
46
|
+
// `not|`
|
|
47
|
+
// `|foo`
|
|
48
|
+
// `foo|`
|
|
49
|
+
else if (nodeClosestBeforePosition === undefined &&
|
|
50
|
+
nodeOnPosition !== undefined &&
|
|
51
|
+
nodeClosestAfterPosition === undefined) {
|
|
52
|
+
// With or without context
|
|
53
|
+
leaf = parser_1.XorNodeUtils.boxAst(nodeOnPosition);
|
|
54
|
+
leafKind = "IsInAst" /* IsInAst */;
|
|
50
55
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
// Case 2c: truthy right
|
|
57
|
+
// `| not`
|
|
58
|
+
// `| 1`
|
|
59
|
+
else if (nodeClosestBeforePosition === undefined &&
|
|
60
|
+
nodeOnPosition === undefined &&
|
|
61
|
+
nodeClosestAfterPosition !== undefined) {
|
|
62
|
+
// With or without context
|
|
63
|
+
return createOutOfBoundPosition(position);
|
|
56
64
|
}
|
|
65
|
+
// Case 3: There's 2 leafs.
|
|
66
|
+
// Case 3a: truthy left and center
|
|
67
|
+
// `1+|1`
|
|
68
|
+
// `if |true`
|
|
69
|
+
// `if true|`
|
|
70
|
+
// `{1, foo|`
|
|
71
|
+
else if (nodeClosestBeforePosition !== undefined &&
|
|
72
|
+
nodeOnPosition !== undefined &&
|
|
73
|
+
nodeClosestAfterPosition == undefined) {
|
|
74
|
+
// With or without context
|
|
75
|
+
leaf = parser_1.XorNodeUtils.boxAst(nodeOnPosition);
|
|
76
|
+
leafKind = "IsInAst" /* IsInAst */;
|
|
77
|
+
}
|
|
78
|
+
// Case 3b: truthy left and right
|
|
79
|
+
else if (nodeClosestBeforePosition !== undefined &&
|
|
80
|
+
nodeOnPosition === undefined &&
|
|
81
|
+
nodeClosestAfterPosition !== undefined) {
|
|
82
|
+
if (language_1.AstUtils.isNodeKind(nodeClosestBeforePosition, "Constant" /* Constant */) &&
|
|
83
|
+
ShiftRightConstantKinds.includes(nodeClosestBeforePosition.constantKind)) {
|
|
84
|
+
leaf = parser_1.XorNodeUtils.boxAst(nodeClosestAfterPosition);
|
|
85
|
+
leafKind = "IsAfterPosition" /* IsAfterPosition */;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
leaf = parser_1.XorNodeUtils.boxAst(nodeClosestBeforePosition);
|
|
89
|
+
leafKind = "IsBeforePosition" /* IsBeforePosition */;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Case 3c: truthy center and right
|
|
93
|
+
// `|not true
|
|
94
|
+
else if (nodeClosestBeforePosition === undefined &&
|
|
95
|
+
nodeOnPosition !== undefined &&
|
|
96
|
+
nodeClosestAfterPosition !== undefined) {
|
|
97
|
+
leaf = parser_1.XorNodeUtils.boxAst(nodeOnPosition);
|
|
98
|
+
leafKind = "IsInAst" /* IsInAst */;
|
|
99
|
+
}
|
|
100
|
+
// Case 4: There's 3 leafs
|
|
101
|
+
else if (nodeClosestBeforePosition !== undefined &&
|
|
102
|
+
nodeOnPosition !== undefined &&
|
|
103
|
+
nodeClosestAfterPosition !== undefined) {
|
|
104
|
+
leaf = parser_1.XorNodeUtils.boxAst(nodeOnPosition);
|
|
105
|
+
leafKind = "IsInAst" /* IsInAst */;
|
|
106
|
+
}
|
|
107
|
+
// Case 5: TypeScript can't tell this is exhaustive.
|
|
57
108
|
else {
|
|
58
|
-
|
|
109
|
+
throw new powerquery_parser_1.CommonError.InvariantError(`this should never be reached`);
|
|
59
110
|
}
|
|
60
111
|
const inclusiveIdentifierUnderPosition = findLeafIdentifier(nodeIdMapCollection, leaf);
|
|
61
112
|
const exclusiveIdentifierUnderPosition = inclusiveIdentifierUnderPosition &&
|
|
62
113
|
__1.PositionUtils.isInAst(position, inclusiveIdentifierUnderPosition.node, false, true)
|
|
63
114
|
? inclusiveIdentifierUnderPosition
|
|
64
115
|
: undefined;
|
|
65
|
-
const ancestry = parser_1.AncestryUtils.
|
|
116
|
+
const ancestry = parser_1.AncestryUtils.assertAncestry(nodeIdMapCollection, leaf.node.id);
|
|
66
117
|
return {
|
|
67
|
-
ancestry,
|
|
68
118
|
kind: "ActiveNode" /* ActiveNode */,
|
|
69
119
|
leafKind,
|
|
120
|
+
position,
|
|
121
|
+
ancestry,
|
|
122
|
+
isInKey: isInKey(ancestry),
|
|
70
123
|
exclusiveIdentifierUnderPosition,
|
|
71
124
|
inclusiveIdentifierUnderPosition,
|
|
72
|
-
position,
|
|
73
125
|
};
|
|
74
126
|
}
|
|
75
127
|
exports.activeNode = activeNode;
|
|
@@ -87,12 +139,12 @@ function assertActiveNode(nodeIdMapCollection, position) {
|
|
|
87
139
|
}
|
|
88
140
|
exports.assertActiveNode = assertActiveNode;
|
|
89
141
|
function assertGetLeaf(activeNode) {
|
|
90
|
-
return parser_1.AncestryUtils.
|
|
142
|
+
return parser_1.AncestryUtils.assertFirst(activeNode.ancestry);
|
|
91
143
|
}
|
|
92
144
|
exports.assertGetLeaf = assertGetLeaf;
|
|
93
145
|
function assertPositionInBounds(value) {
|
|
94
146
|
if (!isPositionInBounds(value)) {
|
|
95
|
-
throw new
|
|
147
|
+
throw new powerquery_parser_1.CommonError.InvariantError(`value was not in bounds`);
|
|
96
148
|
}
|
|
97
149
|
}
|
|
98
150
|
exports.assertPositionInBounds = assertPositionInBounds;
|
|
@@ -100,154 +152,121 @@ function isPositionInBounds(value) {
|
|
|
100
152
|
return value.kind === "ActiveNode" /* ActiveNode */;
|
|
101
153
|
}
|
|
102
154
|
exports.isPositionInBounds = isPositionInBounds;
|
|
103
|
-
function
|
|
104
|
-
return parser_1.AncestryUtils.
|
|
155
|
+
function findNodeKind(activeNode, nodeKind) {
|
|
156
|
+
return parser_1.AncestryUtils.findNodeKind(activeNode.ancestry, nodeKind);
|
|
105
157
|
}
|
|
106
|
-
exports.
|
|
107
|
-
const
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
158
|
+
exports.findNodeKind = findNodeKind;
|
|
159
|
+
const ShiftLeftConstantKinds = [
|
|
160
|
+
"}" /* RightBrace */,
|
|
161
|
+
"]" /* RightBracket */,
|
|
162
|
+
")" /* RightParenthesis */,
|
|
111
163
|
];
|
|
112
164
|
const ShiftRightConstantKinds = [
|
|
165
|
+
...language_1.Constant.BinOpExpressionOperators,
|
|
166
|
+
"&" /* Ampersand */,
|
|
113
167
|
"," /* Comma */,
|
|
168
|
+
".." /* DotDot */,
|
|
114
169
|
"=" /* Equal */,
|
|
115
170
|
"=>" /* FatArrow */,
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
")" /* RightParenthesis */,
|
|
171
|
+
"??" /* NullCoalescingOperator */,
|
|
172
|
+
"?" /* QuestionMark */,
|
|
119
173
|
";" /* Semicolon */,
|
|
120
|
-
|
|
174
|
+
"{" /* LeftBrace */,
|
|
175
|
+
"[" /* LeftBracket */,
|
|
176
|
+
"(" /* LeftParenthesis */,
|
|
121
177
|
];
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
if (astNode.kind === "Identifier" /* Identifier */ || astNode.kind === "GeneralizedIdentifier" /* GeneralizedIdentifier */) {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
else if (astNode.kind === "LiteralExpression" /* LiteralExpression */ && astNode.literalKind === "Numeric" /* Numeric */) {
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
else if (astNode.kind === "Constant" /* Constant */) {
|
|
133
|
-
switch (astNode.constantKind) {
|
|
134
|
-
case "as" /* As */:
|
|
135
|
-
case "each" /* Each */:
|
|
136
|
-
case "else" /* Else */:
|
|
137
|
-
case "error" /* Error */:
|
|
138
|
-
case "if" /* If */:
|
|
139
|
-
case "in" /* In */:
|
|
140
|
-
case "is" /* Is */:
|
|
141
|
-
case "section" /* Section */:
|
|
142
|
-
case "shared" /* Shared */:
|
|
143
|
-
case "let" /* Let */:
|
|
144
|
-
case "meta" /* Meta */:
|
|
145
|
-
case "otherwise" /* Otherwise */:
|
|
146
|
-
case "then" /* Then */:
|
|
147
|
-
case "try" /* Try */:
|
|
148
|
-
case "type" /* Type */:
|
|
149
|
-
case "null" /* Null */:
|
|
150
|
-
return true;
|
|
151
|
-
default:
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function astNodeSearch(nodeIdMapCollection, position) {
|
|
178
|
+
// Searches for the closest leaf to the left, right, and on the given position if such an option exists.
|
|
179
|
+
function leafSearch(nodeIdMapCollection, position) {
|
|
160
180
|
const astNodeById = nodeIdMapCollection.astNodeById;
|
|
161
|
-
let
|
|
162
|
-
let
|
|
163
|
-
let
|
|
164
|
-
// Find
|
|
165
|
-
// the closest leaf to the left or on position.
|
|
166
|
-
// the closest leaf to the right of position.
|
|
181
|
+
let nodeClosestBeforePosition;
|
|
182
|
+
let nodeOnPosition;
|
|
183
|
+
let nodeClosestAfterPosition;
|
|
184
|
+
// Find the closest leaf on or to the left of the position.
|
|
167
185
|
for (const nodeId of nodeIdMapCollection.leafIds) {
|
|
168
186
|
const candidate = astNodeById.get(nodeId);
|
|
187
|
+
powerquery_parser_1.Assert.isDefined(candidate, `leafIds contained a value that wasn't found in astNodeById`, { nodeId });
|
|
188
|
+
language_1.AstUtils.assertIsLeaf(candidate);
|
|
189
|
+
// This shouldn't occur, but safety first.
|
|
169
190
|
if (candidate === undefined) {
|
|
170
191
|
continue;
|
|
171
192
|
}
|
|
172
|
-
let
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
isBoundIncluded = true;
|
|
184
|
-
}
|
|
185
|
-
if (!__1.PositionUtils.isBeforeTokenPosition(position, candidate.tokenRange.positionStart, isBoundIncluded)) {
|
|
186
|
-
if (bestOnOrBeforeNode === undefined ||
|
|
187
|
-
candidate.tokenRange.tokenIndexStart > bestOnOrBeforeNode.tokenRange.tokenIndexStart) {
|
|
188
|
-
bestOnOrBeforeNode = candidate;
|
|
193
|
+
let includeLowerBound = true;
|
|
194
|
+
let includeUpperBound = true;
|
|
195
|
+
if (language_1.AstUtils.isNodeKind(candidate, "Constant" /* Constant */)) {
|
|
196
|
+
if (ShiftRightConstantKinds.includes(candidate.constantKind)) {
|
|
197
|
+
includeLowerBound = false;
|
|
198
|
+
includeUpperBound = false;
|
|
199
|
+
}
|
|
200
|
+
else if (ShiftLeftConstantKinds.includes(candidate.constantKind)) {
|
|
201
|
+
includeLowerBound = false;
|
|
189
202
|
}
|
|
190
203
|
}
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// Might need to shift.
|
|
198
|
-
if ((bestOnOrBeforeNode === null || bestOnOrBeforeNode === void 0 ? void 0 : bestOnOrBeforeNode.kind) === "Constant" /* Constant */) {
|
|
199
|
-
const currentOnOrBefore = bestOnOrBeforeNode;
|
|
200
|
-
// Requires a shift into an empty ArrayWrapper.
|
|
201
|
-
if (DrilldownConstantKind.indexOf(bestOnOrBeforeNode.constantKind) !== -1 &&
|
|
202
|
-
(bestAfter === null || bestAfter === void 0 ? void 0 : bestAfter.kind) === "Constant" /* Constant */ &&
|
|
203
|
-
PQP.Language.ConstantUtils.isPairedWrapperConstantKinds(bestOnOrBeforeNode.constantKind, bestAfter.constantKind)) {
|
|
204
|
-
const parent = parser_1.NodeIdMapUtils.assertUnboxParentAstChecked(nodeIdMapCollection, currentOnOrBefore.id, [
|
|
205
|
-
"RecordExpression" /* RecordExpression */,
|
|
206
|
-
"RecordLiteral" /* RecordLiteral */,
|
|
207
|
-
"ListExpression" /* ListExpression */,
|
|
208
|
-
"ListLiteral" /* ListLiteral */,
|
|
209
|
-
"InvokeExpression" /* InvokeExpression */,
|
|
210
|
-
]);
|
|
211
|
-
const arrayWrapper = parser_1.NodeIdMapUtils.assertUnboxArrayWrapperAst(nodeIdMapCollection, parent.id);
|
|
212
|
-
shiftedRightNode = arrayWrapper;
|
|
204
|
+
// If the candidate starts under the cursor position then it's safe to assume it's the best candidate,
|
|
205
|
+
// as each leaf node is guaranteed to be non-overlapping.
|
|
206
|
+
if (__1.PositionUtils.isInAst(position, candidate, includeLowerBound, includeUpperBound)) {
|
|
207
|
+
nodeOnPosition = candidate;
|
|
213
208
|
}
|
|
214
|
-
//
|
|
215
|
-
else if (
|
|
216
|
-
|
|
209
|
+
// Else if the candidate is before the cursor position
|
|
210
|
+
else if (__1.PositionUtils.isAfterAst(position, candidate, includeUpperBound)) {
|
|
211
|
+
// And we either haven't found a closestNodeOnOrBeforePosition yet, or if the candidate is better (more right) than the current closestNodeOnOrBeforePosition.
|
|
212
|
+
if (nodeClosestBeforePosition === undefined ||
|
|
213
|
+
nodeClosestBeforePosition.tokenRange.tokenIndexStart < candidate.tokenRange.tokenIndexStart) {
|
|
214
|
+
nodeClosestBeforePosition = candidate;
|
|
215
|
+
}
|
|
217
216
|
}
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
// Else the candidate must be after the cursor position.
|
|
218
|
+
// And we either haven't found a closestAfterPosition yet, or if the candidate is better (more left) than the current nodeClosestAfterPosition.
|
|
219
|
+
else if (nodeClosestAfterPosition === undefined ||
|
|
220
|
+
nodeClosestAfterPosition.tokenRange.tokenIndexStart > candidate.tokenRange.tokenIndexStart) {
|
|
221
|
+
nodeClosestAfterPosition = candidate;
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
|
-
else {
|
|
224
|
-
shiftedRightNode = undefined;
|
|
225
|
-
}
|
|
226
224
|
return {
|
|
227
|
-
|
|
228
|
-
|
|
225
|
+
nodeClosestBeforePosition,
|
|
226
|
+
nodeOnPosition,
|
|
227
|
+
nodeClosestAfterPosition,
|
|
229
228
|
};
|
|
230
229
|
}
|
|
231
|
-
function findContext(nodeIdMapCollection,
|
|
232
|
-
|
|
230
|
+
function findContext(nodeIdMapCollection, searchedLeafs) {
|
|
231
|
+
var _a, _b, _c, _d, _e;
|
|
232
|
+
const tokenIndexLowBound = (_d = (_b = (_a = searchedLeafs.nodeClosestAfterPosition) === null || _a === void 0 ? void 0 : _a.tokenRange.tokenIndexStart) !== null && _b !== void 0 ? _b : (_c = searchedLeafs.nodeOnPosition) === null || _c === void 0 ? void 0 : _c.tokenRange.tokenIndexStart) !== null && _d !== void 0 ? _d : (_e = searchedLeafs.nodeClosestBeforePosition) === null || _e === void 0 ? void 0 : _e.tokenRange.tokenIndexStart;
|
|
233
|
+
if (tokenIndexLowBound === undefined) {
|
|
233
234
|
return undefined;
|
|
234
235
|
}
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
// Look for the deepest ParseContext that starts on or before the cursor.
|
|
237
|
+
// We can use searchedLeafs to generate a bound on tokenIndex.
|
|
238
|
+
// It's possible/likely that multiple ParseContexts exist with the same tokenIndex,
|
|
239
|
+
// so we pick the "deepest" one.
|
|
240
|
+
const depthCache = new Map();
|
|
241
|
+
let closestContextOnOrAfterPosition = undefined;
|
|
237
242
|
for (const candidate of nodeIdMapCollection.contextNodeById.values()) {
|
|
238
|
-
if (candidate.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
if (candidate.tokenIndexStart < tokenIndexLowBound) {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (closestContextOnOrAfterPosition === undefined ||
|
|
247
|
+
candidate.tokenIndexStart > closestContextOnOrAfterPosition.tokenIndexStart ||
|
|
248
|
+
findDepth(nodeIdMapCollection.parentIdById, candidate.id, depthCache) >
|
|
249
|
+
findDepth(nodeIdMapCollection.parentIdById, closestContextOnOrAfterPosition.id, depthCache)) {
|
|
250
|
+
closestContextOnOrAfterPosition = candidate;
|
|
245
251
|
}
|
|
246
252
|
}
|
|
247
|
-
return
|
|
253
|
+
return closestContextOnOrAfterPosition;
|
|
254
|
+
}
|
|
255
|
+
function findDepth(parentIdById, nodeId, depthCache) {
|
|
256
|
+
const cachedDepth = depthCache.get(nodeId);
|
|
257
|
+
if (cachedDepth !== undefined) {
|
|
258
|
+
return cachedDepth;
|
|
259
|
+
}
|
|
260
|
+
const parentId = parentIdById.get(nodeId);
|
|
261
|
+
if (parentId === undefined) {
|
|
262
|
+
return 0;
|
|
263
|
+
}
|
|
264
|
+
const summedDepth = 1 + findDepth(parentIdById, parentId, depthCache);
|
|
265
|
+
depthCache.set(nodeId, summedDepth);
|
|
266
|
+
return summedDepth;
|
|
248
267
|
}
|
|
249
268
|
function findLeafIdentifier(nodeIdMapCollection, leafXorNode) {
|
|
250
|
-
if (parser_1.XorNodeUtils.
|
|
269
|
+
if (parser_1.XorNodeUtils.isContext(leafXorNode)) {
|
|
251
270
|
return undefined;
|
|
252
271
|
}
|
|
253
272
|
const leaf = leafXorNode.node;
|
|
@@ -255,25 +274,27 @@ function findLeafIdentifier(nodeIdMapCollection, leafXorNode) {
|
|
|
255
274
|
const parentId = nodeIdMapCollection.parentIdById.get(leaf.id);
|
|
256
275
|
if (leaf.kind === "Identifier" /* Identifier */) {
|
|
257
276
|
if (parentId === undefined) {
|
|
258
|
-
return undefined;
|
|
259
|
-
}
|
|
260
|
-
const parent = parser_1.NodeIdMapUtils.unboxIfAst(nodeIdMapCollection, parentId);
|
|
261
|
-
if ((parent === null || parent === void 0 ? void 0 : parent.kind) === "IdentifierPairedExpression" /* IdentifierPairedExpression */) {
|
|
262
277
|
identifier = leaf;
|
|
263
278
|
}
|
|
264
|
-
else if ((parent === null || parent === void 0 ? void 0 : parent.kind) === "IdentifierExpression" /* IdentifierExpression */) {
|
|
265
|
-
identifier = parent;
|
|
266
|
-
}
|
|
267
279
|
else {
|
|
268
|
-
|
|
280
|
+
const parent = parser_1.NodeIdMapUtils.ast(nodeIdMapCollection, parentId);
|
|
281
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.kind) === "IdentifierPairedExpression" /* IdentifierPairedExpression */) {
|
|
282
|
+
identifier = leaf;
|
|
283
|
+
}
|
|
284
|
+
else if ((parent === null || parent === void 0 ? void 0 : parent.kind) === "IdentifierExpression" /* IdentifierExpression */) {
|
|
285
|
+
identifier = parent;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
identifier = leaf;
|
|
289
|
+
}
|
|
269
290
|
}
|
|
270
291
|
}
|
|
271
|
-
// If
|
|
292
|
+
// If '@', then check if it's part of an IdentifierExpression.
|
|
272
293
|
else if (leaf.kind === "Constant" /* Constant */ && leaf.constantKind === "@" /* AtSign */) {
|
|
273
294
|
if (parentId === undefined) {
|
|
274
295
|
return undefined;
|
|
275
296
|
}
|
|
276
|
-
const parent = parser_1.NodeIdMapUtils.
|
|
297
|
+
const parent = parser_1.NodeIdMapUtils.ast(nodeIdMapCollection, parentId);
|
|
277
298
|
if ((parent === null || parent === void 0 ? void 0 : parent.kind) === "IdentifierExpression" /* IdentifierExpression */) {
|
|
278
299
|
identifier = parent;
|
|
279
300
|
}
|
|
@@ -302,15 +323,27 @@ function findLeafIdentifier(nodeIdMapCollection, leafXorNode) {
|
|
|
302
323
|
const normalizedLiteral = language_1.TextUtils.normalizeIdentifier(identifier.identifier.literal);
|
|
303
324
|
result = {
|
|
304
325
|
node: identifier,
|
|
305
|
-
isRecursive: Boolean(identifier.inclusiveConstant),
|
|
306
326
|
normalizedLiteral,
|
|
307
|
-
normalizedRecursiveLiteral: `@${normalizedLiteral}
|
|
327
|
+
normalizedRecursiveLiteral: identifier.inclusiveConstant ? `@${normalizedLiteral}` : undefined,
|
|
308
328
|
};
|
|
309
329
|
break;
|
|
310
330
|
}
|
|
311
331
|
default:
|
|
312
|
-
throw
|
|
332
|
+
throw powerquery_parser_1.Assert.isNever(identifier);
|
|
313
333
|
}
|
|
314
334
|
return result;
|
|
315
335
|
}
|
|
336
|
+
function isInKey(ancestry) {
|
|
337
|
+
if (ancestry.length < 2) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
const child = powerquery_parser_1.ArrayUtils.assertGet(ancestry, 0);
|
|
341
|
+
const parent = powerquery_parser_1.ArrayUtils.assertGet(ancestry, 1);
|
|
342
|
+
// Return true if we're in the key portion of a key-value pair.
|
|
343
|
+
return ([
|
|
344
|
+
"GeneralizedIdentifierPairedAnyLiteral" /* GeneralizedIdentifierPairedAnyLiteral */,
|
|
345
|
+
"GeneralizedIdentifierPairedExpression" /* GeneralizedIdentifierPairedExpression */,
|
|
346
|
+
"IdentifierPairedExpression" /* IdentifierPairedExpression */,
|
|
347
|
+
].includes(parent.node.kind) && child.node.attributeIndex === 0);
|
|
348
|
+
}
|
|
316
349
|
//# sourceMappingURL=activeNodeUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activeNodeUtils.js","sourceRoot":"","sources":["../../../../src/powerquery-language-services/inspection/activeNode/activeNodeUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,
|
|
1
|
+
{"version":3,"file":"activeNodeUtils.js","sourceRoot":"","sources":["../../../../src/powerquery-language-services/inspection/activeNode/activeNodeUtils.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,4BAA4B;AAC5B,uCAAuC;AACvC,kCAAkC;;;AAElC,sFAQmE;AACnE,oEAA+E;AAC/E,0FAAiH;AAWjH,6BAAsC;AAEtC,SAAgB,UAAU,CAAC,mBAAyC,EAAE,QAAkB;IACpF,MAAM,WAAW,GAAkB,UAAU,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IAE7E,MAAM,EAAE,yBAAyB,EAAE,cAAc,EAAE,wBAAwB,EAAE,GAAkB,UAAU,CACrG,mBAAmB,EACnB,QAAQ,CACX,CAAC;IAEF,MAAM,+BAA+B,GAAmC,WAAW,CAC/E,mBAAmB,EACnB,WAAW,CACd,CAAC;IAEF,IAAI,IAA0B,CAAC;IAC/B,IAAI,QAAwC,CAAC;IAE7C,yBAAyB;IACzB,IACI,yBAAyB,KAAK,SAAS;QACvC,cAAc,KAAK,SAAS;QAC5B,wBAAwB,KAAK,SAAS,EACxC;QACE,OAAO,wBAAwB,CAAC,QAAQ,CAAC,CAAC;KAC7C;IAED,8BAA8B;IAE9B,uBAAuB;IACvB,UAAU;IACV,UAAU;SACL,IACD,yBAAyB,KAAK,SAAS;QACvC,cAAc,KAAK,SAAS;QAC5B,wBAAwB,KAAK,SAAS,EACxC;QACE,eAAe;QACf,UAAU;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C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACrB,OAAO,KAAK,CAAC;KAChB;IAED,MAAM,KAAK,GAAa,8BAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC1D,MAAM,MAAM,GAAa,8BAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAE3D,+DAA+D;IAC/D,OAAO,CACH;;;;KAIC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,cAAc,KAAK,CAAC,CAClE,CAAC;AACN,CAAC"}
|
|
@@ -25,7 +25,7 @@ function tryAutocompleteFieldAccess(settings, parseState, activeNode, typeCache)
|
|
|
25
25
|
const updatedSettings = Object.assign(Object.assign({}, settings), { initialCorrelationId: trace.id });
|
|
26
26
|
let result;
|
|
27
27
|
if (!activeNode_1.ActiveNodeUtils.isPositionInBounds(activeNode)) {
|
|
28
|
-
result = powerquery_parser_1.ResultUtils.
|
|
28
|
+
result = powerquery_parser_1.ResultUtils.ok(undefined);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
result = yield powerquery_parser_1.ResultUtils.ensureResultAsync(() => autocompleteFieldAccess(updatedSettings, parseState, activeNode, typeCache), updatedSettings.locale);
|
|
@@ -155,7 +155,7 @@ function inspectFieldSelector(lexerSnapshot, nodeIdMapCollection, position, fiel
|
|
|
155
155
|
return createInspectedFieldAccess(nodeIdMapCollection.astNodeById.has(childIds[0]));
|
|
156
156
|
}
|
|
157
157
|
const generalizedIdentifierId = childIds[1];
|
|
158
|
-
const generalizedIdentifierXor = parser_1.NodeIdMapUtils.
|
|
158
|
+
const generalizedIdentifierXor = parser_1.NodeIdMapUtils.assertXorChecked(nodeIdMapCollection, generalizedIdentifierId, "GeneralizedIdentifier" /* GeneralizedIdentifier */);
|
|
159
159
|
switch (generalizedIdentifierXor.kind) {
|
|
160
160
|
case "Ast" /* Ast */: {
|
|
161
161
|
const generalizedIdentifier = generalizedIdentifierXor.node;
|
|
@@ -170,7 +170,7 @@ function inspectFieldSelector(lexerSnapshot, nodeIdMapCollection, position, fiel
|
|
|
170
170
|
// TODO [Autocomplete]:
|
|
171
171
|
// This doesn't take into account of generalized identifiers consisting of multiple tokens.
|
|
172
172
|
// Eg. `foo[bar baz]` or `foo[#"bar baz"].
|
|
173
|
-
const openBracketConstant = parser_1.NodeIdMapUtils.
|
|
173
|
+
const openBracketConstant = parser_1.NodeIdMapUtils.assertNthChildAstChecked(nodeIdMapCollection, fieldSelector.node.id, 0, "Constant" /* Constant */);
|
|
174
174
|
const nextTokenPosition = (_a = lexerSnapshot.tokens[openBracketConstant.tokenRange.tokenIndexEnd + 1]) === null || _a === void 0 ? void 0 : _a.positionStart;
|
|
175
175
|
const isAutocompleteAllowed = __1.PositionUtils.isAfterAst(position, openBracketConstant, false) &&
|
|
176
176
|
(nextTokenPosition === undefined ||
|
|
@@ -195,7 +195,7 @@ function createAutocompleteItems(fieldEntries, inspectedFieldAccess) {
|
|
|
195
195
|
if (fieldAccessNames.includes(label) && label !== identifierUnderPositionLiteral) {
|
|
196
196
|
continue;
|
|
197
197
|
}
|
|
198
|
-
autocompleteItems.push(autocompleteItem_1.AutocompleteItemUtils.
|
|
198
|
+
autocompleteItems.push(autocompleteItem_1.AutocompleteItemUtils.fromFieldAccess(label, powerQueryType, identifierUnderPositionLiteral));
|
|
199
199
|
}
|
|
200
200
|
return autocompleteItems;
|
|
201
201
|
}
|
|
@@ -208,7 +208,7 @@ function typablePrimaryExpression(nodeIdMapCollection, activeNode) {
|
|
|
208
208
|
const xorNode = ancestry[index];
|
|
209
209
|
if (xorNode.node.kind === "RecursivePrimaryExpression" /* RecursivePrimaryExpression */) {
|
|
210
210
|
// The previous ancestor must be an attribute of Rpe, which is either its head or ArrrayWrapper.
|
|
211
|
-
const xorNodeBeforeRpe = parser_1.AncestryUtils.
|
|
211
|
+
const xorNodeBeforeRpe = parser_1.AncestryUtils.assertNth(ancestry, index - 1);
|
|
212
212
|
// If we're coming from the head node,
|
|
213
213
|
// then return undefined as there can be no nodes before the head ode.
|
|
214
214
|
if (xorNodeBeforeRpe.node.attributeIndex === 0) {
|
|
@@ -217,7 +217,7 @@ function typablePrimaryExpression(nodeIdMapCollection, activeNode) {
|
|
|
217
217
|
// Else if we're coming from the ArrayWrapper,
|
|
218
218
|
// then grab the previous sibling.
|
|
219
219
|
else if (xorNodeBeforeRpe.node.attributeIndex === 1) {
|
|
220
|
-
const rpeChild = parser_1.AncestryUtils.
|
|
220
|
+
const rpeChild = parser_1.AncestryUtils.assertNth(ancestry, index - 2);
|
|
221
221
|
return parser_1.NodeIdMapUtils.assertRecursiveExpressionPreviousSibling(nodeIdMapCollection, rpeChild.node.id);
|
|
222
222
|
}
|
|
223
223
|
else {
|