mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Monomorphic flag calculation and property access for name/jsDoc
This commit is contained in:
+769
-40
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
@@ -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
File diff suppressed because it is too large
Load Diff
+92
-286
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user