Fixed bug with discovery in processTypes
This commit is contained in:
parent
6a61fd295c
commit
2e4975d4a8
|
@ -308,13 +308,10 @@ export function discover(): DiscoveryResult {
|
|||
function discoverTestableType(syntaxType: SyntaxType) {
|
||||
if (syntaxType.type !== nodeType && !syntaxType.syntaxNodes) {
|
||||
syntaxType.syntaxNodes = [];
|
||||
if (syntaxType.type.findFirstAnnotation(/*inherited*/ false, KindAnnotation.match)) {
|
||||
copySyntaxNodes(syntaxType.type, syntaxType.syntaxNodes, []);
|
||||
}
|
||||
else {
|
||||
discoverSyntaxNodes(syntaxType.type, syntaxType.syntaxNodes, []);
|
||||
}
|
||||
|
||||
let includeAliasAndUnionConstituents = !syntaxType.type.findFirstAnnotation(/*inherited*/ false, KindAnnotation.match);
|
||||
|
||||
discoverSyntaxNodes(syntaxType.type, syntaxType.syntaxNodes, [], includeAliasAndUnionConstituents);
|
||||
if (syntaxType.syntaxNodes.length > 0) {
|
||||
let testFunctionName = discoverIsAnyNodeFunctionName(syntaxType.type);
|
||||
if (testFunctionName) {
|
||||
|
@ -325,7 +322,7 @@ export function discover(): DiscoveryResult {
|
|||
}
|
||||
}
|
||||
|
||||
function discoverSyntaxNodes(type: TypeInfo, syntaxNodes: SyntaxNode[], seen: boolean[]) {
|
||||
function discoverSyntaxNodes(type: TypeInfo, syntaxNodes: SyntaxNode[], seen: boolean[], includeAliasAndUnionConstituents?: boolean) {
|
||||
copySyntaxNodes(type, syntaxNodes, seen);
|
||||
|
||||
for (let aliasType of type.getAliases()) {
|
||||
|
@ -338,13 +335,15 @@ export function discover(): DiscoveryResult {
|
|||
}
|
||||
}
|
||||
|
||||
if (type.isTypeAlias) {
|
||||
discoverSyntaxNodes(type.getAliasedType(), syntaxNodes, seen);
|
||||
}
|
||||
if (includeAliasAndUnionConstituents) {
|
||||
if (type.isTypeAlias) {
|
||||
discoverSyntaxNodes(type.getAliasedType(), syntaxNodes, seen);
|
||||
}
|
||||
|
||||
if (type.isUnionType) {
|
||||
for (let constituentType of type.getConstituentTypes()) {
|
||||
discoverSyntaxNodes(constituentType, syntaxNodes, seen);
|
||||
if (type.isUnionType) {
|
||||
for (let constituentType of type.getConstituentTypes()) {
|
||||
discoverSyntaxNodes(constituentType, syntaxNodes, seen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2311,15 +2311,10 @@ namespace ts {
|
|||
export function isRawStatement(node: Node): node is RawStatement {
|
||||
return node && node.kind === SyntaxKind.RawStatement;
|
||||
}
|
||||
export function isLiteralExpression(node: Node): node is LiteralExpression {
|
||||
export function isFunctionBody(node: Node): node is FunctionBody {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.TemplateHead:
|
||||
case SyntaxKind.TemplateMiddle:
|
||||
case SyntaxKind.TemplateTail:
|
||||
case SyntaxKind.Block:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2343,54 +2338,6 @@ namespace ts {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
export function isEntityName(node: Node): node is EntityName {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.QualifiedName:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function isDeclarationNameNode(node: Node): node is DeclarationName {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.TemplateHead:
|
||||
case SyntaxKind.TemplateMiddle:
|
||||
case SyntaxKind.TemplateTail:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.RawExpression:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function isPropertyName(node: Node): node is PropertyName {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.TemplateHead:
|
||||
case SyntaxKind.TemplateMiddle:
|
||||
case SyntaxKind.TemplateTail:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.RawExpression:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function isStatementNode(node: Node): node is Statement {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
|
@ -2539,15 +2486,6 @@ namespace ts {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
export function isFunctionBody(node: Node): node is FunctionBody {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Block:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function isExpressionNode(node: Node): node is Expression {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
|
@ -2599,16 +2537,9 @@ namespace ts {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
export function isConciseBody(node: Node): node is ConciseBody {
|
||||
export function isLiteralExpression(node: Node): node is LiteralExpression {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.OmittedExpression:
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.FalseKeyword:
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
|
@ -2617,35 +2548,6 @@ namespace ts {
|
|||
case SyntaxKind.TemplateTail:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.RawExpression:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.TemplateExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.JsxElement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
case SyntaxKind.DeleteExpression:
|
||||
case SyntaxKind.TypeOfExpression:
|
||||
case SyntaxKind.VoidExpression:
|
||||
case SyntaxKind.AwaitExpression:
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.YieldExpression:
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.SpreadElementExpression:
|
||||
case SyntaxKind.AsExpression:
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
case SyntaxKind.JsxExpression:
|
||||
case SyntaxKind.Block:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2678,18 +2580,6 @@ namespace ts {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
export function isJsxChild(node: Node): node is JsxChild {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.JsxElement:
|
||||
case SyntaxKind.JsxExpression:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.JsxText:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function isExpressionOrVariableDeclarationList(node: Node): node is Expression | VariableDeclarationList {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
|
@ -2742,16 +2632,6 @@ namespace ts {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
export function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.DefaultClause:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function isIdentifierOrLiteralExpression(node: Node): node is Identifier | LiteralExpression {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
|
@ -2769,21 +2649,9 @@ namespace ts {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
export function isModuleBody(node: Node): node is ModuleBody {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function isEntityNameOrExternalModuleReference(node: Node): node is EntityName | ExternalModuleReference {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.QualifiedName:
|
||||
case SyntaxKind.ExternalModuleReference:
|
||||
return true;
|
||||
}
|
||||
|
@ -2794,7 +2662,6 @@ namespace ts {
|
|||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.NamedImports:
|
||||
case SyntaxKind.NamedExports:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue