Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[demo] Use alternate file symbol syntax #339

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions snapshots/output/enclosing-ranges-ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// < definition enclosing-ranges-ts 1.0.0 `index.ts`/
// < definition enclosing-ranges-ts 1.0.0 file://index.ts

// format-options: showRanges

// < start enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/Foo#
// < start enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/
// < start enclosing_range enclosing-ranges-ts 1.0.0 file://index.ts
interface Foo {
// ^^^ definition enclosing-ranges-ts 1.0.0 `index.ts`/Foo#
bar: string
Expand Down Expand Up @@ -48,4 +48,4 @@ type ComplexTypeAlias<T> = Single<Single<T>>
// ^ reference enclosing-ranges-ts 1.0.0 `index.ts`/ComplexTypeAlias#[T]
// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/ComplexTypeAlias#

// < end enclosing_range enclosing-ranges-ts 1.0.0 `index.ts`/
// < end enclosing_range enclosing-ranges-ts 1.0.0 file://index.ts
6 changes: 3 additions & 3 deletions snapshots/output/enclosing-ranges/range.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// < definition enclosing-ranges 0.0.1 `range.js`/
// < definition enclosing-ranges 0.0.1 file://range.js

// format-options: showRanges

// < start enclosing_range enclosing-ranges 0.0.1 `range.js`/
// < start enclosing_range enclosing-ranges 0.0.1 file://range.js
// ⌄ start enclosing_range enclosing-ranges 0.0.1 `range.js`/test.
const test = () => {
// ^^^^ definition enclosing-ranges 0.0.1 `range.js`/test.
Expand Down Expand Up @@ -76,4 +76,4 @@ class Test {
}
// < end enclosing_range enclosing-ranges 0.0.1 `range.js`/Test#

// < end enclosing_range enclosing-ranges 0.0.1 `range.js`/
// < end enclosing_range enclosing-ranges 0.0.1 file://range.js
2 changes: 1 addition & 1 deletion snapshots/output/invalid-package-json/packages/a/src/a.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition @example/a HEAD src/`a.ts`/
// < definition @example/a HEAD file://src/a.ts

export function a(): string {
// ^ definition @example/a HEAD src/`a.ts`/a().
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/multi-project/packages/a/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition @example/a 1.0.0 src/`index.ts`/
// < definition @example/a 1.0.0 file://src/index.ts
//documentation ```ts
// > module "index.ts"
// > ```
Expand Down
4 changes: 2 additions & 2 deletions snapshots/output/multi-project/packages/b/src/b.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// < definition @example/b 1.0.0 src/`b.ts`/
// < definition @example/b 1.0.0 file://src/b.ts

import { a } from '@example/a/src'
// ^ reference @example/a 1.0.0 src/`index.ts`/a().
// ^^^^^^^^^^^^^^^^ reference @example/a 1.0.0 src/`index.ts`/
// ^^^^^^^^^^^^^^^^ reference @example/a 1.0.0 file://src/index.ts

export function b() {
// ^ definition @example/b 1.0.0 src/`b.ts`/b().
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/pnpm-workspaces/packages/a/src/a.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition @example/a 1.0.0 src/`a.ts`/
// < definition @example/a 1.0.0 file://src/a.ts

export function a(): string {
// ^ definition @example/a 1.0.0 src/`a.ts`/a().
Expand Down
4 changes: 2 additions & 2 deletions snapshots/output/pnpm-workspaces/packages/b/src/b.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// < definition @example/b 1.0.0 src/`b.ts`/
// < definition @example/b 1.0.0 file://src/b.ts

import { a } from '@example/a'
// ^ reference @example/a 1.0.0 src/`a.ts`/a().
// ^^^^^^^^^^^^ reference @example/a 1.0.0 src/`a.ts`/
// ^^^^^^^^^^^^ reference @example/a 1.0.0 file://src/a.ts

export function b() {
// ^ definition @example/b 1.0.0 src/`b.ts`/b().
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/pure-js/src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition pure-js 1.0.0 src/`main.js`/
// < definition pure-js 1.0.0 file://src/main.js

function fib(n) {
// ^^^ definition pure-js 1.0.0 src/`main.js`/fib().
Expand Down
4 changes: 2 additions & 2 deletions snapshots/output/react/src/LoaderInput.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// < definition react-example 1.0.0 src/`LoaderInput.tsx`/
// < definition react-example 1.0.0 file://src/LoaderInput.tsx

import React from 'react'
// ^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/
// ^^^^^^^ reference @types/react 18.2.39 `index.d.ts`/
// ^^^^^^^ reference @types/react 18.2.39 file://index.d.ts

/** Takes loading prop, input component as child */
interface Props {
Expand Down
4 changes: 2 additions & 2 deletions snapshots/output/react/src/MyTSXElement.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// < definition react-example 1.0.0 src/`MyTSXElement.tsx`/
// < definition react-example 1.0.0 file://src/MyTSXElement.tsx

import React from 'react'
// ^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/
// ^^^^^^^ reference @types/react 18.2.39 `index.d.ts`/
// ^^^^^^^ reference @types/react 18.2.39 file://index.d.ts

export interface MyProps {}
// ^^^^^^^ definition react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
Expand Down
6 changes: 3 additions & 3 deletions snapshots/output/react/src/UseMyTSXElement.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// < definition react-example 1.0.0 src/`UseMyTSXElement.tsx`/
// < definition react-example 1.0.0 file://src/UseMyTSXElement.tsx

import React from "react";
// ^^^^^ reference @types/react 18.2.39 `index.d.ts`/React/
// ^^^^^^^ reference @types/react 18.2.39 `index.d.ts`/
// ^^^^^^^ reference @types/react 18.2.39 file://index.d.ts

import { MyProps, MyTSXElement } from "./MyTSXElement";
// ^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyProps#
// ^^^^^^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/MyTSXElement.
// ^^^^^^^^^^^^^^^^ reference react-example 1.0.0 src/`MyTSXElement.tsx`/
// ^^^^^^^^^^^^^^^^ reference react-example 1.0.0 file://src/MyTSXElement.tsx

export const _: React.FunctionComponent<MyProps> =
// ^ definition react-example 1.0.0 src/`UseMyTSXElement.tsx`/_.
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/ClassWithPrivate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`ClassWithPrivate.ts`/
// < definition syntax 1.0.0 file://src/ClassWithPrivate.ts

export class ClassWithPrivate {
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`ClassWithPrivate.ts`/ClassWithPrivate#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/accessors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`accessors.ts`/
// < definition syntax 1.0.0 file://src/accessors.ts

class C {
// ^ definition syntax 1.0.0 src/`accessors.ts`/C#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/class.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`class.ts`/
// < definition syntax 1.0.0 file://src/class.ts

export class Class {
// ^^^^^ definition syntax 1.0.0 src/`class.ts`/Class#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/conflicting-const-interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`conflicting-const-interface.ts`/
// < definition syntax 1.0.0 file://src/conflicting-const-interface.ts

export const ConflictingConst = 42
// ^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`conflicting-const-interface.ts`/ConflictingConst.
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/constructor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`constructor.ts`/
// < definition syntax 1.0.0 file://src/constructor.ts

namespace Yay {
// ^^^ definition syntax 1.0.0 src/`constructor.ts`/Yay/
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/destructuring.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`destructuring.ts`/
// < definition syntax 1.0.0 file://src/destructuring.ts

interface Props {
// ^^^^^ definition syntax 1.0.0 src/`destructuring.ts`/Props#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`enum.ts`/
// < definition syntax 1.0.0 file://src/enum.ts

export enum Enum {
// ^^^^ definition syntax 1.0.0 src/`enum.ts`/Enum#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/function.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`function.ts`/
// < definition syntax 1.0.0 file://src/function.ts

export function newFunction(): void {}
// ^^^^^^^^^^^ definition syntax 1.0.0 src/`function.ts`/newFunction().
Expand Down
14 changes: 7 additions & 7 deletions snapshots/output/syntax/src/import.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// < definition syntax 1.0.0 src/`import.ts`/
// < definition syntax 1.0.0 file://src/import.ts

import * as namespace from './namespace'
// ^^^^^^^^^ reference syntax 1.0.0 src/`namespace.ts`/
// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`namespace.ts`/
// ^^^^^^^^^^^^^ reference syntax 1.0.0 file://src/namespace.ts
import { Class } from './class'
// ^^^^^ reference syntax 1.0.0 src/`class.ts`/Class#
// ^^^^^^^^^ reference syntax 1.0.0 src/`class.ts`/
// ^^^^^^^^^ reference syntax 1.0.0 file://src/class.ts
import { Enum } from './enum'
// ^^^^ reference syntax 1.0.0 src/`enum.ts`/Enum#
// ^^^^^^^^ reference syntax 1.0.0 src/`enum.ts`/
// ^^^^^^^^ reference syntax 1.0.0 file://src/enum.ts
import { newFunction } from './function'
// ^^^^^^^^^^^ reference syntax 1.0.0 src/`function.ts`/newFunction().
// ^^^^^^^^^^^^ reference syntax 1.0.0 src/`function.ts`/
// ^^^^^^^^^^^^ reference syntax 1.0.0 file://src/function.ts
import { newInterface as renamedInterface } from './interface'
// ^^^^^^^^^^^^ reference syntax 1.0.0 src/`interface.ts`/newInterface().
// ^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`interface.ts`/newInterface().
// ^^^^^^^^^^^^^ reference syntax 1.0.0 src/`interface.ts`/
// ^^^^^^^^^^^^^ reference syntax 1.0.0 file://src/interface.ts

export function useEverything(): string {
// ^^^^^^^^^^^^^ definition syntax 1.0.0 src/`import.ts`/useEverything().
Expand Down Expand Up @@ -47,7 +47,7 @@ export function dynamicImport(): Promise<void> {
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2015.symbol.wellknown.d.ts`/Promise#
// ^^^^^^^ reference typescript 5.3.3 lib/`lib.es2018.promise.d.ts`/Promise#
return import('./function').then(c => c.newFunction())
// ^^^^^^^^^^^^ reference syntax 1.0.0 src/`function.ts`/
// ^^^^^^^^^^^^ reference syntax 1.0.0 file://src/function.ts
// ^^^^ reference typescript 5.3.3 lib/`lib.es5.d.ts`/Promise#then().
// ^ definition local 3
// ^ reference local 3
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/infer-relationship.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`infer-relationship.ts`/
// < definition syntax 1.0.0 file://src/infer-relationship.ts

interface Configuration {
// ^^^^^^^^^^^^^ definition syntax 1.0.0 src/`infer-relationship.ts`/Configuration#
Expand Down
4 changes: 2 additions & 2 deletions snapshots/output/syntax/src/inheritance.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// < definition syntax 1.0.0 src/`inheritance.ts`/
// < definition syntax 1.0.0 file://src/inheritance.ts

import { Overloader } from './overload'
// ^^^^^^^^^^ reference syntax 1.0.0 src/`overload.d.ts`/Overloader#
// ^^^^^^^^^^^^ reference syntax 1.0.0 src/`overload.d.ts`/
// ^^^^^^^^^^^^ reference syntax 1.0.0 file://src/overload.d.ts

export interface Superinterface {
// ^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`inheritance.ts`/Superinterface#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`interface.ts`/
// < definition syntax 1.0.0 file://src/interface.ts

export interface Interface {
// ^^^^^^^^^ definition syntax 1.0.0 src/`interface.ts`/Interface#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/issue-45.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`issue-45.d.ts`/
// < definition syntax 1.0.0 file://src/issue-45.d.ts

export namespace example {
// ^^^^^^^ definition syntax 1.0.0 src/`issue-45.d.ts`/example/
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/local.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`local.ts`/
// < definition syntax 1.0.0 file://src/local.ts

export function local(): string {
// ^^^^^ definition syntax 1.0.0 src/`local.ts`/local().
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/module.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`module.d.ts`/
// < definition syntax 1.0.0 file://src/module.d.ts

declare module 'a:b' {
// ^^^^^ definition syntax 1.0.0 src/`module.d.ts`/`'a:b'`/
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/namespace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`namespace.ts`/
// < definition syntax 1.0.0 file://src/namespace.ts

export declare namespace a {
// ^ definition syntax 1.0.0 src/`namespace.ts`/a/
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/overload.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`overload.d.ts`/
// < definition syntax 1.0.0 file://src/overload.d.ts

export interface Overloader {
// ^^^^^^^^^^ definition syntax 1.0.0 src/`overload.d.ts`/Overloader#
Expand Down
4 changes: 2 additions & 2 deletions snapshots/output/syntax/src/property-assignment-reference.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// < definition syntax 1.0.0 src/`property-assignment-reference.ts`/
// < definition syntax 1.0.0 file://src/property-assignment-reference.ts

import {
propertyAssignment,
//^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`property-assignment.ts`/propertyAssignment().
shorthandPropertyAssignment,
//^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`property-assignment.ts`/shorthandPropertyAssignment().
} from './property-assignment'
// ^^^^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 src/`property-assignment.ts`/
// ^^^^^^^^^^^^^^^^^^^^^^^ reference syntax 1.0.0 file://src/property-assignment.ts

export function run(): string {
// ^^^ definition syntax 1.0.0 src/`property-assignment-reference.ts`/run().
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/property-assignment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`property-assignment.ts`/
// < definition syntax 1.0.0 file://src/property-assignment.ts

export function propertyAssignment() {
// ^^^^^^^^^^^^^^^^^^ definition syntax 1.0.0 src/`property-assignment.ts`/propertyAssignment().
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/string-literals.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`string-literals.ts`/
// < definition syntax 1.0.0 file://src/string-literals.ts

interface SomeInterface {
// ^^^^^^^^^^^^^ definition syntax 1.0.0 src/`string-literals.ts`/SomeInterface#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/structural-type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`structural-type.ts`/
// < definition syntax 1.0.0 file://src/structural-type.ts

export function foo(): Promise<{ member: number }> {
// ^^^ definition syntax 1.0.0 src/`structural-type.ts`/foo().
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/type-alias.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`type-alias.ts`/
// < definition syntax 1.0.0 file://src/type-alias.ts

type S = string
// ^ definition syntax 1.0.0 src/`type-alias.ts`/S#
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/type-parameter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`type-parameter.ts`/
// < definition syntax 1.0.0 file://src/type-parameter.ts

export function typeParameter<A, B>(parameter: A, parameter2: B): [A, B] {
// ^^^^^^^^^^^^^ definition syntax 1.0.0 src/`type-parameter.ts`/typeParameter().
Expand Down
2 changes: 1 addition & 1 deletion snapshots/output/syntax/src/typings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// < definition syntax 1.0.0 src/`typings.ts`/
// < definition syntax 1.0.0 file://src/typings.ts

export function process() {
// ^^^^^^^ definition syntax 1.0.0 src/`typings.ts`/process().
Expand Down
20 changes: 20 additions & 0 deletions src/Debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import ts from 'typescript';

import { Range } from './Range';

export function printFullAST(sourceFile: ts.SourceFile): void {
console.log(`path: ${sourceFile.fileName}`)
printPartialAST(sourceFile)
}

export function printPartialAST(node: ts.Node): void {
let indent = 0;
const print = (node: ts.Node): void => {
const range = Range.fromNode(node)
console.log(new Array(indent + 1).join(' ') + ts.SyntaxKind[node.kind] + ` (${range.start.line},${range.start.character}-${range.end.character})`);
indent++;
ts.forEachChild(node, print);
indent--;
}
print(node)
}
8 changes: 6 additions & 2 deletions src/FileIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class FileIndexer {
// if (!this.sourceFile.fileName.includes('constructor')) {
// return
// }
// Debug.printFullAST(this.sourceFile)

const byteSize = Buffer.from(this.sourceFile.getText()).length
if (
Expand All @@ -64,7 +65,7 @@ export class FileIndexer {
this.visit(this.sourceFile)
}
private emitSourceFileOccurrence(): void {
const symbol = this.scipSymbol(this.sourceFile)
const symbol = this.packages.fileSymbol(this.sourceFile.fileName)
if (symbol.isEmpty()) {
return
}
Expand Down Expand Up @@ -167,7 +168,10 @@ export class FileIndexer {
[node.parent]
: sym?.declarations || []
for (const declaration of declarations) {
let scipSymbol = this.scipSymbol(declaration)
let scipSymbol =
(ts.isStringLiteralLike(node) && ts.isSourceFile(declaration))
? this.packages.fileSymbol(declaration.fileName)
: this.scipSymbol(declaration)

let enclosingRange: number[] | undefined

Expand Down
31 changes: 31 additions & 0 deletions src/Packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,37 @@ export class Packages {
)
}

public fileSymbol(filePath: string): ScipSymbol {
if (path.normalize(filePath) !== filePath) {
throw new Error(
`unexpected error: path.normalize('${filePath}') !== ${filePath}`
)
}
const cacheKey = 'file://' + filePath
const fromCache = this.cache.get(cacheKey)
if (fromCache) {
return fromCache
}
const packageJsonPath = path.join(filePath, 'package.json')
try {
if (
fs.existsSync(packageJsonPath) &&
fs.lstatSync(packageJsonPath).isFile()
) {
return this.cached(cacheKey, ScipSymbol.path(this.symbol(filePath), ''))
}
} catch (error) {
console.error(`error parsing ${packageJsonPath}`, error)
return this.cached(cacheKey, ScipSymbol.anonymousPackage())
}

const owner = this.fileSymbol(path.dirname(filePath))
return this.cached(
cacheKey,
ScipSymbol.path(owner, filePath)
)
}

private cached(filePath: string, sym: ScipSymbol): ScipSymbol {
this.cache.set(filePath, sym)
return sym
Expand Down
Loading
Loading