mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Removed ModifiersArray
This commit is contained in:
+6
-47
@@ -46,46 +46,9 @@ namespace ts {
|
||||
array.hasTrailingComma = true;
|
||||
}
|
||||
|
||||
array.arrayKind = ArrayKind.NodeArray;
|
||||
return array;
|
||||
}
|
||||
|
||||
export function createModifiersArray(elements?: Modifier[], location?: TextRange): ModifiersArray {
|
||||
if (elements) {
|
||||
if (isModifiersArray(elements)) {
|
||||
return elements;
|
||||
}
|
||||
}
|
||||
else {
|
||||
elements = [];
|
||||
}
|
||||
|
||||
const array = <ModifiersArray>elements;
|
||||
if (location) {
|
||||
array.pos = location.pos;
|
||||
array.end = location.end;
|
||||
}
|
||||
else {
|
||||
array.pos = -1;
|
||||
array.end = -1;
|
||||
}
|
||||
|
||||
array.arrayKind = ArrayKind.ModifiersArray;
|
||||
return array;
|
||||
}
|
||||
|
||||
export function setModifiers<T extends Node>(node: T, modifiers: Modifier[]) {
|
||||
if (modifiers) {
|
||||
const array = createModifiersArray(modifiers);
|
||||
node.modifiers = array;
|
||||
}
|
||||
else {
|
||||
node.modifiers = undefined;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node {
|
||||
const node = createNode(kind, /*location*/ undefined);
|
||||
node.startsOnNewLine = startsOnNewLine;
|
||||
@@ -96,10 +59,6 @@ namespace ts {
|
||||
return createNodeArray(elements, /*location*/ undefined);
|
||||
}
|
||||
|
||||
export function createSynthesizedModifiersArray(elements?: Modifier[]): ModifiersArray {
|
||||
return createModifiersArray(elements, /*location*/ undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a shallow, memberwise clone of a node with no source map location.
|
||||
*/
|
||||
@@ -238,7 +197,7 @@ namespace ts {
|
||||
export function createMethod(modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block, location?: TextRange) {
|
||||
const node = <MethodDeclaration>createNode(SyntaxKind.MethodDeclaration, location);
|
||||
node.decorators = undefined;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
node.name = typeof name === "string" ? createIdentifier(name) : name;
|
||||
node.typeParameters = undefined;
|
||||
node.parameters = createNodeArray(parameters);
|
||||
@@ -260,7 +219,7 @@ namespace ts {
|
||||
export function createGetAccessor(modifiers: Modifier[], name: string | PropertyName, body: Block, location?: TextRange) {
|
||||
const node = <GetAccessorDeclaration>createNode(SyntaxKind.GetAccessor, location);
|
||||
node.decorators = undefined;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
node.name = typeof name === "string" ? createIdentifier(name) : name;
|
||||
node.typeParameters = undefined;
|
||||
node.parameters = createNodeArray<ParameterDeclaration>();
|
||||
@@ -271,7 +230,7 @@ namespace ts {
|
||||
export function createSetAccessor(modifiers: Modifier[], name: string | PropertyName, parameter: ParameterDeclaration, body: Block, location?: TextRange) {
|
||||
const node = <SetAccessorDeclaration>createNode(SyntaxKind.SetAccessor, location);
|
||||
node.decorators = undefined;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
node.name = typeof name === "string" ? createIdentifier(name) : name;
|
||||
node.typeParameters = undefined;
|
||||
node.parameters = createNodeArray([parameter]);
|
||||
@@ -463,7 +422,7 @@ namespace ts {
|
||||
export function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList, location?: TextRange): VariableStatement {
|
||||
const node = <VariableStatement>createNode(SyntaxKind.VariableStatement, location);
|
||||
node.decorators = undefined;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
node.declarationList = declarationList;
|
||||
return node;
|
||||
}
|
||||
@@ -562,7 +521,7 @@ namespace ts {
|
||||
export function createFunctionDeclaration(modifiers: Modifier[], asteriskToken: Node, name: string | Identifier, parameters: ParameterDeclaration[], body: Block, location?: TextRange, original?: Node) {
|
||||
const node = <FunctionDeclaration>createNode(SyntaxKind.FunctionDeclaration, location);
|
||||
node.decorators = undefined;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
node.asteriskToken = asteriskToken;
|
||||
node.name = typeof name === "string" ? createIdentifier(name) : name;
|
||||
node.typeParameters = undefined;
|
||||
@@ -578,7 +537,7 @@ namespace ts {
|
||||
export function createClassDeclaration(modifiers: Modifier[], name: Identifier, heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange) {
|
||||
const node = <ClassDeclaration>createNode(SyntaxKind.ClassDeclaration, location);
|
||||
node.decorators = undefined;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
node.name = name;
|
||||
node.typeParameters = undefined;
|
||||
node.heritageClauses = createNodeArray(heritageClauses);
|
||||
|
||||
+50
-68
@@ -997,18 +997,6 @@ namespace ts {
|
||||
}
|
||||
array.pos = pos;
|
||||
array.end = pos;
|
||||
array.arrayKind = ArrayKind.NodeArray;
|
||||
return array;
|
||||
}
|
||||
|
||||
function createModifiersArray(elements?: Modifier[], pos?: number): ModifiersArray {
|
||||
const array = <ModifiersArray>(elements || []);
|
||||
if (!(pos >= 0)) {
|
||||
pos = getNodePos();
|
||||
}
|
||||
array.pos = pos;
|
||||
array.end = pos;
|
||||
array.arrayKind = ArrayKind.ModifiersArray;
|
||||
return array;
|
||||
}
|
||||
|
||||
@@ -2018,16 +2006,10 @@ namespace ts {
|
||||
return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifierKind(token) || token === SyntaxKind.AtToken;
|
||||
}
|
||||
|
||||
function setModifiers(node: Node, modifiers: ModifiersArray) {
|
||||
if (modifiers) {
|
||||
node.modifiers = modifiers;
|
||||
}
|
||||
}
|
||||
|
||||
function parseParameter(): ParameterDeclaration {
|
||||
const node = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
|
||||
node.decorators = parseDecorators();
|
||||
setModifiers(node, parseModifiers());
|
||||
node.modifiers = parseModifiers();
|
||||
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
|
||||
|
||||
// FormalParameter [Yield,Await]:
|
||||
@@ -2216,23 +2198,23 @@ namespace ts {
|
||||
return token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken || token === SyntaxKind.CloseBracketToken;
|
||||
}
|
||||
|
||||
function parseIndexSignatureDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): IndexSignatureDeclaration {
|
||||
function parseIndexSignatureDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): IndexSignatureDeclaration {
|
||||
const node = <IndexSignatureDeclaration>createNode(SyntaxKind.IndexSignature, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
|
||||
node.type = parseTypeAnnotation();
|
||||
parseTypeMemberSemicolon();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parsePropertyOrMethodSignature(fullStart: number, modifiers: ModifiersArray): PropertySignature | MethodSignature {
|
||||
function parsePropertyOrMethodSignature(fullStart: number, modifiers: NodeArray<Modifier>): PropertySignature | MethodSignature {
|
||||
const name = parsePropertyName();
|
||||
const questionToken = parseOptionalToken(SyntaxKind.QuestionToken);
|
||||
|
||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||
const method = <MethodSignature>createNode(SyntaxKind.MethodSignature, fullStart);
|
||||
setModifiers(method, modifiers);
|
||||
method.modifiers = modifiers;
|
||||
method.name = name;
|
||||
method.questionToken = questionToken;
|
||||
|
||||
@@ -2244,7 +2226,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
const property = <PropertySignature>createNode(SyntaxKind.PropertySignature, fullStart);
|
||||
setModifiers(property, modifiers);
|
||||
property.modifiers = modifiers;
|
||||
property.name = name;
|
||||
property.questionToken = questionToken;
|
||||
property.type = parseTypeAnnotation();
|
||||
@@ -2969,7 +2951,7 @@ namespace ts {
|
||||
|
||||
function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction {
|
||||
const node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction);
|
||||
setModifiers(node, parseModifiersForArrowFunction());
|
||||
node.modifiers = parseModifiersForArrowFunction();
|
||||
const isAsync = !!(getModifierFlags(node) & ModifierFlags.Async);
|
||||
|
||||
// Arrow functions are never generators.
|
||||
@@ -3940,7 +3922,7 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): AccessorDeclaration {
|
||||
function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): AccessorDeclaration {
|
||||
if (parseContextualModifier(SyntaxKind.GetKeyword)) {
|
||||
return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers);
|
||||
}
|
||||
@@ -4025,7 +4007,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const node = <FunctionExpression>createNode(SyntaxKind.FunctionExpression);
|
||||
setModifiers(node, parseModifiers());
|
||||
node.modifiers = parseModifiers();
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
|
||||
@@ -4613,7 +4595,7 @@ namespace ts {
|
||||
const node = <Statement>createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
|
||||
node.pos = fullStart;
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
return finishNode(node);
|
||||
}
|
||||
}
|
||||
@@ -4748,19 +4730,19 @@ namespace ts {
|
||||
return nextTokenIsIdentifier() && nextToken() === SyntaxKind.CloseParenToken;
|
||||
}
|
||||
|
||||
function parseVariableStatement(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): VariableStatement {
|
||||
function parseVariableStatement(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): VariableStatement {
|
||||
const node = <VariableStatement>createNode(SyntaxKind.VariableStatement, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false);
|
||||
parseSemicolon();
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
|
||||
function parseFunctionDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): FunctionDeclaration {
|
||||
function parseFunctionDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): FunctionDeclaration {
|
||||
const node = <FunctionDeclaration>createNode(SyntaxKind.FunctionDeclaration, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
node.name = hasModifier(node, ModifierFlags.Default) ? parseOptionalIdentifier() : parseIdentifier();
|
||||
@@ -4771,20 +4753,20 @@ namespace ts {
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
|
||||
function parseConstructorDeclaration(pos: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ConstructorDeclaration {
|
||||
function parseConstructorDeclaration(pos: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): ConstructorDeclaration {
|
||||
const node = <ConstructorDeclaration>createNode(SyntaxKind.Constructor, pos);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
parseExpected(SyntaxKind.ConstructorKeyword);
|
||||
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node);
|
||||
node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, Diagnostics.or_expected);
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
|
||||
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, asteriskToken: Node, name: PropertyName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
|
||||
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, asteriskToken: Node, name: PropertyName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
|
||||
const method = <MethodDeclaration>createNode(SyntaxKind.MethodDeclaration, fullStart);
|
||||
method.decorators = decorators;
|
||||
setModifiers(method, modifiers);
|
||||
method.modifiers = modifiers;
|
||||
method.asteriskToken = asteriskToken;
|
||||
method.name = name;
|
||||
method.questionToken = questionToken;
|
||||
@@ -4795,10 +4777,10 @@ namespace ts {
|
||||
return addJSDocComment(finishNode(method));
|
||||
}
|
||||
|
||||
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, name: PropertyName, questionToken: Node): ClassElement {
|
||||
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, name: PropertyName, questionToken: Node): ClassElement {
|
||||
const property = <PropertyDeclaration>createNode(SyntaxKind.PropertyDeclaration, fullStart);
|
||||
property.decorators = decorators;
|
||||
setModifiers(property, modifiers);
|
||||
property.modifiers = modifiers;
|
||||
property.name = name;
|
||||
property.questionToken = questionToken;
|
||||
property.type = parseTypeAnnotation();
|
||||
@@ -4820,7 +4802,7 @@ namespace ts {
|
||||
return finishNode(property);
|
||||
}
|
||||
|
||||
function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ClassElement {
|
||||
function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): ClassElement {
|
||||
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
const name = parsePropertyName();
|
||||
|
||||
@@ -4839,10 +4821,10 @@ namespace ts {
|
||||
return parseInitializer(/*inParameter*/ false);
|
||||
}
|
||||
|
||||
function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): AccessorDeclaration {
|
||||
function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): AccessorDeclaration {
|
||||
const node = <AccessorDeclaration>createNode(kind, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
node.name = parsePropertyName();
|
||||
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node);
|
||||
node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false);
|
||||
@@ -4961,8 +4943,8 @@ namespace ts {
|
||||
*
|
||||
* In such situations, 'permitInvalidConstAsModifier' should be set to true.
|
||||
*/
|
||||
function parseModifiers(permitInvalidConstAsModifier?: boolean): ModifiersArray {
|
||||
let modifiers: ModifiersArray;
|
||||
function parseModifiers(permitInvalidConstAsModifier?: boolean): NodeArray<Modifier> {
|
||||
let modifiers: NodeArray<Modifier>;
|
||||
while (true) {
|
||||
const modifierStart = scanner.getStartPos();
|
||||
const modifierKind = token;
|
||||
@@ -4982,7 +4964,7 @@ namespace ts {
|
||||
|
||||
const modifier = finishNode(createNode(modifierKind, modifierStart));
|
||||
if (!modifiers) {
|
||||
modifiers = createModifiersArray([modifier], modifierStart);
|
||||
modifiers = createNodeArray<Modifier>([modifier], modifierStart);
|
||||
}
|
||||
else {
|
||||
modifiers.push(modifier);
|
||||
@@ -4994,14 +4976,14 @@ namespace ts {
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
function parseModifiersForArrowFunction(): ModifiersArray {
|
||||
let modifiers: ModifiersArray;
|
||||
function parseModifiersForArrowFunction(): NodeArray<Modifier> {
|
||||
let modifiers: NodeArray<Modifier>;
|
||||
if (token === SyntaxKind.AsyncKeyword) {
|
||||
const modifierStart = scanner.getStartPos();
|
||||
const modifierKind = token;
|
||||
nextToken();
|
||||
const modifier = finishNode(createNode(modifierKind, modifierStart));
|
||||
modifiers = createModifiersArray([modifier], modifierStart);
|
||||
modifiers = createNodeArray<Modifier>([modifier], modifierStart);
|
||||
modifiers.end = scanner.getStartPos();
|
||||
}
|
||||
|
||||
@@ -5061,14 +5043,14 @@ namespace ts {
|
||||
SyntaxKind.ClassExpression);
|
||||
}
|
||||
|
||||
function parseClassDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ClassDeclaration {
|
||||
function parseClassDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): ClassDeclaration {
|
||||
return <ClassDeclaration>parseClassDeclarationOrExpression(fullStart, decorators, modifiers, SyntaxKind.ClassDeclaration);
|
||||
}
|
||||
|
||||
function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration {
|
||||
function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, kind: SyntaxKind): ClassLikeDeclaration {
|
||||
const node = <ClassLikeDeclaration>createNode(kind, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
parseExpected(SyntaxKind.ClassKeyword);
|
||||
node.name = parseNameOfClassDeclarationOrExpression();
|
||||
node.typeParameters = parseTypeParameters();
|
||||
@@ -5143,10 +5125,10 @@ namespace ts {
|
||||
return parseList(ParsingContext.ClassMembers, parseClassElement);
|
||||
}
|
||||
|
||||
function parseInterfaceDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): InterfaceDeclaration {
|
||||
function parseInterfaceDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): InterfaceDeclaration {
|
||||
const node = <InterfaceDeclaration>createNode(SyntaxKind.InterfaceDeclaration, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
parseExpected(SyntaxKind.InterfaceKeyword);
|
||||
node.name = parseIdentifier();
|
||||
node.typeParameters = parseTypeParameters();
|
||||
@@ -5155,10 +5137,10 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseTypeAliasDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): TypeAliasDeclaration {
|
||||
function parseTypeAliasDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): TypeAliasDeclaration {
|
||||
const node = <TypeAliasDeclaration>createNode(SyntaxKind.TypeAliasDeclaration, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
parseExpected(SyntaxKind.TypeKeyword);
|
||||
node.name = parseIdentifier();
|
||||
node.typeParameters = parseTypeParameters();
|
||||
@@ -5179,10 +5161,10 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseEnumDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): EnumDeclaration {
|
||||
function parseEnumDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): EnumDeclaration {
|
||||
const node = <EnumDeclaration>createNode(SyntaxKind.EnumDeclaration, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
parseExpected(SyntaxKind.EnumKeyword);
|
||||
node.name = parseIdentifier();
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
@@ -5207,13 +5189,13 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseModuleOrNamespaceDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration {
|
||||
function parseModuleOrNamespaceDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>, flags: NodeFlags): ModuleDeclaration {
|
||||
const node = <ModuleDeclaration>createNode(SyntaxKind.ModuleDeclaration, fullStart);
|
||||
// If we are parsing a dotted namespace name, we want to
|
||||
// propagate the 'Namespace' flag across the names if set.
|
||||
const namespaceFlag = flags & NodeFlags.Namespace;
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
node.flags |= flags;
|
||||
node.name = parseIdentifier();
|
||||
node.body = parseOptional(SyntaxKind.DotToken)
|
||||
@@ -5222,10 +5204,10 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseAmbientExternalModuleDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ModuleDeclaration {
|
||||
function parseAmbientExternalModuleDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): ModuleDeclaration {
|
||||
const node = <ModuleDeclaration>createNode(SyntaxKind.ModuleDeclaration, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
if (token === SyntaxKind.GlobalKeyword) {
|
||||
// parse 'global' as name of global scope augmentation
|
||||
node.name = parseIdentifier();
|
||||
@@ -5238,7 +5220,7 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseModuleDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ModuleDeclaration {
|
||||
function parseModuleDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): ModuleDeclaration {
|
||||
let flags: NodeFlags = 0;
|
||||
if (token === SyntaxKind.GlobalKeyword) {
|
||||
// global augmentation
|
||||
@@ -5269,7 +5251,7 @@ namespace ts {
|
||||
return nextToken() === SyntaxKind.SlashToken;
|
||||
}
|
||||
|
||||
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
|
||||
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): ImportEqualsDeclaration | ImportDeclaration {
|
||||
parseExpected(SyntaxKind.ImportKeyword);
|
||||
const afterImportPos = scanner.getStartPos();
|
||||
|
||||
@@ -5282,7 +5264,7 @@ namespace ts {
|
||||
// import x = M.x;
|
||||
const importEqualsDeclaration = <ImportEqualsDeclaration>createNode(SyntaxKind.ImportEqualsDeclaration, fullStart);
|
||||
importEqualsDeclaration.decorators = decorators;
|
||||
setModifiers(importEqualsDeclaration, modifiers);
|
||||
importEqualsDeclaration.modifiers = modifiers;
|
||||
importEqualsDeclaration.name = identifier;
|
||||
parseExpected(SyntaxKind.EqualsToken);
|
||||
importEqualsDeclaration.moduleReference = parseModuleReference();
|
||||
@@ -5294,7 +5276,7 @@ namespace ts {
|
||||
// Import statement
|
||||
const importDeclaration = <ImportDeclaration>createNode(SyntaxKind.ImportDeclaration, fullStart);
|
||||
importDeclaration.decorators = decorators;
|
||||
setModifiers(importDeclaration, modifiers);
|
||||
importDeclaration.modifiers = modifiers;
|
||||
|
||||
// ImportDeclaration:
|
||||
// import ImportClause from ModuleSpecifier ;
|
||||
@@ -5430,10 +5412,10 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseExportDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ExportDeclaration {
|
||||
function parseExportDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): ExportDeclaration {
|
||||
const node = <ExportDeclaration>createNode(SyntaxKind.ExportDeclaration, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
if (parseOptional(SyntaxKind.AsteriskToken)) {
|
||||
parseExpected(SyntaxKind.FromKeyword);
|
||||
node.moduleSpecifier = parseModuleSpecifier();
|
||||
@@ -5453,10 +5435,10 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseExportAssignment(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ExportAssignment {
|
||||
function parseExportAssignment(fullStart: number, decorators: NodeArray<Decorator>, modifiers: NodeArray<Modifier>): ExportAssignment {
|
||||
const node = <ExportAssignment>createNode(SyntaxKind.ExportAssignment, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
node.modifiers = modifiers;
|
||||
if (parseOptional(SyntaxKind.EqualsToken)) {
|
||||
node.isExportEquals = true;
|
||||
}
|
||||
|
||||
@@ -1958,7 +1958,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
}
|
||||
|
||||
function emitModifiers(node: Node, modifiers: ModifiersArray) {
|
||||
function emitModifiers(node: Node, modifiers: NodeArray<Modifier>) {
|
||||
if (modifiers && modifiers.length) {
|
||||
emitList(node, modifiers, ListFormat.SingleLine);
|
||||
write(" ");
|
||||
|
||||
@@ -1196,7 +1196,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkModifiers(modifiers: ModifiersArray): boolean {
|
||||
function checkModifiers(modifiers: NodeArray<Modifier>): boolean {
|
||||
if (modifiers) {
|
||||
for (const modifier of modifiers) {
|
||||
switch (modifier.kind) {
|
||||
|
||||
+1
-11
@@ -453,7 +453,7 @@ namespace ts {
|
||||
/* @internal */ transformFlags?: TransformFlags;
|
||||
/* @internal */ excludeTransformFlags?: TransformFlags;
|
||||
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
|
||||
modifiers?: ModifiersArray; // Array of modifiers
|
||||
modifiers?: NodeArray<Modifier>; // Array of modifiers
|
||||
/* @internal */ id?: number; // Unique id (used to look up NodeLinks)
|
||||
parent?: Node; // Parent node (initialized by binding)
|
||||
/* @internal */ original?: Node; // The original node if this is an updated node.
|
||||
@@ -465,13 +465,7 @@ namespace ts {
|
||||
/* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
|
||||
}
|
||||
|
||||
export const enum ArrayKind {
|
||||
NodeArray = 1,
|
||||
ModifiersArray = 2,
|
||||
}
|
||||
|
||||
export interface NodeArray<T extends Node> extends Array<T>, TextRange {
|
||||
arrayKind: ArrayKind;
|
||||
hasTrailingComma?: boolean;
|
||||
}
|
||||
|
||||
@@ -488,10 +482,6 @@ namespace ts {
|
||||
nodes: NodeArray<T>;
|
||||
}
|
||||
|
||||
export interface ModifiersArray extends NodeArray<Modifier> {
|
||||
// flags: number;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.AbstractKeyword)
|
||||
// @kind(SyntaxKind.AsyncKeyword)
|
||||
// @kind(SyntaxKind.ConstKeyword)
|
||||
|
||||
@@ -2987,11 +2987,8 @@ namespace ts {
|
||||
// Node Arrays
|
||||
|
||||
export function isNodeArray<T extends Node>(array: T[]): array is NodeArray<T> {
|
||||
return (<NodeArray<T>>array).arrayKind === ArrayKind.NodeArray;
|
||||
}
|
||||
|
||||
export function isModifiersArray(array: Modifier[]): array is ModifiersArray {
|
||||
return (<ModifiersArray>array).arrayKind === ArrayKind.ModifiersArray;
|
||||
return array.hasOwnProperty("pos")
|
||||
&& array.hasOwnProperty("end");
|
||||
}
|
||||
|
||||
// Literals
|
||||
|
||||
@@ -580,9 +580,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (updated !== undefined) {
|
||||
return isModifiersArray(nodes)
|
||||
? createModifiersArray(updated, nodes)
|
||||
: createNodeArray(updated, nodes, nodes.hasTrailingComma);
|
||||
return createNodeArray(updated, nodes, nodes.hasTrailingComma);
|
||||
}
|
||||
|
||||
return nodes;
|
||||
|
||||
Reference in New Issue
Block a user