mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 20:25:23 -06:00
PR feedback, removed now-redundant getUniqueClone
This commit is contained in:
parent
4db144811d
commit
3bf4f2a6f5
@ -82,12 +82,9 @@ namespace ts {
|
||||
function getLeadingComments(range: TextRange): CommentRange[];
|
||||
function getLeadingComments(range: TextRange, contextNode: Node, ignoreNodeCallback: (contextNode: Node) => boolean, getTextRangeCallback: (contextNode: Node) => TextRange): CommentRange[];
|
||||
function getLeadingComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean, getTextRangeCallback?: (contextNode: Node) => TextRange) {
|
||||
let comments: CommentRange[] = [];
|
||||
let ignored = false;
|
||||
if (contextNode) {
|
||||
range = getTextRangeCallback(contextNode) || range;
|
||||
if (ignoreNodeCallback(contextNode)) {
|
||||
ignored = true;
|
||||
// If the node will not be emitted in JS, remove all the comments (normal,
|
||||
// pinned and `///`) associated with the node, unless it is a triple slash
|
||||
// comment at the top of the file.
|
||||
@ -101,16 +98,14 @@ namespace ts {
|
||||
// The first `///` will NOT be removed while the second one will be removed
|
||||
// even though both nodes will not be emitted.
|
||||
if (range.pos === 0) {
|
||||
comments = filter(getLeadingCommentsOfPosition(0), isTripleSlashComment);
|
||||
return filter(getLeadingCommentsOfPosition(0), isTripleSlashComment);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignored) {
|
||||
comments = getLeadingCommentsOfPosition(range.pos);
|
||||
}
|
||||
|
||||
return comments;
|
||||
return getLeadingCommentsOfPosition(range.pos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -91,16 +91,6 @@ namespace ts {
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a clone of a node with a unique node ID.
|
||||
*/
|
||||
export function getUniqueClone<T extends Node>(node: T): T {
|
||||
const clone = getMutableClone(node);
|
||||
clone.id = 0;
|
||||
getNodeId(clone);
|
||||
return clone;
|
||||
}
|
||||
|
||||
// Literals
|
||||
|
||||
export function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange): StringLiteral;
|
||||
@ -821,8 +811,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createReactNamespace(reactNamespace: string, parent: JsxOpeningLikeElement) {
|
||||
// Create an identifier and give it a parent. This allows us to resolve the react
|
||||
// namespace during emit.
|
||||
// To ensure the emit resolver can properly resolve the namespace, we need to
|
||||
// treat this identifier as if it were a source tree node by clearing the `Synthesized`
|
||||
// flag and setting a parent node.
|
||||
const react = createIdentifier(reactNamespace || "React");
|
||||
react.flags &= ~NodeFlags.Synthesized;
|
||||
react.parent = parent;
|
||||
|
||||
@ -1003,7 +1003,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// `declarationName` is the name of the local declaration for the parameter.
|
||||
const declarationName = getUniqueClone(<Identifier>parameter.name);
|
||||
const declarationName = getMutableClone(<Identifier>parameter.name);
|
||||
setNodeEmitFlags(declarationName, NodeEmitFlags.NoSourceMap);
|
||||
|
||||
// `expressionName` is the name of the parameter used in expressions.
|
||||
@ -2916,7 +2916,7 @@ namespace ts {
|
||||
*/
|
||||
function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: NodeEmitFlags) {
|
||||
if (node.name && !isGeneratedIdentifier(node.name)) {
|
||||
const name = getUniqueClone(node.name);
|
||||
const name = getMutableClone(node.name);
|
||||
emitFlags |= getNodeEmitFlags(node.name);
|
||||
if (!allowSourceMaps) {
|
||||
emitFlags |= NodeEmitFlags.NoSourceMap;
|
||||
|
||||
@ -928,10 +928,10 @@ namespace ts {
|
||||
function transformParameterWithPropertyAssignment(node: ParameterDeclaration) {
|
||||
Debug.assert(isIdentifier(node.name));
|
||||
const name = node.name as Identifier;
|
||||
const propertyName = getUniqueClone(name);
|
||||
const propertyName = getMutableClone(name);
|
||||
setNodeEmitFlags(propertyName, NodeEmitFlags.NoComments | NodeEmitFlags.NoSourceMap);
|
||||
|
||||
const localName = getUniqueClone(name);
|
||||
const localName = getMutableClone(name);
|
||||
setNodeEmitFlags(localName, NodeEmitFlags.NoComments);
|
||||
|
||||
return startOnNewLine(
|
||||
@ -2922,7 +2922,7 @@ namespace ts {
|
||||
*/
|
||||
function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: NodeEmitFlags) {
|
||||
if (node.name) {
|
||||
const name = getUniqueClone(node.name);
|
||||
const name = getMutableClone(node.name);
|
||||
emitFlags |= getNodeEmitFlags(node.name);
|
||||
if (!allowSourceMaps) {
|
||||
emitFlags |= NodeEmitFlags.NoSourceMap;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user