Monomorphic flag calculation and property access for name/jsDoc

This commit is contained in:
Ron Buckton
2024-09-20 15:54:06 -04:00
parent 0f2a20fa57
commit aaf7906ce3
6 changed files with 1165 additions and 827 deletions
+769 -40
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -52,6 +52,7 @@ import {
FunctionExpression,
FunctionTypeNode,
GetAccessorDeclaration,
HasJSDoc,
HasLocals,
HasName,
HeritageClause,
@@ -235,6 +236,14 @@ import {
];
}
{
// eslint-disable-next-line @typescript-eslint/naming-convention
type _ = [
__Expect<HasJSDoc, Extract<Nodes, { jsDoc: any }>>,
__Expect<Extract<Nodes, { jsDoc: any }>, HasJSDoc>,
];
}
// Registry
/**
+5 -3
View File
@@ -59,6 +59,7 @@ import {
AstFunctionExpression,
AstFunctionOrConstructorTypeNode,
AstHasJSDoc,
astHasJSDoc,
astHasJSDocNodes,
AstHasModifiers,
AstHeritageClause,
@@ -183,6 +184,7 @@ import {
AstReadonlyKeyword,
AstReturnStatement,
AstSatisfiesExpression,
astSetJSDoc,
AstShorthandPropertyAssignment,
AstSourceFile,
AstStatement,
@@ -938,12 +940,12 @@ namespace Parser {
return node;
}
Debug.assert(!node.data.jsDoc); // Should only be called once per node
Debug.assert(!astHasJSDoc(node)); // Should only be called once per node
const jsDoc = mapDefined(getJSDocCommentRanges(node, sourceText), comment => JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos)?.node); // TODO(rbuckton): do not instantiate .node
if (jsDoc.length) node.data.jsDoc = jsDoc;
if (jsDoc.length) astSetJSDoc(node, jsDoc);
if (hasDeprecatedTag) {
hasDeprecatedTag = false;
(node as Mutable<T>).flags |= NodeFlags.Deprecated;
node.flags |= NodeFlags.Deprecated;
}
return node;
}
+15 -3
View File
@@ -334,6 +334,8 @@ import {
WriteFileCallbackData,
writeFileEnsuringDirectories,
PartialSourceFile,
PackageJsonInfo,
JSDocParsingMode,
} from "./_namespaces/ts.js";
import * as performance from "./_namespaces/ts.performance.js";
@@ -3724,9 +3726,19 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
const result = getImpliedNodeFormatForFileWorker(getNormalizedAbsolutePath(fileName, currentDirectory), moduleResolutionCache?.getPackageJsonInfoCache(), host, options);
const languageVersion = getEmitScriptTarget(options);
const setExternalModuleIndicator = getSetExternalModuleIndicator(options);
return typeof result === "object" ?
{ ...result, languageVersion, setExternalModuleIndicator, jsDocParsingMode: host.jsDocParsingMode } :
{ languageVersion, impliedNodeFormat: result, setExternalModuleIndicator, jsDocParsingMode: host.jsDocParsingMode };
const jsDocParsingMode = host.jsDocParsingMode;
let impliedNodeFormat: ResolutionMode | undefined;
let packageJsonLocations: readonly string[] | undefined;
let packageJsonScope: PackageJsonInfo | undefined;
if (typeof result === "object") {
impliedNodeFormat = result.impliedNodeFormat;
packageJsonLocations = result.packageJsonLocations;
packageJsonScope = result.packageJsonScope;
}
else {
impliedNodeFormat = result;
}
return { languageVersion, impliedNodeFormat, setExternalModuleIndicator, packageJsonLocations, packageJsonScope, jsDocParsingMode };
}
function findSourceFileWorker(fileName: string, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, reason: FileIncludeReason, packageId: PackageId | undefined): SourceFile | undefined {
+275 -495
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff