quicktype 18.0.6 → 19.0.5
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 +1 -1
- package/dist/{cli/CompressedJSONFromStream.d.ts → CompressedJSONFromStream.d.ts} +1 -1
- package/dist/{cli/CompressedJSONFromStream.js → CompressedJSONFromStream.js} +2 -2
- package/dist/{cli/GraphQLIntrospection.d.ts → GraphQLIntrospection.d.ts} +0 -0
- package/dist/{cli/GraphQLIntrospection.js → GraphQLIntrospection.js} +1 -1
- package/dist/{cli/TypeSource.d.ts → TypeSource.d.ts} +2 -2
- package/dist/{cli/TypeSource.js → TypeSource.js} +0 -0
- package/dist/{cli/URLGrammar.d.ts → URLGrammar.d.ts} +0 -0
- package/dist/{cli/URLGrammar.js → URLGrammar.js} +1 -1
- package/dist/{cli/index.d.ts → index.d.ts} +2 -1
- package/dist/{cli/index.js → index.js} +4 -4
- package/package.json +61 -77
- package/dist/quicktype-core/Annotation.d.ts +0 -8
- package/dist/quicktype-core/Annotation.js +0 -16
- package/dist/quicktype-core/ConvenienceRenderer.d.ts +0 -138
- package/dist/quicktype-core/ConvenienceRenderer.js +0 -668
- package/dist/quicktype-core/DateTime.d.ts +0 -10
- package/dist/quicktype-core/DateTime.js +0 -57
- package/dist/quicktype-core/DeclarationIR.d.ts +0 -14
- package/dist/quicktype-core/DeclarationIR.js +0 -167
- package/dist/quicktype-core/EncodedMarkovChain.d.ts +0 -1
- package/dist/quicktype-core/EncodedMarkovChain.js +0 -4
- package/dist/quicktype-core/GatherNames.d.ts +0 -2
- package/dist/quicktype-core/GatherNames.js +0 -333
- package/dist/quicktype-core/Graph.d.ts +0 -12
- package/dist/quicktype-core/Graph.js +0 -220
- package/dist/quicktype-core/GraphRewriting.d.ts +0 -87
- package/dist/quicktype-core/GraphRewriting.js +0 -421
- package/dist/quicktype-core/MakeTransformations.d.ts +0 -4
- package/dist/quicktype-core/MakeTransformations.js +0 -193
- package/dist/quicktype-core/MarkovChain.d.ts +0 -15
- package/dist/quicktype-core/MarkovChain.js +0 -154
- package/dist/quicktype-core/Messages.d.ts +0 -294
- package/dist/quicktype-core/Messages.js +0 -105
- package/dist/quicktype-core/Naming.d.ts +0 -64
- package/dist/quicktype-core/Naming.js +0 -356
- package/dist/quicktype-core/Renderer.d.ts +0 -50
- package/dist/quicktype-core/Renderer.js +0 -274
- package/dist/quicktype-core/RendererOptions.d.ts +0 -71
- package/dist/quicktype-core/RendererOptions.js +0 -141
- package/dist/quicktype-core/Run.d.ts +0 -174
- package/dist/quicktype-core/Run.js +0 -393
- package/dist/quicktype-core/Source.d.ts +0 -65
- package/dist/quicktype-core/Source.js +0 -204
- package/dist/quicktype-core/TargetLanguage.d.ts +0 -34
- package/dist/quicktype-core/TargetLanguage.js +0 -66
- package/dist/quicktype-core/Transformers.d.ts +0 -209
- package/dist/quicktype-core/Transformers.js +0 -836
- package/dist/quicktype-core/Type.d.ts +0 -206
- package/dist/quicktype-core/Type.js +0 -716
- package/dist/quicktype-core/TypeBuilder.d.ts +0 -61
- package/dist/quicktype-core/TypeBuilder.js +0 -324
- package/dist/quicktype-core/TypeGraph.d.ts +0 -75
- package/dist/quicktype-core/TypeGraph.js +0 -420
- package/dist/quicktype-core/TypeUtils.d.ts +0 -33
- package/dist/quicktype-core/TypeUtils.js +0 -230
- package/dist/quicktype-core/UnifyClasses.d.ts +0 -16
- package/dist/quicktype-core/UnifyClasses.js +0 -159
- package/dist/quicktype-core/UnionBuilder.d.ts +0 -49
- package/dist/quicktype-core/UnionBuilder.js +0 -282
- package/dist/quicktype-core/attributes/AccessorNames.d.ts +0 -18
- package/dist/quicktype-core/attributes/AccessorNames.js +0 -182
- package/dist/quicktype-core/attributes/Constraints.d.ts +0 -38
- package/dist/quicktype-core/attributes/Constraints.js +0 -172
- package/dist/quicktype-core/attributes/Description.d.ts +0 -9
- package/dist/quicktype-core/attributes/Description.js +0 -97
- package/dist/quicktype-core/attributes/EnumValues.d.ts +0 -8
- package/dist/quicktype-core/attributes/EnumValues.js +0 -31
- package/dist/quicktype-core/attributes/StringTypes.d.ts +0 -28
- package/dist/quicktype-core/attributes/StringTypes.js +0 -189
- package/dist/quicktype-core/attributes/TypeAttributes.d.ts +0 -34
- package/dist/quicktype-core/attributes/TypeAttributes.js +0 -119
- package/dist/quicktype-core/attributes/TypeNames.d.ts +0 -46
- package/dist/quicktype-core/attributes/TypeNames.js +0 -274
- package/dist/quicktype-core/attributes/URIAttributes.d.ts +0 -8
- package/dist/quicktype-core/attributes/URIAttributes.js +0 -85
- package/dist/quicktype-core/index.d.ts +0 -48
- package/dist/quicktype-core/index.js +0 -180
- package/dist/quicktype-core/input/CompressedJSON.d.ts +0 -69
- package/dist/quicktype-core/input/CompressedJSON.js +0 -276
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.d.ts +0 -6
- package/dist/quicktype-core/input/FetchingJSONSchemaStore.js +0 -18
- package/dist/quicktype-core/input/Inference.d.ts +0 -22
- package/dist/quicktype-core/input/Inference.js +0 -240
- package/dist/quicktype-core/input/Inputs.d.ts +0 -48
- package/dist/quicktype-core/input/Inputs.js +0 -145
- package/dist/quicktype-core/input/JSONSchemaInput.d.ts +0 -91
- package/dist/quicktype-core/input/JSONSchemaInput.js +0 -1041
- package/dist/quicktype-core/input/JSONSchemaStore.d.ts +0 -8
- package/dist/quicktype-core/input/JSONSchemaStore.js +0 -36
- package/dist/quicktype-core/input/PostmanCollection.d.ts +0 -5
- package/dist/quicktype-core/input/PostmanCollection.js +0 -60
- package/dist/quicktype-core/input/io/NodeIO.d.ts +0 -3
- package/dist/quicktype-core/input/io/NodeIO.js +0 -87
- package/dist/quicktype-core/input/io/get-stream/buffer-stream.d.ts +0 -2
- package/dist/quicktype-core/input/io/get-stream/buffer-stream.js +0 -45
- package/dist/quicktype-core/input/io/get-stream/index.d.ts +0 -9
- package/dist/quicktype-core/input/io/get-stream/index.js +0 -52
- package/dist/quicktype-core/language/All.d.ts +0 -3
- package/dist/quicktype-core/language/All.js +0 -57
- package/dist/quicktype-core/language/CPlusPlus.d.ts +0 -241
- package/dist/quicktype-core/language/CPlusPlus.js +0 -1847
- package/dist/quicktype-core/language/CSharp.d.ts +0 -201
- package/dist/quicktype-core/language/CSharp.js +0 -1850
- package/dist/quicktype-core/language/Crystal.d.ts +0 -37
- package/dist/quicktype-core/language/Crystal.js +0 -337
- package/dist/quicktype-core/language/Dart.d.ts +0 -66
- package/dist/quicktype-core/language/Dart.js +0 -576
- package/dist/quicktype-core/language/Elm.d.ts +0 -58
- package/dist/quicktype-core/language/Elm.js +0 -522
- package/dist/quicktype-core/language/Golang.d.ts +0 -51
- package/dist/quicktype-core/language/Golang.js +0 -460
- package/dist/quicktype-core/language/Haskell.d.ts +0 -56
- package/dist/quicktype-core/language/Haskell.js +0 -411
- package/dist/quicktype-core/language/JSONSchema.d.ts +0 -31
- package/dist/quicktype-core/language/JSONSchema.js +0 -169
- package/dist/quicktype-core/language/Java.d.ts +0 -125
- package/dist/quicktype-core/language/Java.js +0 -1081
- package/dist/quicktype-core/language/JavaScript.d.ts +0 -68
- package/dist/quicktype-core/language/JavaScript.js +0 -435
- package/dist/quicktype-core/language/JavaScriptPropTypes.d.ts +0 -40
- package/dist/quicktype-core/language/JavaScriptPropTypes.js +0 -213
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.d.ts +0 -2
- package/dist/quicktype-core/language/JavaScriptUnicodeMaps.js +0 -134
- package/dist/quicktype-core/language/Kotlin.d.ts +0 -109
- package/dist/quicktype-core/language/Kotlin.js +0 -832
- package/dist/quicktype-core/language/Objective-C.d.ts +0 -79
- package/dist/quicktype-core/language/Objective-C.js +0 -777
- package/dist/quicktype-core/language/Php.d.ts +0 -80
- package/dist/quicktype-core/language/Php.js +0 -702
- package/dist/quicktype-core/language/Pike.d.ts +0 -37
- package/dist/quicktype-core/language/Pike.js +0 -276
- package/dist/quicktype-core/language/Python.d.ts +0 -107
- package/dist/quicktype-core/language/Python.js +0 -969
- package/dist/quicktype-core/language/Rust.d.ts +0 -56
- package/dist/quicktype-core/language/Rust.js +0 -309
- package/dist/quicktype-core/language/Swift.d.ts +0 -96
- package/dist/quicktype-core/language/Swift.js +0 -1211
- package/dist/quicktype-core/language/TypeScriptFlow.d.ts +0 -77
- package/dist/quicktype-core/language/TypeScriptFlow.js +0 -286
- package/dist/quicktype-core/language/ruby/index.d.ts +0 -52
- package/dist/quicktype-core/language/ruby/index.js +0 -557
- package/dist/quicktype-core/language/ruby/keywords.d.ts +0 -3
- package/dist/quicktype-core/language/ruby/keywords.js +0 -358
- package/dist/quicktype-core/rewrites/CombineClasses.d.ts +0 -3
- package/dist/quicktype-core/rewrites/CombineClasses.js +0 -125
- package/dist/quicktype-core/rewrites/ExpandStrings.d.ts +0 -4
- package/dist/quicktype-core/rewrites/ExpandStrings.js +0 -143
- package/dist/quicktype-core/rewrites/FlattenStrings.d.ts +0 -3
- package/dist/quicktype-core/rewrites/FlattenStrings.js +0 -45
- package/dist/quicktype-core/rewrites/FlattenUnions.d.ts +0 -3
- package/dist/quicktype-core/rewrites/FlattenUnions.js +0 -47
- package/dist/quicktype-core/rewrites/InferMaps.d.ts +0 -3
- package/dist/quicktype-core/rewrites/InferMaps.js +0 -117
- package/dist/quicktype-core/rewrites/ReplaceObjectType.d.ts +0 -3
- package/dist/quicktype-core/rewrites/ReplaceObjectType.js +0 -60
- package/dist/quicktype-core/rewrites/ResolveIntersections.d.ts +0 -3
- package/dist/quicktype-core/rewrites/ResolveIntersections.js +0 -244
- package/dist/quicktype-core/support/Acronyms.d.ts +0 -10
- package/dist/quicktype-core/support/Acronyms.js +0 -1128
- package/dist/quicktype-core/support/Chance.d.ts +0 -38
- package/dist/quicktype-core/support/Chance.js +0 -2146
- package/dist/quicktype-core/support/Converters.d.ts +0 -6
- package/dist/quicktype-core/support/Converters.js +0 -16
- package/dist/quicktype-core/support/Strings.d.ts +0 -44
- package/dist/quicktype-core/support/Strings.js +0 -525
- package/dist/quicktype-core/support/Support.d.ts +0 -29
- package/dist/quicktype-core/support/Support.js +0 -162
- package/dist/quicktype-graphql-input/GraphQLSchema.d.ts +0 -645
- package/dist/quicktype-graphql-input/GraphQLSchema.js +0 -39
- package/dist/quicktype-graphql-input/index.d.ts +0 -17
- package/dist/quicktype-graphql-input/index.js +0 -407
- package/dist/quicktype-typescript-input/index.d.ts +0 -2
- package/dist/quicktype-typescript-input/index.js +0 -98
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// https://github.com/epoberezkin/ajv/blob/4d76c6fb813b136b6ec4fe74990bc97233d75dea/lib/compile/formats.js
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.DefaultDateTimeRecognizer = void 0;
|
|
5
|
-
/*
|
|
6
|
-
The MIT License (MIT)
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2015 Evgeny Poberezkin
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
SOFTWARE.
|
|
27
|
-
*/
|
|
28
|
-
const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
29
|
-
const DAYS = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
30
|
-
const TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i;
|
|
31
|
-
const DATE_TIME_SEPARATOR = /t|\s/i;
|
|
32
|
-
class DefaultDateTimeRecognizer {
|
|
33
|
-
isDate(str) {
|
|
34
|
-
// full-date from http://tools.ietf.org/html/rfc3339#section-5.6
|
|
35
|
-
const matches = str.match(DATE);
|
|
36
|
-
if (matches === null)
|
|
37
|
-
return false;
|
|
38
|
-
const month = +matches[2];
|
|
39
|
-
const day = +matches[3];
|
|
40
|
-
return month >= 1 && month <= 12 && day >= 1 && day <= DAYS[month];
|
|
41
|
-
}
|
|
42
|
-
isTime(str) {
|
|
43
|
-
const matches = str.match(TIME);
|
|
44
|
-
if (matches === null)
|
|
45
|
-
return false;
|
|
46
|
-
const hour = +matches[1];
|
|
47
|
-
const minute = +matches[2];
|
|
48
|
-
const second = +matches[3];
|
|
49
|
-
return hour <= 23 && minute <= 59 && second <= 59;
|
|
50
|
-
}
|
|
51
|
-
isDateTime(str) {
|
|
52
|
-
// http://tools.ietf.org/html/rfc3339#section-5.6
|
|
53
|
-
const dateTime = str.split(DATE_TIME_SEPARATOR);
|
|
54
|
-
return dateTime.length === 2 && this.isDate(dateTime[0]) && this.isTime(dateTime[1]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.DefaultDateTimeRecognizer = DefaultDateTimeRecognizer;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TypeGraph } from "./TypeGraph";
|
|
2
|
-
import { Type } from "./Type";
|
|
3
|
-
export type DeclarationKind = "forward" | "define";
|
|
4
|
-
export interface Declaration {
|
|
5
|
-
readonly kind: DeclarationKind;
|
|
6
|
-
readonly type: Type;
|
|
7
|
-
}
|
|
8
|
-
export declare class DeclarationIR {
|
|
9
|
-
readonly forwardedTypes: Set<Type>;
|
|
10
|
-
readonly declarations: ReadonlyArray<Declaration>;
|
|
11
|
-
constructor(declarations: Iterable<Declaration>, forwardedTypes: Set<Type>);
|
|
12
|
-
}
|
|
13
|
-
export declare function cycleBreakerTypesForGraph(graph: TypeGraph, isImplicitCycleBreaker: (t: Type) => boolean, canBreakCycles: (t: Type) => boolean): Set<Type>;
|
|
14
|
-
export declare function declarationsForGraph(typeGraph: TypeGraph, canBeForwardDeclared: ((t: Type) => boolean) | undefined, childrenOfType: (t: Type) => ReadonlySet<Type>, needsDeclaration: (t: Type) => boolean): DeclarationIR;
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.declarationsForGraph = exports.cycleBreakerTypesForGraph = exports.DeclarationIR = void 0;
|
|
4
|
-
const collection_utils_1 = require("collection-utils");
|
|
5
|
-
const Support_1 = require("./support/Support");
|
|
6
|
-
const Graph_1 = require("./Graph");
|
|
7
|
-
const Messages_1 = require("./Messages");
|
|
8
|
-
class DeclarationIR {
|
|
9
|
-
forwardedTypes;
|
|
10
|
-
declarations;
|
|
11
|
-
constructor(declarations, forwardedTypes) {
|
|
12
|
-
this.forwardedTypes = forwardedTypes;
|
|
13
|
-
this.declarations = Array.from(declarations);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.DeclarationIR = DeclarationIR;
|
|
17
|
-
function findBreaker(t, path, canBreak) {
|
|
18
|
-
const index = path.indexOf(t);
|
|
19
|
-
if (index < 0)
|
|
20
|
-
return undefined;
|
|
21
|
-
if (canBreak === undefined) {
|
|
22
|
-
return path[index];
|
|
23
|
-
}
|
|
24
|
-
const potentialBreakers = path.slice(0, index + 1).reverse();
|
|
25
|
-
const maybeBreaker = potentialBreakers.find(canBreak);
|
|
26
|
-
if (maybeBreaker === undefined) {
|
|
27
|
-
return (0, Support_1.panic)("Found a cycle that cannot be broken");
|
|
28
|
-
}
|
|
29
|
-
return maybeBreaker;
|
|
30
|
-
}
|
|
31
|
-
function cycleBreakerTypesForGraph(graph, isImplicitCycleBreaker, canBreakCycles) {
|
|
32
|
-
const visitedTypes = new Set();
|
|
33
|
-
const cycleBreakerTypes = new Set();
|
|
34
|
-
const queue = Array.from(graph.topLevels.values());
|
|
35
|
-
function visit(t, path) {
|
|
36
|
-
if (visitedTypes.has(t))
|
|
37
|
-
return;
|
|
38
|
-
if (isImplicitCycleBreaker(t)) {
|
|
39
|
-
for (const c of t.getChildren()) {
|
|
40
|
-
queue.push(c);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
const maybeBreaker = findBreaker(t, path, canBreakCycles);
|
|
45
|
-
if (maybeBreaker !== undefined) {
|
|
46
|
-
cycleBreakerTypes.add(maybeBreaker);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
for (const c of t.getChildren()) {
|
|
50
|
-
path.unshift(t);
|
|
51
|
-
visit(c, path);
|
|
52
|
-
path.shift();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
visitedTypes.add(t);
|
|
56
|
-
}
|
|
57
|
-
for (;;) {
|
|
58
|
-
const maybeType = queue.pop();
|
|
59
|
-
if (maybeType === undefined)
|
|
60
|
-
break;
|
|
61
|
-
const path = [];
|
|
62
|
-
visit(maybeType, path);
|
|
63
|
-
(0, Support_1.assert)(path.length === 0);
|
|
64
|
-
}
|
|
65
|
-
return cycleBreakerTypes;
|
|
66
|
-
}
|
|
67
|
-
exports.cycleBreakerTypesForGraph = cycleBreakerTypesForGraph;
|
|
68
|
-
function declarationsForGraph(typeGraph, canBeForwardDeclared, childrenOfType, needsDeclaration) {
|
|
69
|
-
/*
|
|
70
|
-
function nodeTitle(t: Type): string {
|
|
71
|
-
const indexAndKind = `${t.typeRef.index} ${t.kind}`;
|
|
72
|
-
if (t.hasNames) {
|
|
73
|
-
return `${indexAndKind} ${t.getCombinedName()}`;
|
|
74
|
-
} else {
|
|
75
|
-
return indexAndKind;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function componentName(c: Iterable<Type>): string {
|
|
79
|
-
return Array.from(c).map(nodeTitle).join(", ");
|
|
80
|
-
}
|
|
81
|
-
*/
|
|
82
|
-
const topDown = canBeForwardDeclared === undefined;
|
|
83
|
-
const declarations = [];
|
|
84
|
-
const forwardedTypes = new Set();
|
|
85
|
-
const visitedComponents = new Set();
|
|
86
|
-
function processGraph(graph, _writeComponents) {
|
|
87
|
-
const componentsGraph = graph.stronglyConnectedComponents();
|
|
88
|
-
function visitComponent(component) {
|
|
89
|
-
if (visitedComponents.has(component))
|
|
90
|
-
return;
|
|
91
|
-
visitedComponents.add(component);
|
|
92
|
-
// console.log(`visiting component ${componentName(component)}`);
|
|
93
|
-
const declarationNeeded = (0, collection_utils_1.setFilter)(component, needsDeclaration);
|
|
94
|
-
// 1. Only one node in the cycle needs a declaration, in which
|
|
95
|
-
// case it's the breaker, and no forward declaration is necessary.
|
|
96
|
-
if (declarationNeeded.size === 1) {
|
|
97
|
-
declarations.push({ kind: "define", type: (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(declarationNeeded)) });
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
// 2. No node in the cycle needs a declaration, but it's also
|
|
101
|
-
// the only node, so we don't actually need a declaration at all.
|
|
102
|
-
if (declarationNeeded.size === 0 && component.size === 1) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
// 3. No node in the cycle needs a declaration, but there's more.
|
|
106
|
-
// than one node total. We have to pick a node to make a
|
|
107
|
-
// declaration, so we can pick any one. This is not a forward
|
|
108
|
-
// declaration, either.
|
|
109
|
-
if (declarationNeeded.size === 0) {
|
|
110
|
-
declarations.push({ kind: "define", type: (0, Support_1.defined)((0, collection_utils_1.iterableFirst)(component)) });
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
// 4. More than one node needs a declaration, and we don't need
|
|
114
|
-
// forward declarations. Just declare all of them and be done
|
|
115
|
-
// with it.
|
|
116
|
-
if (canBeForwardDeclared === undefined) {
|
|
117
|
-
for (const t of declarationNeeded) {
|
|
118
|
-
declarations.push({ kind: "define", type: t });
|
|
119
|
-
}
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
// 5. More than one node needs a declaration, and we have
|
|
123
|
-
// to make forward declarations. We do the simple thing and first
|
|
124
|
-
// forward-declare all forward-declarable types in the SCC. If
|
|
125
|
-
// there are none, we're stuck. If there are, we take them out of
|
|
126
|
-
// the component and try the whole thing again recursively. Then
|
|
127
|
-
// we declare the types we previously forward-declared.
|
|
128
|
-
const forwardDeclarable = (0, collection_utils_1.setFilter)(component, canBeForwardDeclared);
|
|
129
|
-
if (forwardDeclarable.size === 0) {
|
|
130
|
-
return (0, Messages_1.messageError)("IRNoForwardDeclarableTypeInCycle", {});
|
|
131
|
-
}
|
|
132
|
-
for (const t of forwardDeclarable) {
|
|
133
|
-
declarations.push({ kind: "forward", type: t });
|
|
134
|
-
}
|
|
135
|
-
(0, collection_utils_1.setUnionInto)(forwardedTypes, forwardDeclarable);
|
|
136
|
-
const rest = (0, collection_utils_1.setSubtract)(component, forwardDeclarable);
|
|
137
|
-
const restGraph = new Graph_1.Graph(rest, true, t => (0, collection_utils_1.setIntersect)(childrenOfType(t), rest));
|
|
138
|
-
processGraph(restGraph, false);
|
|
139
|
-
for (const t of forwardDeclarable) {
|
|
140
|
-
declarations.push({ kind: "define", type: t });
|
|
141
|
-
}
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
/*
|
|
145
|
-
if (_writeComponents) {
|
|
146
|
-
componentsGraph.nodes.forEach(types => {
|
|
147
|
-
console.log(
|
|
148
|
-
`scc: ${types
|
|
149
|
-
.filter(t => t instanceof ClassType)
|
|
150
|
-
.map(t => t.getCombinedName())
|
|
151
|
-
.join(", ")}`
|
|
152
|
-
);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
*/
|
|
156
|
-
const rootsUnordered = componentsGraph.findRoots();
|
|
157
|
-
const roots = rootsUnordered;
|
|
158
|
-
for (const component of roots) {
|
|
159
|
-
componentsGraph.dfsTraversal(component, topDown, visitComponent);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const fullGraph = typeGraph.makeGraph(false, childrenOfType);
|
|
163
|
-
// fs.writeFileSync("graph.dot", fullGraph.makeDot(t => !(t instanceof PrimitiveType), nodeTitle));
|
|
164
|
-
processGraph(fullGraph, true);
|
|
165
|
-
return new DeclarationIR(declarations, forwardedTypes);
|
|
166
|
-
}
|
|
167
|
-
exports.declarationsForGraph = declarationsForGraph;
|