@artel/artc 0.6.25282 → 0.6.25283
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/build/Cli.js +3 -3
- package/build/api/Api.js +4 -8
- package/build/api/ApiNodeJS.js +3 -3
- package/build/api/ApiServices.js +1091 -973
- package/build/{chunk-VVFLEWSA.js → chunk-2Q4QKW7T.js} +6998 -6268
- package/build/{chunk-3DN3M64Y.js → chunk-7RAZAZE6.js} +2 -2
- package/build/{chunk-DURHSZYF.js → chunk-MJ2ZVHII.js} +1 -1
- package/build/types/analysis/Analyzer.d.ts +41 -74
- package/build/types/analysis/ResolvedImplementationPackage.d.ts +48 -0
- package/build/types/analysis/semantic-context/FieldWithInitializerSemanticContext.d.ts +4 -5
- package/build/types/analysis/semantic-context/SemanticContextBase.d.ts +4 -4
- package/build/types/analysis/semantic-context/SemanticContextValidatingNameConflicts.d.ts +4 -5
- package/build/types/analysis/semantic-context/SourceFileSemanticContext.d.ts +4 -4
- package/build/types/analysis/semantic-context/SubprogramSemanticContext.d.ts +4 -5
- package/build/types/analysis/semantic-context/TypeSemanticContext.d.ts +8 -8
- package/build/types/common/HelperPhrases.d.ts +2 -1
- package/build/types/common/LocalizationHelper.d.ts +6 -4
- package/build/types/diagnostic/DiagnosticCode.d.ts +10 -0
- package/build/types/emitter/EntityMap.d.ts +1 -1
- package/build/types/emitter/ir/Nodes.d.ts +11 -2
- package/build/types/entities/Entity.d.ts +0 -12
- package/build/types/entities/EntityLocalizationContext.d.ts +1 -2
- package/build/types/entities/IEntity.d.ts +2 -1
- package/build/types/entities/OperatorKind.d.ts +6 -3
- package/build/types/entities/TypeEntity.d.ts +4 -4
- package/build/types/entities/interfaces/AliasTypeEntity.d.ts +3 -8
- package/build/types/entities/interfaces/ConstructorEntity.d.ts +0 -4
- package/build/types/entities/interfaces/DereferenceOperatorEntity.d.ts +0 -4
- package/build/types/entities/interfaces/DestructorEntity.d.ts +0 -4
- package/build/types/entities/interfaces/FunctionEntity.d.ts +1 -8
- package/build/types/entities/interfaces/FunctionTypeEntity.d.ts +0 -8
- package/build/types/entities/interfaces/GetterEntity.d.ts +0 -4
- package/build/types/entities/interfaces/IndexerEntity.d.ts +0 -4
- package/build/types/entities/interfaces/OperatorEntity.d.ts +0 -4
- package/build/types/entities/interfaces/PackageAliasEntity.d.ts +0 -5
- package/build/types/entities/interfaces/PackageEntity.d.ts +1 -9
- package/build/types/entities/interfaces/SetterEntity.d.ts +0 -4
- package/build/types/entities/interfaces/StructuredTypeEntity.d.ts +0 -8
- package/build/types/entities/interfaces/TextTranslationEntity.d.ts +1 -0
- package/build/types/entities/interfaces/TypeExtensionEntity.d.ts +1 -7
- package/build/types/entities/interfaces/TypeParameterEntity.d.ts +0 -2
- package/build/types/entities/interfaces/VariableEntity.d.ts +1 -11
- package/build/types/entities/interfaces/VariantTypeEntity.d.ts +1 -8
- package/build/types/entities/intrinsic/IntrinsicFunctionTypeEntity.d.ts +3 -3
- package/build/types/entities/intrinsic/IntrinsicStructuredTypeEntity.d.ts +3 -3
- package/build/types/entities/intrinsic/IntrinsicTypeParameterEntity.d.ts +2 -4
- package/build/types/entities/source/SourceAliasTypeEntity.d.ts +1 -2
- package/build/types/entities/source/SourceFunctionTypeEntity.d.ts +1 -3
- package/build/types/entities/source/SourceStructuredTypeEntity.d.ts +1 -3
- package/build/types/entities/source/SourceTextTranslationEntity.d.ts +1 -0
- package/build/types/entities/source/SourceTypeExtensionEntity.d.ts +1 -2
- package/build/types/entities/source/SourceTypeParameterEntity.d.ts +1 -2
- package/build/types/entities/source/SourceVariantTypeEntity.d.ts +1 -3
- package/build/types/entities/translated/TranslatedAliasTypeEntity.d.ts +1 -3
- package/build/types/entities/translated/TranslatedFunctionTypeEntity.d.ts +1 -5
- package/build/types/entities/translated/TranslatedStructuredTypeEntity.d.ts +1 -5
- package/build/types/entities/translated/TranslatedTypeExtensionEntity.d.ts +1 -3
- package/build/types/entities/translated/TranslatedTypeParameterEntity.d.ts +1 -3
- package/build/types/entities/translated/TranslatedVariantTypeEntity.d.ts +1 -5
- package/build/types/parser/KeywordDictionary.d.ts +10 -2
- package/build/types/parser/TokenKind.d.ts +46 -44
- package/build/types/services/CustomRequests.d.ts +17 -6
- package/build/types/services/DisplayService.d.ts +9 -1
- package/build/types/services/LanguageServer.d.ts +3 -4
- package/build/types/services/ScriptEditingService.d.ts +25 -0
- package/build/types/services/Types.d.ts +6 -0
- package/build/types/services/source-generation/EntityToSyntax.d.ts +12 -0
- package/build/types/tree/BaseNode.d.ts +56 -2
- package/build/types/tree/KeywordFlags.d.ts +28 -0
- package/build/types/tree/KeywordKind.d.ts +3 -1
- package/build/types/tree/Nodes.d.ts +4 -18
- package/build/types/tree/NodesDebug.d.ts +9 -0
- package/build/types/tree/OperatorKind.d.ts +6 -3
- package/build/types/tree/SyntaxFactory.d.ts +31 -29
- package/build/types/tree/SyntaxToCode.d.ts +3 -0
- package/build/types/tree/TokenFlags.d.ts +15 -0
- package/build/types/tree/TokenKind.d.ts +58 -44
- package/build/types/tree/Utils.d.ts +2 -2
- package/build/types/tree/index.d.ts +2 -1
- package/build/types/ts-interop/Entities.d.ts +1 -11
- package/build/types/ts-interop/TsInteropContext.d.ts +1 -2
- package/build/types/types/AliasType.d.ts +0 -1
- package/build/types/types/FunctionType.d.ts +0 -1
- package/build/types/types/IntersectionType.d.ts +0 -1
- package/build/types/types/ParameterType.d.ts +0 -1
- package/build/types/types/StructuredType.d.ts +1 -2
- package/build/types/types/SubstitutionStubType.d.ts +21 -0
- package/build/types/types/Type.d.ts +4 -3
- package/build/types/types/TypeFactory.d.ts +2 -1
- package/build/types/types/UnionType.d.ts +0 -1
- package/build/types/types/UnresolvedType.d.ts +0 -1
- package/build/types/types/VariantType.d.ts +0 -1
- package/build/types/types/index.d.ts +2 -1
- package/package.json +1 -1
- package/build/types/services/AddBlockToScriptService.d.ts +0 -17
- package/build/types/services/AssignFieldService.d.ts +0 -10
- package/build/types/services/DeleteBlockFromScriptService.d.ts +0 -6
- package/build/types/tree/Token.d.ts +0 -58
- /package/build/types/services/{ProjectItemsService.d.ts → WorkspaceItemsService.d.ts} +0 -0
package/build/api/ApiServices.js
CHANGED
|
@@ -188,7 +188,7 @@ import {
|
|
|
188
188
|
unwrapParenthesizedExpressions,
|
|
189
189
|
visitChildren,
|
|
190
190
|
yieldTask
|
|
191
|
-
} from "../chunk-
|
|
191
|
+
} from "../chunk-2Q4QKW7T.js";
|
|
192
192
|
|
|
193
193
|
// source/services/CustomRequests.ts
|
|
194
194
|
import * as ls from "vscode-languageserver";
|
|
@@ -205,7 +205,8 @@ var customRequests = {
|
|
|
205
205
|
deleteSourceFile: new CustomRequestType("artel/fs.deleteSourceFile"),
|
|
206
206
|
getNodeRange: new CustomRequestType("artel/getNodeRange"),
|
|
207
207
|
assignField: new CustomRequestType("artel/assignField"),
|
|
208
|
-
|
|
208
|
+
addBlocksToScript: new CustomRequestType("artel/addBlocksToScript"),
|
|
209
|
+
canDeleteBlocksFromScript: new CustomRequestType("artel/canDeleteBlocksFromScript"),
|
|
209
210
|
deleteBlocksFromScript: new CustomRequestType("artel/deleteBlocksFromScript")
|
|
210
211
|
};
|
|
211
212
|
|
|
@@ -215,157 +216,6 @@ import * as ls3 from "vscode-languageserver";
|
|
|
215
216
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
216
217
|
import { URI } from "vscode-uri";
|
|
217
218
|
|
|
218
|
-
// source/services/Types.ts
|
|
219
|
-
import * as ls2 from "vscode-languageserver";
|
|
220
|
-
var SourceLocation = class {
|
|
221
|
-
constructor(sourceFile, range) {
|
|
222
|
-
this.sourceFile = sourceFile;
|
|
223
|
-
this.range = range;
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
function isCompletionItemData(value) {
|
|
227
|
-
Debug.cast(value);
|
|
228
|
-
return value instanceof Object && typeof value.cacheId === "number" && typeof value.indexInCache === "number";
|
|
229
|
-
}
|
|
230
|
-
function isCodeActionData(value) {
|
|
231
|
-
Debug.cast(value);
|
|
232
|
-
return value instanceof Object && typeof value.name === "string" && value.location instanceof Object && ls2.DocumentUri.is(value.location.uri) && ls2.Position.is(value.location.position) && "data" in value;
|
|
233
|
-
}
|
|
234
|
-
var SourceFileEdit = class {
|
|
235
|
-
constructor(sourceFile, range, text) {
|
|
236
|
-
this.sourceFile = sourceFile;
|
|
237
|
-
this.range = range;
|
|
238
|
-
this.text = text;
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
// source/services/AddBlockToScriptService.ts
|
|
243
|
-
var AddBlockToScriptService = class _AddBlockToScriptService {
|
|
244
|
-
static {
|
|
245
|
-
this.indentationStep = " ";
|
|
246
|
-
}
|
|
247
|
-
static {
|
|
248
|
-
this.elementParameterName = "el";
|
|
249
|
-
}
|
|
250
|
-
createEditAddingBlock(sourceFile, subprogramDeclaration, addedBlockInfo) {
|
|
251
|
-
const subprogramBlock = subprogramDeclaration.block;
|
|
252
|
-
if (subprogramBlock === void 0) {
|
|
253
|
-
return void 0;
|
|
254
|
-
}
|
|
255
|
-
let scriptBlockIndentation;
|
|
256
|
-
let editStart;
|
|
257
|
-
if (subprogramBlock.expressionOrStatementList.kind === 93 /* StatementList */) {
|
|
258
|
-
const lastStatement = subprogramBlock.expressionOrStatementList.statements.last();
|
|
259
|
-
if (lastStatement !== void 0) {
|
|
260
|
-
const lastStatementStartCharacter = sourceFile.getPositionAt(lastStatement.rangeWithoutTrivia.start).character;
|
|
261
|
-
scriptBlockIndentation = " ".repeat(lastStatementStartCharacter);
|
|
262
|
-
editStart = lastStatement.rangeWithoutTrivia.end;
|
|
263
|
-
} else {
|
|
264
|
-
const openBraceStartCharacter = sourceFile.getPositionAt(subprogramBlock.openBraceToken.rangeWithoutTrivia.start).character;
|
|
265
|
-
scriptBlockIndentation = " ".repeat(openBraceStartCharacter) + _AddBlockToScriptService.indentationStep;
|
|
266
|
-
editStart = subprogramBlock.openBraceToken.rangeWithoutTrivia.end;
|
|
267
|
-
}
|
|
268
|
-
} else {
|
|
269
|
-
const expressionStartCharacter = sourceFile.getPositionAt(subprogramBlock.expressionOrStatementList.rangeWithoutTrivia.start).character;
|
|
270
|
-
scriptBlockIndentation = " ".repeat(expressionStartCharacter);
|
|
271
|
-
editStart = subprogramBlock.expressionOrStatementList.rangeWithoutTrivia.end;
|
|
272
|
-
}
|
|
273
|
-
const newLine = this.detectNewLine(sourceFile.getSourceText());
|
|
274
|
-
const scriptBlockText = this.createScriptBlockText(addedBlockInfo, scriptBlockIndentation, newLine);
|
|
275
|
-
const editText = `${newLine}${scriptBlockText}`;
|
|
276
|
-
const result = new SourceFileEdit(sourceFile, Range.empty(editStart), editText);
|
|
277
|
-
return result;
|
|
278
|
-
}
|
|
279
|
-
createScriptBlockText(blockInfo, indentation, newLine) {
|
|
280
|
-
const i = indentation;
|
|
281
|
-
const s = _AddBlockToScriptService.indentationStep;
|
|
282
|
-
const nl = newLine;
|
|
283
|
-
const el = _AddBlockToScriptService.elementParameterName;
|
|
284
|
-
return `${i}${blockInfo.name}(${nl}${i}${s}key = ${blockInfo.key},${nl}${i}${s}script =${nl}${i}${s}{${nl}` + Object.entries(blockInfo.elementProperties).map(([p, v]) => `${i}${s}${s}${el}.${p} = ${v}${nl}`).join("") + `${i}${s}})`;
|
|
285
|
-
}
|
|
286
|
-
detectNewLine(text) {
|
|
287
|
-
return text.includes("\r\n") ? "\r\n" : "\n";
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
// source/services/AssignFieldService.ts
|
|
292
|
-
var AssignFieldService = class _AssignFieldService {
|
|
293
|
-
static {
|
|
294
|
-
this.receiverVariableName = new Name("el");
|
|
295
|
-
}
|
|
296
|
-
createEditWithAssignment(analyzer, sourceFile, subprogramDeclaration, fieldName, value) {
|
|
297
|
-
const subprogramBlock = subprogramDeclaration.block;
|
|
298
|
-
if (subprogramBlock === void 0) {
|
|
299
|
-
return void 0;
|
|
300
|
-
}
|
|
301
|
-
const lastAssignmentStatement = this.findLastAssignmentToField(analyzer, subprogramBlock, fieldName);
|
|
302
|
-
let result;
|
|
303
|
-
if (lastAssignmentStatement !== void 0) {
|
|
304
|
-
result = new SourceFileEdit(sourceFile, lastAssignmentStatement.right.rangeWithoutTrivia, value);
|
|
305
|
-
} else {
|
|
306
|
-
const assignmentText = `${_AssignFieldService.receiverVariableName.unescapedOriginal}.${fieldName} = ${value}`;
|
|
307
|
-
if (subprogramBlock.expressionOrStatementList.kind === 93 /* StatementList */) {
|
|
308
|
-
const lastStatement = subprogramBlock.expressionOrStatementList?.statements.last();
|
|
309
|
-
let editRange;
|
|
310
|
-
let indentationText;
|
|
311
|
-
if (lastStatement !== void 0) {
|
|
312
|
-
editRange = Range.empty(lastStatement.rangeWithoutTrivia.end);
|
|
313
|
-
const statementStartCharacter = sourceFile.getPositionAt(lastStatement.rangeWithoutTrivia.start).character;
|
|
314
|
-
indentationText = `${this.detectNewLine(sourceFile.getSourceText())}${" ".repeat(statementStartCharacter)}`;
|
|
315
|
-
} else {
|
|
316
|
-
const openBraceRange = subprogramBlock.openBraceToken.rangeWithoutTrivia;
|
|
317
|
-
const closeBraceRange = subprogramBlock.closeBraceToken.rangeWithoutTrivia;
|
|
318
|
-
const openBracePosition = sourceFile.getPositionAt(openBraceRange.start);
|
|
319
|
-
const closeBracePosition = sourceFile.getPositionAt(closeBraceRange.start);
|
|
320
|
-
if (openBracePosition.line !== closeBracePosition.line) {
|
|
321
|
-
editRange = Range.empty(openBraceRange.end);
|
|
322
|
-
indentationText = `${this.detectNewLine(sourceFile.getSourceText())}${" ".repeat(closeBracePosition.character + 2)}`;
|
|
323
|
-
} else {
|
|
324
|
-
editRange = Range.empty(openBraceRange.end);
|
|
325
|
-
indentationText = " ";
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
result = new SourceFileEdit(sourceFile, editRange, `${indentationText}${assignmentText}`);
|
|
329
|
-
} else {
|
|
330
|
-
const expressionStartCharacter = sourceFile.getPositionAt(subprogramBlock.expressionOrStatementList.rangeWithoutTrivia.start).character;
|
|
331
|
-
const indentationText = `${this.detectNewLine(sourceFile.getSourceText())}${" ".repeat(expressionStartCharacter)}`;
|
|
332
|
-
const editRange = Range.empty(subprogramBlock.expressionOrStatementList.rangeWithoutTrivia.end);
|
|
333
|
-
result = new SourceFileEdit(sourceFile, editRange, `${indentationText}${assignmentText}`);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return result;
|
|
337
|
-
}
|
|
338
|
-
findLastAssignmentToField(analyzer, block, fieldNameText) {
|
|
339
|
-
if (block.expressionOrStatementList.kind !== 93 /* StatementList */) {
|
|
340
|
-
return void 0;
|
|
341
|
-
}
|
|
342
|
-
const fieldName = new Name(fieldNameText);
|
|
343
|
-
const statements = block.expressionOrStatementList.statements.toArray();
|
|
344
|
-
for (let i = statements.length - 1; i >= 0; i--) {
|
|
345
|
-
const statement = statements[i];
|
|
346
|
-
if (statement.kind === 92 /* AssignmentStatement */) {
|
|
347
|
-
const left = unwrapParenthesizedExpressions(statement.left);
|
|
348
|
-
if (left.kind === 76 /* MemberAccessExpression */) {
|
|
349
|
-
const memberAccessMeaning = analyzer.resolveMemberAccessExpression(left);
|
|
350
|
-
if (memberAccessMeaning.kind === "instance-field-access" && memberAccessMeaning.field.getName().considerEqual(fieldName)) {
|
|
351
|
-
const receiver = unwrapParenthesizedExpressions(left.expression);
|
|
352
|
-
if (receiver.kind === 89 /* IdentifierExpression */) {
|
|
353
|
-
const receiverMeaning = analyzer.resolveIdentifierExpression(receiver);
|
|
354
|
-
if (receiverMeaning.kind === "variable-access" && receiverMeaning.variable.getName().considerEqual(_AssignFieldService.receiverVariableName)) {
|
|
355
|
-
return statement;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
return void 0;
|
|
363
|
-
}
|
|
364
|
-
detectNewLine(text) {
|
|
365
|
-
return text.includes("\r\n") ? "\r\n" : "\n";
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
|
-
|
|
369
219
|
// source/tree/SyntaxFactory.ts
|
|
370
220
|
var SyntaxFactory = class {
|
|
371
221
|
static sourceFile(packageImportDirectives, declarations) {
|
|
@@ -386,8 +236,8 @@ var SyntaxFactory = class {
|
|
|
386
236
|
let aliasIdentifier;
|
|
387
237
|
let equalsToken;
|
|
388
238
|
if (alias !== void 0) {
|
|
389
|
-
aliasIdentifier = this.
|
|
390
|
-
equalsToken = this.token(
|
|
239
|
+
aliasIdentifier = this.identifier(alias);
|
|
240
|
+
equalsToken = this.token(64 /* Equals */);
|
|
391
241
|
}
|
|
392
242
|
const packageName = this.packageName(pathSegments);
|
|
393
243
|
const packageImport = new PackageImport(aliasIdentifier, equalsToken, packageName, void 0);
|
|
@@ -395,17 +245,17 @@ var SyntaxFactory = class {
|
|
|
395
245
|
return new SinglePackageImportDirective(importKeyword, packageImport, void 0);
|
|
396
246
|
}
|
|
397
247
|
static packageName(segments) {
|
|
398
|
-
const segmentIdentifiers = segments.map((s) => this.
|
|
399
|
-
const packageNameParts = this.
|
|
248
|
+
const segmentIdentifiers = segments.map((s) => this.identifier(s));
|
|
249
|
+
const packageNameParts = this.createSeparatedElements(segmentIdentifiers, 28 /* Dot */);
|
|
400
250
|
return new PackageName(packageNameParts, void 0);
|
|
401
251
|
}
|
|
402
252
|
static packageAliasTypeDeclaration(tags, modifiers, name, typeParameters, body) {
|
|
403
253
|
const tagList = new TagList(tags, void 0);
|
|
404
254
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
405
255
|
const typeKeyword = this.keyword(16 /* Type */);
|
|
406
|
-
const nameIdentifier = this.
|
|
256
|
+
const nameIdentifier = this.identifier(name);
|
|
407
257
|
const typeParameterClause = this.createTypeParameterClause(typeParameters);
|
|
408
|
-
const equalsToken = this.token(
|
|
258
|
+
const equalsToken = this.token(64 /* Equals */);
|
|
409
259
|
return new PackageAliasTypeDeclaration(
|
|
410
260
|
tagList,
|
|
411
261
|
modifierList,
|
|
@@ -428,9 +278,9 @@ var SyntaxFactory = class {
|
|
|
428
278
|
return new PackageMemberGroupDeclaration(
|
|
429
279
|
tagList,
|
|
430
280
|
modifierList,
|
|
431
|
-
this.token(
|
|
281
|
+
this.token(46 /* OpenBrace */),
|
|
432
282
|
declarationList,
|
|
433
|
-
this.token(
|
|
283
|
+
this.token(22 /* CloseBrace */),
|
|
434
284
|
void 0
|
|
435
285
|
);
|
|
436
286
|
}
|
|
@@ -438,7 +288,7 @@ var SyntaxFactory = class {
|
|
|
438
288
|
const tagList = new TagList(tags, void 0);
|
|
439
289
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
440
290
|
const functionKeyword = this.keyword(12 /* Function */);
|
|
441
|
-
const nameIdentifier = this.
|
|
291
|
+
const nameIdentifier = this.identifier(name);
|
|
442
292
|
const typeParameterClause = this.createTypeParameterClause(typeParameters);
|
|
443
293
|
const parameterClause = this.parameterClause(parameters);
|
|
444
294
|
const returnTypeAnnotation = this.createTypeAnnotation(returnTypeSpecifier);
|
|
@@ -458,9 +308,9 @@ var SyntaxFactory = class {
|
|
|
458
308
|
const tagList = new TagList(tags, void 0);
|
|
459
309
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
460
310
|
const typeKeyword = this.keyword(16 /* Type */);
|
|
461
|
-
const nameIdentifier = this.
|
|
311
|
+
const nameIdentifier = this.identifier(name);
|
|
462
312
|
const typeParameterClause = this.createTypeParameterClause(typeParameters);
|
|
463
|
-
const equalsToken = this.token(
|
|
313
|
+
const equalsToken = this.token(64 /* Equals */);
|
|
464
314
|
return new PackageFunctionTypeDeclaration(
|
|
465
315
|
tagList,
|
|
466
316
|
modifierList,
|
|
@@ -488,9 +338,9 @@ var SyntaxFactory = class {
|
|
|
488
338
|
const tagList = new TagList(tags, void 0);
|
|
489
339
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
490
340
|
const typeKeyword = this.keyword(16 /* Type */);
|
|
491
|
-
const nameIdentifier = this.
|
|
341
|
+
const nameIdentifier = this.identifier(name);
|
|
492
342
|
const typeParameterClause = this.createTypeParameterClause(typeParameters);
|
|
493
|
-
const equalsToken = this.token(
|
|
343
|
+
const equalsToken = this.token(64 /* Equals */);
|
|
494
344
|
return new PackageStructuredTypeDeclaration(
|
|
495
345
|
tagList,
|
|
496
346
|
modifierList,
|
|
@@ -504,7 +354,7 @@ var SyntaxFactory = class {
|
|
|
504
354
|
}
|
|
505
355
|
static structuredTypeDeclarationBody(structuredTypeKind, baseTypes, members) {
|
|
506
356
|
const structuredTypeKindKeyword = this.keyword(structuredTypeKind);
|
|
507
|
-
const baseTypeList = baseTypes !== void 0 && baseTypes.length > 0 ? new BaseTypeList(this.
|
|
357
|
+
const baseTypeList = baseTypes !== void 0 && baseTypes.length > 0 ? new BaseTypeList(this.createSeparatedElements(baseTypes, 26 /* Comma */), void 0) : void 0;
|
|
508
358
|
const memberBlock = this.typeMemberDeclarationBlock(members);
|
|
509
359
|
return new StructuredTypeDeclarationBody(
|
|
510
360
|
structuredTypeKindKeyword,
|
|
@@ -516,11 +366,11 @@ var SyntaxFactory = class {
|
|
|
516
366
|
static packageVariableDeclaration(tags, modifiers, name, typeSpecifier, initializer) {
|
|
517
367
|
const tagList = new TagList(tags, void 0);
|
|
518
368
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
519
|
-
const nameIdentifier = this.
|
|
369
|
+
const nameIdentifier = this.identifier(name);
|
|
520
370
|
const typeAnnotation = this.createTypeAnnotation(typeSpecifier);
|
|
521
371
|
let equalsToken;
|
|
522
372
|
if (initializer !== void 0) {
|
|
523
|
-
equalsToken = this.token(
|
|
373
|
+
equalsToken = this.token(64 /* Equals */);
|
|
524
374
|
}
|
|
525
375
|
return new PackageVariableDeclaration(
|
|
526
376
|
tagList,
|
|
@@ -536,7 +386,7 @@ var SyntaxFactory = class {
|
|
|
536
386
|
const tagList = new TagList(tags, void 0);
|
|
537
387
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
538
388
|
const getKeyword = this.keyword(58 /* Get */);
|
|
539
|
-
const nameIdentifier = this.
|
|
389
|
+
const nameIdentifier = this.identifier(name);
|
|
540
390
|
const typeAnnotation = this.typeAnnotation(typeSpecifier);
|
|
541
391
|
return new PackageVariableGetterDeclaration(
|
|
542
392
|
tagList,
|
|
@@ -552,16 +402,16 @@ var SyntaxFactory = class {
|
|
|
552
402
|
const tagList = new TagList(tags, void 0);
|
|
553
403
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
554
404
|
const setKeyword = this.keyword(59 /* Set */);
|
|
555
|
-
const nameIdentifier = this.
|
|
405
|
+
const nameIdentifier = this.identifier(name);
|
|
556
406
|
return new PackageVariableSetterDeclaration(tagList, modifierList, setKeyword, nameIdentifier, body, void 0);
|
|
557
407
|
}
|
|
558
408
|
static packageVariantTypeDeclaration(tags, modifiers, name, typeParameters, body) {
|
|
559
409
|
const tagList = new TagList(tags, void 0);
|
|
560
410
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
561
411
|
const typeKeyword = this.keyword(16 /* Type */);
|
|
562
|
-
const nameIdentifier = this.
|
|
412
|
+
const nameIdentifier = this.identifier(name);
|
|
563
413
|
const typeParameterClause = this.createTypeParameterClause(typeParameters);
|
|
564
|
-
const equalsToken = this.token(
|
|
414
|
+
const equalsToken = this.token(64 /* Equals */);
|
|
565
415
|
return new PackageVariantTypeDeclaration(
|
|
566
416
|
tagList,
|
|
567
417
|
modifierList,
|
|
@@ -581,11 +431,11 @@ var SyntaxFactory = class {
|
|
|
581
431
|
static fieldDeclaration(tags, modifiers, name, typeSpecifier, initializer) {
|
|
582
432
|
const tagList = new TagList(tags, void 0);
|
|
583
433
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
584
|
-
const nameIdentifier = this.
|
|
434
|
+
const nameIdentifier = this.identifier(name);
|
|
585
435
|
const typeAnnotation = this.createTypeAnnotation(typeSpecifier);
|
|
586
436
|
let equalsToken;
|
|
587
437
|
if (initializer !== void 0) {
|
|
588
|
-
equalsToken = this.token(
|
|
438
|
+
equalsToken = this.token(64 /* Equals */);
|
|
589
439
|
}
|
|
590
440
|
return new FieldDeclaration(
|
|
591
441
|
tagList,
|
|
@@ -601,7 +451,7 @@ var SyntaxFactory = class {
|
|
|
601
451
|
const tagList = new TagList(tags, void 0);
|
|
602
452
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
603
453
|
const getKeyword = this.keyword(58 /* Get */);
|
|
604
|
-
const nameIdentifier = this.
|
|
454
|
+
const nameIdentifier = this.identifier(name);
|
|
605
455
|
const typeAnnotation = this.typeAnnotation(typeSpecifier);
|
|
606
456
|
return new FieldGetterDeclaration(
|
|
607
457
|
tagList,
|
|
@@ -617,14 +467,14 @@ var SyntaxFactory = class {
|
|
|
617
467
|
const tagList = new TagList(tags, void 0);
|
|
618
468
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
619
469
|
const setKeyword = this.keyword(59 /* Set */);
|
|
620
|
-
const nameIdentifier = this.
|
|
470
|
+
const nameIdentifier = this.identifier(name);
|
|
621
471
|
return new FieldSetterDeclaration(tagList, modifierList, setKeyword, nameIdentifier, body, void 0);
|
|
622
472
|
}
|
|
623
473
|
static methodDeclaration(tags, modifiers, name, typeParameters, parameters, returnTypeSpecifier, body) {
|
|
624
474
|
const tagList = new TagList(tags, void 0);
|
|
625
475
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
626
476
|
const functionKeyword = this.keyword(12 /* Function */);
|
|
627
|
-
const nameIdentifier = this.
|
|
477
|
+
const nameIdentifier = this.identifier(name);
|
|
628
478
|
const typeParameterClause = this.createTypeParameterClause(typeParameters);
|
|
629
479
|
const parameterClause = this.parameterClause(parameters);
|
|
630
480
|
const returnTypeAnnotation = this.createTypeAnnotation(returnTypeSpecifier);
|
|
@@ -685,42 +535,42 @@ var SyntaxFactory = class {
|
|
|
685
535
|
}
|
|
686
536
|
static typeMemberDeclarationBlock(members) {
|
|
687
537
|
return new TypeMemberDeclarationBlock(
|
|
688
|
-
this.token(
|
|
538
|
+
this.token(46 /* OpenBrace */),
|
|
689
539
|
new TypeMemberDeclarationList(members, void 0),
|
|
690
|
-
this.token(
|
|
540
|
+
this.token(22 /* CloseBrace */),
|
|
691
541
|
void 0
|
|
692
542
|
);
|
|
693
543
|
}
|
|
694
544
|
static variantValueDeclaration(tags, modifiers, name, value) {
|
|
695
545
|
const tagList = new TagList(tags, void 0);
|
|
696
546
|
const modifierList = new ModifierList(modifiers, void 0);
|
|
697
|
-
const nameIdentifier = this.
|
|
547
|
+
const nameIdentifier = this.identifier(name);
|
|
698
548
|
let equalsToken;
|
|
699
549
|
if (value !== void 0) {
|
|
700
|
-
equalsToken = this.token(
|
|
550
|
+
equalsToken = this.token(64 /* Equals */);
|
|
701
551
|
}
|
|
702
552
|
return new VariantValueDeclaration(tagList, modifierList, nameIdentifier, equalsToken, value, void 0);
|
|
703
553
|
}
|
|
704
554
|
static parameterClause(parameters) {
|
|
705
555
|
return new ParameterClause(
|
|
706
|
-
this.token(
|
|
707
|
-
new ParameterList(this.
|
|
708
|
-
this.token(
|
|
556
|
+
this.token(47 /* OpenParenthesis */),
|
|
557
|
+
new ParameterList(this.createSeparatedElements(parameters, 26 /* Comma */), void 0),
|
|
558
|
+
this.token(23 /* CloseParenthesis */),
|
|
709
559
|
void 0
|
|
710
560
|
);
|
|
711
561
|
}
|
|
712
562
|
static indexParameterClause(indexParameters) {
|
|
713
563
|
return new IndexParameterClause(
|
|
714
|
-
this.token(
|
|
715
|
-
new ParameterList(this.
|
|
716
|
-
this.token(
|
|
564
|
+
this.token(48 /* OpenSquareBracket */),
|
|
565
|
+
new ParameterList(this.createSeparatedElements(indexParameters, 26 /* Comma */), void 0),
|
|
566
|
+
this.token(24 /* CloseSquareBracket */),
|
|
717
567
|
void 0
|
|
718
568
|
);
|
|
719
569
|
}
|
|
720
570
|
static namedTypeSpecifier(name, typeArguments) {
|
|
721
|
-
const qualifiedNameIdentifiers = typeof name === "string" ? [this.
|
|
571
|
+
const qualifiedNameIdentifiers = typeof name === "string" || name instanceof Token ? [this.identifier(name)] : name.map((s) => this.identifier(s));
|
|
722
572
|
const qualifiedName = new QualifiedName(
|
|
723
|
-
this.
|
|
573
|
+
this.createSeparatedElements(qualifiedNameIdentifiers, 28 /* Dot */),
|
|
724
574
|
void 0
|
|
725
575
|
);
|
|
726
576
|
let typeArgumentClause;
|
|
@@ -730,21 +580,21 @@ var SyntaxFactory = class {
|
|
|
730
580
|
return new NamedTypeSpecifier(qualifiedName, typeArgumentClause, void 0);
|
|
731
581
|
}
|
|
732
582
|
static unionTypeSpecifier(typeSpecifiers) {
|
|
733
|
-
return new UnionTypeSpecifier(this.
|
|
583
|
+
return new UnionTypeSpecifier(this.createSeparatedElements(typeSpecifiers, 17 /* Bar */), void 0);
|
|
734
584
|
}
|
|
735
585
|
static intersectionTypeSpecifier(typeSpecifiers) {
|
|
736
|
-
return new IntersectionTypeSpecifier(this.
|
|
586
|
+
return new IntersectionTypeSpecifier(this.createSeparatedElements(
|
|
737
587
|
typeSpecifiers,
|
|
738
588
|
10 /* Ampersand */
|
|
739
589
|
), void 0);
|
|
740
590
|
}
|
|
741
591
|
static nullableTypeSpecifier(typeSpecifier) {
|
|
742
|
-
const questionToken = this.token(
|
|
592
|
+
const questionToken = this.token(52 /* Question */);
|
|
743
593
|
return new NullableTypeSpecifier(typeSpecifier, questionToken, void 0);
|
|
744
594
|
}
|
|
745
595
|
static parenthesizedTypeSpecifier(typeSpecifier) {
|
|
746
|
-
const openParenthesisToken = this.token(
|
|
747
|
-
const closeParenthesisToken = this.token(
|
|
596
|
+
const openParenthesisToken = this.token(47 /* OpenParenthesis */);
|
|
597
|
+
const closeParenthesisToken = this.token(23 /* CloseParenthesis */);
|
|
748
598
|
return new ParenthesizedTypeSpecifier(openParenthesisToken, typeSpecifier, closeParenthesisToken, void 0);
|
|
749
599
|
}
|
|
750
600
|
static anonymousStructuredTypeSpecifier(body) {
|
|
@@ -757,14 +607,14 @@ var SyntaxFactory = class {
|
|
|
757
607
|
return new AnonymousTypeSpecifier(new AnonymousVariantTypeDeclaration(body, void 0), void 0);
|
|
758
608
|
}
|
|
759
609
|
static typeParameterDeclaration(name, constraint, defaultType) {
|
|
760
|
-
const nameIdentifier = this.
|
|
610
|
+
const nameIdentifier = this.identifier(name);
|
|
761
611
|
let colonToken;
|
|
762
612
|
if (constraint !== void 0) {
|
|
763
|
-
colonToken = this.token(
|
|
613
|
+
colonToken = this.token(25 /* Colon */);
|
|
764
614
|
}
|
|
765
615
|
let equalsToken;
|
|
766
616
|
if (defaultType !== void 0) {
|
|
767
|
-
equalsToken = this.token(
|
|
617
|
+
equalsToken = this.token(64 /* Equals */);
|
|
768
618
|
}
|
|
769
619
|
return new TypeParameterDeclaration(
|
|
770
620
|
nameIdentifier,
|
|
@@ -777,19 +627,19 @@ var SyntaxFactory = class {
|
|
|
777
627
|
}
|
|
778
628
|
static parameterDeclaration(tags, name, typeSpecifier, defaultValue) {
|
|
779
629
|
const tagList = new TagList(tags, void 0);
|
|
780
|
-
const nameIdentifier = this.
|
|
630
|
+
const nameIdentifier = this.identifier(name);
|
|
781
631
|
const typeAnnotation = this.createTypeAnnotation(typeSpecifier);
|
|
782
632
|
let equalsToken;
|
|
783
633
|
if (defaultValue !== void 0) {
|
|
784
|
-
equalsToken = this.token(
|
|
634
|
+
equalsToken = this.token(64 /* Equals */);
|
|
785
635
|
}
|
|
786
636
|
return new ParameterDeclaration(tagList, nameIdentifier, typeAnnotation, equalsToken, defaultValue, void 0);
|
|
787
637
|
}
|
|
788
638
|
static tag(name, typeArguments, args) {
|
|
789
|
-
const hashSignToken = this.token(
|
|
790
|
-
const qualifiedNameIdentifiers = typeof name === "string" ? [this.
|
|
639
|
+
const hashSignToken = this.token(36 /* HashSign */);
|
|
640
|
+
const qualifiedNameIdentifiers = typeof name === "string" || name instanceof Token ? [this.identifier(name)] : name.map((s) => this.identifier(s));
|
|
791
641
|
const qualifiedName = new QualifiedName(
|
|
792
|
-
this.
|
|
642
|
+
this.createSeparatedElements(qualifiedNameIdentifiers, 28 /* Dot */),
|
|
793
643
|
void 0
|
|
794
644
|
);
|
|
795
645
|
const typeArgumentClause = typeArguments !== void 0 ? this.typeArgumentClause(typeArguments) : void 0;
|
|
@@ -797,12 +647,12 @@ var SyntaxFactory = class {
|
|
|
797
647
|
let argumentList;
|
|
798
648
|
let closeParenthesisToken;
|
|
799
649
|
if (args !== void 0) {
|
|
800
|
-
openParenthesisToken = this.token(
|
|
650
|
+
openParenthesisToken = this.token(47 /* OpenParenthesis */);
|
|
801
651
|
argumentList = new ArgumentList(
|
|
802
|
-
this.
|
|
652
|
+
this.createSeparatedElements(args, 26 /* Comma */),
|
|
803
653
|
void 0
|
|
804
654
|
);
|
|
805
|
-
closeParenthesisToken = this.token(
|
|
655
|
+
closeParenthesisToken = this.token(23 /* CloseParenthesis */);
|
|
806
656
|
}
|
|
807
657
|
return new Tag(
|
|
808
658
|
hashSignToken,
|
|
@@ -815,44 +665,44 @@ var SyntaxFactory = class {
|
|
|
815
665
|
);
|
|
816
666
|
}
|
|
817
667
|
static modifier(value, level) {
|
|
818
|
-
const valueKeyword = this.
|
|
668
|
+
const valueKeyword = this.createKeyword(value, 1 /* Missing */ | 12296 /* SingularNeuAdjective */);
|
|
819
669
|
let openParenthesisToken;
|
|
820
670
|
let levelKeyword;
|
|
821
671
|
let closeParenthesisToken;
|
|
822
672
|
if (level !== void 0) {
|
|
823
|
-
openParenthesisToken = this.token(
|
|
673
|
+
openParenthesisToken = this.token(47 /* OpenParenthesis */);
|
|
824
674
|
levelKeyword = this.keyword(level);
|
|
825
|
-
closeParenthesisToken = this.token(
|
|
675
|
+
closeParenthesisToken = this.token(23 /* CloseParenthesis */);
|
|
826
676
|
}
|
|
827
677
|
return new Modifier(valueKeyword, openParenthesisToken, levelKeyword, closeParenthesisToken, void 0);
|
|
828
678
|
}
|
|
829
679
|
static typeArgumentClause(typeArguments) {
|
|
830
|
-
const lessThanToken = this.token(
|
|
680
|
+
const lessThanToken = this.token(37 /* LessThan */);
|
|
831
681
|
const typeArgumentList = new TypeArgumentList(
|
|
832
|
-
this.
|
|
682
|
+
this.createSeparatedElements(typeArguments, 26 /* Comma */),
|
|
833
683
|
void 0
|
|
834
684
|
);
|
|
835
|
-
const greaterThanToken = this.token(
|
|
685
|
+
const greaterThanToken = this.token(34 /* GreaterThan */);
|
|
836
686
|
return new TypeArgumentClause(lessThanToken, typeArgumentList, greaterThanToken, void 0);
|
|
837
687
|
}
|
|
838
688
|
static typeAnnotation(typeSpecifier) {
|
|
839
|
-
return new TypeAnnotation(this.token(
|
|
689
|
+
return new TypeAnnotation(this.token(25 /* Colon */), typeSpecifier, void 0);
|
|
840
690
|
}
|
|
841
691
|
static statementBlock(statements) {
|
|
842
|
-
const openBraceToken = this.token(
|
|
692
|
+
const openBraceToken = this.token(46 /* OpenBrace */);
|
|
843
693
|
const statementList = new StatementList(statements, void 0);
|
|
844
|
-
const closeBraceToken = this.token(
|
|
694
|
+
const closeBraceToken = this.token(22 /* CloseBrace */);
|
|
845
695
|
return new StatementBlock(openBraceToken, statementList, closeBraceToken, void 0);
|
|
846
696
|
}
|
|
847
697
|
static functionExpressionBlock(expression) {
|
|
848
|
-
const openBraceToken = this.token(
|
|
849
|
-
const closeBraceToken = this.token(
|
|
698
|
+
const openBraceToken = this.token(46 /* OpenBrace */);
|
|
699
|
+
const closeBraceToken = this.token(22 /* CloseBrace */);
|
|
850
700
|
return new FunctionBlock(openBraceToken, expression, closeBraceToken, void 0);
|
|
851
701
|
}
|
|
852
702
|
static functionStatementBlock(statements) {
|
|
853
|
-
const openBraceToken = this.token(
|
|
703
|
+
const openBraceToken = this.token(46 /* OpenBrace */);
|
|
854
704
|
const statementList = new StatementList(statements, void 0);
|
|
855
|
-
const closeBraceToken = this.token(
|
|
705
|
+
const closeBraceToken = this.token(22 /* CloseBrace */);
|
|
856
706
|
return new FunctionBlock(openBraceToken, statementList, closeBraceToken, void 0);
|
|
857
707
|
}
|
|
858
708
|
static nullLiteral() {
|
|
@@ -865,9 +715,9 @@ var SyntaxFactory = class {
|
|
|
865
715
|
const tagList = new TagList([], void 0);
|
|
866
716
|
const modifierList = new ModifierList([], void 0);
|
|
867
717
|
const translationsKeyword = this.keyword(55 /* Translations */);
|
|
868
|
-
const openBraceToken = this.token(
|
|
718
|
+
const openBraceToken = this.token(46 /* OpenBrace */);
|
|
869
719
|
const translationList = new TopLevelTranslationList(translations, void 0);
|
|
870
|
-
const closeBraceToken = this.token(
|
|
720
|
+
const closeBraceToken = this.token(22 /* CloseBrace */);
|
|
871
721
|
return new TranslationsDeclaration(
|
|
872
722
|
tagList,
|
|
873
723
|
modifierList,
|
|
@@ -879,9 +729,9 @@ var SyntaxFactory = class {
|
|
|
879
729
|
);
|
|
880
730
|
}
|
|
881
731
|
static packageVariableTranslation(sourceName, translatedName) {
|
|
882
|
-
const sourceNameIdentifier = this.
|
|
883
|
-
const minusGreaterThanToken = this.token(
|
|
884
|
-
const translatedNameIdentifier = this.
|
|
732
|
+
const sourceNameIdentifier = this.identifier(sourceName);
|
|
733
|
+
const minusGreaterThanToken = this.token(45 /* MinusGreaterThan */);
|
|
734
|
+
const translatedNameIdentifier = this.identifier(translatedName);
|
|
885
735
|
return new PackageVariableTranslationDeclaration(
|
|
886
736
|
sourceNameIdentifier,
|
|
887
737
|
minusGreaterThanToken,
|
|
@@ -891,11 +741,11 @@ var SyntaxFactory = class {
|
|
|
891
741
|
}
|
|
892
742
|
static packageFunctionTranslation(sourceName, sourceTypeParameters, sourceParameters, translatedName, translatedTypeParameters, translatedParameters) {
|
|
893
743
|
const functionKeyword = this.keyword(12 /* Function */);
|
|
894
|
-
const sourceNameIdentifier = this.
|
|
744
|
+
const sourceNameIdentifier = this.identifier(sourceName);
|
|
895
745
|
const sourceTypeParameterClause = this.createTranslationTypeParameterClause(sourceTypeParameters);
|
|
896
746
|
const sourceParameterClause = this.translationParameterClause(sourceParameters);
|
|
897
|
-
const minusGreaterThanToken = this.token(
|
|
898
|
-
const translatedNameIdentifier = this.
|
|
747
|
+
const minusGreaterThanToken = this.token(45 /* MinusGreaterThan */);
|
|
748
|
+
const translatedNameIdentifier = this.identifier(translatedName);
|
|
899
749
|
const translatedTypeParameterClause = this.createTranslationTypeParameterClause(translatedTypeParameters);
|
|
900
750
|
const translatedParameterClause = this.translationParameterClause(translatedParameters);
|
|
901
751
|
return new PackageFunctionTranslationDeclaration(
|
|
@@ -912,18 +762,18 @@ var SyntaxFactory = class {
|
|
|
912
762
|
}
|
|
913
763
|
static typeTranslation(sourceName, sourceTypeParameters, translatedName, translatedTypeParameters, members) {
|
|
914
764
|
const typeKeyword = this.keyword(16 /* Type */);
|
|
915
|
-
const sourceNameIdentifier = this.
|
|
765
|
+
const sourceNameIdentifier = this.identifier(sourceName);
|
|
916
766
|
const sourceTypeParameterClause = this.createTranslationTypeParameterClause(sourceTypeParameters);
|
|
917
|
-
const minusGreaterThanToken = this.token(
|
|
918
|
-
const translatedNameIdentifier = this.
|
|
767
|
+
const minusGreaterThanToken = this.token(45 /* MinusGreaterThan */);
|
|
768
|
+
const translatedNameIdentifier = this.identifier(translatedName);
|
|
919
769
|
const translatedTypeParameterClause = this.createTranslationTypeParameterClause(translatedTypeParameters);
|
|
920
770
|
let openBraceToken;
|
|
921
771
|
let memberList;
|
|
922
772
|
let closeBraceToken;
|
|
923
773
|
if (members !== void 0) {
|
|
924
|
-
openBraceToken = this.token(
|
|
774
|
+
openBraceToken = this.token(46 /* OpenBrace */);
|
|
925
775
|
memberList = new TypeMemberTranslationList(members, void 0);
|
|
926
|
-
closeBraceToken = this.token(
|
|
776
|
+
closeBraceToken = this.token(22 /* CloseBrace */);
|
|
927
777
|
}
|
|
928
778
|
return new TypeTranslationDeclaration(
|
|
929
779
|
typeKeyword,
|
|
@@ -940,11 +790,11 @@ var SyntaxFactory = class {
|
|
|
940
790
|
}
|
|
941
791
|
static functionTypeTranslation(sourceName, sourceTypeParameters, sourceParameters, translatedName, translatedTypeParameters, translatedParameters) {
|
|
942
792
|
const typeKeyword = this.keyword(16 /* Type */);
|
|
943
|
-
const sourceNameIdentifier = this.
|
|
793
|
+
const sourceNameIdentifier = this.identifier(sourceName);
|
|
944
794
|
const sourceTypeParameterClause = this.createTranslationTypeParameterClause(sourceTypeParameters);
|
|
945
795
|
const sourceParameterClause = this.translationParameterClause(sourceParameters);
|
|
946
|
-
const minusGreaterThanToken = this.token(
|
|
947
|
-
const translatedNameIdentifier = this.
|
|
796
|
+
const minusGreaterThanToken = this.token(45 /* MinusGreaterThan */);
|
|
797
|
+
const translatedNameIdentifier = this.identifier(translatedName);
|
|
948
798
|
const translatedTypeParameterClause = this.createTranslationTypeParameterClause(translatedTypeParameters);
|
|
949
799
|
const translatedParameterClause = this.translationParameterClause(translatedParameters);
|
|
950
800
|
return new FunctionTypeTranslationDeclaration(
|
|
@@ -960,9 +810,9 @@ var SyntaxFactory = class {
|
|
|
960
810
|
);
|
|
961
811
|
}
|
|
962
812
|
static fieldOrVariantTranslation(sourceName, translatedName) {
|
|
963
|
-
const sourceNameIdentifier = this.
|
|
964
|
-
const minusGreaterThanToken = this.token(
|
|
965
|
-
const translatedNameIdentifier = this.
|
|
813
|
+
const sourceNameIdentifier = this.identifier(sourceName);
|
|
814
|
+
const minusGreaterThanToken = this.token(45 /* MinusGreaterThan */);
|
|
815
|
+
const translatedNameIdentifier = this.identifier(translatedName);
|
|
966
816
|
return new FieldOrVariantTranslation(
|
|
967
817
|
sourceNameIdentifier,
|
|
968
818
|
minusGreaterThanToken,
|
|
@@ -972,11 +822,11 @@ var SyntaxFactory = class {
|
|
|
972
822
|
}
|
|
973
823
|
static methodTranslation(sourceName, sourceTypeParameters, sourceParameters, translatedName, translatedTypeParameters, translatedParameters) {
|
|
974
824
|
const functionKeyword = this.keyword(12 /* Function */);
|
|
975
|
-
const sourceNameIdentifier = this.
|
|
825
|
+
const sourceNameIdentifier = this.identifier(sourceName);
|
|
976
826
|
const sourceTypeParameterClause = this.createTranslationTypeParameterClause(sourceTypeParameters);
|
|
977
827
|
const sourceParameterClause = this.translationParameterClause(sourceParameters);
|
|
978
|
-
const minusGreaterThanToken = this.token(
|
|
979
|
-
const translatedNameIdentifier = this.
|
|
828
|
+
const minusGreaterThanToken = this.token(45 /* MinusGreaterThan */);
|
|
829
|
+
const translatedNameIdentifier = this.identifier(translatedName);
|
|
980
830
|
const translatedTypeParameterClause = this.createTranslationTypeParameterClause(translatedTypeParameters);
|
|
981
831
|
const translatedParameterClause = this.translationParameterClause(translatedParameters);
|
|
982
832
|
return new MethodTranslation(
|
|
@@ -994,7 +844,7 @@ var SyntaxFactory = class {
|
|
|
994
844
|
static constructorTranslation(sourceParameters, translatedParameters) {
|
|
995
845
|
const creationKeyword = this.keyword(31 /* Creation */);
|
|
996
846
|
const sourceParameterClause = this.translationParameterClause(sourceParameters);
|
|
997
|
-
const minusGreaterThanToken = this.token(
|
|
847
|
+
const minusGreaterThanToken = this.token(45 /* MinusGreaterThan */);
|
|
998
848
|
const translatedParameterClause = this.translationParameterClause(translatedParameters);
|
|
999
849
|
return new ConstructorTranslation(
|
|
1000
850
|
creationKeyword,
|
|
@@ -1006,7 +856,7 @@ var SyntaxFactory = class {
|
|
|
1006
856
|
}
|
|
1007
857
|
static indexerTranslation(sourceParameters, translatedParameters) {
|
|
1008
858
|
const sourceParameterClause = this.indexParameterTranslationClause(sourceParameters);
|
|
1009
|
-
const minusGreaterThanToken = this.token(
|
|
859
|
+
const minusGreaterThanToken = this.token(45 /* MinusGreaterThan */);
|
|
1010
860
|
const translatedParameterClause = this.indexParameterTranslationClause(translatedParameters);
|
|
1011
861
|
return new IndexerTranslation(
|
|
1012
862
|
sourceParameterClause,
|
|
@@ -1016,21 +866,21 @@ var SyntaxFactory = class {
|
|
|
1016
866
|
);
|
|
1017
867
|
}
|
|
1018
868
|
static translationParameterClause(parameters) {
|
|
1019
|
-
const openParenthesisToken = this.token(
|
|
869
|
+
const openParenthesisToken = this.token(47 /* OpenParenthesis */);
|
|
1020
870
|
const parameterList = new TranslationParameterList(
|
|
1021
|
-
this.
|
|
871
|
+
this.createSeparatedElements(parameters.map((p) => this.identifier(p)), 26 /* Comma */),
|
|
1022
872
|
void 0
|
|
1023
873
|
);
|
|
1024
|
-
const closeParenthesisToken = this.token(
|
|
874
|
+
const closeParenthesisToken = this.token(23 /* CloseParenthesis */);
|
|
1025
875
|
return new TranslationParameterClause(openParenthesisToken, parameterList, closeParenthesisToken, void 0);
|
|
1026
876
|
}
|
|
1027
877
|
static indexParameterTranslationClause(parameters) {
|
|
1028
|
-
const openSquareBracketToken = this.token(
|
|
878
|
+
const openSquareBracketToken = this.token(48 /* OpenSquareBracket */);
|
|
1029
879
|
const parameterList = new TranslationParameterList(
|
|
1030
|
-
this.
|
|
880
|
+
this.createSeparatedElements(parameters.map((p) => this.identifier(p)), 26 /* Comma */),
|
|
1031
881
|
void 0
|
|
1032
882
|
);
|
|
1033
|
-
const closeSquareBracketToken = this.token(
|
|
883
|
+
const closeSquareBracketToken = this.token(24 /* CloseSquareBracket */);
|
|
1034
884
|
return new IndexParameterTranslationClause(
|
|
1035
885
|
openSquareBracketToken,
|
|
1036
886
|
parameterList,
|
|
@@ -1038,21 +888,33 @@ var SyntaxFactory = class {
|
|
|
1038
888
|
void 0
|
|
1039
889
|
);
|
|
1040
890
|
}
|
|
891
|
+
static identifier(value) {
|
|
892
|
+
if (typeof value === "string") {
|
|
893
|
+
return this.createToken(9 /* Identifier */, value, 0 /* None */);
|
|
894
|
+
}
|
|
895
|
+
return value;
|
|
896
|
+
}
|
|
1041
897
|
static token(kind, value) {
|
|
1042
898
|
const flags = value === void 0 ? 1 /* Missing */ : 0 /* None */;
|
|
1043
|
-
return
|
|
899
|
+
return this.createToken(kind, value ?? "", flags);
|
|
1044
900
|
}
|
|
1045
901
|
static keyword(kind) {
|
|
1046
|
-
return
|
|
902
|
+
return this.createKeyword(kind, 1 /* Missing */);
|
|
903
|
+
}
|
|
904
|
+
static createToken(kind, value, flags) {
|
|
905
|
+
return new Token(kind, value, [], [], flags, void 0, void 0);
|
|
906
|
+
}
|
|
907
|
+
static createKeyword(kind, flags) {
|
|
908
|
+
return new Keyword([], kind, flags, void 0);
|
|
1047
909
|
}
|
|
1048
910
|
static createTypeParameterClause(typeParameters) {
|
|
1049
911
|
if (typeParameters === void 0) {
|
|
1050
912
|
return void 0;
|
|
1051
913
|
}
|
|
1052
914
|
return new TypeParameterClause(
|
|
1053
|
-
this.token(
|
|
1054
|
-
new TypeParameterList(this.
|
|
1055
|
-
this.token(
|
|
915
|
+
this.token(37 /* LessThan */),
|
|
916
|
+
new TypeParameterList(this.createSeparatedElements(typeParameters, 26 /* Comma */), void 0),
|
|
917
|
+
this.token(34 /* GreaterThan */),
|
|
1056
918
|
void 0
|
|
1057
919
|
);
|
|
1058
920
|
}
|
|
@@ -1061,12 +923,12 @@ var SyntaxFactory = class {
|
|
|
1061
923
|
return void 0;
|
|
1062
924
|
}
|
|
1063
925
|
return new TranslationTypeParameterClause(
|
|
1064
|
-
this.token(
|
|
926
|
+
this.token(37 /* LessThan */),
|
|
1065
927
|
new TranslationTypeParameterList(
|
|
1066
|
-
this.
|
|
928
|
+
this.createSeparatedElements(typeParameters.map((p) => this.identifier(p)), 26 /* Comma */),
|
|
1067
929
|
void 0
|
|
1068
930
|
),
|
|
1069
|
-
this.token(
|
|
931
|
+
this.token(34 /* GreaterThan */),
|
|
1070
932
|
void 0
|
|
1071
933
|
);
|
|
1072
934
|
}
|
|
@@ -1074,19 +936,13 @@ var SyntaxFactory = class {
|
|
|
1074
936
|
if (typeSpecifier === void 0) {
|
|
1075
937
|
return void 0;
|
|
1076
938
|
}
|
|
1077
|
-
return new TypeAnnotation(this.token(
|
|
1078
|
-
}
|
|
1079
|
-
static createIdentifier(value) {
|
|
1080
|
-
if (typeof value === "string") {
|
|
1081
|
-
return new Token(9 /* Identifier */, value, [], [], 0 /* None */, void 0, void 0);
|
|
1082
|
-
}
|
|
1083
|
-
return value;
|
|
939
|
+
return new TypeAnnotation(this.token(25 /* Colon */), typeSpecifier, void 0);
|
|
1084
940
|
}
|
|
1085
|
-
static
|
|
941
|
+
static createSeparatedElements(elements, separator) {
|
|
1086
942
|
const result = new Array();
|
|
1087
943
|
for (let i = 0; i < elements.length; i++) {
|
|
1088
944
|
if (i > 0) {
|
|
1089
|
-
const token = this.token(
|
|
945
|
+
const token = this.token(separator);
|
|
1090
946
|
result.push(token);
|
|
1091
947
|
}
|
|
1092
948
|
result.push(elements[i]);
|
|
@@ -1104,6 +960,7 @@ var SyntaxToCode = class _SyntaxToCode {
|
|
|
1104
960
|
this.node = node;
|
|
1105
961
|
this.newLine = options7?.newLine ?? "\n";
|
|
1106
962
|
this.indentationStep = options7?.indentationStep ?? " ";
|
|
963
|
+
this.modifiersOnSeparateLine = options7?.modifiersOnSeparateLine ?? false;
|
|
1107
964
|
this.keywordsLocale = options7?.keywordsLocale ?? 1 /* Ru */;
|
|
1108
965
|
this.keywordsDialect = options7?.keywordsDialect ?? DefaultDialect;
|
|
1109
966
|
this.singleWordKeywordValues = Query.from(getOrCreateKeywordDictionary(this.keywordsLocale, this.keywordsDialect).values()).mapAndFilter((k) => k.keywordKind !== 0 /* Unknown */ ? k.value : void 0).uniqueToSet();
|
|
@@ -1270,7 +1127,7 @@ var SyntaxToCode = class _SyntaxToCode {
|
|
|
1270
1127
|
}
|
|
1271
1128
|
writePackageMemberGroupDeclaration(node) {
|
|
1272
1129
|
this.writeDeclarationTags(node.tagList);
|
|
1273
|
-
this.writeDeclarationModifiers(node.modifierList);
|
|
1130
|
+
this.writeDeclarationModifiers(node.modifierList, true);
|
|
1274
1131
|
this.writeToken(node.openBraceToken);
|
|
1275
1132
|
this.writeNewLineOrWhitespace();
|
|
1276
1133
|
if (node.declarationList.elements.length > 0) {
|
|
@@ -1477,7 +1334,7 @@ var SyntaxToCode = class _SyntaxToCode {
|
|
|
1477
1334
|
}
|
|
1478
1335
|
writeTypeMemberGroupDeclaration(node) {
|
|
1479
1336
|
this.writeDeclarationTags(node.tagList);
|
|
1480
|
-
this.writeDeclarationModifiers(node.modifierList);
|
|
1337
|
+
this.writeDeclarationModifiers(node.modifierList, true);
|
|
1481
1338
|
this.writeTypeMemberDeclarationBlock(node.memberBlock, false);
|
|
1482
1339
|
}
|
|
1483
1340
|
writeTypeParameterClause(node) {
|
|
@@ -1543,12 +1400,16 @@ var SyntaxToCode = class _SyntaxToCode {
|
|
|
1543
1400
|
this.writeToken(node.closeParenthesisToken);
|
|
1544
1401
|
}
|
|
1545
1402
|
}
|
|
1546
|
-
writeDeclarationModifiers(modifierList) {
|
|
1403
|
+
writeDeclarationModifiers(modifierList, isGroupDeclarationModifiers = false) {
|
|
1547
1404
|
if (modifierList.modifiers.length > 0) {
|
|
1548
1405
|
const modifiers = Array.from(modifierList.modifiers);
|
|
1549
1406
|
modifiers.sort((m1, m2) => modifierSortOrder[m1.value.keywordKind] - modifierSortOrder[m2.value.keywordKind]);
|
|
1550
1407
|
this.writeWhitespaceSeparatedList(modifiers, (n) => this.writeModifier(n));
|
|
1551
|
-
this.
|
|
1408
|
+
if (isGroupDeclarationModifiers === true || this.modifiersOnSeparateLine) {
|
|
1409
|
+
this.writeNewLineOrWhitespace();
|
|
1410
|
+
} else {
|
|
1411
|
+
this.writeWhitespace();
|
|
1412
|
+
}
|
|
1552
1413
|
}
|
|
1553
1414
|
}
|
|
1554
1415
|
writeModifier(node) {
|
|
@@ -1925,7 +1786,7 @@ var SyntaxToCode = class _SyntaxToCode {
|
|
|
1925
1786
|
let isPreviousElementSemicolon = false;
|
|
1926
1787
|
for (let i = 0; i < elements.length; i++) {
|
|
1927
1788
|
const element = elements[i];
|
|
1928
|
-
if (element.kind === 0 /* Token */ && element.tokenKind ===
|
|
1789
|
+
if (element.kind === 0 /* Token */ && element.tokenKind === 58 /* Semicolon */) {
|
|
1929
1790
|
this.writeToken(element);
|
|
1930
1791
|
isPreviousElementSemicolon = true;
|
|
1931
1792
|
} else {
|
|
@@ -1943,7 +1804,7 @@ var SyntaxToCode = class _SyntaxToCode {
|
|
|
1943
1804
|
writeCommaSeparatedList(elements, writeNonCommaElement) {
|
|
1944
1805
|
for (let i = 0; i < elements.length; i++) {
|
|
1945
1806
|
const element = elements[i];
|
|
1946
|
-
if (element.kind === 0 /* Token */ && element.tokenKind ===
|
|
1807
|
+
if (element.kind === 0 /* Token */ && element.tokenKind === 26 /* Comma */) {
|
|
1947
1808
|
this.writeToken(element);
|
|
1948
1809
|
} else {
|
|
1949
1810
|
if (i > 0) {
|
|
@@ -1955,10 +1816,17 @@ var SyntaxToCode = class _SyntaxToCode {
|
|
|
1955
1816
|
}
|
|
1956
1817
|
writeKeyword(keyword) {
|
|
1957
1818
|
if (keyword.isMissing) {
|
|
1958
|
-
|
|
1819
|
+
let preferredFlags;
|
|
1820
|
+
if (keyword.parent.kind === 154 /* Modifier */) {
|
|
1821
|
+
preferredFlags = this.getModifierPreferredFlags(keyword.parent);
|
|
1822
|
+
} else {
|
|
1823
|
+
preferredFlags = 12290 /* SingularNeuNoun */;
|
|
1824
|
+
}
|
|
1825
|
+
this.writeCode(LocalizationHelper.localizeKeywordAndTakeBest(
|
|
1959
1826
|
keyword.keywordKind,
|
|
1960
1827
|
this.keywordsLocale,
|
|
1961
|
-
this.keywordsDialect
|
|
1828
|
+
this.keywordsDialect,
|
|
1829
|
+
preferredFlags
|
|
1962
1830
|
));
|
|
1963
1831
|
} else {
|
|
1964
1832
|
for (let i = 0; i < keyword.tokens.length; i++) {
|
|
@@ -1969,6 +1837,45 @@ var SyntaxToCode = class _SyntaxToCode {
|
|
|
1969
1837
|
}
|
|
1970
1838
|
}
|
|
1971
1839
|
}
|
|
1840
|
+
getModifierPreferredFlags(modifier) {
|
|
1841
|
+
const modifierTarget = modifier.parent.parent;
|
|
1842
|
+
switch (modifierTarget.kind) {
|
|
1843
|
+
case 25 /* PackageFunctionDeclaration */:
|
|
1844
|
+
case 35 /* PackageVariableSetterDeclaration */:
|
|
1845
|
+
case 54 /* FieldSetterDeclaration */:
|
|
1846
|
+
case 46 /* IndexedElementSetterDeclaration */:
|
|
1847
|
+
case 49 /* DereferencedVariableSetterDeclaration */:
|
|
1848
|
+
case 50 /* MethodDeclaration */:
|
|
1849
|
+
case 51 /* OperatorDeclaration */:
|
|
1850
|
+
case 24 /* PackageEntryPointDeclaration */:
|
|
1851
|
+
return 10242 /* SingularFemNoun */;
|
|
1852
|
+
case 20 /* PackageAliasTypeDeclaration */:
|
|
1853
|
+
case 31 /* PackageStructuredTypeDeclaration */:
|
|
1854
|
+
case 36 /* PackageVariantTypeDeclaration */:
|
|
1855
|
+
case 26 /* PackageFunctionTypeDeclaration */:
|
|
1856
|
+
return 9218 /* SingularMasNoun */;
|
|
1857
|
+
case 33 /* PackageVariableDeclaration */:
|
|
1858
|
+
case 34 /* PackageVariableGetterDeclaration */:
|
|
1859
|
+
case 38 /* TypeExtensionDeclaration */:
|
|
1860
|
+
case 23 /* PackageConstructorDeclaration */:
|
|
1861
|
+
case 43 /* ConstructorDeclaration */:
|
|
1862
|
+
case 44 /* DestructorDeclaration */:
|
|
1863
|
+
case 45 /* IndexedElementGetterDeclaration */:
|
|
1864
|
+
case 48 /* DereferencedVariableGetterDeclaration */:
|
|
1865
|
+
case 52 /* FieldDeclaration */:
|
|
1866
|
+
case 53 /* FieldGetterDeclaration */:
|
|
1867
|
+
case 147 /* VariantValueDeclaration */:
|
|
1868
|
+
case 41 /* MissingPackageMemberDeclaration */:
|
|
1869
|
+
case 55 /* MissingTypeMemberDeclaration */:
|
|
1870
|
+
return 12290 /* SingularNeuNoun */;
|
|
1871
|
+
case 42 /* TypeMemberGroupDeclaration */:
|
|
1872
|
+
case 22 /* PackageMemberGroupDeclaration */:
|
|
1873
|
+
case 123 /* TranslationsDeclaration */:
|
|
1874
|
+
return 16386 /* PluralNoun */;
|
|
1875
|
+
default:
|
|
1876
|
+
Debug.never(modifierTarget);
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1972
1879
|
writeToken(token) {
|
|
1973
1880
|
if ((token.flags & 1 /* Missing */) !== 0) {
|
|
1974
1881
|
this.writeCode(tokenKindValues[token.tokenKind]);
|
|
@@ -2356,6 +2263,36 @@ function getTriviaAtOffset(sourceFile, offset) {
|
|
|
2356
2263
|
return token?.getTriviaAt(offset);
|
|
2357
2264
|
}
|
|
2358
2265
|
|
|
2266
|
+
// source/services/Types.ts
|
|
2267
|
+
import * as ls2 from "vscode-languageserver";
|
|
2268
|
+
var SourceLocation = class {
|
|
2269
|
+
constructor(sourceFile, range) {
|
|
2270
|
+
this.sourceFile = sourceFile;
|
|
2271
|
+
this.range = range;
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
function isCompletionItemData(value) {
|
|
2275
|
+
Debug.cast(value);
|
|
2276
|
+
return value instanceof Object && typeof value.cacheId === "number" && typeof value.indexInCache === "number";
|
|
2277
|
+
}
|
|
2278
|
+
function isCodeActionData(value) {
|
|
2279
|
+
Debug.cast(value);
|
|
2280
|
+
return value instanceof Object && typeof value.name === "string" && value.location instanceof Object && ls2.DocumentUri.is(value.location.uri) && ls2.Position.is(value.location.position) && "data" in value;
|
|
2281
|
+
}
|
|
2282
|
+
var SourceFileEdit = class {
|
|
2283
|
+
constructor(sourceFile, range, text) {
|
|
2284
|
+
this.sourceFile = sourceFile;
|
|
2285
|
+
this.range = range;
|
|
2286
|
+
this.text = text;
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
var NodeLocation = class {
|
|
2290
|
+
constructor(sourceFile, path) {
|
|
2291
|
+
this.sourceFile = sourceFile;
|
|
2292
|
+
this.path = path;
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
|
|
2359
2296
|
// source/services/TranslationsGenerationService.ts
|
|
2360
2297
|
var TranslationsGenerationService = class {
|
|
2361
2298
|
generateMissingTranslations(analyzer, sourceFile, offset, onlyTypeMembers) {
|
|
@@ -3263,18 +3200,18 @@ var CompletionService = class {
|
|
|
3263
3200
|
if (tokenOrKeyword.isKeyword(18 /* Import */) && tokenOrKeyword.parent.kind === 5 /* SinglePackageImportDirective */) {
|
|
3264
3201
|
return new PackageImportCompletionContext([], void 0);
|
|
3265
3202
|
}
|
|
3266
|
-
if (tokenOrKeyword.isToken(
|
|
3203
|
+
if (tokenOrKeyword.isToken(64 /* Equals */) && tokenOrKeyword.parent.kind === 8 /* PackageImport */) {
|
|
3267
3204
|
return new PackageImportCompletionContext([], void 0);
|
|
3268
3205
|
}
|
|
3269
|
-
if (tokenOrKeyword.isToken(
|
|
3206
|
+
if (tokenOrKeyword.isToken(28 /* Dot */) && tokenOrKeyword.parent.kind === 9 /* PackageName */) {
|
|
3270
3207
|
const packageImport = tokenOrKeyword.parent.parent;
|
|
3271
3208
|
const precedingSegmentNames = packageImport.packageName.segments.takeWhile((s) => s.rangeWithTrivia.start < tokenOrKeyword.value.rangeWithTrivia.start).map((p) => this.analyzer.createNameFromIdentifier(p)).toArray();
|
|
3272
3209
|
return new PackageImportCompletionContext(precedingSegmentNames, void 0);
|
|
3273
3210
|
}
|
|
3274
|
-
if (tokenOrKeyword.isToken(
|
|
3211
|
+
if (tokenOrKeyword.isToken(46 /* OpenBrace */) && tokenOrKeyword.parent.kind === 6 /* PackageGroupImportDirective */ || this.tokenOrKeywordIsPackageImportListChild(tokenOrKeyword)) {
|
|
3275
3212
|
return new PackageImportCompletionContext([], void 0);
|
|
3276
3213
|
}
|
|
3277
|
-
if (tokenOrKeyword.isToken(
|
|
3214
|
+
if (tokenOrKeyword.isToken(28 /* Dot */) && tokenOrKeyword.parent.kind === 76 /* MemberAccessExpression */) {
|
|
3278
3215
|
const memberAccess = tokenOrKeyword.parent;
|
|
3279
3216
|
{
|
|
3280
3217
|
const packageTreeNode = this.analyzer.getDenotedPackageNameTreeNode(memberAccess.expression);
|
|
@@ -3304,7 +3241,7 @@ var CompletionService = class {
|
|
|
3304
3241
|
const hidingMatcher = semanticContext.getHidingMatcher();
|
|
3305
3242
|
return new TypeMemberCompletionContext(type, isStaticAccess, hidingMatcher, semanticContext);
|
|
3306
3243
|
}
|
|
3307
|
-
if (tokenOrKeyword.isToken(
|
|
3244
|
+
if (tokenOrKeyword.isToken(28 /* Dot */) && tokenOrKeyword.parent.kind === 135 /* QualifiedName */ && tokenOrKeyword.parent.parent.kind === 10 /* NamedTypeSpecifier */) {
|
|
3308
3245
|
const namedTypeSpecifier = tokenOrKeyword.parent.parent;
|
|
3309
3246
|
const resolutionResult = this.analyzer.resolveNamedTypeSpecifier(namedTypeSpecifier);
|
|
3310
3247
|
const segmentIndex = Math.floor(
|
|
@@ -3343,7 +3280,7 @@ var CompletionService = class {
|
|
|
3343
3280
|
}
|
|
3344
3281
|
return { kind: "none" };
|
|
3345
3282
|
}
|
|
3346
|
-
if (tokenOrKeyword.isToken(
|
|
3283
|
+
if (tokenOrKeyword.isToken(28 /* Dot */) && tokenOrKeyword.parent.kind === 135 /* QualifiedName */ && tokenOrKeyword.parent.parent.kind === 152 /* Tag */) {
|
|
3347
3284
|
const tag = tokenOrKeyword.parent.parent;
|
|
3348
3285
|
const resolutionResult = this.analyzer.resolveTag(tag);
|
|
3349
3286
|
const segmentIndex = Math.floor(
|
|
@@ -3704,45 +3641,45 @@ var CompletionService = class {
|
|
|
3704
3641
|
if (positionDescription.kind === "after-token-or-keyword" && positionDescription.tokenOrKeyword.isKeyword(40 /* Async */) && (positionDescription.tokenOrKeyword.parent.kind === 56 /* NestedFunctionDeclaration */ || positionDescription.tokenOrKeyword.parent.kind === 65 /* FunctionLiteral */ || positionDescription.tokenOrKeyword.parent.kind === 27 /* FunctionTypeDeclarationBody */)) {
|
|
3705
3642
|
kinds.add(12 /* Function */);
|
|
3706
3643
|
}
|
|
3707
|
-
return Query.from(kinds.values()).map((k) => LocalizationHelper.localizeKeyword(k, this.locale, this.dialect).map((v) => new KeywordCompletionItemInfo(this.completionItemInfoContext, k, v))).flatMap((i) => i).toArray();
|
|
3644
|
+
return Query.from(kinds.values()).map((k) => LocalizationHelper.localizeKeyword(k, this.locale, this.dialect).map((v) => new KeywordCompletionItemInfo(this.completionItemInfoContext, k, v.value))).flatMap((i) => i).toArray();
|
|
3708
3645
|
}
|
|
3709
3646
|
isRepeatWhileKeywordContext(positionDescription) {
|
|
3710
3647
|
if (positionDescription.kind !== "after-token-or-keyword") {
|
|
3711
3648
|
return false;
|
|
3712
3649
|
}
|
|
3713
3650
|
const tokenOrKeyword = positionDescription.tokenOrKeyword;
|
|
3714
|
-
return tokenOrKeyword.isToken(
|
|
3651
|
+
return tokenOrKeyword.isToken(22 /* CloseBrace */) && tokenOrKeyword.parent.kind === 94 /* StatementBlock */ && tokenOrKeyword.parent.parent.kind === 115 /* LoopStatement */;
|
|
3715
3652
|
}
|
|
3716
3653
|
isModifierLevelContext(positionDescription) {
|
|
3717
3654
|
if (positionDescription.kind !== "after-token-or-keyword") {
|
|
3718
3655
|
return false;
|
|
3719
3656
|
}
|
|
3720
3657
|
const tokenOrKeyword = positionDescription.tokenOrKeyword;
|
|
3721
|
-
return tokenOrKeyword.isToken(
|
|
3658
|
+
return tokenOrKeyword.isToken(47 /* OpenParenthesis */) && tokenOrKeyword.parent.kind === 154 /* Modifier */;
|
|
3722
3659
|
}
|
|
3723
3660
|
isElseOrElseIfKeywordContext(positionDescription) {
|
|
3724
3661
|
if (positionDescription.kind !== "after-token-or-keyword") {
|
|
3725
3662
|
return false;
|
|
3726
3663
|
}
|
|
3727
3664
|
const tokenOrKeyword = positionDescription.tokenOrKeyword;
|
|
3728
|
-
return tokenOrKeyword.isToken(
|
|
3665
|
+
return tokenOrKeyword.isToken(22 /* CloseBrace */) && tokenOrKeyword.parent.kind === 94 /* StatementBlock */ && (tokenOrKeyword.parent.parent.kind === 108 /* IfStatement */ && tokenOrKeyword.parent === tokenOrKeyword.parent.parent.block || tokenOrKeyword.parent.parent.kind === 110 /* ElseIfClause */);
|
|
3729
3666
|
}
|
|
3730
3667
|
isCatchKeywordContext(positionDescription) {
|
|
3731
3668
|
if (positionDescription.kind !== "after-token-or-keyword") {
|
|
3732
3669
|
return false;
|
|
3733
3670
|
}
|
|
3734
3671
|
const tokenOrKeyword = positionDescription.tokenOrKeyword;
|
|
3735
|
-
return tokenOrKeyword.isToken(
|
|
3672
|
+
return tokenOrKeyword.isToken(22 /* CloseBrace */) && tokenOrKeyword.parent.kind === 94 /* StatementBlock */ && tokenOrKeyword.parent.parent.kind === 100 /* TryStatement */;
|
|
3736
3673
|
}
|
|
3737
3674
|
isFinallyKeywordContext(positionDescription) {
|
|
3738
3675
|
if (positionDescription.kind !== "after-token-or-keyword") {
|
|
3739
3676
|
return false;
|
|
3740
3677
|
}
|
|
3741
3678
|
const tokenOrKeyword = positionDescription.tokenOrKeyword;
|
|
3742
|
-
return tokenOrKeyword.isToken(
|
|
3679
|
+
return tokenOrKeyword.isToken(22 /* CloseBrace */) && tokenOrKeyword.parent.kind === 94 /* StatementBlock */ && (tokenOrKeyword.parent.parent.kind === 100 /* TryStatement */ || tokenOrKeyword.parent.parent.kind === 101 /* CatchClause */);
|
|
3743
3680
|
}
|
|
3744
3681
|
isTypeKindCompletionContext(positionDescription) {
|
|
3745
|
-
return positionDescription.kind === "after-token-or-keyword" && positionDescription.tokenOrKeyword.isToken(
|
|
3682
|
+
return positionDescription.kind === "after-token-or-keyword" && positionDescription.tokenOrKeyword.isToken(64 /* Equals */) && NodeTypeUtils.isPackageTypeDeclaration(positionDescription.tokenOrKeyword.parent);
|
|
3746
3683
|
}
|
|
3747
3684
|
isFromKeywordContext(positionDescription) {
|
|
3748
3685
|
if (!(positionDescription.kind === "after-token-or-keyword" && positionDescription.tokenOrKeyword.isToken(9 /* Identifier */))) {
|
|
@@ -3756,7 +3693,7 @@ var CompletionService = class {
|
|
|
3756
3693
|
return false;
|
|
3757
3694
|
}
|
|
3758
3695
|
const tokenOrKeyword = positionDescription.tokenOrKeyword;
|
|
3759
|
-
if (tokenOrKeyword.isToken(
|
|
3696
|
+
if (tokenOrKeyword.isToken(22 /* CloseBrace */) && tokenOrKeyword.parent.kind === 94 /* StatementBlock */ && tokenOrKeyword.parent.parent.kind === 120 /* CaseClause */) {
|
|
3760
3697
|
return true;
|
|
3761
3698
|
}
|
|
3762
3699
|
if (syntaxContext.precedingExpression !== void 0 && syntaxContext.precedingExpression.parent.kind === 118 /* SwitchStatement */) {
|
|
@@ -4050,7 +3987,7 @@ var CompletionService = class {
|
|
|
4050
3987
|
12 /* Function */
|
|
4051
3988
|
];
|
|
4052
3989
|
result = result.chain(
|
|
4053
|
-
Query.from(keywords).map((k) => LocalizationHelper.localizeKeyword(k, this.locale, this.dialect).map((v) => new KeywordCompletionItemInfo(this.completionItemInfoContext, k, v))).flatMap((i) => i)
|
|
3990
|
+
Query.from(keywords).map((k) => LocalizationHelper.localizeKeyword(k, this.locale, this.dialect).map((v) => new KeywordCompletionItemInfo(this.completionItemInfoContext, k, v.value))).flatMap((i) => i)
|
|
4054
3991
|
);
|
|
4055
3992
|
}
|
|
4056
3993
|
return result.toArray();
|
|
@@ -4108,7 +4045,7 @@ var CompletionService = class {
|
|
|
4108
4045
|
31 /* Creation */
|
|
4109
4046
|
];
|
|
4110
4047
|
result = result.chain(
|
|
4111
|
-
Query.from(keywords).map((k) => LocalizationHelper.localizeKeyword(k, this.locale, this.dialect).map((v) => new KeywordCompletionItemInfo(this.completionItemInfoContext, k, v))).flatMap((i) => i)
|
|
4048
|
+
Query.from(keywords).map((k) => LocalizationHelper.localizeKeyword(k, this.locale, this.dialect).map((v) => new KeywordCompletionItemInfo(this.completionItemInfoContext, k, v.value))).flatMap((i) => i)
|
|
4112
4049
|
);
|
|
4113
4050
|
}
|
|
4114
4051
|
return result.toArray();
|
|
@@ -5060,7 +4997,7 @@ var SyntaxContextFactory = class {
|
|
|
5060
4997
|
if (positionDescription.kind === "after-token-or-keyword") {
|
|
5061
4998
|
isUnqualifiedTypeContext = this.isUnqualifiedTypeContext(positionDescription.tokenOrKeyword);
|
|
5062
4999
|
}
|
|
5063
|
-
const isUnqualifiedTagNameCompletionContext = positionDescription.kind === "after-token-or-keyword" && positionDescription.tokenOrKeyword.isToken(
|
|
5000
|
+
const isUnqualifiedTagNameCompletionContext = positionDescription.kind === "after-token-or-keyword" && positionDescription.tokenOrKeyword.isToken(36 /* HashSign */) && positionDescription.tokenOrKeyword.parent.kind === 152 /* Tag */;
|
|
5064
5001
|
let isTopLevelTranslationListContext;
|
|
5065
5002
|
if (positionDescription.kind === "after-token-or-keyword") {
|
|
5066
5003
|
isTopLevelTranslationListContext = this.isTopLevelTranslationListContext(positionDescription.tokenOrKeyword);
|
|
@@ -5085,7 +5022,7 @@ var SyntaxContextFactory = class {
|
|
|
5085
5022
|
);
|
|
5086
5023
|
}
|
|
5087
5024
|
static isExpressionOrStatementContext(tokenOrKeyword) {
|
|
5088
|
-
if (tokenOrKeyword.isToken(
|
|
5025
|
+
if (tokenOrKeyword.isToken(64 /* Equals */)) {
|
|
5089
5026
|
if (tokenOrKeyword.parent.kind === 92 /* AssignmentStatement */) {
|
|
5090
5027
|
const expressionRole = new ExpressionRole_other(tokenOrKeyword.parent.right);
|
|
5091
5028
|
return { isExpressionContext: { expressionRole }, isStatementContext: false };
|
|
@@ -5143,10 +5080,10 @@ var SyntaxContextFactory = class {
|
|
|
5143
5080
|
isStatementContext: false
|
|
5144
5081
|
};
|
|
5145
5082
|
}
|
|
5146
|
-
if (tokenOrKeyword.isToken(
|
|
5083
|
+
if (tokenOrKeyword.isToken(46 /* OpenBrace */) && tokenOrKeyword.parent.kind === 94 /* StatementBlock */) {
|
|
5147
5084
|
return { isExpressionContext: { expressionRole: new ExpressionRole_other(void 0) }, isStatementContext: true };
|
|
5148
5085
|
}
|
|
5149
|
-
if (tokenOrKeyword.isToken(
|
|
5086
|
+
if (tokenOrKeyword.isToken(46 /* OpenBrace */) && tokenOrKeyword.parent.kind === 95 /* FunctionBlock */) {
|
|
5150
5087
|
const block = tokenOrKeyword.parent;
|
|
5151
5088
|
if (block.expressionOrStatementList.kind !== 93 /* StatementList */ || block.expressionOrStatementList.statements.count() === 0) {
|
|
5152
5089
|
return {
|
|
@@ -5160,10 +5097,10 @@ var SyntaxContextFactory = class {
|
|
|
5160
5097
|
};
|
|
5161
5098
|
}
|
|
5162
5099
|
}
|
|
5163
|
-
if (tokenOrKeyword.isToken(
|
|
5100
|
+
if (tokenOrKeyword.isToken(58 /* Semicolon */) && tokenOrKeyword.parent.kind === 93 /* StatementList */) {
|
|
5164
5101
|
return { isExpressionContext: { expressionRole: new ExpressionRole_other(void 0) }, isStatementContext: true };
|
|
5165
5102
|
}
|
|
5166
|
-
if (tokenOrKeyword.isToken(
|
|
5103
|
+
if (tokenOrKeyword.isToken(47 /* OpenParenthesis */)) {
|
|
5167
5104
|
if (tokenOrKeyword.parent.kind === 73 /* ParenthesizedExpression */) {
|
|
5168
5105
|
const expressionRole = new ExpressionRole_other(tokenOrKeyword.parent.expression);
|
|
5169
5106
|
return { isExpressionContext: { expressionRole }, isStatementContext: false };
|
|
@@ -5192,15 +5129,15 @@ var SyntaxContextFactory = class {
|
|
|
5192
5129
|
return { isExpressionContext: { expressionRole }, isStatementContext: false };
|
|
5193
5130
|
}
|
|
5194
5131
|
}
|
|
5195
|
-
if (tokenOrKeyword.isToken(
|
|
5132
|
+
if (tokenOrKeyword.isToken(48 /* OpenSquareBracket */) && tokenOrKeyword.parent.kind === 70 /* IndexedAccessExpression */) {
|
|
5196
5133
|
const expressionRole = new ExpressionRole_argument(tokenOrKeyword.parent.argumentList, 0);
|
|
5197
5134
|
return { isExpressionContext: { expressionRole }, isStatementContext: false };
|
|
5198
5135
|
}
|
|
5199
|
-
if (tokenOrKeyword.isToken(
|
|
5136
|
+
if (tokenOrKeyword.isToken(48 /* OpenSquareBracket */) && tokenOrKeyword.parent.kind === 59 /* ArrayLiteral */) {
|
|
5200
5137
|
const expressionRole = new ExpressionRole_arrayElement(tokenOrKeyword.parent);
|
|
5201
5138
|
return { isExpressionContext: { expressionRole }, isStatementContext: false };
|
|
5202
5139
|
}
|
|
5203
|
-
if (tokenOrKeyword.isToken(
|
|
5140
|
+
if (tokenOrKeyword.isToken(26 /* Comma */)) {
|
|
5204
5141
|
if (tokenOrKeyword.parent.kind === 67 /* ArgumentList */) {
|
|
5205
5142
|
const argumentList = tokenOrKeyword.parent;
|
|
5206
5143
|
let index = 0;
|
|
@@ -5295,16 +5232,16 @@ var SyntaxContextFactory = class {
|
|
|
5295
5232
|
return { isExpressionContext: void 0, isStatementContext: false };
|
|
5296
5233
|
}
|
|
5297
5234
|
static isPackageMemberDeclarationListContext(tokenOrKeyword) {
|
|
5298
|
-
if (tokenOrKeyword.isToken(
|
|
5235
|
+
if (tokenOrKeyword.isToken(58 /* Semicolon */) && (tokenOrKeyword.parent.kind === 2 /* PackageMemberDeclarationList */ || tokenOrKeyword.parent.kind === 4 /* PackageImportDirectiveList */)) {
|
|
5299
5236
|
return true;
|
|
5300
5237
|
}
|
|
5301
|
-
if (tokenOrKeyword.isToken(
|
|
5238
|
+
if (tokenOrKeyword.isToken(22 /* CloseBrace */) && tokenOrKeyword.parent.kind === 30 /* TypeMemberDeclarationBlock */ && (tokenOrKeyword.parent.parent.kind === 38 /* TypeExtensionDeclaration */ || tokenOrKeyword.parent.parent.parent.kind === 31 /* PackageStructuredTypeDeclaration */ || tokenOrKeyword.parent.parent.parent.kind === 36 /* PackageVariantTypeDeclaration */ || tokenOrKeyword.parent.parent.parent.kind === 20 /* PackageAliasTypeDeclaration */)) {
|
|
5302
5239
|
return true;
|
|
5303
5240
|
}
|
|
5304
|
-
if (tokenOrKeyword.isToken(
|
|
5241
|
+
if (tokenOrKeyword.isToken(22 /* CloseBrace */) && (tokenOrKeyword.parent.kind === 123 /* TranslationsDeclaration */ || tokenOrKeyword.parent.kind === 22 /* PackageMemberGroupDeclaration */ || tokenOrKeyword.parent.kind === 6 /* PackageGroupImportDirective */ || tokenOrKeyword.parent.kind === 95 /* FunctionBlock */ && (tokenOrKeyword.parent.parent.kind === 23 /* PackageConstructorDeclaration */ || tokenOrKeyword.parent.parent.kind === 24 /* PackageEntryPointDeclaration */ || tokenOrKeyword.parent.parent.kind === 25 /* PackageFunctionDeclaration */))) {
|
|
5305
5242
|
return true;
|
|
5306
5243
|
}
|
|
5307
|
-
if (tokenOrKeyword.isToken(
|
|
5244
|
+
if (tokenOrKeyword.isToken(46 /* OpenBrace */) && tokenOrKeyword.parent.kind === 22 /* PackageMemberGroupDeclaration */) {
|
|
5308
5245
|
return true;
|
|
5309
5246
|
}
|
|
5310
5247
|
if (SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(tokenOrKeyword, 5 /* SinglePackageImportDirective */) || SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(tokenOrKeyword, 25 /* PackageFunctionDeclaration */) || SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(tokenOrKeyword, 26 /* PackageFunctionTypeDeclaration */) || SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(tokenOrKeyword, 20 /* PackageAliasTypeDeclaration */) || SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(tokenOrKeyword, 33 /* PackageVariableDeclaration */) || SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(
|
|
@@ -5316,7 +5253,7 @@ var SyntaxContextFactory = class {
|
|
|
5316
5253
|
if (tokenOrKeyword.isKeyword() && tokenOrKeyword.parent.kind === 154 /* Modifier */ && tokenOrKeyword.value === tokenOrKeyword.parent.value && tokenOrKeyword.parent.openParenthesisToken === void 0 && NodeTypeUtils.isPackageMemberDeclaration(tokenOrKeyword.parent.parent.parent)) {
|
|
5317
5254
|
return true;
|
|
5318
5255
|
}
|
|
5319
|
-
if (tokenOrKeyword.isToken(
|
|
5256
|
+
if (tokenOrKeyword.isToken(23 /* CloseParenthesis */) && tokenOrKeyword.parent.kind === 154 /* Modifier */ && NodeTypeUtils.isPackageMemberDeclaration(tokenOrKeyword.parent.parent.parent)) {
|
|
5320
5257
|
return true;
|
|
5321
5258
|
}
|
|
5322
5259
|
const tag = SyntaxContextUtils.ifTokenIsValidEndOfNodeThenNode(tokenOrKeyword, 152 /* Tag */);
|
|
@@ -5326,13 +5263,13 @@ var SyntaxContextFactory = class {
|
|
|
5326
5263
|
return false;
|
|
5327
5264
|
}
|
|
5328
5265
|
static isTypeMemberDeclarationListContext(tokenOrKeyword) {
|
|
5329
|
-
if (tokenOrKeyword.isToken(
|
|
5266
|
+
if (tokenOrKeyword.isToken(58 /* Semicolon */) && tokenOrKeyword.parent.kind === 29 /* TypeMemberDeclarationList */) {
|
|
5330
5267
|
return true;
|
|
5331
5268
|
}
|
|
5332
|
-
if (tokenOrKeyword.isToken(
|
|
5269
|
+
if (tokenOrKeyword.isToken(46 /* OpenBrace */) && tokenOrKeyword.parent.kind === 30 /* TypeMemberDeclarationBlock */) {
|
|
5333
5270
|
return true;
|
|
5334
5271
|
}
|
|
5335
|
-
if (tokenOrKeyword.isToken(
|
|
5272
|
+
if (tokenOrKeyword.isToken(22 /* CloseBrace */) && tokenOrKeyword.parent.kind === 30 /* TypeMemberDeclarationBlock */ && tokenOrKeyword.parent.parent.kind === 42 /* TypeMemberGroupDeclaration */) {
|
|
5336
5273
|
return true;
|
|
5337
5274
|
}
|
|
5338
5275
|
if (SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(tokenOrKeyword, 52 /* FieldDeclaration */) || SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(tokenOrKeyword, 53 /* FieldGetterDeclaration */) || SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(tokenOrKeyword, 54 /* FieldSetterDeclaration */) || SyntaxContextUtils.tokenOrKeywordIsValidEndOfNode(
|
|
@@ -5353,7 +5290,7 @@ var SyntaxContextFactory = class {
|
|
|
5353
5290
|
if (tokenOrKeyword.isKeyword() && tokenOrKeyword.parent.kind === 154 /* Modifier */ && tokenOrKeyword.value === tokenOrKeyword.parent.value && tokenOrKeyword.parent.openParenthesisToken === void 0 && NodeTypeUtils.isTypeMemberDeclaration(tokenOrKeyword.parent.parent.parent)) {
|
|
5354
5291
|
return true;
|
|
5355
5292
|
}
|
|
5356
|
-
if (tokenOrKeyword.isToken(
|
|
5293
|
+
if (tokenOrKeyword.isToken(23 /* CloseParenthesis */) && tokenOrKeyword.parent.kind === 154 /* Modifier */ && NodeTypeUtils.isTypeMemberDeclaration(tokenOrKeyword.parent.parent.parent)) {
|
|
5357
5294
|
return true;
|
|
5358
5295
|
}
|
|
5359
5296
|
const tag = SyntaxContextUtils.ifTokenIsValidEndOfNodeThenNode(tokenOrKeyword, 152 /* Tag */);
|
|
@@ -5394,7 +5331,7 @@ var SyntaxContextFactory = class {
|
|
|
5394
5331
|
return result;
|
|
5395
5332
|
}
|
|
5396
5333
|
static isUnqualifiedTypeContext(tokenOrKeyword) {
|
|
5397
|
-
if (tokenOrKeyword.isToken(
|
|
5334
|
+
if (tokenOrKeyword.isToken(25 /* Colon */) && tokenOrKeyword.parent.kind === 161 /* TypeAnnotation */) {
|
|
5398
5335
|
return { allowsAnonymousTypes: true };
|
|
5399
5336
|
}
|
|
5400
5337
|
if ((tokenOrKeyword.isKeyword(4 /* Object */) || tokenOrKeyword.isKeyword(5 /* PlainObject */) || tokenOrKeyword.isKeyword(3 /* Aspect */)) && tokenOrKeyword.parent.kind === 32 /* StructuredTypeDeclarationBody */) {
|
|
@@ -5403,19 +5340,19 @@ var SyntaxContextFactory = class {
|
|
|
5403
5340
|
if (tokenOrKeyword.isKeyword(16 /* Type */) && (NodeTypeUtils.isPackageTypeDeclaration(tokenOrKeyword.parent) || tokenOrKeyword.parent.kind === 38 /* TypeExtensionDeclaration */)) {
|
|
5404
5341
|
return { allowsAnonymousTypes: false };
|
|
5405
5342
|
}
|
|
5406
|
-
if (tokenOrKeyword.isToken(
|
|
5343
|
+
if (tokenOrKeyword.isToken(37 /* LessThan */) && tokenOrKeyword.parent.kind === 157 /* TypeArgumentClause */) {
|
|
5407
5344
|
return { allowsAnonymousTypes: true };
|
|
5408
5345
|
}
|
|
5409
|
-
if (tokenOrKeyword.isToken(
|
|
5346
|
+
if (tokenOrKeyword.isToken(26 /* Comma */) && (tokenOrKeyword.parent.kind === 28 /* BaseTypeList */ || tokenOrKeyword.parent.kind === 158 /* TypeArgumentList */)) {
|
|
5410
5347
|
return { allowsAnonymousTypes: tokenOrKeyword.parent.kind === 158 /* TypeArgumentList */ };
|
|
5411
5348
|
}
|
|
5412
|
-
if (tokenOrKeyword.isToken(
|
|
5349
|
+
if (tokenOrKeyword.isToken(36 /* HashSign */) && tokenOrKeyword.parent.kind === 152 /* Tag */) {
|
|
5413
5350
|
return { allowsAnonymousTypes: false };
|
|
5414
5351
|
}
|
|
5415
|
-
if ((tokenOrKeyword.isToken(
|
|
5352
|
+
if ((tokenOrKeyword.isToken(25 /* Colon */) || tokenOrKeyword.isToken(64 /* Equals */)) && tokenOrKeyword.parent.kind === 148 /* TypeParameterDeclaration */) {
|
|
5416
5353
|
return { allowsAnonymousTypes: false };
|
|
5417
5354
|
}
|
|
5418
|
-
if (tokenOrKeyword.isToken(
|
|
5355
|
+
if (tokenOrKeyword.isToken(64 /* Equals */) && tokenOrKeyword.parent.kind === 20 /* PackageAliasTypeDeclaration */) {
|
|
5419
5356
|
return { allowsAnonymousTypes: false };
|
|
5420
5357
|
}
|
|
5421
5358
|
if (tokenOrKeyword.isKeyword(14 /* Is */) && tokenOrKeyword.parent.kind === 72 /* IsExpression */) {
|
|
@@ -5430,16 +5367,16 @@ var SyntaxContextFactory = class {
|
|
|
5430
5367
|
if (tokenOrKeyword.isToken(10 /* Ampersand */) && tokenOrKeyword.parent.kind === 12 /* IntersectionTypeSpecifier */) {
|
|
5431
5368
|
return { allowsAnonymousTypes: false };
|
|
5432
5369
|
}
|
|
5433
|
-
if (tokenOrKeyword.isToken(
|
|
5370
|
+
if (tokenOrKeyword.isToken(47 /* OpenParenthesis */) && tokenOrKeyword.parent.kind === 13 /* ParenthesizedTypeSpecifier */) {
|
|
5434
5371
|
return { allowsAnonymousTypes: true };
|
|
5435
5372
|
}
|
|
5436
5373
|
return void 0;
|
|
5437
5374
|
}
|
|
5438
5375
|
static isTopLevelTranslationListContext(tokenOrKeyword) {
|
|
5439
|
-
if (tokenOrKeyword.isToken(
|
|
5376
|
+
if (tokenOrKeyword.isToken(58 /* Semicolon */) && tokenOrKeyword.parent.kind === 124 /* TopLevelTranslationList */) {
|
|
5440
5377
|
return { translationsDeclaration: tokenOrKeyword.parent.parent };
|
|
5441
5378
|
}
|
|
5442
|
-
if (tokenOrKeyword.isToken(
|
|
5379
|
+
if (tokenOrKeyword.isToken(46 /* OpenBrace */) && tokenOrKeyword.parent.kind === 123 /* TranslationsDeclaration */) {
|
|
5443
5380
|
return { translationsDeclaration: tokenOrKeyword.parent };
|
|
5444
5381
|
}
|
|
5445
5382
|
const type = SyntaxContextUtils.ifTokenIsValidEndOfNodeThenNode(
|
|
@@ -5473,10 +5410,10 @@ var SyntaxContextFactory = class {
|
|
|
5473
5410
|
return void 0;
|
|
5474
5411
|
}
|
|
5475
5412
|
static isTypeMemberTranslationListContext(tokenOrKeyword) {
|
|
5476
|
-
if (tokenOrKeyword.isToken(
|
|
5413
|
+
if (tokenOrKeyword.isToken(58 /* Semicolon */) && tokenOrKeyword.parent.kind === 138 /* TypeMemberTranslationList */) {
|
|
5477
5414
|
return { typeTranslation: tokenOrKeyword.parent.parent };
|
|
5478
5415
|
}
|
|
5479
|
-
if (tokenOrKeyword.isToken(
|
|
5416
|
+
if (tokenOrKeyword.isToken(46 /* OpenBrace */) && tokenOrKeyword.parent.kind === 139 /* TypeTranslationDeclaration */) {
|
|
5480
5417
|
return { typeTranslation: tokenOrKeyword.parent };
|
|
5481
5418
|
}
|
|
5482
5419
|
const indexer = SyntaxContextUtils.ifTokenIsValidEndOfNodeThenNode(tokenOrKeyword, 129 /* IndexerTranslation */);
|
|
@@ -5618,9 +5555,9 @@ var NodeSemanticInfoService = class {
|
|
|
5618
5555
|
return this.ofPrefixUnaryExpressionOperator(analyzer, tokenOrKeyword.parent, options7);
|
|
5619
5556
|
} else if (tokenOrKeyword.parent.kind === 64 /* BinaryExpression */) {
|
|
5620
5557
|
return this.ofBinaryExpressionOperator(analyzer, tokenOrKeyword.parent, options7);
|
|
5621
|
-
} else if (tokenOrKeyword.isToken(
|
|
5558
|
+
} else if (tokenOrKeyword.isToken(21 /* Caret */) && (tokenOrKeyword.parent.kind === 48 /* DereferencedVariableGetterDeclaration */ || tokenOrKeyword.parent.kind === 49 /* DereferencedVariableSetterDeclaration */)) {
|
|
5622
5559
|
return this.ofDereferenceOperatorDeclaration(analyzer, tokenOrKeyword.parent);
|
|
5623
|
-
} else if (tokenOrKeyword.isToken(
|
|
5560
|
+
} else if (tokenOrKeyword.isToken(21 /* Caret */) && tokenOrKeyword.parent.kind === 78 /* DereferenceExpression */) {
|
|
5624
5561
|
return this.ofDereferenceExpressionOperator(analyzer, tokenOrKeyword.parent, options7);
|
|
5625
5562
|
} else if (tokenOrKeyword.parent.kind === 92 /* AssignmentStatement */) {
|
|
5626
5563
|
return this.ofAssignmentStatementOperator(analyzer, tokenOrKeyword.parent, options7);
|
|
@@ -5630,23 +5567,23 @@ var NodeSemanticInfoService = class {
|
|
|
5630
5567
|
return this.ofDefaultMatchExpression(analyzer, tokenOrKeyword.parent);
|
|
5631
5568
|
} else if (tokenOrKeyword.isKeyword(12 /* Function */) && tokenOrKeyword.parent.kind === 65 /* FunctionLiteral */) {
|
|
5632
5569
|
return this.ofRegularOrBlockFunctionLiteral(analyzer, tokenOrKeyword.parent);
|
|
5633
|
-
} else if (tokenOrKeyword.isToken(
|
|
5570
|
+
} else if (tokenOrKeyword.isToken(46 /* OpenBrace */) && tokenOrKeyword.parent.kind === 95 /* FunctionBlock */ && tokenOrKeyword.parent.parent.kind === 66 /* FunctionBlockLiteral */) {
|
|
5634
5571
|
return this.ofRegularOrBlockFunctionLiteral(analyzer, tokenOrKeyword.parent.parent);
|
|
5635
5572
|
} else if (tokenOrKeyword.isKeyword(4 /* Object */) && tokenOrKeyword.parent.kind === 87 /* ObjectExpression */) {
|
|
5636
5573
|
return this.ofObjectExpression(analyzer, tokenOrKeyword.parent, options7);
|
|
5637
5574
|
} else if (tokenOrKeyword.isKeyword(56 /* Base */) && tokenOrKeyword.parent.kind === 88 /* BaseExpression */) {
|
|
5638
5575
|
return this.ofBaseExpression(analyzer, tokenOrKeyword.parent, options7);
|
|
5639
|
-
} else if ((tokenOrKeyword.isToken(
|
|
5576
|
+
} else if ((tokenOrKeyword.isToken(48 /* OpenSquareBracket */) || tokenOrKeyword.isToken(24 /* CloseSquareBracket */)) && tokenOrKeyword.parent.kind === 47 /* IndexParameterClause */) {
|
|
5640
5577
|
return this.ofIndexedElementAccessorDeclaration(analyzer, tokenOrKeyword.parent.parent);
|
|
5641
|
-
} else if ((tokenOrKeyword.isToken(
|
|
5578
|
+
} else if ((tokenOrKeyword.isToken(48 /* OpenSquareBracket */) || tokenOrKeyword.isToken(24 /* CloseSquareBracket */)) && tokenOrKeyword.parent.kind === 70 /* IndexedAccessExpression */) {
|
|
5642
5579
|
return this.ofIndexedAccessExpressionOperator(analyzer, tokenOrKeyword.parent, options7);
|
|
5643
5580
|
} else if (tokenOrKeyword.isKeyword(31 /* Creation */) && tokenOrKeyword.parent.kind === 127 /* ConstructorTranslation */) {
|
|
5644
5581
|
return this.ofConstructorTranslationSourceConstructor(analyzer, tokenOrKeyword.parent, options7);
|
|
5645
|
-
} else if ((tokenOrKeyword.isToken(
|
|
5582
|
+
} else if ((tokenOrKeyword.isToken(47 /* OpenParenthesis */) || tokenOrKeyword.isToken(23 /* CloseParenthesis */)) && tokenOrKeyword.parent.kind === 126 /* TranslationParameterClause */ && tokenOrKeyword.parent.parent.kind === 127 /* ConstructorTranslation */ && tokenOrKeyword.parent.parent.translatedParameterClause === tokenOrKeyword.parent) {
|
|
5646
5583
|
return this.ofConstructorTranslationTranslatedConstructor(analyzer, tokenOrKeyword.parent.parent, options7);
|
|
5647
|
-
} else if ((tokenOrKeyword.isToken(
|
|
5584
|
+
} else if ((tokenOrKeyword.isToken(48 /* OpenSquareBracket */) || tokenOrKeyword.isToken(24 /* CloseSquareBracket */)) && tokenOrKeyword.parent.kind === 128 /* IndexParameterTranslationClause */ && tokenOrKeyword.parent.parent.kind === 129 /* IndexerTranslation */ && tokenOrKeyword.parent.parent.sourceParameterClause === tokenOrKeyword.parent) {
|
|
5648
5585
|
return this.ofIndexerTranslationSourceIndexer(analyzer, tokenOrKeyword.parent.parent, options7);
|
|
5649
|
-
} else if ((tokenOrKeyword.isToken(
|
|
5586
|
+
} else if ((tokenOrKeyword.isToken(48 /* OpenSquareBracket */) || tokenOrKeyword.isToken(24 /* CloseSquareBracket */)) && tokenOrKeyword.parent.kind === 128 /* IndexParameterTranslationClause */ && tokenOrKeyword.parent.parent.kind === 129 /* IndexerTranslation */ && tokenOrKeyword.parent.parent.translatedParameterClause === tokenOrKeyword.parent) {
|
|
5650
5587
|
return this.ofIndexerTranslationTranslatedIndexer(analyzer, tokenOrKeyword.parent.parent, options7);
|
|
5651
5588
|
}
|
|
5652
5589
|
return void 0;
|
|
@@ -6906,7 +6843,7 @@ var DefinitionService = class {
|
|
|
6906
6843
|
const tokenOrKeyword = getTokenOrKeywordsTouchingOffset(sourceFile.getSyntaxNode(), offset).getSingleWithHighestPriority((t) => {
|
|
6907
6844
|
if (t.isToken(9 /* Identifier */) || t.isKeyword()) {
|
|
6908
6845
|
return 2;
|
|
6909
|
-
} else if (t.isToken(
|
|
6846
|
+
} else if (t.isToken(21 /* Caret */) || t.isToken(48 /* OpenSquareBracket */) || t.isToken(24 /* CloseSquareBracket */)) {
|
|
6910
6847
|
return 1;
|
|
6911
6848
|
} else {
|
|
6912
6849
|
return 0;
|
|
@@ -7131,38 +7068,6 @@ var DefinitionsAndReferenceInfo = class {
|
|
|
7131
7068
|
}
|
|
7132
7069
|
};
|
|
7133
7070
|
|
|
7134
|
-
// source/services/DeleteBlockFromScriptService.ts
|
|
7135
|
-
var DeleteBlockFromScriptService = class {
|
|
7136
|
-
createEditDeletingBlock(sourceFile, subprogramDeclaration) {
|
|
7137
|
-
let result;
|
|
7138
|
-
if (NodeTypeUtils.isRegularOrBlockFunctionLiteral(subprogramDeclaration) && subprogramDeclaration.parent.kind === 150 /* Argument */ && subprogramDeclaration.parent.parent.parent.kind === 68 /* CallExpression */) {
|
|
7139
|
-
const callExpression = subprogramDeclaration.parent.parent.parent;
|
|
7140
|
-
let rangeStart = callExpression.rangeWithoutTrivia.start;
|
|
7141
|
-
let rangeEnd = callExpression.rangeWithoutTrivia.end;
|
|
7142
|
-
const leadingTrivia = callExpression.findLeftmostToken()?.selectLeadingTrivia(() => true);
|
|
7143
|
-
const lastLeadingTrivia = leadingTrivia !== void 0 && leadingTrivia.length > 0 ? leadingTrivia[leadingTrivia.length - 1] : void 0;
|
|
7144
|
-
if (lastLeadingTrivia?.kind === 0 /* Whitespace */) {
|
|
7145
|
-
rangeStart = lastLeadingTrivia.range.start;
|
|
7146
|
-
}
|
|
7147
|
-
const trailingTrivia = callExpression.findRightmostToken()?.selectTrailingTrivia(() => true);
|
|
7148
|
-
if (trailingTrivia !== void 0) {
|
|
7149
|
-
let trailingTriviaIndex = -1;
|
|
7150
|
-
if (trailingTrivia.length > trailingTriviaIndex + 1 && trailingTrivia[trailingTriviaIndex + 1].kind === 0 /* Whitespace */) {
|
|
7151
|
-
trailingTriviaIndex++;
|
|
7152
|
-
}
|
|
7153
|
-
if (trailingTrivia.length > trailingTriviaIndex + 1 && trailingTrivia[trailingTriviaIndex + 1].kind === 1 /* NewLine */) {
|
|
7154
|
-
trailingTriviaIndex++;
|
|
7155
|
-
}
|
|
7156
|
-
if (trailingTriviaIndex >= 0) {
|
|
7157
|
-
rangeEnd = trailingTrivia[trailingTriviaIndex].range.end;
|
|
7158
|
-
}
|
|
7159
|
-
}
|
|
7160
|
-
result = new SourceFileEdit(sourceFile, new Range(rangeStart, rangeEnd), "");
|
|
7161
|
-
}
|
|
7162
|
-
return result;
|
|
7163
|
-
}
|
|
7164
|
-
};
|
|
7165
|
-
|
|
7166
7071
|
// source/services/ReferencesService.ts
|
|
7167
7072
|
var ReferencesService = class {
|
|
7168
7073
|
getReferencesInCompilation(analyzer, sourceFile, offset, options7, taskController) {
|
|
@@ -7463,7 +7368,7 @@ var ReferencesService = class {
|
|
|
7463
7368
|
const tokenOrKeyword = getTokenOrKeywordsTouchingOffset(sourceFile.getSyntaxNode(), offset).getSingleWithHighestPriority((t) => {
|
|
7464
7369
|
if (t.isToken(9 /* Identifier */) || t.isKeyword()) {
|
|
7465
7370
|
return 2;
|
|
7466
|
-
} else if (t.isToken(
|
|
7371
|
+
} else if (t.isToken(21 /* Caret */) || t.isToken(48 /* OpenSquareBracket */) || t.isToken(24 /* CloseSquareBracket */)) {
|
|
7467
7372
|
return 1;
|
|
7468
7373
|
} else {
|
|
7469
7374
|
return 0;
|
|
@@ -7978,7 +7883,7 @@ var HoverService = class {
|
|
|
7978
7883
|
return 2;
|
|
7979
7884
|
} else if (t.isToken(13 /* Asterisk */)) {
|
|
7980
7885
|
return 1;
|
|
7981
|
-
} else if (t.isToken(
|
|
7886
|
+
} else if (t.isToken(21 /* Caret */) || t.isToken(48 /* OpenSquareBracket */) || t.isToken(24 /* CloseSquareBracket */) || t.isToken(46 /* OpenBrace */)) {
|
|
7982
7887
|
return 1;
|
|
7983
7888
|
} else {
|
|
7984
7889
|
return 0;
|
|
@@ -8114,311 +8019,14 @@ var Hover = class {
|
|
|
8114
8019
|
}
|
|
8115
8020
|
};
|
|
8116
8021
|
|
|
8117
|
-
// source/services/
|
|
8118
|
-
var
|
|
8119
|
-
|
|
8120
|
-
this.
|
|
8121
|
-
return this.getChildItems(sourceFile.getSyntaxNode());
|
|
8122
|
-
}
|
|
8123
|
-
get locale() {
|
|
8124
|
-
return this.sourceFile.package.locale;
|
|
8022
|
+
// source/services/RenameService.ts
|
|
8023
|
+
var RenameService = class {
|
|
8024
|
+
constructor() {
|
|
8025
|
+
this.referencesService = new ReferencesService();
|
|
8125
8026
|
}
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
getChildItems(node) {
|
|
8130
|
-
const result = new Array();
|
|
8131
|
-
visitChildren(node, false, (node2) => {
|
|
8132
|
-
const items = this.getChildItems(node2);
|
|
8133
|
-
switch (node2.kind) {
|
|
8134
|
-
case 8 /* PackageImport */: {
|
|
8135
|
-
if (node2.alias !== void 0) {
|
|
8136
|
-
result.push(this.createItem(
|
|
8137
|
-
0 /* PackageAlias */,
|
|
8138
|
-
node2.alias.value,
|
|
8139
|
-
node2.rangeWithoutTrivia,
|
|
8140
|
-
node2.alias.rangeWithoutTrivia,
|
|
8141
|
-
items
|
|
8142
|
-
));
|
|
8143
|
-
}
|
|
8144
|
-
break;
|
|
8145
|
-
}
|
|
8146
|
-
case 33 /* PackageVariableDeclaration */: {
|
|
8147
|
-
result.push(this.createItem(
|
|
8148
|
-
1 /* PackageVariable */,
|
|
8149
|
-
node2.name.value,
|
|
8150
|
-
node2.rangeWithoutTrivia,
|
|
8151
|
-
node2.name.rangeWithoutTrivia,
|
|
8152
|
-
items
|
|
8153
|
-
));
|
|
8154
|
-
break;
|
|
8155
|
-
}
|
|
8156
|
-
case 34 /* PackageVariableGetterDeclaration */: {
|
|
8157
|
-
result.push(this.createItem(
|
|
8158
|
-
2 /* PackageVariableGetter */,
|
|
8159
|
-
node2.name.value,
|
|
8160
|
-
node2.rangeWithoutTrivia,
|
|
8161
|
-
node2.name.rangeWithoutTrivia,
|
|
8162
|
-
items
|
|
8163
|
-
));
|
|
8164
|
-
break;
|
|
8165
|
-
}
|
|
8166
|
-
case 35 /* PackageVariableSetterDeclaration */: {
|
|
8167
|
-
result.push(this.createItem(
|
|
8168
|
-
3 /* PackageVariableSetter */,
|
|
8169
|
-
node2.name.value,
|
|
8170
|
-
node2.rangeWithoutTrivia,
|
|
8171
|
-
node2.name.rangeWithoutTrivia,
|
|
8172
|
-
items
|
|
8173
|
-
));
|
|
8174
|
-
break;
|
|
8175
|
-
}
|
|
8176
|
-
case 25 /* PackageFunctionDeclaration */: {
|
|
8177
|
-
result.push(this.createItem(
|
|
8178
|
-
4 /* PackageFunction */,
|
|
8179
|
-
node2.name.value,
|
|
8180
|
-
node2.rangeWithoutTrivia,
|
|
8181
|
-
node2.name.rangeWithoutTrivia,
|
|
8182
|
-
items
|
|
8183
|
-
));
|
|
8184
|
-
break;
|
|
8185
|
-
}
|
|
8186
|
-
case 31 /* PackageStructuredTypeDeclaration */: {
|
|
8187
|
-
result.push(this.createItem(
|
|
8188
|
-
5 /* StructuredType */,
|
|
8189
|
-
node2.name.value,
|
|
8190
|
-
node2.rangeWithoutTrivia,
|
|
8191
|
-
node2.name.rangeWithoutTrivia,
|
|
8192
|
-
items
|
|
8193
|
-
));
|
|
8194
|
-
break;
|
|
8195
|
-
}
|
|
8196
|
-
case 52 /* FieldDeclaration */: {
|
|
8197
|
-
result.push(this.createItem(
|
|
8198
|
-
12 /* Field */,
|
|
8199
|
-
node2.name.value,
|
|
8200
|
-
node2.rangeWithoutTrivia,
|
|
8201
|
-
node2.name.rangeWithoutTrivia,
|
|
8202
|
-
items
|
|
8203
|
-
));
|
|
8204
|
-
break;
|
|
8205
|
-
}
|
|
8206
|
-
case 53 /* FieldGetterDeclaration */: {
|
|
8207
|
-
result.push(this.createItem(
|
|
8208
|
-
13 /* FieldGetter */,
|
|
8209
|
-
node2.name.value,
|
|
8210
|
-
node2.rangeWithoutTrivia,
|
|
8211
|
-
node2.name.rangeWithoutTrivia,
|
|
8212
|
-
items
|
|
8213
|
-
));
|
|
8214
|
-
break;
|
|
8215
|
-
}
|
|
8216
|
-
case 54 /* FieldSetterDeclaration */: {
|
|
8217
|
-
result.push(this.createItem(
|
|
8218
|
-
14 /* FieldSetter */,
|
|
8219
|
-
node2.name.value,
|
|
8220
|
-
node2.rangeWithoutTrivia,
|
|
8221
|
-
node2.name.rangeWithoutTrivia,
|
|
8222
|
-
items
|
|
8223
|
-
));
|
|
8224
|
-
break;
|
|
8225
|
-
}
|
|
8226
|
-
case 50 /* MethodDeclaration */: {
|
|
8227
|
-
result.push(this.createItem(
|
|
8228
|
-
15 /* Method */,
|
|
8229
|
-
node2.name.value,
|
|
8230
|
-
node2.rangeWithoutTrivia,
|
|
8231
|
-
node2.name.rangeWithoutTrivia,
|
|
8232
|
-
items
|
|
8233
|
-
));
|
|
8234
|
-
break;
|
|
8235
|
-
}
|
|
8236
|
-
case 43 /* ConstructorDeclaration */: {
|
|
8237
|
-
result.push(this.createItem(
|
|
8238
|
-
10 /* Constructor */,
|
|
8239
|
-
void 0,
|
|
8240
|
-
node2.rangeWithoutTrivia,
|
|
8241
|
-
node2.rangeWithoutTrivia,
|
|
8242
|
-
items
|
|
8243
|
-
));
|
|
8244
|
-
break;
|
|
8245
|
-
}
|
|
8246
|
-
case 44 /* DestructorDeclaration */: {
|
|
8247
|
-
result.push(this.createItem(
|
|
8248
|
-
11 /* Destructor */,
|
|
8249
|
-
void 0,
|
|
8250
|
-
node2.rangeWithoutTrivia,
|
|
8251
|
-
node2.rangeWithoutTrivia,
|
|
8252
|
-
items
|
|
8253
|
-
));
|
|
8254
|
-
break;
|
|
8255
|
-
}
|
|
8256
|
-
case 45 /* IndexedElementGetterDeclaration */: {
|
|
8257
|
-
result.push(this.createItem(
|
|
8258
|
-
16 /* IndexedElementGetter */,
|
|
8259
|
-
void 0,
|
|
8260
|
-
node2.rangeWithoutTrivia,
|
|
8261
|
-
node2.rangeWithoutTrivia,
|
|
8262
|
-
items
|
|
8263
|
-
));
|
|
8264
|
-
break;
|
|
8265
|
-
}
|
|
8266
|
-
case 46 /* IndexedElementSetterDeclaration */: {
|
|
8267
|
-
result.push(this.createItem(
|
|
8268
|
-
17 /* IndexedElementSetter */,
|
|
8269
|
-
void 0,
|
|
8270
|
-
node2.rangeWithoutTrivia,
|
|
8271
|
-
node2.rangeWithoutTrivia,
|
|
8272
|
-
items
|
|
8273
|
-
));
|
|
8274
|
-
break;
|
|
8275
|
-
}
|
|
8276
|
-
case 26 /* PackageFunctionTypeDeclaration */: {
|
|
8277
|
-
result.push(this.createItem(
|
|
8278
|
-
6 /* FunctionType */,
|
|
8279
|
-
node2.name.value,
|
|
8280
|
-
node2.rangeWithoutTrivia,
|
|
8281
|
-
node2.name.rangeWithoutTrivia,
|
|
8282
|
-
items
|
|
8283
|
-
));
|
|
8284
|
-
break;
|
|
8285
|
-
}
|
|
8286
|
-
case 36 /* PackageVariantTypeDeclaration */: {
|
|
8287
|
-
result.push(this.createItem(
|
|
8288
|
-
7 /* VariantType */,
|
|
8289
|
-
node2.name.value,
|
|
8290
|
-
node2.rangeWithoutTrivia,
|
|
8291
|
-
node2.name.rangeWithoutTrivia,
|
|
8292
|
-
items
|
|
8293
|
-
));
|
|
8294
|
-
break;
|
|
8295
|
-
}
|
|
8296
|
-
case 147 /* VariantValueDeclaration */: {
|
|
8297
|
-
result.push(this.createItem(
|
|
8298
|
-
9 /* VariantValue */,
|
|
8299
|
-
node2.name.value,
|
|
8300
|
-
node2.rangeWithoutTrivia,
|
|
8301
|
-
node2.name.rangeWithoutTrivia,
|
|
8302
|
-
items
|
|
8303
|
-
));
|
|
8304
|
-
break;
|
|
8305
|
-
}
|
|
8306
|
-
case 148 /* TypeParameterDeclaration */: {
|
|
8307
|
-
result.push(this.createItem(
|
|
8308
|
-
18 /* TypeParameter */,
|
|
8309
|
-
node2.name.value,
|
|
8310
|
-
node2.rangeWithoutTrivia,
|
|
8311
|
-
node2.name.rangeWithoutTrivia,
|
|
8312
|
-
items
|
|
8313
|
-
));
|
|
8314
|
-
break;
|
|
8315
|
-
}
|
|
8316
|
-
case 56 /* NestedFunctionDeclaration */: {
|
|
8317
|
-
result.push(this.createItem(
|
|
8318
|
-
19 /* NestedFunction */,
|
|
8319
|
-
node2.name.value,
|
|
8320
|
-
node2.rangeWithoutTrivia,
|
|
8321
|
-
node2.name.rangeWithoutTrivia,
|
|
8322
|
-
items
|
|
8323
|
-
));
|
|
8324
|
-
break;
|
|
8325
|
-
}
|
|
8326
|
-
default: {
|
|
8327
|
-
result.push(...items);
|
|
8328
|
-
break;
|
|
8329
|
-
}
|
|
8330
|
-
}
|
|
8331
|
-
});
|
|
8332
|
-
return result;
|
|
8333
|
-
}
|
|
8334
|
-
createItem(kind, name, range, selectionRange, items) {
|
|
8335
|
-
const itemName = this.getNameOrStubIfEmpty(name, kind);
|
|
8336
|
-
return new Item(kind, itemName, range, selectionRange, items, this.sourceFile);
|
|
8337
|
-
}
|
|
8338
|
-
getNameOrStubIfEmpty(name, kind) {
|
|
8339
|
-
if (name !== void 0 && name.trim().length === 0) {
|
|
8340
|
-
name = void 0;
|
|
8341
|
-
}
|
|
8342
|
-
switch (kind) {
|
|
8343
|
-
case 0 /* PackageAlias */:
|
|
8344
|
-
return name ?? `<${LocalizationHelper.localizeHelperPhrase(4 /* PackageAlias */, this.locale)}>`;
|
|
8345
|
-
case 1 /* PackageVariable */:
|
|
8346
|
-
case 12 /* Field */:
|
|
8347
|
-
return name ?? `<${LocalizationHelper.localizeHelperPhrase(6 /* Variable */, this.locale)}>`;
|
|
8348
|
-
case 4 /* PackageFunction */:
|
|
8349
|
-
case 15 /* Method */:
|
|
8350
|
-
case 19 /* NestedFunction */:
|
|
8351
|
-
return name ?? `<${LocalizationHelper.localizeKeywordAndTakeFirst(12 /* Function */, this.locale, this.dialect)}>`;
|
|
8352
|
-
case 5 /* StructuredType */:
|
|
8353
|
-
case 6 /* FunctionType */:
|
|
8354
|
-
case 7 /* VariantType */:
|
|
8355
|
-
case 8 /* InvalidType */:
|
|
8356
|
-
return name ?? `<${LocalizationHelper.localizeKeywordAndTakeFirst(16 /* Type */, this.locale, this.dialect)}>`;
|
|
8357
|
-
case 10 /* Constructor */:
|
|
8358
|
-
return name ?? LocalizationHelper.localizeKeywordAndTakeFirst(31 /* Creation */, this.locale, this.dialect);
|
|
8359
|
-
case 11 /* Destructor */:
|
|
8360
|
-
return name ?? LocalizationHelper.localizeKeywordAndTakeFirst(47 /* Destruction */, this.locale, this.dialect);
|
|
8361
|
-
case 9 /* VariantValue */:
|
|
8362
|
-
return name ?? `<${LocalizationHelper.localizeKeywordAndTakeFirst(6 /* Variant */, this.locale, this.dialect)}>`;
|
|
8363
|
-
case 18 /* TypeParameter */:
|
|
8364
|
-
return name ?? `<${LocalizationHelper.localizeHelperPhrase(2 /* TypeParameter */, this.locale)}>`;
|
|
8365
|
-
case 2 /* PackageVariableGetter */:
|
|
8366
|
-
case 13 /* FieldGetter */:
|
|
8367
|
-
return `${LocalizationHelper.localizeKeywordAndTakeFirst(58 /* Get */, this.locale, this.dialect)} ${name ?? ""}`;
|
|
8368
|
-
case 3 /* PackageVariableSetter */:
|
|
8369
|
-
case 14 /* FieldSetter */:
|
|
8370
|
-
return `${LocalizationHelper.localizeKeywordAndTakeFirst(59 /* Set */, this.locale, this.dialect)} ${name ?? ""}`;
|
|
8371
|
-
case 16 /* IndexedElementGetter */:
|
|
8372
|
-
return `${LocalizationHelper.localizeKeywordAndTakeFirst(58 /* Get */, this.locale, this.dialect)} []`;
|
|
8373
|
-
case 17 /* IndexedElementSetter */:
|
|
8374
|
-
return `${LocalizationHelper.localizeKeywordAndTakeFirst(59 /* Set */, this.locale, this.dialect)} []`;
|
|
8375
|
-
default:
|
|
8376
|
-
Debug.never(kind);
|
|
8377
|
-
}
|
|
8378
|
-
}
|
|
8379
|
-
};
|
|
8380
|
-
var Item = class {
|
|
8381
|
-
constructor(kind, name, range, selectionRange, items, sourceFile) {
|
|
8382
|
-
this.kind = kind;
|
|
8383
|
-
this.name = name;
|
|
8384
|
-
this.range = range;
|
|
8385
|
-
this.selectionRange = selectionRange;
|
|
8386
|
-
this.items = items;
|
|
8387
|
-
this.sourceFile = sourceFile;
|
|
8388
|
-
}
|
|
8389
|
-
};
|
|
8390
|
-
|
|
8391
|
-
// source/services/ProjectItemsService.ts
|
|
8392
|
-
var WorkspaceItemsService = class {
|
|
8393
|
-
constructor() {
|
|
8394
|
-
this.sourceFileItemsService = new SourceFileItemsService();
|
|
8395
|
-
}
|
|
8396
|
-
getItems(compilations) {
|
|
8397
|
-
const result = new Array();
|
|
8398
|
-
const packageUris = /* @__PURE__ */ new Set();
|
|
8399
|
-
for (const compilation of compilations) {
|
|
8400
|
-
for (const pkg of compilation.allPackages) {
|
|
8401
|
-
if (packageUris.has(pkg.uri.toString())) {
|
|
8402
|
-
continue;
|
|
8403
|
-
}
|
|
8404
|
-
packageUris.add(pkg.uri.toString());
|
|
8405
|
-
for (const sourceFile of pkg.sourceFiles) {
|
|
8406
|
-
result.push(...this.sourceFileItemsService.getItems(sourceFile));
|
|
8407
|
-
}
|
|
8408
|
-
}
|
|
8409
|
-
}
|
|
8410
|
-
return result;
|
|
8411
|
-
}
|
|
8412
|
-
};
|
|
8413
|
-
|
|
8414
|
-
// source/services/RenameService.ts
|
|
8415
|
-
var RenameService = class {
|
|
8416
|
-
constructor() {
|
|
8417
|
-
this.referencesService = new ReferencesService();
|
|
8418
|
-
}
|
|
8419
|
-
prepareRename(analyzer, sourceFile, offset) {
|
|
8420
|
-
const checkResult = this.canRename(analyzer, sourceFile, offset);
|
|
8421
|
-
return checkResult?.renameRange;
|
|
8027
|
+
prepareRename(analyzer, sourceFile, offset) {
|
|
8028
|
+
const checkResult = this.canRename(analyzer, sourceFile, offset);
|
|
8029
|
+
return checkResult?.renameRange;
|
|
8422
8030
|
}
|
|
8423
8031
|
rename(analyzer, sourceFile, offset, newText, taskController) {
|
|
8424
8032
|
return __async(this, null, function* () {
|
|
@@ -8520,6 +8128,167 @@ var Rename = class {
|
|
|
8520
8128
|
}
|
|
8521
8129
|
};
|
|
8522
8130
|
|
|
8131
|
+
// source/services/ScriptEditingService.ts
|
|
8132
|
+
var ScriptEditingService = class _ScriptEditingService {
|
|
8133
|
+
static {
|
|
8134
|
+
this.indentationStep = " ";
|
|
8135
|
+
}
|
|
8136
|
+
static {
|
|
8137
|
+
this.elementParameterNameText = "el";
|
|
8138
|
+
}
|
|
8139
|
+
static {
|
|
8140
|
+
this.elementParameterName = new Name(_ScriptEditingService.elementParameterNameText);
|
|
8141
|
+
}
|
|
8142
|
+
createEditWithFieldAssignment(analyzer, sourceFile, scriptDeclaration, fieldName, value) {
|
|
8143
|
+
const subprogramBlock = scriptDeclaration.block;
|
|
8144
|
+
if (subprogramBlock === void 0) {
|
|
8145
|
+
return void 0;
|
|
8146
|
+
}
|
|
8147
|
+
const lastAssignmentStatement = this.findLastAssignmentToField(analyzer, subprogramBlock, fieldName);
|
|
8148
|
+
let result;
|
|
8149
|
+
if (lastAssignmentStatement !== void 0) {
|
|
8150
|
+
result = new SourceFileEdit(sourceFile, lastAssignmentStatement.right.rangeWithoutTrivia, value);
|
|
8151
|
+
} else {
|
|
8152
|
+
const assignmentText = `${_ScriptEditingService.elementParameterNameText}.${fieldName} = ${value}`;
|
|
8153
|
+
if (subprogramBlock.expressionOrStatementList.kind === 93 /* StatementList */) {
|
|
8154
|
+
const lastStatement = subprogramBlock.expressionOrStatementList?.statements.last();
|
|
8155
|
+
let editRange;
|
|
8156
|
+
let indentationText;
|
|
8157
|
+
if (lastStatement !== void 0) {
|
|
8158
|
+
editRange = Range.empty(lastStatement.rangeWithoutTrivia.end);
|
|
8159
|
+
const statementStartCharacter = sourceFile.getPositionAt(lastStatement.rangeWithoutTrivia.start).character;
|
|
8160
|
+
indentationText = `${this.detectNewLine(sourceFile.getSourceText())}${" ".repeat(statementStartCharacter)}`;
|
|
8161
|
+
} else {
|
|
8162
|
+
const openBraceRange = subprogramBlock.openBraceToken.rangeWithoutTrivia;
|
|
8163
|
+
const closeBraceRange = subprogramBlock.closeBraceToken.rangeWithoutTrivia;
|
|
8164
|
+
const openBracePosition = sourceFile.getPositionAt(openBraceRange.start);
|
|
8165
|
+
const closeBracePosition = sourceFile.getPositionAt(closeBraceRange.start);
|
|
8166
|
+
if (openBracePosition.line !== closeBracePosition.line) {
|
|
8167
|
+
editRange = Range.empty(openBraceRange.end);
|
|
8168
|
+
indentationText = `${this.detectNewLine(sourceFile.getSourceText())}${" ".repeat(closeBracePosition.character + 2)}`;
|
|
8169
|
+
} else {
|
|
8170
|
+
editRange = Range.empty(openBraceRange.end);
|
|
8171
|
+
indentationText = " ";
|
|
8172
|
+
}
|
|
8173
|
+
}
|
|
8174
|
+
result = new SourceFileEdit(sourceFile, editRange, `${indentationText}${assignmentText}`);
|
|
8175
|
+
} else {
|
|
8176
|
+
const expressionStartCharacter = sourceFile.getPositionAt(subprogramBlock.expressionOrStatementList.rangeWithoutTrivia.start).character;
|
|
8177
|
+
const indentationText = `${this.detectNewLine(sourceFile.getSourceText())}${" ".repeat(expressionStartCharacter)}`;
|
|
8178
|
+
const editRange = Range.empty(subprogramBlock.expressionOrStatementList.rangeWithoutTrivia.end);
|
|
8179
|
+
result = new SourceFileEdit(sourceFile, editRange, `${indentationText}${assignmentText}`);
|
|
8180
|
+
}
|
|
8181
|
+
}
|
|
8182
|
+
return result;
|
|
8183
|
+
}
|
|
8184
|
+
createEditAddingBlocks(sourceFile, scriptDeclaration, addedBlockInfos) {
|
|
8185
|
+
const subprogramBlock = scriptDeclaration.block;
|
|
8186
|
+
if (subprogramBlock === void 0) {
|
|
8187
|
+
return void 0;
|
|
8188
|
+
}
|
|
8189
|
+
let scriptBlockIndentation;
|
|
8190
|
+
let editStart;
|
|
8191
|
+
if (subprogramBlock.expressionOrStatementList.kind === 93 /* StatementList */) {
|
|
8192
|
+
const lastStatement = subprogramBlock.expressionOrStatementList.statements.last();
|
|
8193
|
+
if (lastStatement !== void 0) {
|
|
8194
|
+
const lastStatementStartCharacter = sourceFile.getPositionAt(lastStatement.rangeWithoutTrivia.start).character;
|
|
8195
|
+
scriptBlockIndentation = " ".repeat(lastStatementStartCharacter);
|
|
8196
|
+
editStart = lastStatement.rangeWithoutTrivia.end;
|
|
8197
|
+
} else {
|
|
8198
|
+
const openBraceStartCharacter = sourceFile.getPositionAt(subprogramBlock.openBraceToken.rangeWithoutTrivia.start).character;
|
|
8199
|
+
scriptBlockIndentation = " ".repeat(openBraceStartCharacter) + _ScriptEditingService.indentationStep;
|
|
8200
|
+
editStart = subprogramBlock.openBraceToken.rangeWithoutTrivia.end;
|
|
8201
|
+
}
|
|
8202
|
+
} else {
|
|
8203
|
+
const expressionStartCharacter = sourceFile.getPositionAt(subprogramBlock.expressionOrStatementList.rangeWithoutTrivia.start).character;
|
|
8204
|
+
scriptBlockIndentation = " ".repeat(expressionStartCharacter);
|
|
8205
|
+
editStart = subprogramBlock.expressionOrStatementList.rangeWithoutTrivia.end;
|
|
8206
|
+
}
|
|
8207
|
+
const newLine = this.detectNewLine(sourceFile.getSourceText());
|
|
8208
|
+
const scriptBlocksText = addedBlockInfos.map((i) => this.createScriptBlockText(i, scriptBlockIndentation, newLine)).join(newLine);
|
|
8209
|
+
const editText = `${newLine}${scriptBlocksText}`;
|
|
8210
|
+
const result = new SourceFileEdit(sourceFile, Range.empty(editStart), editText);
|
|
8211
|
+
return result;
|
|
8212
|
+
}
|
|
8213
|
+
canDeleteBlocks(outerScriptFunctionLocation, scriptFunctionLocations) {
|
|
8214
|
+
const outerScriptPathText = outerScriptFunctionLocation.path.toString();
|
|
8215
|
+
return scriptFunctionLocations.every((l) => l.sourceFile === outerScriptFunctionLocation.sourceFile && l.path.toString().startsWith(outerScriptPathText));
|
|
8216
|
+
}
|
|
8217
|
+
createEditDeletingBlock(sourceFile, scriptDeclaration) {
|
|
8218
|
+
let result;
|
|
8219
|
+
if (NodeTypeUtils.isRegularOrBlockFunctionLiteral(scriptDeclaration) && scriptDeclaration.parent.kind === 150 /* Argument */ && scriptDeclaration.parent.parent.parent.kind === 68 /* CallExpression */) {
|
|
8220
|
+
const callExpression = scriptDeclaration.parent.parent.parent;
|
|
8221
|
+
let rangeStart = callExpression.rangeWithoutTrivia.start;
|
|
8222
|
+
let rangeEnd = callExpression.rangeWithoutTrivia.end;
|
|
8223
|
+
const leadingTrivia = callExpression.findLeftmostToken()?.selectLeadingTrivia(() => true);
|
|
8224
|
+
const lastLeadingTrivia = leadingTrivia !== void 0 && leadingTrivia.length > 0 ? leadingTrivia[leadingTrivia.length - 1] : void 0;
|
|
8225
|
+
if (lastLeadingTrivia?.kind === 0 /* Whitespace */) {
|
|
8226
|
+
rangeStart = lastLeadingTrivia.range.start;
|
|
8227
|
+
}
|
|
8228
|
+
const trailingTrivia = callExpression.findRightmostToken()?.selectTrailingTrivia(() => true);
|
|
8229
|
+
if (trailingTrivia !== void 0) {
|
|
8230
|
+
let trailingTriviaIndex = -1;
|
|
8231
|
+
if (trailingTrivia.length > trailingTriviaIndex + 1 && trailingTrivia[trailingTriviaIndex + 1].kind === 0 /* Whitespace */) {
|
|
8232
|
+
trailingTriviaIndex++;
|
|
8233
|
+
}
|
|
8234
|
+
if (trailingTrivia.length > trailingTriviaIndex + 1 && trailingTrivia[trailingTriviaIndex + 1].kind === 1 /* NewLine */) {
|
|
8235
|
+
trailingTriviaIndex++;
|
|
8236
|
+
}
|
|
8237
|
+
if (trailingTriviaIndex >= 0) {
|
|
8238
|
+
rangeEnd = trailingTrivia[trailingTriviaIndex].range.end;
|
|
8239
|
+
}
|
|
8240
|
+
}
|
|
8241
|
+
result = new SourceFileEdit(sourceFile, new Range(rangeStart, rangeEnd), "");
|
|
8242
|
+
}
|
|
8243
|
+
return result;
|
|
8244
|
+
}
|
|
8245
|
+
findLastAssignmentToField(analyzer, block, fieldNameText) {
|
|
8246
|
+
if (block.expressionOrStatementList.kind !== 93 /* StatementList */) {
|
|
8247
|
+
return void 0;
|
|
8248
|
+
}
|
|
8249
|
+
const fieldName = new Name(fieldNameText);
|
|
8250
|
+
const statements = block.expressionOrStatementList.statements.toArray();
|
|
8251
|
+
for (let i = statements.length - 1; i >= 0; i--) {
|
|
8252
|
+
const statement = statements[i];
|
|
8253
|
+
if (statement.kind === 92 /* AssignmentStatement */) {
|
|
8254
|
+
const left = unwrapParenthesizedExpressions(statement.left);
|
|
8255
|
+
if (left.kind === 76 /* MemberAccessExpression */) {
|
|
8256
|
+
const memberAccessMeaning = analyzer.resolveMemberAccessExpression(left);
|
|
8257
|
+
if (memberAccessMeaning.kind === "instance-field-access" && memberAccessMeaning.field.getName().considerEqual(fieldName)) {
|
|
8258
|
+
const receiver = unwrapParenthesizedExpressions(left.expression);
|
|
8259
|
+
if (receiver.kind === 89 /* IdentifierExpression */) {
|
|
8260
|
+
const receiverMeaning = analyzer.resolveIdentifierExpression(receiver);
|
|
8261
|
+
if (receiverMeaning.kind === "variable-access" && receiverMeaning.variable.getName().considerEqual(_ScriptEditingService.elementParameterName)) {
|
|
8262
|
+
return statement;
|
|
8263
|
+
}
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
}
|
|
8267
|
+
}
|
|
8268
|
+
}
|
|
8269
|
+
return void 0;
|
|
8270
|
+
}
|
|
8271
|
+
createScriptBlockText(blockInfo, indentation, newLine) {
|
|
8272
|
+
const i = indentation;
|
|
8273
|
+
const s = _ScriptEditingService.indentationStep;
|
|
8274
|
+
const nl = newLine;
|
|
8275
|
+
const el = _ScriptEditingService.elementParameterNameText;
|
|
8276
|
+
let result = `${i}${blockInfo.name}(${nl}${i}${s}key = ${blockInfo.key},${nl}`;
|
|
8277
|
+
if (blockInfo.areaIndex !== void 0) {
|
|
8278
|
+
result += `${i}${s}areaIndex = ${blockInfo.areaIndex},${nl}`;
|
|
8279
|
+
}
|
|
8280
|
+
result += `${i}${s}script =${nl}${i}${s}{${nl}` + Object.entries(blockInfo.elementProperties).map(([p, v]) => `${i}${s}${s}${el}.${p} = ${v}${nl}`).join("");
|
|
8281
|
+
if (blockInfo.nestedBlocks.length > 0) {
|
|
8282
|
+
result += blockInfo.nestedBlocks.map((b) => this.createScriptBlockText(b, `${i}${s}${s}`, nl) + nl).join("");
|
|
8283
|
+
}
|
|
8284
|
+
result += `${i}${s}})`;
|
|
8285
|
+
return result;
|
|
8286
|
+
}
|
|
8287
|
+
detectNewLine(text) {
|
|
8288
|
+
return text.includes("\r\n") ? "\r\n" : "\n";
|
|
8289
|
+
}
|
|
8290
|
+
};
|
|
8291
|
+
|
|
8523
8292
|
// source/services/SelectionRangeService.ts
|
|
8524
8293
|
var SelectionRangeService = class {
|
|
8525
8294
|
getSelectionRange(sourceFile, offset) {
|
|
@@ -8542,10 +8311,10 @@ var SelectionRangeService = class {
|
|
|
8542
8311
|
if (child.kind === 0 /* Token */ && (child.tokenKind === 5 /* TextLiteral */ || child.tokenKind === 6 /* TextTemplateHead */ || child.tokenKind === 7 /* TextTemplatePart */ || child.tokenKind === 8 /* TextTemplateTail */)) {
|
|
8543
8312
|
let textContentStart = child.rangeWithoutTrivia.start + 1;
|
|
8544
8313
|
let textContentEnd = child.rangeWithoutTrivia.end - 1;
|
|
8545
|
-
if ((child.flags &
|
|
8314
|
+
if ((child.flags & 512 /* StartsWithTilde */) !== 0) {
|
|
8546
8315
|
textContentStart += 1;
|
|
8547
8316
|
}
|
|
8548
|
-
if ((child.flags &
|
|
8317
|
+
if ((child.flags & 1024 /* EndsWithTilde */) !== 0) {
|
|
8549
8318
|
textContentEnd -= 1;
|
|
8550
8319
|
}
|
|
8551
8320
|
if (offset >= textContentStart && offset < textContentEnd) {
|
|
@@ -11836,56 +11605,40 @@ var EntityToSyntax = class {
|
|
|
11836
11605
|
}
|
|
11837
11606
|
}
|
|
11838
11607
|
convertPackageVariable(entity) {
|
|
11839
|
-
const commonModifiers = new Array();
|
|
11840
|
-
if (entity.isConstant()) {
|
|
11841
|
-
commonModifiers.push(SyntaxFactory.modifier(36 /* Const */));
|
|
11842
|
-
}
|
|
11843
11608
|
const name = this.getEntityName(entity);
|
|
11844
11609
|
const type = this.convertType(entity.getType());
|
|
11610
|
+
const tags = this.convertTags(entity.getTags());
|
|
11611
|
+
const modifiers = this.convertPackageVariableModifiers(entity);
|
|
11845
11612
|
let result;
|
|
11846
11613
|
if (isComputedVariableEntity(entity)) {
|
|
11847
11614
|
result = [];
|
|
11848
11615
|
const getterEntity = entity.getGetter();
|
|
11849
11616
|
if (getterEntity !== void 0) {
|
|
11850
|
-
const tags = this.convertTags(getterEntity.getTags());
|
|
11851
|
-
const modifiers = Array.from(commonModifiers);
|
|
11852
|
-
const isHidden = getterEntity.isHidden();
|
|
11853
|
-
if (isHidden !== void 0) {
|
|
11854
|
-
modifiers.push(this.createHidingModifier(isHidden));
|
|
11855
|
-
}
|
|
11856
11617
|
result.push(SyntaxFactory.packageVariableGetterDeclaration(tags, modifiers, name, type, void 0));
|
|
11857
11618
|
}
|
|
11858
11619
|
const setterEntity = entity.getSetter();
|
|
11859
11620
|
if (setterEntity !== void 0) {
|
|
11860
|
-
const tags = this.convertTags(setterEntity.getTags());
|
|
11861
|
-
const modifiers = Array.from(commonModifiers);
|
|
11862
|
-
const isHidden = setterEntity.isHidden();
|
|
11863
|
-
if (isHidden !== void 0) {
|
|
11864
|
-
modifiers.push(this.createHidingModifier(isHidden));
|
|
11865
|
-
}
|
|
11866
11621
|
result.push(SyntaxFactory.packageVariableSetterDeclaration(tags, modifiers, name, void 0));
|
|
11867
11622
|
}
|
|
11868
11623
|
} else {
|
|
11869
|
-
const tags = this.convertTags(entity.getTags());
|
|
11870
|
-
const modifiers = Array.from(commonModifiers);
|
|
11871
|
-
const isHidden = entity.isHidden();
|
|
11872
|
-
if (isHidden !== void 0) {
|
|
11873
|
-
modifiers.push(this.createHidingModifier(isHidden));
|
|
11874
|
-
}
|
|
11875
11624
|
result = SyntaxFactory.packageVariableDeclaration(tags, modifiers, name, type);
|
|
11876
11625
|
}
|
|
11877
11626
|
return result;
|
|
11878
11627
|
}
|
|
11879
|
-
|
|
11880
|
-
const tags = this.convertTags(entity.getTags());
|
|
11628
|
+
convertPackageVariableModifiers(entity) {
|
|
11881
11629
|
const modifiers = new Array();
|
|
11882
|
-
if (entity.isAsync()) {
|
|
11883
|
-
modifiers.push(SyntaxFactory.modifier(40 /* Async */));
|
|
11884
|
-
}
|
|
11885
11630
|
const isHidden = entity.isHidden();
|
|
11886
11631
|
if (isHidden !== void 0) {
|
|
11887
11632
|
modifiers.push(this.createHidingModifier(isHidden));
|
|
11888
11633
|
}
|
|
11634
|
+
if (entity.isConstant()) {
|
|
11635
|
+
modifiers.push(SyntaxFactory.modifier(36 /* Const */));
|
|
11636
|
+
}
|
|
11637
|
+
return modifiers;
|
|
11638
|
+
}
|
|
11639
|
+
convertPackageFunction(entity) {
|
|
11640
|
+
const tags = this.convertTags(entity.getTags());
|
|
11641
|
+
const modifiers = this.convertPackageFunctionModifiers(entity);
|
|
11889
11642
|
const name = this.getEntityName(entity);
|
|
11890
11643
|
const typeParameters = this.convertTypeParameters(entity.getTypeParameters());
|
|
11891
11644
|
const parameters = this.convertParameters(entity.getParameters());
|
|
@@ -11900,60 +11653,87 @@ var EntityToSyntax = class {
|
|
|
11900
11653
|
void 0
|
|
11901
11654
|
);
|
|
11902
11655
|
}
|
|
11903
|
-
|
|
11904
|
-
const tags = this.convertTags(entity.getTags());
|
|
11656
|
+
convertPackageFunctionModifiers(entity) {
|
|
11905
11657
|
const modifiers = new Array();
|
|
11906
11658
|
const isHidden = entity.isHidden();
|
|
11907
11659
|
if (isHidden !== void 0) {
|
|
11908
11660
|
modifiers.push(this.createHidingModifier(isHidden));
|
|
11909
11661
|
}
|
|
11910
|
-
if (entity.
|
|
11911
|
-
modifiers.push(SyntaxFactory.modifier(
|
|
11912
|
-
}
|
|
11913
|
-
if (entity.isAbstract()) {
|
|
11914
|
-
modifiers.push(SyntaxFactory.modifier(38 /* Abstract */));
|
|
11662
|
+
if (entity.isAsync()) {
|
|
11663
|
+
modifiers.push(SyntaxFactory.modifier(40 /* Async */));
|
|
11915
11664
|
}
|
|
11665
|
+
return modifiers;
|
|
11666
|
+
}
|
|
11667
|
+
convertPackageStructuredType(entity) {
|
|
11668
|
+
const tags = this.convertTags(entity.getTags());
|
|
11669
|
+
const modifiers = this.convertPackageStructuredTypeModifiers(entity);
|
|
11916
11670
|
const name = this.getEntityName(entity);
|
|
11917
11671
|
const typeParameters = this.convertTypeParameters(entity.getTypeParameters());
|
|
11918
11672
|
const body = this.createStructuredTypeDeclarationBody(entity);
|
|
11919
11673
|
return SyntaxFactory.packageStructuredTypeDeclaration(tags, modifiers, name, typeParameters, body);
|
|
11920
11674
|
}
|
|
11921
|
-
|
|
11922
|
-
const tags = this.convertTags(entity.getTags());
|
|
11675
|
+
convertPackageStructuredTypeModifiers(entity) {
|
|
11923
11676
|
const modifiers = new Array();
|
|
11924
11677
|
const isHidden = entity.isHidden();
|
|
11925
11678
|
if (isHidden !== void 0) {
|
|
11926
11679
|
modifiers.push(this.createHidingModifier(isHidden));
|
|
11927
11680
|
}
|
|
11681
|
+
if (entity.markedBasic()) {
|
|
11682
|
+
modifiers.push(SyntaxFactory.modifier(17 /* Basic */));
|
|
11683
|
+
}
|
|
11684
|
+
if (entity.isAbstract()) {
|
|
11685
|
+
modifiers.push(SyntaxFactory.modifier(38 /* Abstract */));
|
|
11686
|
+
}
|
|
11687
|
+
return modifiers;
|
|
11688
|
+
}
|
|
11689
|
+
convertPackageAliasType(entity) {
|
|
11690
|
+
const tags = this.convertTags(entity.getTags());
|
|
11691
|
+
const modifiers = this.convertPackageAliasTypeModifiers(entity);
|
|
11928
11692
|
const name = this.getEntityName(entity);
|
|
11929
11693
|
const typeParameters = this.convertTypeParameters(entity.getTypeParameters());
|
|
11930
11694
|
const body = this.createAliasTypeDeclarationBody(entity);
|
|
11931
11695
|
return SyntaxFactory.packageAliasTypeDeclaration(tags, modifiers, name, typeParameters, body);
|
|
11932
11696
|
}
|
|
11933
|
-
|
|
11934
|
-
const tags = this.convertTags(entity.getTags());
|
|
11697
|
+
convertPackageAliasTypeModifiers(entity) {
|
|
11935
11698
|
const modifiers = new Array();
|
|
11936
11699
|
const isHidden = entity.isHidden();
|
|
11937
11700
|
if (isHidden !== void 0) {
|
|
11938
11701
|
modifiers.push(this.createHidingModifier(isHidden));
|
|
11939
11702
|
}
|
|
11703
|
+
return modifiers;
|
|
11704
|
+
}
|
|
11705
|
+
convertPackageVariantType(entity) {
|
|
11706
|
+
const tags = this.convertTags(entity.getTags());
|
|
11707
|
+
const modifiers = this.convertPackageVariantTypeModifiers(entity);
|
|
11940
11708
|
const name = this.getEntityName(entity);
|
|
11941
11709
|
const typeParameters = this.convertTypeParameters(entity.getTypeParameters());
|
|
11942
11710
|
const body = this.createVariantTypeDeclarationBody(entity);
|
|
11943
11711
|
return SyntaxFactory.packageVariantTypeDeclaration(tags, modifiers, name, typeParameters, body);
|
|
11944
11712
|
}
|
|
11945
|
-
|
|
11946
|
-
const tags = this.convertTags(entity.getTags());
|
|
11713
|
+
convertPackageVariantTypeModifiers(entity) {
|
|
11947
11714
|
const modifiers = new Array();
|
|
11948
11715
|
const isHidden = entity.isHidden();
|
|
11949
11716
|
if (isHidden !== void 0) {
|
|
11950
11717
|
modifiers.push(this.createHidingModifier(isHidden));
|
|
11951
11718
|
}
|
|
11719
|
+
return modifiers;
|
|
11720
|
+
}
|
|
11721
|
+
convertPackageFunctionType(entity) {
|
|
11722
|
+
const tags = this.convertTags(entity.getTags());
|
|
11723
|
+
const modifiers = this.convertPackageFunctionTypeModifiers(entity);
|
|
11952
11724
|
const name = this.getEntityName(entity);
|
|
11953
11725
|
const typeParameters = this.convertTypeParameters(entity.getTypeParameters());
|
|
11954
11726
|
const body = this.createFunctionTypeDeclarationBody(entity);
|
|
11955
11727
|
return SyntaxFactory.packageFunctionTypeDeclaration(tags, modifiers, name, typeParameters, body);
|
|
11956
11728
|
}
|
|
11729
|
+
convertPackageFunctionTypeModifiers(entity) {
|
|
11730
|
+
const modifiers = new Array();
|
|
11731
|
+
const isHidden = entity.isHidden();
|
|
11732
|
+
if (isHidden !== void 0) {
|
|
11733
|
+
modifiers.push(this.createHidingModifier(isHidden));
|
|
11734
|
+
}
|
|
11735
|
+
return modifiers;
|
|
11736
|
+
}
|
|
11957
11737
|
convertTypeEntityMembers(members) {
|
|
11958
11738
|
const variables = members.getNamedMembers().filter((m) => m.kind === 0 /* Variable */).flatMap((m) => this.convertField(m));
|
|
11959
11739
|
const methods = members.getNamedMembers().filter((m) => m.kind !== 0 /* Variable */).map((m) => this.convertMethod(m));
|
|
@@ -11966,60 +11746,27 @@ var EntityToSyntax = class {
|
|
|
11966
11746
|
if (entity.isVariant()) {
|
|
11967
11747
|
return this.convertVariant(entity);
|
|
11968
11748
|
}
|
|
11969
|
-
const commonModifiers = new Array();
|
|
11970
|
-
if (entity.isConstant()) {
|
|
11971
|
-
commonModifiers.push(SyntaxFactory.modifier(36 /* Const */));
|
|
11972
|
-
}
|
|
11973
|
-
if (entity.isStatic()) {
|
|
11974
|
-
commonModifiers.push(SyntaxFactory.modifier(41 /* Static */));
|
|
11975
|
-
}
|
|
11976
|
-
if (entity.markedAbstract()) {
|
|
11977
|
-
commonModifiers.push(SyntaxFactory.modifier(38 /* Abstract */));
|
|
11978
|
-
}
|
|
11979
|
-
if (entity.markedBasic()) {
|
|
11980
|
-
commonModifiers.push(SyntaxFactory.modifier(17 /* Basic */));
|
|
11981
|
-
}
|
|
11982
|
-
if (entity.isOverride()) {
|
|
11983
|
-
commonModifiers.push(SyntaxFactory.modifier(39 /* Override */));
|
|
11984
|
-
}
|
|
11985
11749
|
const name = this.getEntityName(entity);
|
|
11986
11750
|
const type = this.convertType(entity.getType());
|
|
11751
|
+
const tags = this.convertTags(entity.getTags());
|
|
11752
|
+
const modifiers = this.convertFieldModifiers(entity);
|
|
11987
11753
|
let result;
|
|
11988
11754
|
if (isComputedVariableEntity(entity)) {
|
|
11989
11755
|
result = [];
|
|
11990
11756
|
const getterEntity = entity.getGetter();
|
|
11991
11757
|
if (getterEntity !== void 0) {
|
|
11992
|
-
const tags = this.convertTags(getterEntity.getTags());
|
|
11993
|
-
const modifiers = Array.from(commonModifiers);
|
|
11994
|
-
const isHidden = getterEntity.isHidden();
|
|
11995
|
-
if (isHidden !== void 0) {
|
|
11996
|
-
modifiers.push(this.createHidingModifier(isHidden));
|
|
11997
|
-
}
|
|
11998
11758
|
result.push(SyntaxFactory.fieldGetterDeclaration(tags, modifiers, name, type, void 0));
|
|
11999
11759
|
}
|
|
12000
11760
|
const setterEntity = entity.getSetter();
|
|
12001
11761
|
if (setterEntity !== void 0) {
|
|
12002
|
-
const tags = this.convertTags(setterEntity.getTags());
|
|
12003
|
-
const modifiers = Array.from(commonModifiers);
|
|
12004
|
-
const isHidden = setterEntity.isHidden();
|
|
12005
|
-
if (isHidden !== void 0) {
|
|
12006
|
-
modifiers.push(this.createHidingModifier(isHidden));
|
|
12007
|
-
}
|
|
12008
11762
|
result.push(SyntaxFactory.fieldSetterDeclaration(tags, modifiers, name, void 0));
|
|
12009
11763
|
}
|
|
12010
11764
|
} else {
|
|
12011
|
-
|
|
12012
|
-
const modifiers = Array.from(commonModifiers);
|
|
12013
|
-
const isHidden = entity.isHidden();
|
|
12014
|
-
if (isHidden !== void 0) {
|
|
12015
|
-
modifiers.push(this.createHidingModifier(isHidden));
|
|
12016
|
-
}
|
|
12017
|
-
result = SyntaxFactory.fieldDeclaration(tags, commonModifiers, name, type);
|
|
11765
|
+
result = SyntaxFactory.fieldDeclaration(tags, modifiers, name, type);
|
|
12018
11766
|
}
|
|
12019
11767
|
return result;
|
|
12020
11768
|
}
|
|
12021
|
-
|
|
12022
|
-
const tags = this.convertTags(entity.getTags());
|
|
11769
|
+
convertFieldModifiers(entity) {
|
|
12023
11770
|
const modifiers = new Array();
|
|
12024
11771
|
const isHidden = entity.isHidden();
|
|
12025
11772
|
if (isHidden !== void 0) {
|
|
@@ -12028,36 +11775,56 @@ var EntityToSyntax = class {
|
|
|
12028
11775
|
if (entity.isStatic()) {
|
|
12029
11776
|
modifiers.push(SyntaxFactory.modifier(41 /* Static */));
|
|
12030
11777
|
}
|
|
12031
|
-
if (entity.markedAbstract()) {
|
|
12032
|
-
modifiers.push(SyntaxFactory.modifier(38 /* Abstract */));
|
|
12033
|
-
}
|
|
12034
11778
|
if (entity.markedBasic()) {
|
|
12035
11779
|
modifiers.push(SyntaxFactory.modifier(17 /* Basic */));
|
|
12036
11780
|
}
|
|
11781
|
+
if (entity.markedAbstract()) {
|
|
11782
|
+
modifiers.push(SyntaxFactory.modifier(38 /* Abstract */));
|
|
11783
|
+
}
|
|
12037
11784
|
if (entity.isOverride()) {
|
|
12038
11785
|
modifiers.push(SyntaxFactory.modifier(39 /* Override */));
|
|
12039
11786
|
}
|
|
11787
|
+
if (entity.isConstant()) {
|
|
11788
|
+
modifiers.push(SyntaxFactory.modifier(36 /* Const */));
|
|
11789
|
+
}
|
|
11790
|
+
return modifiers;
|
|
11791
|
+
}
|
|
11792
|
+
convertMethod(entity) {
|
|
11793
|
+
const tags = this.convertTags(entity.getTags());
|
|
11794
|
+
const modifiers = this.convertMethodModifiers(entity);
|
|
12040
11795
|
const name = this.getEntityName(entity);
|
|
12041
11796
|
const typeParameters = this.convertTypeParameters(entity.getTypeParameters());
|
|
12042
11797
|
const parameters = this.convertParameters(entity.getParameters());
|
|
12043
11798
|
const returnType = this.convertType(entity.getReturnType());
|
|
12044
11799
|
return SyntaxFactory.methodDeclaration(tags, modifiers, name, typeParameters, parameters, returnType, void 0);
|
|
12045
11800
|
}
|
|
12046
|
-
|
|
12047
|
-
const tags = this.convertTags(entity.getTags());
|
|
11801
|
+
convertMethodModifiers(entity) {
|
|
12048
11802
|
const modifiers = new Array();
|
|
12049
11803
|
const isHidden = entity.isHidden();
|
|
12050
11804
|
if (isHidden !== void 0) {
|
|
12051
11805
|
modifiers.push(this.createHidingModifier(isHidden));
|
|
12052
11806
|
}
|
|
11807
|
+
if (entity.isStatic()) {
|
|
11808
|
+
modifiers.push(SyntaxFactory.modifier(41 /* Static */));
|
|
11809
|
+
}
|
|
11810
|
+
if (entity.markedBasic()) {
|
|
11811
|
+
modifiers.push(SyntaxFactory.modifier(17 /* Basic */));
|
|
11812
|
+
}
|
|
12053
11813
|
if (entity.markedAbstract()) {
|
|
12054
11814
|
modifiers.push(SyntaxFactory.modifier(38 /* Abstract */));
|
|
12055
11815
|
}
|
|
11816
|
+
if (entity.isOverride()) {
|
|
11817
|
+
modifiers.push(SyntaxFactory.modifier(39 /* Override */));
|
|
11818
|
+
}
|
|
11819
|
+
return modifiers;
|
|
11820
|
+
}
|
|
11821
|
+
convertConstructor(entity) {
|
|
11822
|
+
const tags = this.convertTags(entity.getTags());
|
|
11823
|
+
const modifiers = this.convertConstructorModifiers(entity);
|
|
12056
11824
|
const parameters = this.convertParameters(entity.getParameters());
|
|
12057
11825
|
return SyntaxFactory.constructorDeclaration(tags, modifiers, parameters, void 0);
|
|
12058
11826
|
}
|
|
12059
|
-
|
|
12060
|
-
const tags = this.convertTags(entity.getTags());
|
|
11827
|
+
convertConstructorModifiers(entity) {
|
|
12061
11828
|
const modifiers = new Array();
|
|
12062
11829
|
const isHidden = entity.isHidden();
|
|
12063
11830
|
if (isHidden !== void 0) {
|
|
@@ -12066,40 +11833,57 @@ var EntityToSyntax = class {
|
|
|
12066
11833
|
if (entity.markedAbstract()) {
|
|
12067
11834
|
modifiers.push(SyntaxFactory.modifier(38 /* Abstract */));
|
|
12068
11835
|
}
|
|
11836
|
+
return modifiers;
|
|
11837
|
+
}
|
|
11838
|
+
convertDestructor(entity) {
|
|
11839
|
+
const tags = this.convertTags(entity.getTags());
|
|
11840
|
+
const modifiers = this.convertDestructorModifiers(entity);
|
|
12069
11841
|
const parameters = this.convertParameters(entity.getParameters());
|
|
12070
11842
|
return SyntaxFactory.destructorDeclaration(tags, modifiers, parameters, void 0);
|
|
12071
11843
|
}
|
|
12072
|
-
|
|
12073
|
-
const
|
|
12074
|
-
|
|
12075
|
-
|
|
11844
|
+
convertDestructorModifiers(entity) {
|
|
11845
|
+
const modifiers = new Array();
|
|
11846
|
+
const isHidden = entity.isHidden();
|
|
11847
|
+
if (isHidden !== void 0) {
|
|
11848
|
+
modifiers.push(this.createHidingModifier(isHidden));
|
|
12076
11849
|
}
|
|
12077
11850
|
if (entity.markedAbstract()) {
|
|
12078
|
-
|
|
11851
|
+
modifiers.push(SyntaxFactory.modifier(38 /* Abstract */));
|
|
12079
11852
|
}
|
|
11853
|
+
return modifiers;
|
|
11854
|
+
}
|
|
11855
|
+
convertIndexer(entity) {
|
|
11856
|
+
const tags = this.convertTags(entity.getTags());
|
|
11857
|
+
const modifiers = this.convertIndexerModifiers(entity);
|
|
12080
11858
|
const parameters = this.convertParameters(entity.getParameters());
|
|
12081
11859
|
const result = new Array();
|
|
12082
11860
|
const getterEntity = entity.getGetter();
|
|
12083
11861
|
if (getterEntity !== void 0) {
|
|
12084
|
-
const tags = this.convertTags(getterEntity.getTags());
|
|
12085
|
-
const modifiers = Array.from(commonModifiers);
|
|
12086
|
-
const isHidden = entity.isHidden();
|
|
12087
|
-
if (isHidden !== void 0) {
|
|
12088
|
-
modifiers.push(this.createHidingModifier(isHidden));
|
|
12089
|
-
}
|
|
12090
11862
|
const type = this.convertType(entity.getType());
|
|
12091
11863
|
const declaration = SyntaxFactory.indexedElementGetterDeclaration(tags, modifiers, parameters, type, void 0);
|
|
12092
11864
|
result.push(declaration);
|
|
12093
11865
|
}
|
|
12094
11866
|
const setterEntity = entity.getSetter();
|
|
12095
11867
|
if (setterEntity !== void 0) {
|
|
12096
|
-
const tags = this.convertTags(setterEntity.getTags());
|
|
12097
|
-
const modifiers = Array.from(commonModifiers);
|
|
12098
11868
|
const declaration = SyntaxFactory.indexedElementSetterDeclaration(tags, modifiers, parameters, void 0);
|
|
12099
11869
|
result.push(declaration);
|
|
12100
11870
|
}
|
|
12101
11871
|
return result;
|
|
12102
11872
|
}
|
|
11873
|
+
convertIndexerModifiers(entity) {
|
|
11874
|
+
const modifiers = new Array();
|
|
11875
|
+
const isHidden = entity.isHidden();
|
|
11876
|
+
if (isHidden !== void 0) {
|
|
11877
|
+
modifiers.push(this.createHidingModifier(isHidden));
|
|
11878
|
+
}
|
|
11879
|
+
if (entity.isStatic()) {
|
|
11880
|
+
modifiers.push(SyntaxFactory.modifier(41 /* Static */));
|
|
11881
|
+
}
|
|
11882
|
+
if (entity.markedAbstract()) {
|
|
11883
|
+
modifiers.push(SyntaxFactory.modifier(38 /* Abstract */));
|
|
11884
|
+
}
|
|
11885
|
+
return modifiers;
|
|
11886
|
+
}
|
|
12103
11887
|
convertVariant(entity) {
|
|
12104
11888
|
const tags = this.convertTags(entity.getTags());
|
|
12105
11889
|
const name = this.getEntityName(entity);
|
|
@@ -12234,6 +12018,8 @@ var EntityToSyntax = class {
|
|
|
12234
12018
|
return this.convertIntersectionType(type);
|
|
12235
12019
|
case "unresolved":
|
|
12236
12020
|
return this.convertUnresolvedType(type);
|
|
12021
|
+
case "substitution-stub":
|
|
12022
|
+
return this.convertSubstitutionStubType(type);
|
|
12237
12023
|
default:
|
|
12238
12024
|
Debug.never(type);
|
|
12239
12025
|
}
|
|
@@ -12295,6 +12081,9 @@ var EntityToSyntax = class {
|
|
|
12295
12081
|
convertUnresolvedType(_type) {
|
|
12296
12082
|
return SyntaxFactory.namedTypeSpecifier("\u041E\u0431\u044A\u0435\u043A\u0442");
|
|
12297
12083
|
}
|
|
12084
|
+
convertSubstitutionStubType(_type) {
|
|
12085
|
+
return SyntaxFactory.namedTypeSpecifier("\u041E\u0431\u044A\u0435\u043A\u0442");
|
|
12086
|
+
}
|
|
12298
12087
|
createNamedTypeSpecifier(name, substitutions) {
|
|
12299
12088
|
const typeArguments = Query.from(substitutions.getTypes()).map((t) => this.convertType(t)).toArray();
|
|
12300
12089
|
return SyntaxFactory.namedTypeSpecifier(name, typeArguments);
|
|
@@ -12699,191 +12488,488 @@ var EntityFinder = class {
|
|
|
12699
12488
|
return index >= 0 ? members[index] : void 0;
|
|
12700
12489
|
}
|
|
12701
12490
|
}
|
|
12702
|
-
case "nested":
|
|
12703
|
-
case "anonymous":
|
|
12491
|
+
case "nested":
|
|
12492
|
+
case "anonymous":
|
|
12493
|
+
return void 0;
|
|
12494
|
+
default:
|
|
12495
|
+
Debug.never(entity);
|
|
12496
|
+
}
|
|
12497
|
+
}
|
|
12498
|
+
findConstructorEntity(entity) {
|
|
12499
|
+
const containingType = this.findEntity(entity.getContainingEntity());
|
|
12500
|
+
if (!(containingType !== void 0 && isTypeEntity(containingType) && isTypeEntityWithMembers(containingType))) {
|
|
12501
|
+
return void 0;
|
|
12502
|
+
}
|
|
12503
|
+
const members = containingType.getMembers().getConstructors();
|
|
12504
|
+
if (members.length === 0) {
|
|
12505
|
+
return void 0;
|
|
12506
|
+
} else if (members.length === 1) {
|
|
12507
|
+
return members[0];
|
|
12508
|
+
} else {
|
|
12509
|
+
const referenceData = new DataForFindingOverloadedMember([], entity.getParameters());
|
|
12510
|
+
const membersData = members.map((m) => new DataForFindingOverloadedMember([], m.getParameters()));
|
|
12511
|
+
const index = this.findOverloadedMemberIndex(referenceData, membersData);
|
|
12512
|
+
return index >= 0 ? members[index] : void 0;
|
|
12513
|
+
}
|
|
12514
|
+
}
|
|
12515
|
+
findDestructorEntity(entity) {
|
|
12516
|
+
const containingType = this.findEntity(entity.getContainingEntity());
|
|
12517
|
+
if (!(containingType !== void 0 && isTypeEntity(containingType) && isTypeEntityWithMembers(containingType))) {
|
|
12518
|
+
return void 0;
|
|
12519
|
+
}
|
|
12520
|
+
const members = containingType.getMembers().getDestructors();
|
|
12521
|
+
if (members.length === 0) {
|
|
12522
|
+
return void 0;
|
|
12523
|
+
} else if (members.length === 1) {
|
|
12524
|
+
return members[0];
|
|
12525
|
+
} else {
|
|
12526
|
+
const referenceData = new DataForFindingOverloadedMember([], entity.getParameters());
|
|
12527
|
+
const membersData = members.map((m) => new DataForFindingOverloadedMember([], m.getParameters()));
|
|
12528
|
+
const index = this.findOverloadedMemberIndex(referenceData, membersData);
|
|
12529
|
+
return index >= 0 ? members[index] : void 0;
|
|
12530
|
+
}
|
|
12531
|
+
}
|
|
12532
|
+
findOperatorEntity(entity) {
|
|
12533
|
+
const containingType = this.findEntity(entity.getContainingEntity());
|
|
12534
|
+
if (!(containingType !== void 0 && isTypeEntity(containingType) && isTypeEntityWithMembers(containingType))) {
|
|
12535
|
+
return void 0;
|
|
12536
|
+
}
|
|
12537
|
+
const members = containingType.getMembers().getOperators();
|
|
12538
|
+
if (members.length === 0) {
|
|
12539
|
+
return void 0;
|
|
12540
|
+
} else if (members.length === 1) {
|
|
12541
|
+
return members[0];
|
|
12542
|
+
} else {
|
|
12543
|
+
const referenceData = new DataForFindingOverloadedMember([], entity.getParameters());
|
|
12544
|
+
const membersData = members.map((m) => new DataForFindingOverloadedMember([], m.getParameters()));
|
|
12545
|
+
const index = this.findOverloadedMemberIndex(referenceData, membersData);
|
|
12546
|
+
return index >= 0 ? members[index] : void 0;
|
|
12547
|
+
}
|
|
12548
|
+
}
|
|
12549
|
+
findIndexerEntity(entity) {
|
|
12550
|
+
const containingType = this.findEntity(entity.getContainingEntity());
|
|
12551
|
+
if (!(containingType !== void 0 && isTypeEntity(containingType) && isTypeEntityWithMembers(containingType))) {
|
|
12552
|
+
return void 0;
|
|
12553
|
+
}
|
|
12554
|
+
const members = containingType.getMembers().getIndexers();
|
|
12555
|
+
if (members.length === 0) {
|
|
12556
|
+
return void 0;
|
|
12557
|
+
} else if (members.length === 1) {
|
|
12558
|
+
return members[0];
|
|
12559
|
+
} else {
|
|
12560
|
+
const referenceData = new DataForFindingOverloadedMember([], entity.getParameters());
|
|
12561
|
+
const membersData = members.map((m) => new DataForFindingOverloadedMember([], m.getParameters()));
|
|
12562
|
+
const index = this.findOverloadedMemberIndex(referenceData, membersData);
|
|
12563
|
+
return index >= 0 ? members[index] : void 0;
|
|
12564
|
+
}
|
|
12565
|
+
}
|
|
12566
|
+
findDereferenceOperatorEntity(entity) {
|
|
12567
|
+
const containingType = this.findEntity(entity.getContainingEntity());
|
|
12568
|
+
if (!(containingType !== void 0 && isTypeEntity(containingType) && isTypeEntityWithMembers(containingType))) {
|
|
12569
|
+
return void 0;
|
|
12570
|
+
}
|
|
12571
|
+
const members = containingType.getMembers().getDereferenceOperators();
|
|
12572
|
+
if (members.length === 0) {
|
|
12573
|
+
return void 0;
|
|
12574
|
+
} else if (members.length === 1) {
|
|
12575
|
+
return members[0];
|
|
12576
|
+
} else {
|
|
12577
|
+
return void 0;
|
|
12578
|
+
}
|
|
12579
|
+
}
|
|
12580
|
+
findTypeParameterEntity(entity) {
|
|
12581
|
+
const containingEntity = this.findEntity(entity.getContainingEntity());
|
|
12582
|
+
const index = entity.getContainingEntity().getTypeParameters().indexOf(entity);
|
|
12583
|
+
if (containingEntity !== void 0 && index >= 0) {
|
|
12584
|
+
return this.ifEntityWithTypeParametersThenParameters(containingEntity)?.[index];
|
|
12585
|
+
} else {
|
|
12586
|
+
return void 0;
|
|
12587
|
+
}
|
|
12588
|
+
}
|
|
12589
|
+
findPackageTypeEntityByNameAndArity(name, arity) {
|
|
12590
|
+
return this.packageEntity.getMembers().getNamedMembersByName(name).filter((m) => m.kind === 2 /* Type */).find((m) => m.getArity() === arity);
|
|
12591
|
+
}
|
|
12592
|
+
ifEntityWithParametersThenParameters(entity) {
|
|
12593
|
+
switch (entity.kind) {
|
|
12594
|
+
case 1 /* Function */:
|
|
12595
|
+
return entity.getParameters();
|
|
12596
|
+
case 5 /* Indexer */:
|
|
12597
|
+
return entity.getParameters();
|
|
12598
|
+
case 7 /* Constructor */:
|
|
12599
|
+
return entity.getParameters();
|
|
12600
|
+
case 8 /* Destructor */:
|
|
12601
|
+
return entity.getParameters();
|
|
12602
|
+
case 2 /* Type */: {
|
|
12603
|
+
if (entity.typeEntityKind === 0 /* Function */) {
|
|
12604
|
+
return entity.getParameters();
|
|
12605
|
+
}
|
|
12606
|
+
return void 0;
|
|
12607
|
+
}
|
|
12608
|
+
case 9 /* Operator */:
|
|
12609
|
+
return entity.getParameters();
|
|
12610
|
+
case 0 /* Variable */:
|
|
12611
|
+
case 3 /* Getter */:
|
|
12612
|
+
case 4 /* Setter */:
|
|
12613
|
+
case 10 /* PackageAlias */:
|
|
12614
|
+
case 12 /* Package */:
|
|
12615
|
+
case 11 /* TypeExtension */:
|
|
12616
|
+
case 6 /* DereferenceOperator */:
|
|
12617
|
+
return void 0;
|
|
12618
|
+
case 13 /* TextTranslation */:
|
|
12619
|
+
return void 0;
|
|
12620
|
+
default:
|
|
12621
|
+
Debug.never(entity);
|
|
12622
|
+
}
|
|
12623
|
+
}
|
|
12624
|
+
ifEntityWithTypeParametersThenParameters(entity) {
|
|
12625
|
+
switch (entity.kind) {
|
|
12626
|
+
case 1 /* Function */:
|
|
12627
|
+
return entity.getTypeParameters();
|
|
12628
|
+
case 2 /* Type */: {
|
|
12629
|
+
if (entity.typeEntityKind !== 2 /* Parameter */) {
|
|
12630
|
+
return entity.getTypeParameters();
|
|
12631
|
+
}
|
|
12632
|
+
return void 0;
|
|
12633
|
+
}
|
|
12634
|
+
case 8 /* Destructor */:
|
|
12635
|
+
case 7 /* Constructor */:
|
|
12636
|
+
case 5 /* Indexer */:
|
|
12637
|
+
case 6 /* DereferenceOperator */:
|
|
12638
|
+
case 0 /* Variable */:
|
|
12639
|
+
case 3 /* Getter */:
|
|
12640
|
+
case 4 /* Setter */:
|
|
12641
|
+
case 10 /* PackageAlias */:
|
|
12642
|
+
case 12 /* Package */:
|
|
12643
|
+
case 11 /* TypeExtension */:
|
|
12644
|
+
case 9 /* Operator */:
|
|
12645
|
+
case 13 /* TextTranslation */:
|
|
12704
12646
|
return void 0;
|
|
12705
12647
|
default:
|
|
12706
12648
|
Debug.never(entity);
|
|
12707
12649
|
}
|
|
12708
12650
|
}
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12723
|
-
return index >= 0 ? members[index] : void 0;
|
|
12651
|
+
findOverloadedMemberIndex(referenceData, membersData) {
|
|
12652
|
+
for (let i = 0; i < membersData.length; i++) {
|
|
12653
|
+
const memberData = membersData[i];
|
|
12654
|
+
if (memberData.typeParameters.length !== referenceData.typeParameters.length || memberData.parameters.length !== referenceData.parameters.length) {
|
|
12655
|
+
continue;
|
|
12656
|
+
}
|
|
12657
|
+
const parametersAreEqual = Query.zip(
|
|
12658
|
+
memberData.parameters,
|
|
12659
|
+
referenceData.parameters,
|
|
12660
|
+
(r, m) => this.getEntityName(r).considerEqual(this.getEntityName(m))
|
|
12661
|
+
).all((v) => v);
|
|
12662
|
+
if (parametersAreEqual) {
|
|
12663
|
+
return i;
|
|
12664
|
+
}
|
|
12724
12665
|
}
|
|
12666
|
+
return -1;
|
|
12725
12667
|
}
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
if (!(containingType !== void 0 && isTypeEntity(containingType) && isTypeEntityWithMembers(containingType))) {
|
|
12729
|
-
return void 0;
|
|
12730
|
-
}
|
|
12731
|
-
const members = containingType.getMembers().getDestructors();
|
|
12732
|
-
if (members.length === 0) {
|
|
12733
|
-
return void 0;
|
|
12734
|
-
} else if (members.length === 1) {
|
|
12735
|
-
return members[0];
|
|
12736
|
-
} else {
|
|
12737
|
-
const referenceData = new DataForFindingOverloadedMember([], entity.getParameters());
|
|
12738
|
-
const membersData = members.map((m) => new DataForFindingOverloadedMember([], m.getParameters()));
|
|
12739
|
-
const index = this.findOverloadedMemberIndex(referenceData, membersData);
|
|
12740
|
-
return index >= 0 ? members[index] : void 0;
|
|
12741
|
-
}
|
|
12668
|
+
getEntityName(entity) {
|
|
12669
|
+
return entity.getName();
|
|
12742
12670
|
}
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12671
|
+
};
|
|
12672
|
+
var DataForFindingOverloadedMember = class {
|
|
12673
|
+
constructor(typeParameters, parameters) {
|
|
12674
|
+
this.typeParameters = typeParameters;
|
|
12675
|
+
this.parameters = parameters;
|
|
12676
|
+
}
|
|
12677
|
+
};
|
|
12678
|
+
|
|
12679
|
+
// source/services/SourceFileItemsService.ts
|
|
12680
|
+
var SourceFileItemsService = class {
|
|
12681
|
+
getItems(sourceFile) {
|
|
12682
|
+
this.sourceFile = sourceFile;
|
|
12683
|
+
return this.getChildItems(sourceFile.getSyntaxNode());
|
|
12684
|
+
}
|
|
12685
|
+
get locale() {
|
|
12686
|
+
return this.sourceFile.package.locale;
|
|
12687
|
+
}
|
|
12688
|
+
get dialect() {
|
|
12689
|
+
return this.sourceFile.package.dialect;
|
|
12690
|
+
}
|
|
12691
|
+
getChildItems(node) {
|
|
12692
|
+
const result = new Array();
|
|
12693
|
+
visitChildren(node, false, (node2) => {
|
|
12694
|
+
const items = this.getChildItems(node2);
|
|
12695
|
+
switch (node2.kind) {
|
|
12696
|
+
case 8 /* PackageImport */: {
|
|
12697
|
+
if (node2.alias !== void 0) {
|
|
12698
|
+
result.push(this.createItem(
|
|
12699
|
+
0 /* PackageAlias */,
|
|
12700
|
+
node2.alias.value,
|
|
12701
|
+
node2.rangeWithoutTrivia,
|
|
12702
|
+
node2.alias.rangeWithoutTrivia,
|
|
12703
|
+
items
|
|
12704
|
+
));
|
|
12705
|
+
}
|
|
12706
|
+
break;
|
|
12707
|
+
}
|
|
12708
|
+
case 33 /* PackageVariableDeclaration */: {
|
|
12709
|
+
result.push(this.createItem(
|
|
12710
|
+
1 /* PackageVariable */,
|
|
12711
|
+
node2.name.value,
|
|
12712
|
+
node2.rangeWithoutTrivia,
|
|
12713
|
+
node2.name.rangeWithoutTrivia,
|
|
12714
|
+
items
|
|
12715
|
+
));
|
|
12716
|
+
break;
|
|
12717
|
+
}
|
|
12718
|
+
case 34 /* PackageVariableGetterDeclaration */: {
|
|
12719
|
+
result.push(this.createItem(
|
|
12720
|
+
2 /* PackageVariableGetter */,
|
|
12721
|
+
node2.name.value,
|
|
12722
|
+
node2.rangeWithoutTrivia,
|
|
12723
|
+
node2.name.rangeWithoutTrivia,
|
|
12724
|
+
items
|
|
12725
|
+
));
|
|
12726
|
+
break;
|
|
12727
|
+
}
|
|
12728
|
+
case 35 /* PackageVariableSetterDeclaration */: {
|
|
12729
|
+
result.push(this.createItem(
|
|
12730
|
+
3 /* PackageVariableSetter */,
|
|
12731
|
+
node2.name.value,
|
|
12732
|
+
node2.rangeWithoutTrivia,
|
|
12733
|
+
node2.name.rangeWithoutTrivia,
|
|
12734
|
+
items
|
|
12735
|
+
));
|
|
12736
|
+
break;
|
|
12737
|
+
}
|
|
12738
|
+
case 25 /* PackageFunctionDeclaration */: {
|
|
12739
|
+
result.push(this.createItem(
|
|
12740
|
+
4 /* PackageFunction */,
|
|
12741
|
+
node2.name.value,
|
|
12742
|
+
node2.rangeWithoutTrivia,
|
|
12743
|
+
node2.name.rangeWithoutTrivia,
|
|
12744
|
+
items
|
|
12745
|
+
));
|
|
12746
|
+
break;
|
|
12747
|
+
}
|
|
12748
|
+
case 31 /* PackageStructuredTypeDeclaration */: {
|
|
12749
|
+
result.push(this.createItem(
|
|
12750
|
+
5 /* StructuredType */,
|
|
12751
|
+
node2.name.value,
|
|
12752
|
+
node2.rangeWithoutTrivia,
|
|
12753
|
+
node2.name.rangeWithoutTrivia,
|
|
12754
|
+
items
|
|
12755
|
+
));
|
|
12756
|
+
break;
|
|
12757
|
+
}
|
|
12758
|
+
case 52 /* FieldDeclaration */: {
|
|
12759
|
+
result.push(this.createItem(
|
|
12760
|
+
12 /* Field */,
|
|
12761
|
+
node2.name.value,
|
|
12762
|
+
node2.rangeWithoutTrivia,
|
|
12763
|
+
node2.name.rangeWithoutTrivia,
|
|
12764
|
+
items
|
|
12765
|
+
));
|
|
12766
|
+
break;
|
|
12767
|
+
}
|
|
12768
|
+
case 53 /* FieldGetterDeclaration */: {
|
|
12769
|
+
result.push(this.createItem(
|
|
12770
|
+
13 /* FieldGetter */,
|
|
12771
|
+
node2.name.value,
|
|
12772
|
+
node2.rangeWithoutTrivia,
|
|
12773
|
+
node2.name.rangeWithoutTrivia,
|
|
12774
|
+
items
|
|
12775
|
+
));
|
|
12776
|
+
break;
|
|
12777
|
+
}
|
|
12778
|
+
case 54 /* FieldSetterDeclaration */: {
|
|
12779
|
+
result.push(this.createItem(
|
|
12780
|
+
14 /* FieldSetter */,
|
|
12781
|
+
node2.name.value,
|
|
12782
|
+
node2.rangeWithoutTrivia,
|
|
12783
|
+
node2.name.rangeWithoutTrivia,
|
|
12784
|
+
items
|
|
12785
|
+
));
|
|
12786
|
+
break;
|
|
12787
|
+
}
|
|
12788
|
+
case 50 /* MethodDeclaration */: {
|
|
12789
|
+
result.push(this.createItem(
|
|
12790
|
+
15 /* Method */,
|
|
12791
|
+
node2.name.value,
|
|
12792
|
+
node2.rangeWithoutTrivia,
|
|
12793
|
+
node2.name.rangeWithoutTrivia,
|
|
12794
|
+
items
|
|
12795
|
+
));
|
|
12796
|
+
break;
|
|
12797
|
+
}
|
|
12798
|
+
case 43 /* ConstructorDeclaration */: {
|
|
12799
|
+
result.push(this.createItem(
|
|
12800
|
+
10 /* Constructor */,
|
|
12801
|
+
void 0,
|
|
12802
|
+
node2.rangeWithoutTrivia,
|
|
12803
|
+
node2.rangeWithoutTrivia,
|
|
12804
|
+
items
|
|
12805
|
+
));
|
|
12806
|
+
break;
|
|
12807
|
+
}
|
|
12808
|
+
case 44 /* DestructorDeclaration */: {
|
|
12809
|
+
result.push(this.createItem(
|
|
12810
|
+
11 /* Destructor */,
|
|
12811
|
+
void 0,
|
|
12812
|
+
node2.rangeWithoutTrivia,
|
|
12813
|
+
node2.rangeWithoutTrivia,
|
|
12814
|
+
items
|
|
12815
|
+
));
|
|
12816
|
+
break;
|
|
12817
|
+
}
|
|
12818
|
+
case 45 /* IndexedElementGetterDeclaration */: {
|
|
12819
|
+
result.push(this.createItem(
|
|
12820
|
+
16 /* IndexedElementGetter */,
|
|
12821
|
+
void 0,
|
|
12822
|
+
node2.rangeWithoutTrivia,
|
|
12823
|
+
node2.rangeWithoutTrivia,
|
|
12824
|
+
items
|
|
12825
|
+
));
|
|
12826
|
+
break;
|
|
12827
|
+
}
|
|
12828
|
+
case 46 /* IndexedElementSetterDeclaration */: {
|
|
12829
|
+
result.push(this.createItem(
|
|
12830
|
+
17 /* IndexedElementSetter */,
|
|
12831
|
+
void 0,
|
|
12832
|
+
node2.rangeWithoutTrivia,
|
|
12833
|
+
node2.rangeWithoutTrivia,
|
|
12834
|
+
items
|
|
12835
|
+
));
|
|
12836
|
+
break;
|
|
12837
|
+
}
|
|
12838
|
+
case 26 /* PackageFunctionTypeDeclaration */: {
|
|
12839
|
+
result.push(this.createItem(
|
|
12840
|
+
6 /* FunctionType */,
|
|
12841
|
+
node2.name.value,
|
|
12842
|
+
node2.rangeWithoutTrivia,
|
|
12843
|
+
node2.name.rangeWithoutTrivia,
|
|
12844
|
+
items
|
|
12845
|
+
));
|
|
12846
|
+
break;
|
|
12847
|
+
}
|
|
12848
|
+
case 36 /* PackageVariantTypeDeclaration */: {
|
|
12849
|
+
result.push(this.createItem(
|
|
12850
|
+
7 /* VariantType */,
|
|
12851
|
+
node2.name.value,
|
|
12852
|
+
node2.rangeWithoutTrivia,
|
|
12853
|
+
node2.name.rangeWithoutTrivia,
|
|
12854
|
+
items
|
|
12855
|
+
));
|
|
12856
|
+
break;
|
|
12857
|
+
}
|
|
12858
|
+
case 147 /* VariantValueDeclaration */: {
|
|
12859
|
+
result.push(this.createItem(
|
|
12860
|
+
9 /* VariantValue */,
|
|
12861
|
+
node2.name.value,
|
|
12862
|
+
node2.rangeWithoutTrivia,
|
|
12863
|
+
node2.name.rangeWithoutTrivia,
|
|
12864
|
+
items
|
|
12865
|
+
));
|
|
12866
|
+
break;
|
|
12867
|
+
}
|
|
12868
|
+
case 148 /* TypeParameterDeclaration */: {
|
|
12869
|
+
result.push(this.createItem(
|
|
12870
|
+
18 /* TypeParameter */,
|
|
12871
|
+
node2.name.value,
|
|
12872
|
+
node2.rangeWithoutTrivia,
|
|
12873
|
+
node2.name.rangeWithoutTrivia,
|
|
12874
|
+
items
|
|
12875
|
+
));
|
|
12876
|
+
break;
|
|
12877
|
+
}
|
|
12878
|
+
case 56 /* NestedFunctionDeclaration */: {
|
|
12879
|
+
result.push(this.createItem(
|
|
12880
|
+
19 /* NestedFunction */,
|
|
12881
|
+
node2.name.value,
|
|
12882
|
+
node2.rangeWithoutTrivia,
|
|
12883
|
+
node2.name.rangeWithoutTrivia,
|
|
12884
|
+
items
|
|
12885
|
+
));
|
|
12886
|
+
break;
|
|
12887
|
+
}
|
|
12888
|
+
default: {
|
|
12889
|
+
result.push(...items);
|
|
12890
|
+
break;
|
|
12891
|
+
}
|
|
12892
|
+
}
|
|
12893
|
+
});
|
|
12894
|
+
return result;
|
|
12759
12895
|
}
|
|
12760
|
-
|
|
12761
|
-
const
|
|
12762
|
-
|
|
12763
|
-
return void 0;
|
|
12764
|
-
}
|
|
12765
|
-
const members = containingType.getMembers().getIndexers();
|
|
12766
|
-
if (members.length === 0) {
|
|
12767
|
-
return void 0;
|
|
12768
|
-
} else if (members.length === 1) {
|
|
12769
|
-
return members[0];
|
|
12770
|
-
} else {
|
|
12771
|
-
const referenceData = new DataForFindingOverloadedMember([], entity.getParameters());
|
|
12772
|
-
const membersData = members.map((m) => new DataForFindingOverloadedMember([], m.getParameters()));
|
|
12773
|
-
const index = this.findOverloadedMemberIndex(referenceData, membersData);
|
|
12774
|
-
return index >= 0 ? members[index] : void 0;
|
|
12775
|
-
}
|
|
12896
|
+
createItem(kind, name, range, selectionRange, items) {
|
|
12897
|
+
const itemName = this.getNameOrStubIfEmpty(name, kind);
|
|
12898
|
+
return new Item(kind, itemName, range, selectionRange, items, this.sourceFile);
|
|
12776
12899
|
}
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
return void 0;
|
|
12900
|
+
getNameOrStubIfEmpty(name, kind) {
|
|
12901
|
+
if (name !== void 0 && name.trim().length === 0) {
|
|
12902
|
+
name = void 0;
|
|
12781
12903
|
}
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12904
|
+
switch (kind) {
|
|
12905
|
+
case 0 /* PackageAlias */:
|
|
12906
|
+
return name ?? `<${LocalizationHelper.localizeHelperPhrase(4 /* PackageAlias */, this.locale)}>`;
|
|
12907
|
+
case 1 /* PackageVariable */:
|
|
12908
|
+
case 12 /* Field */:
|
|
12909
|
+
return name ?? `<${LocalizationHelper.localizeHelperPhrase(6 /* Variable */, this.locale)}>`;
|
|
12910
|
+
case 4 /* PackageFunction */:
|
|
12911
|
+
case 15 /* Method */:
|
|
12912
|
+
case 19 /* NestedFunction */:
|
|
12913
|
+
return name ?? `<${LocalizationHelper.localizeKeywordAndTakeFirst(12 /* Function */, this.locale, this.dialect)}>`;
|
|
12914
|
+
case 5 /* StructuredType */:
|
|
12915
|
+
case 6 /* FunctionType */:
|
|
12916
|
+
case 7 /* VariantType */:
|
|
12917
|
+
case 8 /* InvalidType */:
|
|
12918
|
+
return name ?? `<${LocalizationHelper.localizeKeywordAndTakeFirst(16 /* Type */, this.locale, this.dialect)}>`;
|
|
12919
|
+
case 10 /* Constructor */:
|
|
12920
|
+
return name ?? LocalizationHelper.localizeKeywordAndTakeFirst(31 /* Creation */, this.locale, this.dialect);
|
|
12921
|
+
case 11 /* Destructor */:
|
|
12922
|
+
return name ?? LocalizationHelper.localizeKeywordAndTakeFirst(47 /* Destruction */, this.locale, this.dialect);
|
|
12923
|
+
case 9 /* VariantValue */:
|
|
12924
|
+
return name ?? `<${LocalizationHelper.localizeKeywordAndTakeFirst(6 /* Variant */, this.locale, this.dialect)}>`;
|
|
12925
|
+
case 18 /* TypeParameter */:
|
|
12926
|
+
return name ?? `<${LocalizationHelper.localizeHelperPhrase(2 /* TypeParameter */, this.locale)}>`;
|
|
12927
|
+
case 2 /* PackageVariableGetter */:
|
|
12928
|
+
case 13 /* FieldGetter */:
|
|
12929
|
+
return `${LocalizationHelper.localizeKeywordAndTakeFirst(58 /* Get */, this.locale, this.dialect)} ${name ?? ""}`;
|
|
12930
|
+
case 3 /* PackageVariableSetter */:
|
|
12931
|
+
case 14 /* FieldSetter */:
|
|
12932
|
+
return `${LocalizationHelper.localizeKeywordAndTakeFirst(59 /* Set */, this.locale, this.dialect)} ${name ?? ""}`;
|
|
12933
|
+
case 16 /* IndexedElementGetter */:
|
|
12934
|
+
return `${LocalizationHelper.localizeKeywordAndTakeFirst(58 /* Get */, this.locale, this.dialect)} []`;
|
|
12935
|
+
case 17 /* IndexedElementSetter */:
|
|
12936
|
+
return `${LocalizationHelper.localizeKeywordAndTakeFirst(59 /* Set */, this.locale, this.dialect)} []`;
|
|
12937
|
+
default:
|
|
12938
|
+
Debug.never(kind);
|
|
12789
12939
|
}
|
|
12790
12940
|
}
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
|
|
12941
|
+
};
|
|
12942
|
+
var Item = class {
|
|
12943
|
+
constructor(kind, name, range, selectionRange, items, sourceFile) {
|
|
12944
|
+
this.kind = kind;
|
|
12945
|
+
this.name = name;
|
|
12946
|
+
this.range = range;
|
|
12947
|
+
this.selectionRange = selectionRange;
|
|
12948
|
+
this.items = items;
|
|
12949
|
+
this.sourceFile = sourceFile;
|
|
12799
12950
|
}
|
|
12800
|
-
|
|
12801
|
-
|
|
12951
|
+
};
|
|
12952
|
+
|
|
12953
|
+
// source/services/WorkspaceItemsService.ts
|
|
12954
|
+
var WorkspaceItemsService = class {
|
|
12955
|
+
constructor() {
|
|
12956
|
+
this.sourceFileItemsService = new SourceFileItemsService();
|
|
12802
12957
|
}
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
return entity.getParameters();
|
|
12811
|
-
case 8 /* Destructor */:
|
|
12812
|
-
return entity.getParameters();
|
|
12813
|
-
case 2 /* Type */: {
|
|
12814
|
-
if (entity.typeEntityKind === 0 /* Function */) {
|
|
12815
|
-
return entity.getParameters();
|
|
12958
|
+
getItems(compilations) {
|
|
12959
|
+
const result = new Array();
|
|
12960
|
+
const packageUris = /* @__PURE__ */ new Set();
|
|
12961
|
+
for (const compilation of compilations) {
|
|
12962
|
+
for (const pkg of compilation.allPackages) {
|
|
12963
|
+
if (packageUris.has(pkg.uri.toString())) {
|
|
12964
|
+
continue;
|
|
12816
12965
|
}
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
return entity.getParameters();
|
|
12821
|
-
case 0 /* Variable */:
|
|
12822
|
-
case 3 /* Getter */:
|
|
12823
|
-
case 4 /* Setter */:
|
|
12824
|
-
case 10 /* PackageAlias */:
|
|
12825
|
-
case 12 /* Package */:
|
|
12826
|
-
case 11 /* TypeExtension */:
|
|
12827
|
-
case 6 /* DereferenceOperator */:
|
|
12828
|
-
return void 0;
|
|
12829
|
-
case 13 /* TextTranslation */:
|
|
12830
|
-
return void 0;
|
|
12831
|
-
default:
|
|
12832
|
-
Debug.never(entity);
|
|
12833
|
-
}
|
|
12834
|
-
}
|
|
12835
|
-
ifEntityWithTypeParametersThenParameters(entity) {
|
|
12836
|
-
switch (entity.kind) {
|
|
12837
|
-
case 1 /* Function */:
|
|
12838
|
-
return entity.getTypeParameters();
|
|
12839
|
-
case 2 /* Type */: {
|
|
12840
|
-
if (entity.typeEntityKind !== 2 /* Parameter */) {
|
|
12841
|
-
return entity.getTypeParameters();
|
|
12966
|
+
packageUris.add(pkg.uri.toString());
|
|
12967
|
+
for (const sourceFile of pkg.sourceFiles) {
|
|
12968
|
+
result.push(...this.sourceFileItemsService.getItems(sourceFile));
|
|
12842
12969
|
}
|
|
12843
|
-
return void 0;
|
|
12844
|
-
}
|
|
12845
|
-
case 8 /* Destructor */:
|
|
12846
|
-
case 7 /* Constructor */:
|
|
12847
|
-
case 5 /* Indexer */:
|
|
12848
|
-
case 6 /* DereferenceOperator */:
|
|
12849
|
-
case 0 /* Variable */:
|
|
12850
|
-
case 3 /* Getter */:
|
|
12851
|
-
case 4 /* Setter */:
|
|
12852
|
-
case 10 /* PackageAlias */:
|
|
12853
|
-
case 12 /* Package */:
|
|
12854
|
-
case 11 /* TypeExtension */:
|
|
12855
|
-
case 9 /* Operator */:
|
|
12856
|
-
case 13 /* TextTranslation */:
|
|
12857
|
-
return void 0;
|
|
12858
|
-
default:
|
|
12859
|
-
Debug.never(entity);
|
|
12860
|
-
}
|
|
12861
|
-
}
|
|
12862
|
-
findOverloadedMemberIndex(referenceData, membersData) {
|
|
12863
|
-
for (let i = 0; i < membersData.length; i++) {
|
|
12864
|
-
const memberData = membersData[i];
|
|
12865
|
-
if (memberData.typeParameters.length !== referenceData.typeParameters.length || memberData.parameters.length !== referenceData.parameters.length) {
|
|
12866
|
-
continue;
|
|
12867
|
-
}
|
|
12868
|
-
const parametersAreEqual = Query.zip(
|
|
12869
|
-
memberData.parameters,
|
|
12870
|
-
referenceData.parameters,
|
|
12871
|
-
(r, m) => this.getEntityName(r).considerEqual(this.getEntityName(m))
|
|
12872
|
-
).all((v) => v);
|
|
12873
|
-
if (parametersAreEqual) {
|
|
12874
|
-
return i;
|
|
12875
12970
|
}
|
|
12876
12971
|
}
|
|
12877
|
-
return
|
|
12878
|
-
}
|
|
12879
|
-
getEntityName(entity) {
|
|
12880
|
-
return entity.getName();
|
|
12881
|
-
}
|
|
12882
|
-
};
|
|
12883
|
-
var DataForFindingOverloadedMember = class {
|
|
12884
|
-
constructor(typeParameters, parameters) {
|
|
12885
|
-
this.typeParameters = typeParameters;
|
|
12886
|
-
this.parameters = parameters;
|
|
12972
|
+
return result;
|
|
12887
12973
|
}
|
|
12888
12974
|
};
|
|
12889
12975
|
|
|
@@ -12905,9 +12991,7 @@ var _LanguageServer = class _LanguageServer {
|
|
|
12905
12991
|
this.signatureHelpService = new SignatureHelpService();
|
|
12906
12992
|
this.fileSystemTreeDisplayService = new FileSystemTreeDisplayService();
|
|
12907
12993
|
this.selectionRangeService = new SelectionRangeService();
|
|
12908
|
-
this.
|
|
12909
|
-
this.addBlockToScriptService = new AddBlockToScriptService();
|
|
12910
|
-
this.deleteBlockFromScriptService = new DeleteBlockFromScriptService();
|
|
12994
|
+
this.scriptEditingService = new ScriptEditingService();
|
|
12911
12995
|
this.codeActionsService = new CodeActionsService();
|
|
12912
12996
|
this.connection = config.connection;
|
|
12913
12997
|
this.config = config;
|
|
@@ -13004,7 +13088,9 @@ var _LanguageServer = class _LanguageServer {
|
|
|
13004
13088
|
this.disposables.push(disposable);
|
|
13005
13089
|
disposable = this.connection.onRequest(customRequests.assignField, (params, token) => this.withTaskController(token, (taskController) => this.onAssignField(params, taskController)));
|
|
13006
13090
|
this.disposables.push(disposable);
|
|
13007
|
-
disposable = this.connection.onRequest(customRequests.
|
|
13091
|
+
disposable = this.connection.onRequest(customRequests.addBlocksToScript, (params, token) => this.withTaskController(token, (taskController) => this.onAddBlocksToScript(params, taskController)));
|
|
13092
|
+
this.disposables.push(disposable);
|
|
13093
|
+
disposable = this.connection.onRequest(customRequests.canDeleteBlocksFromScript, (params, token) => this.withTaskController(token, (taskController) => this.onCanDeleteBlocksFromScript(params, taskController)));
|
|
13008
13094
|
this.disposables.push(disposable);
|
|
13009
13095
|
disposable = this.connection.onRequest(customRequests.deleteBlocksFromScript, (params, token) => this.withTaskController(token, (taskController) => this.onDeleteBlocksFromScript(params, taskController)));
|
|
13010
13096
|
this.disposables.push(disposable);
|
|
@@ -13557,15 +13643,15 @@ var _LanguageServer = class _LanguageServer {
|
|
|
13557
13643
|
}
|
|
13558
13644
|
onAssignField(params, taskController) {
|
|
13559
13645
|
return __async(this, null, function* () {
|
|
13560
|
-
const
|
|
13561
|
-
const sourceFileContext = yield this.getSourceFileContext(
|
|
13646
|
+
const scriptFunctionUri = URI.parse(params.scriptFunctionUri);
|
|
13647
|
+
const sourceFileContext = yield this.getSourceFileContext(scriptFunctionUri, taskController);
|
|
13562
13648
|
if (sourceFileContext !== void 0) {
|
|
13563
|
-
const
|
|
13564
|
-
if (
|
|
13565
|
-
const sourceFileEdit = this.
|
|
13649
|
+
const scriptDeclaration = NodePath.parse(scriptFunctionUri.fragment).getNode(sourceFileContext.sourceFile.getSyntaxNode());
|
|
13650
|
+
if (scriptDeclaration !== void 0 && NodeTypeUtils.isSubprogramDeclarationOrLiteral(scriptDeclaration)) {
|
|
13651
|
+
const sourceFileEdit = this.scriptEditingService.createEditWithFieldAssignment(
|
|
13566
13652
|
sourceFileContext.analyzer,
|
|
13567
13653
|
sourceFileContext.sourceFile,
|
|
13568
|
-
|
|
13654
|
+
scriptDeclaration,
|
|
13569
13655
|
params.fieldName,
|
|
13570
13656
|
params.value
|
|
13571
13657
|
);
|
|
@@ -13578,54 +13664,86 @@ var _LanguageServer = class _LanguageServer {
|
|
|
13578
13664
|
}
|
|
13579
13665
|
});
|
|
13580
13666
|
}
|
|
13581
|
-
|
|
13667
|
+
onAddBlocksToScript(params, taskController) {
|
|
13582
13668
|
return __async(this, null, function* () {
|
|
13583
|
-
const
|
|
13584
|
-
const
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
);
|
|
13598
|
-
if (
|
|
13599
|
-
const
|
|
13600
|
-
const
|
|
13601
|
-
|
|
13669
|
+
const sourceFileEdits = new Array();
|
|
13670
|
+
const convertAddedScriptBlock = (block) => {
|
|
13671
|
+
return {
|
|
13672
|
+
name: block.name,
|
|
13673
|
+
key: block.key,
|
|
13674
|
+
areaIndex: block.areaIndex,
|
|
13675
|
+
elementProperties: block.elementProperties ?? {},
|
|
13676
|
+
nestedBlocks: block.nestedBlocks?.map(convertAddedScriptBlock) ?? []
|
|
13677
|
+
};
|
|
13678
|
+
};
|
|
13679
|
+
for (const scriptBlockAddedToOuterScript of params) {
|
|
13680
|
+
const scriptFunctionUri = URI.parse(scriptBlockAddedToOuterScript.outerScriptFunctionUri);
|
|
13681
|
+
const sourceFileContext = yield this.getSourceFileContext(scriptFunctionUri, taskController);
|
|
13682
|
+
if (sourceFileContext !== void 0) {
|
|
13683
|
+
const scriptDeclaration = NodePath.parse(scriptFunctionUri.fragment).getNode(sourceFileContext.sourceFile.getSyntaxNode());
|
|
13684
|
+
if (scriptDeclaration !== void 0 && NodeTypeUtils.isSubprogramDeclarationOrLiteral(scriptDeclaration)) {
|
|
13685
|
+
const addedBlockInfos = scriptBlockAddedToOuterScript.values.map(convertAddedScriptBlock);
|
|
13686
|
+
const sourceFileEdit = this.scriptEditingService.createEditAddingBlocks(
|
|
13687
|
+
sourceFileContext.sourceFile,
|
|
13688
|
+
scriptDeclaration,
|
|
13689
|
+
addedBlockInfos
|
|
13690
|
+
);
|
|
13691
|
+
if (sourceFileEdit !== void 0) {
|
|
13692
|
+
sourceFileEdits.push(sourceFileEdit);
|
|
13693
|
+
}
|
|
13602
13694
|
}
|
|
13603
13695
|
}
|
|
13604
13696
|
}
|
|
13697
|
+
if (sourceFileEdits.length > 0) {
|
|
13698
|
+
const workspaceEdit = this.convertSourceFileEditsToWorkspaceEdit(sourceFileEdits);
|
|
13699
|
+
yield this.connection.workspace.applyEdit(workspaceEdit);
|
|
13700
|
+
}
|
|
13701
|
+
});
|
|
13702
|
+
}
|
|
13703
|
+
onCanDeleteBlocksFromScript(params, taskController) {
|
|
13704
|
+
return __async(this, null, function* () {
|
|
13705
|
+
let result = false;
|
|
13706
|
+
const outerScriptFunctionUri = URI.parse(params.outerScriptFunctionUri);
|
|
13707
|
+
const sourceFileContext = yield this.getSourceFileContext(outerScriptFunctionUri, taskController);
|
|
13708
|
+
if (sourceFileContext !== void 0) {
|
|
13709
|
+
const outerScriptFunctionLocation = new NodeLocation(
|
|
13710
|
+
sourceFileContext.sourceFile,
|
|
13711
|
+
NodePath.parse(outerScriptFunctionUri.fragment)
|
|
13712
|
+
);
|
|
13713
|
+
const scriptFunctionLocations = Query.from(params.scriptFunctionUris).map((u) => {
|
|
13714
|
+
const parsedVscodeUri = URI.parse(u);
|
|
13715
|
+
const uri = this.convertVscodeUriToUri(parsedVscodeUri);
|
|
13716
|
+
const sourceFile = sourceFileContext.analyzer.compilation.getSourceFileByUri(uri);
|
|
13717
|
+
return sourceFile !== void 0 ? new NodeLocation(sourceFile, NodePath.parse(parsedVscodeUri.fragment)) : void 0;
|
|
13718
|
+
}).toNullable();
|
|
13719
|
+
if (scriptFunctionLocations !== void 0) {
|
|
13720
|
+
result = this.scriptEditingService.canDeleteBlocks(outerScriptFunctionLocation, scriptFunctionLocations);
|
|
13721
|
+
}
|
|
13722
|
+
}
|
|
13723
|
+
return result;
|
|
13605
13724
|
});
|
|
13606
13725
|
}
|
|
13607
13726
|
onDeleteBlocksFromScript(params, taskController) {
|
|
13608
13727
|
return __async(this, null, function* () {
|
|
13609
|
-
const
|
|
13610
|
-
for (const
|
|
13611
|
-
const
|
|
13612
|
-
const sourceFileContext = yield this.getSourceFileContext(
|
|
13728
|
+
const sourceFileEdits = new Array();
|
|
13729
|
+
for (const scriptFunctionUri of params.scriptFunctionUris) {
|
|
13730
|
+
const parsedScriptFunctionUri = URI.parse(scriptFunctionUri);
|
|
13731
|
+
const sourceFileContext = yield this.getSourceFileContext(parsedScriptFunctionUri, taskController);
|
|
13613
13732
|
if (sourceFileContext !== void 0) {
|
|
13614
|
-
const
|
|
13615
|
-
if (
|
|
13616
|
-
const sourceFileEdit = this.
|
|
13733
|
+
const scriptDeclaration = NodePath.parse(parsedScriptFunctionUri.fragment).getNode(sourceFileContext.sourceFile.getSyntaxNode());
|
|
13734
|
+
if (scriptDeclaration !== void 0 && NodeTypeUtils.isSubprogramDeclarationOrLiteral(scriptDeclaration)) {
|
|
13735
|
+
const sourceFileEdit = this.scriptEditingService.createEditDeletingBlock(
|
|
13617
13736
|
sourceFileContext.sourceFile,
|
|
13618
|
-
|
|
13737
|
+
scriptDeclaration
|
|
13619
13738
|
);
|
|
13620
13739
|
if (sourceFileEdit !== void 0) {
|
|
13621
|
-
|
|
13622
|
-
documentEdits.push(textDocumentEdit);
|
|
13740
|
+
sourceFileEdits.push(sourceFileEdit);
|
|
13623
13741
|
}
|
|
13624
13742
|
}
|
|
13625
13743
|
}
|
|
13626
13744
|
}
|
|
13627
|
-
if (
|
|
13628
|
-
const workspaceEdit =
|
|
13745
|
+
if (sourceFileEdits.length > 0) {
|
|
13746
|
+
const workspaceEdit = this.convertSourceFileEditsToWorkspaceEdit(sourceFileEdits);
|
|
13629
13747
|
yield this.connection.workspace.applyEdit(workspaceEdit);
|
|
13630
13748
|
}
|
|
13631
13749
|
});
|