@artel/artc 0.6.26010 → 0.6.26012

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 CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CommandLineCompiler
4
- } from "./chunk-WK4LR3UK.js";
5
- import "./chunk-CZDVEX34.js";
4
+ } from "./chunk-FXUDXUOA.js";
5
+ import "./chunk-OA77CG6M.js";
6
6
  import {
7
7
  __async
8
- } from "./chunk-HOEHBJ7R.js";
8
+ } from "./chunk-GZUU2AYH.js";
9
9
 
10
10
  // source/Cli.ts
11
11
  function main() {
package/build/api/Api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Compiler
3
- } from "../chunk-CZDVEX34.js";
3
+ } from "../chunk-OA77CG6M.js";
4
4
  import {
5
5
  AccessKind,
6
6
  AccessedFunctionParameter,
@@ -20,6 +20,7 @@ import {
20
20
  ArtelSourceFileExtensions,
21
21
  ArtelVersion,
22
22
  BackingSpecialVariableEntityInfo,
23
+ BaseKeywordPart,
23
24
  BinaryExpressionOperatorClassificationResult,
24
25
  BoundTypeMemberLookup,
25
26
  Cached,
@@ -66,6 +67,7 @@ import {
66
67
  DisplayableOrPrimitive,
67
68
  Emitter,
68
69
  EmitterPackage,
70
+ EndKeywordPart,
69
71
  EntityHidingLevel_file,
70
72
  EntityHidingLevel_package,
71
73
  EntityHidingLevel_type,
@@ -122,7 +124,7 @@ import {
122
124
  JsonConfigurationFileNameSet,
123
125
  JsonConfigurationFileNamesByLocale,
124
126
  Keyword2 as Keyword,
125
- KeywordPart,
127
+ KeywordPartKind,
126
128
  Lazy,
127
129
  LocalVariableDeclarationEntity,
128
130
  LocalVariableKind,
@@ -135,6 +137,7 @@ import {
135
137
  MatchResultParameter,
136
138
  MaybeLazy,
137
139
  MethodDeclarationEntity,
140
+ MiddleKeywordPart,
138
141
  Name,
139
142
  NameFlags,
140
143
  NestedFunctionDeclarationEntity,
@@ -340,7 +343,7 @@ import {
340
343
  withoutQuotes,
341
344
  withoutTemplateQuotes,
342
345
  yieldTask
343
- } from "../chunk-HOEHBJ7R.js";
346
+ } from "../chunk-GZUU2AYH.js";
344
347
  export {
345
348
  AccessKind,
346
349
  AccessedFunctionParameter,
@@ -360,6 +363,7 @@ export {
360
363
  ArtelSourceFileExtensions,
361
364
  ArtelVersion,
362
365
  BackingSpecialVariableEntityInfo,
366
+ BaseKeywordPart,
363
367
  BinaryExpressionOperatorClassificationResult,
364
368
  BoundTypeMemberLookup,
365
369
  Cached,
@@ -407,6 +411,7 @@ export {
407
411
  DisplayableOrPrimitive,
408
412
  Emitter,
409
413
  EmitterPackage,
414
+ EndKeywordPart,
410
415
  EntityHidingLevel_file,
411
416
  EntityHidingLevel_package,
412
417
  EntityHidingLevel_type,
@@ -462,7 +467,7 @@ export {
462
467
  JsonConfigurationFileNameSet,
463
468
  JsonConfigurationFileNamesByLocale,
464
469
  Keyword,
465
- KeywordPart,
470
+ KeywordPartKind,
466
471
  Lazy,
467
472
  LocalVariableDeclarationEntity,
468
473
  LocalVariableKind,
@@ -475,6 +480,7 @@ export {
475
480
  MatchResultParameter,
476
481
  MaybeLazy,
477
482
  MethodDeclarationEntity,
483
+ MiddleKeywordPart,
478
484
  Name,
479
485
  NameFlags,
480
486
  NestedFunctionDeclarationEntity,
@@ -6,9 +6,9 @@ import {
6
6
  PhysicalFileSystem,
7
7
  PhysicalTypeScriptLibrariesProvider,
8
8
  PrintingDiagnosticAcceptor
9
- } from "../chunk-WK4LR3UK.js";
10
- import "../chunk-CZDVEX34.js";
11
- import "../chunk-HOEHBJ7R.js";
9
+ } from "../chunk-FXUDXUOA.js";
10
+ import "../chunk-OA77CG6M.js";
11
+ import "../chunk-GZUU2AYH.js";
12
12
  export {
13
13
  CommandLineCompiler,
14
14
  FileSystemUri,
@@ -166,6 +166,7 @@ import {
166
166
  isEntityWithParameters,
167
167
  isEntityWithTypeParameters,
168
168
  isIdentifier,
169
+ isNamedTypeEntity,
169
170
  isNarrowableReferenceExpression,
170
171
  isNonEmptyArray,
171
172
  isPackageMemberEntity,
@@ -184,7 +185,7 @@ import {
184
185
  unwrapParenthesizedExpressions,
185
186
  visitChildren,
186
187
  yieldTask
187
- } from "../chunk-HOEHBJ7R.js";
188
+ } from "../chunk-GZUU2AYH.js";
188
189
 
189
190
  // source/services/CustomRequests.ts
190
191
  import * as ls from "vscode-languageserver";
@@ -790,7 +791,7 @@ var SyntaxFactory = class {
790
791
  );
791
792
  }
792
793
  static modifier(value, level) {
793
- const valueKeyword = this.createKeyword(value, 1 /* Missing */ | 12296 /* SingularNeuAdjective */);
794
+ const valueKeyword = this.createKeyword(value, 1 /* Missing */ | 3158024 /* SingularNeuAdjective */);
794
795
  let openParenthesisToken;
795
796
  let levelKeyword;
796
797
  let closeParenthesisToken;
@@ -1163,7 +1164,7 @@ var SyntaxToCode = class _SyntaxToCode {
1163
1164
  this.modifiersOnSeparateLine = options7?.modifiersOnSeparateLine ?? false;
1164
1165
  this.keywordsLocale = options7?.keywordsLocale ?? 1 /* Ru */;
1165
1166
  this.keywordsDialect = options7?.keywordsDialect ?? DefaultDialect;
1166
- this.singleWordKeywordValues = Query.from(getOrCreateKeywordDictionary(this.keywordsLocale, this.keywordsDialect).values()).mapAndFilter((k) => k.keywordKind !== 0 /* Unknown */ ? k.value : void 0).uniqueToSet();
1167
+ this.singleWordKeywordValues = Query.from(getOrCreateKeywordDictionary(this.keywordsLocale, this.keywordsDialect).values()).flatMap((k) => k).mapAndFilter((k) => k.kind === 1 /* EndKeywordPart */ ? k.value : void 0).uniqueToSet();
1167
1168
  this.indentation = options7?.initialIndentation ?? "";
1168
1169
  }
1169
1170
  static get writeFunctions() {
@@ -1666,7 +1667,7 @@ var SyntaxToCode = class _SyntaxToCode {
1666
1667
  }
1667
1668
  writeAnonymousFunctionTypeDeclaration(node) {
1668
1669
  if (node.asyncKeyword !== void 0) {
1669
- this.writeKeyword(node.asyncKeyword, 10242 /* SingularFemNoun */);
1670
+ this.writeKeyword(node.asyncKeyword, 3155970 /* SingularFemNoun */);
1670
1671
  this.writeWhitespace();
1671
1672
  }
1672
1673
  this.writeKeyword(node.functionKeyword);
@@ -2042,7 +2043,7 @@ var SyntaxToCode = class _SyntaxToCode {
2042
2043
  }
2043
2044
  }
2044
2045
  }
2045
- writeKeyword(keyword, flags = 12290 /* SingularNeuNoun */) {
2046
+ writeKeyword(keyword, flags = 3158018 /* SingularNeuNoun */) {
2046
2047
  if (keyword.isMissing) {
2047
2048
  this.writeCode(LocalizationHelper.localizeKeywordAndTakeBest(
2048
2049
  keyword.keywordKind,
@@ -2071,13 +2072,13 @@ var SyntaxToCode = class _SyntaxToCode {
2071
2072
  case 47 /* MethodDeclaration */:
2072
2073
  case 48 /* OperatorDeclaration */:
2073
2074
  case 22 /* PackageEntryPointDeclaration */:
2074
- return 10242 /* SingularFemNoun */;
2075
+ return 3155970 /* SingularFemNoun */;
2075
2076
  case 19 /* PackageAliasTypeDeclaration */:
2076
2077
  case 27 /* PackageClassDeclaration */:
2077
2078
  case 29 /* PackageAspectDeclaration */:
2078
2079
  case 30 /* PackageReducedTypeDeclaration */:
2079
2080
  case 31 /* PackageVariantDeclaration */:
2080
- return 9218 /* SingularMasNoun */;
2081
+ return 3154946 /* SingularMasNoun */;
2081
2082
  case 32 /* PackageVariableDeclaration */:
2082
2083
  case 33 /* PackageVariableGetterDeclaration */:
2083
2084
  case 35 /* TypeExtensionDeclaration */:
@@ -2091,11 +2092,11 @@ var SyntaxToCode = class _SyntaxToCode {
2091
2092
  case 145 /* VariantValueDeclaration */:
2092
2093
  case 38 /* MissingPackageMemberDeclaration */:
2093
2094
  case 52 /* MissingTypeMemberDeclaration */:
2094
- return 12290 /* SingularNeuNoun */;
2095
+ return 3158018 /* SingularNeuNoun */;
2095
2096
  case 39 /* TypeMemberGroupDeclaration */:
2096
2097
  case 20 /* PackageMemberGroupDeclaration */:
2097
2098
  case 121 /* TranslationsDeclaration */:
2098
- return 16386 /* PluralNoun */;
2099
+ return 3162114 /* PluralNoun */;
2099
2100
  default:
2100
2101
  Debug.never(modifierTarget);
2101
2102
  }
@@ -2373,8 +2374,8 @@ var modifierKindsInSortOrder = [
2373
2374
  2 /* HiddenInHierarchy */,
2374
2375
  1 /* HiddenInType */,
2375
2376
  5 /* Static */,
2376
- 7 /* Basic */,
2377
2377
  6 /* Abstract */,
2378
+ 7 /* Basic */,
2378
2379
  8 /* Override */,
2379
2380
  9 /* Async */,
2380
2381
  10 /* Var */
@@ -3398,7 +3399,7 @@ var CompletionService = class {
3398
3399
  () => new CompletionItemInfoContext(
3399
3400
  new DisplayService(this.analyzer, this.locale, this.dialect, this.sourceFile),
3400
3401
  this.locale,
3401
- Query.from(getOrCreateKeywordDictionary(this.locale, this.dialect).values()).mapAndFilter((k) => k.keywordKind !== 0 /* Unknown */ ? k.value : void 0).uniqueToSet()
3402
+ Query.from(getOrCreateKeywordDictionary(this.locale, this.dialect).values()).flatMap((k) => k).mapAndFilter((k) => k.kind === 1 /* EndKeywordPart */ ? k.value : void 0).uniqueToSet()
3402
3403
  )
3403
3404
  );
3404
3405
  }
@@ -7231,6 +7232,72 @@ var DefinitionService = class {
7231
7232
  return result;
7232
7233
  });
7233
7234
  }
7235
+ getTypeDefinition(analyzer, sourceFile, offset, taskController) {
7236
+ return __async(this, null, function* () {
7237
+ const tokenOrKeyword = getTokenOrKeywordsTouchingOffset(sourceFile.getSyntaxNode(), offset).getSingleWithHighestPriority((t) => {
7238
+ if (t.isToken(9 /* Identifier */) || t.isKeyword()) {
7239
+ return 2;
7240
+ } else if (t.isToken(21 /* Caret */) || t.isToken(48 /* OpenSquareBracket */) || t.isToken(24 /* CloseSquareBracket */)) {
7241
+ return 1;
7242
+ } else {
7243
+ return 0;
7244
+ }
7245
+ });
7246
+ if (tokenOrKeyword === void 0) {
7247
+ return void 0;
7248
+ }
7249
+ const options7 = {
7250
+ includeBetterReferenceTargets: false,
7251
+ preferredTargetOfExplicitConstructorCall: "type-declaration"
7252
+ };
7253
+ const semanticInfo = NodeSemanticInfoService.ofTokenOrKeyword(analyzer, tokenOrKeyword, options7);
7254
+ if (semanticInfo === void 0) {
7255
+ return void 0;
7256
+ }
7257
+ let types;
7258
+ switch (semanticInfo.kind) {
7259
+ case "definition": {
7260
+ if (semanticInfo.entity.kind === 0 /* Variable */) {
7261
+ types = [semanticInfo.entity.getType()];
7262
+ }
7263
+ break;
7264
+ }
7265
+ case "reference": {
7266
+ types = this.getTypesOfReference(semanticInfo);
7267
+ break;
7268
+ }
7269
+ case "default-switch-match":
7270
+ break;
7271
+ default:
7272
+ Debug.never(semanticInfo);
7273
+ }
7274
+ let result;
7275
+ if (types !== void 0 && types.length > 0) {
7276
+ const entities = types.flatMap((t) => this.getEntitiesThatMakeUpTheType(t));
7277
+ if (entities.length > 0) {
7278
+ const sourceLocations = entities.map((e) => getEntitySourceLocations(analyzer, e)).filter((l) => l !== void 0).flat();
7279
+ if (this.sourceGenerationService !== void 0) {
7280
+ for (const entity of entities) {
7281
+ if (this.sourceGenerationService.entityDefinitionRequiresSourceGeneration(entity)) {
7282
+ const locations = yield this.sourceGenerationService.getDefinitionInGeneratedCode(
7283
+ analyzer,
7284
+ entity,
7285
+ taskController
7286
+ );
7287
+ if (locations !== void 0) {
7288
+ sourceLocations.push(...locations);
7289
+ }
7290
+ }
7291
+ }
7292
+ }
7293
+ if (sourceLocations.length > 0) {
7294
+ result = new DefinitionsAndReferenceInfo(sourceLocations, tokenOrKeyword.value.rangeWithoutTrivia);
7295
+ }
7296
+ }
7297
+ }
7298
+ return result;
7299
+ });
7300
+ }
7234
7301
  getDefinitionOfReference(analyzer, reference, tokenOrKeyword, sourceFile) {
7235
7302
  const targets = reference.betterTargets ?? reference.targets;
7236
7303
  const sourceLocations = Query.from(targets).mapAndFilter((t) => this.getReferenceTargetSourceLocation(analyzer, t, tokenOrKeyword, sourceFile)).flatMap((l) => l).toArray();
@@ -7309,7 +7376,7 @@ var DefinitionService = class {
7309
7376
  }
7310
7377
  getSourceLocationsOfVariableEntity(analyzer, entity) {
7311
7378
  let result = getEntitySourceLocations(analyzer, entity);
7312
- if (result === void 0 && entity.kind === 0 /* Variable */) {
7379
+ if (result === void 0) {
7313
7380
  const specialVariableInfo = entity.isSpecial();
7314
7381
  if (specialVariableInfo !== void 0) {
7315
7382
  result = this.getSourceLocationsOfSpecialVariable(analyzer, specialVariableInfo);
@@ -7384,6 +7451,67 @@ var DefinitionService = class {
7384
7451
  const sourceFile = TreeQuery.getSourceFile(node, analyzer);
7385
7452
  return new SourceLocation(sourceFile, range);
7386
7453
  }
7454
+ getTypesOfReference(reference) {
7455
+ const result = new Array();
7456
+ const targets = reference.targets;
7457
+ for (const target of targets) {
7458
+ switch (target.kind) {
7459
+ case "entity":
7460
+ if (target.entity.kind === 0 /* Variable */) {
7461
+ result.push(target.narrowedType ?? target.entity.getType());
7462
+ }
7463
+ break;
7464
+ case "field":
7465
+ result.push(target.field.getType() ?? target.narrowedType);
7466
+ break;
7467
+ case "type-value-parameter":
7468
+ result.push(target.parameter.getType());
7469
+ break;
7470
+ case "match-result-value-parameter":
7471
+ result.push(target.parameter.type);
7472
+ break;
7473
+ case "type-context":
7474
+ result.push(target.type);
7475
+ break;
7476
+ case "type-constructor":
7477
+ case "operator":
7478
+ case "type-dereference-operator":
7479
+ case "accessed-function":
7480
+ case "type-indexer":
7481
+ case "package":
7482
+ case "package-name-tree-node":
7483
+ break;
7484
+ default:
7485
+ Debug.never(target);
7486
+ }
7487
+ }
7488
+ return result;
7489
+ }
7490
+ getEntitiesThatMakeUpTheType(type) {
7491
+ let types;
7492
+ if (type.kind === "union") {
7493
+ types = type.originalTypes;
7494
+ } else if (type.kind === "intersection") {
7495
+ types = type.originalTypes;
7496
+ } else {
7497
+ types = [type];
7498
+ }
7499
+ const result = new Array();
7500
+ for (const type2 of types) {
7501
+ const entity = type2.getEntity();
7502
+ if (entity !== void 0) {
7503
+ result.push(entity);
7504
+ if (isNamedTypeEntity(entity)) {
7505
+ const substitutions = type2.getSubstitutions();
7506
+ if (substitutions.size > 0) {
7507
+ const typesOfTypeArgument = Query.from(substitutions.getTypes()).flatMap((t) => this.getEntitiesThatMakeUpTheType(t)).toArray();
7508
+ result.push(...typesOfTypeArgument);
7509
+ }
7510
+ }
7511
+ }
7512
+ }
7513
+ return result;
7514
+ }
7387
7515
  };
7388
7516
  var DefinitionsAndReferenceInfo = class {
7389
7517
  constructor(definitionLocations, referenceRange) {
@@ -13476,6 +13604,8 @@ var _LanguageServer = class _LanguageServer {
13476
13604
  this.disposables.push(disposable);
13477
13605
  disposable = this.connection.onDefinition((params, token) => this.withTaskController(token, (taskController) => this.onDefinition(params, taskController)));
13478
13606
  this.disposables.push(disposable);
13607
+ disposable = this.connection.onTypeDefinition((params, token) => this.withTaskController(token, (taskController) => this.onTypeDefinition(params, taskController)));
13608
+ this.disposables.push(disposable);
13479
13609
  disposable = this.connection.onReferences((params, token) => this.withTaskController(token, (taskController) => this.onReferences(params, taskController)));
13480
13610
  this.disposables.push(disposable);
13481
13611
  disposable = this.connection.onDocumentHighlight((params, token) => this.withTaskController(token, (taskController) => this.onDocumentHighlight(params, taskController)));
@@ -13639,6 +13769,7 @@ var _LanguageServer = class _LanguageServer {
13639
13769
  }
13640
13770
  },
13641
13771
  definitionProvider: true,
13772
+ typeDefinitionProvider: true,
13642
13773
  referencesProvider: true,
13643
13774
  documentHighlightProvider: true,
13644
13775
  renameProvider: {
@@ -13901,6 +14032,38 @@ var _LanguageServer = class _LanguageServer {
13901
14032
  return result;
13902
14033
  });
13903
14034
  }
14035
+ onTypeDefinition(params, taskController) {
14036
+ return __async(this, null, function* () {
14037
+ const sourceFileContext = yield this.getSourceFileContext(URI.parse(params.textDocument.uri), taskController);
14038
+ if (sourceFileContext === void 0) {
14039
+ return;
14040
+ }
14041
+ const { analyzer, sourceFile } = sourceFileContext;
14042
+ const position = new Position(params.position.line, params.position.character);
14043
+ const offset = sourceFile.getOffsetAtPosition(position);
14044
+ const definitionAndReferenceInfo = yield this.definitionService.getTypeDefinition(
14045
+ analyzer,
14046
+ sourceFile,
14047
+ offset,
14048
+ taskController
14049
+ );
14050
+ if (definitionAndReferenceInfo === void 0) {
14051
+ return;
14052
+ }
14053
+ const { definitionLocations, referenceRange } = definitionAndReferenceInfo;
14054
+ const originSelectionRange = this.convertSourceFileRange(sourceFile, referenceRange);
14055
+ const result = definitionLocations.map((l) => {
14056
+ const targetRange = this.convertSourceFileRange(l.sourceFile, l.range);
14057
+ return {
14058
+ targetUri: this.convertUriToVscodeUri(l.sourceFile.uri).toString(),
14059
+ originSelectionRange,
14060
+ targetRange,
14061
+ targetSelectionRange: targetRange
14062
+ };
14063
+ });
14064
+ return result;
14065
+ });
14066
+ }
13904
14067
  onReferences(params, taskController) {
13905
14068
  return __async(this, null, function* () {
13906
14069
  let result = new Array();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Compiler
3
- } from "./chunk-CZDVEX34.js";
3
+ } from "./chunk-OA77CG6M.js";
4
4
  import {
5
5
  ArtelVersion,
6
6
  Cached,
@@ -15,7 +15,7 @@ import {
15
15
  __async,
16
16
  performanceMeasurementStageNames,
17
17
  performanceMeasurementStages
18
- } from "./chunk-HOEHBJ7R.js";
18
+ } from "./chunk-GZUU2AYH.js";
19
19
 
20
20
  // source/executor/FileSystemUri.ts
21
21
  import { platform } from "os";