@katana-project/laser 0.2.3 → 0.2.4

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/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # laser
2
2
 
3
- A Java source code analysis engine, built on the Lezer parser.
3
+ A Java source code analysis library, built on the Lezer parser.
@@ -22,10 +22,10 @@ export interface ExternalTypeReference extends TypeReference {
22
22
  /**
23
23
  * Resolved type information.
24
24
  *
25
- * Includes whether the type is declared locally, imported, a built-in type, or unresolved.
25
+ * Includes whether the type is declared locally, imported, or a built-in type.
26
26
  */
27
27
  export interface ResolvedType {
28
- kind: "declared" | "imported" | "builtin" | "unresolved";
28
+ kind: "declared" | "imported" | "builtin";
29
29
  name: string;
30
30
  qualifiedName?: string;
31
31
  declaration?: SyntaxNode;
@@ -42,7 +42,7 @@ export interface ResolvedType {
42
42
  * types in the same package that aren't explicitly imported.
43
43
  * @returns ResolvedType containing complete type information
44
44
  */
45
- export declare const resolveTypeReference: (typeRef: LocalTypeReference, unit: CompilationUnit, externalRefs?: ExternalTypeReference[]) => ResolvedType;
45
+ export declare const resolveTypeReference: (typeRef: LocalTypeReference, unit: CompilationUnit, externalRefs?: ExternalTypeReference[]) => ResolvedType | null;
46
46
  /**
47
47
  * Type reference resolver for a compilation unit.
48
48
  *
package/dist/resolver.js CHANGED
@@ -134,6 +134,8 @@ const resolveImported = (typeRef, unit, externalRefs) => {
134
134
  ref: typeRef,
135
135
  };
136
136
  }
137
+ // returning unresolved types would contain false positives for references that aren't actually types
138
+ // we don't have enough info to do ambiguity resolution here, so just return nothing
137
139
  return null;
138
140
  };
139
141
  /**
@@ -180,11 +182,7 @@ export const resolveTypeReference = (typeRef, unit, externalRefs = []) => {
180
182
  if (importedResolved) {
181
183
  return importedResolved;
182
184
  }
183
- return {
184
- kind: "unresolved",
185
- name: typeName,
186
- ref: typeRef,
187
- };
185
+ return null;
188
186
  };
189
187
  /**
190
188
  * Creates a type reference resolver for a compilation unit.
@@ -227,7 +225,7 @@ export const createTypeReferenceResolver = (unit, refs = []) => {
227
225
  },
228
226
  resolveAll() {
229
227
  const allRefs = collectAllTypeReferences(unit.tree.topNode, unit.source);
230
- return allRefs.map((ref) => resolveTypeReference(ref, unit, refs));
228
+ return allRefs.map((ref) => resolveTypeReference(ref, unit, refs)).filter(Boolean);
231
229
  },
232
230
  };
233
231
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@katana-project/laser",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "author": "katana-project",
6
6
  "license": "MIT",
7
- "description": "A Java source code analysis engine, built on the Lezer parser.",
7
+ "description": "A Java source code analysis library, built on the Lezer parser.",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",