-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
42 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import { | |
StreamSource, | ||
} from "https://deno.land/x/[email protected]/stream/mod.ts" | ||
import { SourceFile } from "../deps/ts_morph.ts" | ||
import { Declaration } from "./deps_map.ts" | ||
import { Declaration } from "./decl_deps.ts" | ||
|
||
/** | ||
* Find initial declarations to begin analyze with. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import type { Declaration } from "../graph/deps_map.ts" | ||
import { getDecls } from "../graph/links.ts" | ||
import type { Declaration } from "./decl_deps.ts" | ||
import { getDecls } from "./decls.ts" | ||
import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts" | ||
import { declExampleText } from "./_example_project.ts" | ||
import { inMemoryProject } from "./_project.ts" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { GraphElement } from "https://deno.land/x/[email protected]/graph/custom/common/link.ts" | ||
import { ArrowGraphHashed } from "https://deno.land/x/[email protected]/graph/mod.ts" | ||
import { Stream } from "https://deno.land/x/[email protected]/stream/mod.ts" | ||
import { DeclDeps } from "./decl_deps.ts" | ||
|
||
export type Id = string | ||
|
||
/** directed graph of references, using `string` as unique key */ | ||
export type Graph = ArrowGraphHashed<Id> | ||
|
||
/** | ||
* ## Warning | ||
* | ||
* uses `Node.getName` as unique key which is prone to collisions | ||
* if there are multiple variables with the same name | ||
* | ||
* FIXME: assumes class declaration has names (hence `!`) | ||
*/ | ||
export const declDepsToGraph = (declDeps: DeclDeps): Graph => | ||
Stream.from(declDeps).flatMap(([source, targets]) => | ||
Stream.from(targets) | ||
.map((to): GraphElement<Id> => [source.getName()!, to.getName()!]) | ||
) | ||
.reduce(ArrowGraphHashed.reducer()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export * from "./create.ts" | ||
export * from "./flatten.ts" | ||
export * from "./links.ts" | ||
export * from "./deps_map.ts" | ||
export * from "./decls.ts" | ||
|
||
export * from "./decl_deps.ts" | ||
export * from "./graph.ts" | ||
export * from "./top_decl_deps.ts" | ||
|
||
export * from "./fs.ts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { HashMap, HashSet } from "https://deno.land/x/[email protected]/hashed/mod.ts" | ||
import { LinkDepsGraph } from "./create.ts" | ||
import type { Graph, Id } from "./graph.ts" | ||
|
||
export type FlatDepsMap = HashMap<string, HashSet<string>> | ||
export type TopDeclDeps = HashMap<Id, HashSet<Id>> | ||
|
||
/** | ||
* Flattens graph of references into top-level links | ||
|
@@ -20,7 +20,7 @@ export type FlatDepsMap = HashMap<string, HashSet<string>> | |
* TOP2 <- B, a, c | ||
* ``` | ||
*/ | ||
export const fromGraph = (graph: LinkDepsGraph): FlatDepsMap => { | ||
export const graphToTopDeclDeps = (graph: Graph): TopDeclDeps => { | ||
const topLevelNodes = graph.streamNodes() | ||
.filter((node) => graph.getConnectionsFrom(node).size === 0) | ||
|
||
|