@atscript/core 0.1.72 → 0.1.73

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/dist/index.cjs CHANGED
@@ -1030,7 +1030,16 @@ var AnnotationSpec = class {
1030
1030
  range: token.range
1031
1031
  });
1032
1032
  if (this.config.defType?.length) {
1033
- let def = mainToken.parentNode.getDefinition();
1033
+ const parentNode = mainToken.parentNode;
1034
+ let def = parentNode.getDefinition();
1035
+ if (!def && isRef(parentNode)) {
1036
+ const idToken = parentNode.token("identifier");
1037
+ const annotateBlock = idToken ? doc.annotateBlockAt(idToken.range.start.line, idToken.range.start.character) : undefined;
1038
+ if (annotateBlock) {
1039
+ const chain = [parentNode.id, ...parentNode.chain.map((c) => c.text)];
1040
+ def = doc.unwindType(annotateBlock.targetName, chain)?.def || def;
1041
+ }
1042
+ }
1034
1043
  if (isRef(def)) def = doc.unwindType(def.id, def.chain)?.def || def;
1035
1044
  let defEntity = def?.entity || "unknown";
1036
1045
  if (isInterface(def) || isStructure(def)) defEntity = "object";
@@ -3462,6 +3471,14 @@ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.pro
3462
3471
  return right;
3463
3472
  }
3464
3473
  /**
3474
+ * If the position falls inside an `annotate` block, returns that block's node
3475
+ * (whose `targetName` is the annotated interface). Entry refs within the block
3476
+ * resolve through the target interface rather than as top-level definitions.
3477
+ */ annotateBlockAt(line, character) {
3478
+ const block$2 = this.blocksIndex.at(line, character);
3479
+ return block$2?.blockType === "annotate" && isAnnotate(block$2.parentNode) ? block$2.parentNode : undefined;
3480
+ }
3481
+ /**
3465
3482
  * Collects ad-hoc annotations from all `annotate` blocks targeting a given type/interface.
3466
3483
  * Returns a map of property path (dot-joined) → annotations array.
3467
3484
  * For entries without a chain (root-level), the key is the entry identifier.
@@ -3753,9 +3770,9 @@ else group$1.nested.push({
3753
3770
  getToDefinitionAt(line, character) {
3754
3771
  const token = this.tokensIndex.at(line, character);
3755
3772
  if (token) {
3756
- const block$2 = this.blocksIndex.at(line, character);
3757
- if (block$2?.blockType === "annotate" && isAnnotate(block$2.parentNode) && isRef(token.parentNode)) {
3758
- const targetName = block$2.parentNode.targetName;
3773
+ const annotateBlock = this.annotateBlockAt(line, character);
3774
+ if (annotateBlock && isRef(token.parentNode)) {
3775
+ const targetName = annotateBlock.targetName;
3759
3776
  const entryRef = token.parentNode;
3760
3777
  const chain = token.isChain && typeof token.index === "number" ? [entryRef.id, ...entryRef.chain.slice(0, token.index).map((c) => c.text)] : [token.text];
3761
3778
  const unwound = this.unwindType(targetName, chain);
@@ -4021,9 +4038,9 @@ else group$1.nested.push({
4021
4038
  }
4022
4039
  }
4023
4040
  for (const t of this.referred) {
4024
- const block$2 = this.blocksIndex.at(t.range.start.line, t.range.start.character);
4025
- if (block$2?.blockType === "annotate" && isAnnotate(block$2.parentNode)) {
4026
- const targetName = block$2.parentNode.targetName;
4041
+ const annotateBlock = this.annotateBlockAt(t.range.start.line, t.range.start.character);
4042
+ if (annotateBlock) {
4043
+ const targetName = annotateBlock.targetName;
4027
4044
  if (!this.registry.isDefined(targetName)) continue;
4028
4045
  const chain = isRef(t.parentNode) && t.parentNode.hasChain ? [t.text, ...t.parentNode.chain.map((c) => c.text)] : [t.text];
4029
4046
  const unwound = this.unwindType(targetName, chain);
package/dist/index.d.ts CHANGED
@@ -525,6 +525,12 @@ declare class AtscriptDoc {
525
525
  token: Token;
526
526
  }[] | undefined;
527
527
  evalAnnotationsForNode(givenNode: SemanticNode): TAnnotationTokens[] | undefined;
528
+ /**
529
+ * If the position falls inside an `annotate` block, returns that block's node
530
+ * (whose `targetName` is the annotated interface). Entry refs within the block
531
+ * resolve through the target interface rather than as top-level definitions.
532
+ */
533
+ annotateBlockAt(line: number, character: number): SemanticAnnotateNode | undefined;
528
534
  /**
529
535
  * Collects ad-hoc annotations from all `annotate` blocks targeting a given type/interface.
530
536
  * Returns a map of property path (dot-joined) → annotations array.
package/dist/index.mjs CHANGED
@@ -1006,7 +1006,16 @@ var AnnotationSpec = class {
1006
1006
  range: token.range
1007
1007
  });
1008
1008
  if (this.config.defType?.length) {
1009
- let def = mainToken.parentNode.getDefinition();
1009
+ const parentNode = mainToken.parentNode;
1010
+ let def = parentNode.getDefinition();
1011
+ if (!def && isRef(parentNode)) {
1012
+ const idToken = parentNode.token("identifier");
1013
+ const annotateBlock = idToken ? doc.annotateBlockAt(idToken.range.start.line, idToken.range.start.character) : undefined;
1014
+ if (annotateBlock) {
1015
+ const chain = [parentNode.id, ...parentNode.chain.map((c) => c.text)];
1016
+ def = doc.unwindType(annotateBlock.targetName, chain)?.def || def;
1017
+ }
1018
+ }
1010
1019
  if (isRef(def)) def = doc.unwindType(def.id, def.chain)?.def || def;
1011
1020
  let defEntity = def?.entity || "unknown";
1012
1021
  if (isInterface(def) || isStructure(def)) defEntity = "object";
@@ -3438,6 +3447,14 @@ else if (isStructure(def) || isInterface(def) || isPrimitive(def)) def = def.pro
3438
3447
  return right;
3439
3448
  }
3440
3449
  /**
3450
+ * If the position falls inside an `annotate` block, returns that block's node
3451
+ * (whose `targetName` is the annotated interface). Entry refs within the block
3452
+ * resolve through the target interface rather than as top-level definitions.
3453
+ */ annotateBlockAt(line, character) {
3454
+ const block$2 = this.blocksIndex.at(line, character);
3455
+ return block$2?.blockType === "annotate" && isAnnotate(block$2.parentNode) ? block$2.parentNode : undefined;
3456
+ }
3457
+ /**
3441
3458
  * Collects ad-hoc annotations from all `annotate` blocks targeting a given type/interface.
3442
3459
  * Returns a map of property path (dot-joined) → annotations array.
3443
3460
  * For entries without a chain (root-level), the key is the entry identifier.
@@ -3729,9 +3746,9 @@ else group$1.nested.push({
3729
3746
  getToDefinitionAt(line, character) {
3730
3747
  const token = this.tokensIndex.at(line, character);
3731
3748
  if (token) {
3732
- const block$2 = this.blocksIndex.at(line, character);
3733
- if (block$2?.blockType === "annotate" && isAnnotate(block$2.parentNode) && isRef(token.parentNode)) {
3734
- const targetName = block$2.parentNode.targetName;
3749
+ const annotateBlock = this.annotateBlockAt(line, character);
3750
+ if (annotateBlock && isRef(token.parentNode)) {
3751
+ const targetName = annotateBlock.targetName;
3735
3752
  const entryRef = token.parentNode;
3736
3753
  const chain = token.isChain && typeof token.index === "number" ? [entryRef.id, ...entryRef.chain.slice(0, token.index).map((c) => c.text)] : [token.text];
3737
3754
  const unwound = this.unwindType(targetName, chain);
@@ -3997,9 +4014,9 @@ else group$1.nested.push({
3997
4014
  }
3998
4015
  }
3999
4016
  for (const t of this.referred) {
4000
- const block$2 = this.blocksIndex.at(t.range.start.line, t.range.start.character);
4001
- if (block$2?.blockType === "annotate" && isAnnotate(block$2.parentNode)) {
4002
- const targetName = block$2.parentNode.targetName;
4017
+ const annotateBlock = this.annotateBlockAt(t.range.start.line, t.range.start.character);
4018
+ if (annotateBlock) {
4019
+ const targetName = annotateBlock.targetName;
4003
4020
  if (!this.registry.isDefined(targetName)) continue;
4004
4021
  const chain = isRef(t.parentNode) && t.parentNode.hasChain ? [t.text, ...t.parentNode.chain.map((c) => c.text)] : [t.text];
4005
4022
  const unwound = this.unwindType(targetName, chain);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/core",
3
- "version": "0.1.72",
3
+ "version": "0.1.73",
4
4
  "description": "Core library for Atscript parsing and file generation.",
5
5
  "keywords": [
6
6
  "annotations",