mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
@@ -12,7 +12,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const enum Reachability {
|
||||
Unintialized = 1 << 0,
|
||||
Uninitialized = 1 << 0,
|
||||
Reachable = 1 << 1,
|
||||
Unreachable = 1 << 2,
|
||||
ReportedUnreachable = 1 << 3
|
||||
@@ -393,7 +393,7 @@ namespace ts {
|
||||
// the getLocalNameOfContainer function in the type checker to validate that the local name
|
||||
// used for a container is unique.
|
||||
function bindChildren(node: Node) {
|
||||
// Before we recurse into a node's chilren, we first save the existing parent, container
|
||||
// Before we recurse into a node's children, we first save the existing parent, container
|
||||
// and block-container. Then after we pop out of processing the children, we restore
|
||||
// these saved values.
|
||||
const saveParent = parent;
|
||||
@@ -418,7 +418,7 @@ namespace ts {
|
||||
// Finally, if this is a block-container, then we clear out any existing .locals object
|
||||
// it may contain within it. This happens in incremental scenarios. Because we can be
|
||||
// reusing a node from a previous compilation, that node may have had 'locals' created
|
||||
// for it. We must clear this so we don't accidently move any stale data forward from
|
||||
// for it. We must clear this so we don't accidentally move any stale data forward from
|
||||
// a previous compilation.
|
||||
const containerFlags = getContainerFlags(node);
|
||||
if (containerFlags & ContainerFlags.IsContainer) {
|
||||
@@ -699,7 +699,7 @@ namespace ts {
|
||||
|
||||
const hasDefault = forEach(n.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause);
|
||||
|
||||
// post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case
|
||||
// post switch state is unreachable if switch is exhaustive (has a default case ) and does not have fallthrough from the last case
|
||||
const postSwitchState = hasDefault && currentReachabilityState !== Reachability.Reachable ? Reachability.Unreachable : preSwitchState;
|
||||
|
||||
popImplicitLabel(postSwitchLabel, postSwitchState);
|
||||
@@ -766,7 +766,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.Block:
|
||||
// do not treat blocks directly inside a function as a block-scoped-container.
|
||||
// Locals that reside in this block should go to the function locals. Othewise 'x'
|
||||
// Locals that reside in this block should go to the function locals. Otherwise 'x'
|
||||
// would not appear to be a redeclaration of a block scoped local in the following
|
||||
// example:
|
||||
//
|
||||
@@ -956,7 +956,7 @@ namespace ts {
|
||||
|
||||
const identifier = <Identifier>prop.name;
|
||||
|
||||
// ECMA-262 11.1.5 Object Initialiser
|
||||
// ECMA-262 11.1.5 Object Initializer
|
||||
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
|
||||
// IsDataDescriptor(propId.descriptor) is true.
|
||||
@@ -1629,14 +1629,14 @@ namespace ts {
|
||||
if (hasProperty(labelIndexMap, name.text)) {
|
||||
return false;
|
||||
}
|
||||
labelIndexMap[name.text] = labelStack.push(Reachability.Unintialized) - 1;
|
||||
labelIndexMap[name.text] = labelStack.push(Reachability.Uninitialized) - 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
function pushImplicitLabel(): number {
|
||||
initializeReachabilityStateIfNecessary();
|
||||
|
||||
const index = labelStack.push(Reachability.Unintialized) - 1;
|
||||
const index = labelStack.push(Reachability.Uninitialized) - 1;
|
||||
implicitLabels.push(index);
|
||||
return index;
|
||||
}
|
||||
@@ -1666,7 +1666,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function setCurrentStateAtLabel(innerMergedState: Reachability, outerState: Reachability, label: Identifier): void {
|
||||
if (innerMergedState === Reachability.Unintialized) {
|
||||
if (innerMergedState === Reachability.Uninitialized) {
|
||||
if (label && !options.allowUnusedLabels) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label));
|
||||
}
|
||||
@@ -1687,7 +1687,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
const stateAtLabel = labelStack[index];
|
||||
labelStack[index] = stateAtLabel === Reachability.Unintialized ? outerState : or(stateAtLabel, outerState);
|
||||
labelStack[index] = stateAtLabel === Reachability.Uninitialized ? outerState : or(stateAtLabel, outerState);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -577,7 +577,7 @@ namespace ts {
|
||||
scanner.setText("");
|
||||
scanner.setOnError(undefined);
|
||||
|
||||
// Clear any data. We don't want to accidently hold onto it for too long.
|
||||
// Clear any data. We don't want to accidentally hold onto it for too long.
|
||||
parseDiagnostics = undefined;
|
||||
sourceFile = undefined;
|
||||
identifiers = undefined;
|
||||
@@ -1442,8 +1442,8 @@ namespace ts {
|
||||
// We can only reuse a node if it was parsed under the same strict mode that we're
|
||||
// currently in. i.e. if we originally parsed a node in non-strict mode, but then
|
||||
// the user added 'using strict' at the top of the file, then we can't use that node
|
||||
// again as the presense of strict mode may cause us to parse the tokens in the file
|
||||
// differetly.
|
||||
// again as the presence of strict mode may cause us to parse the tokens in the file
|
||||
// differently.
|
||||
//
|
||||
// Note: we *can* reuse tokens when the strict mode changes. That's because tokens
|
||||
// are unaffected by strict mode. It's just the parser will decide what to do with it
|
||||
@@ -1456,7 +1456,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Ok, we have a node that looks like it could be reused. Now verify that it is valid
|
||||
// in the currest list parsing context that we're currently at.
|
||||
// in the current list parsing context that we're currently at.
|
||||
if (!canReuseNode(node, parsingContext)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1719,7 +1719,7 @@ namespace ts {
|
||||
};
|
||||
|
||||
// Parses a comma-delimited list of elements
|
||||
function parseDelimitedList<T extends Node>(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimeter?: boolean): NodeArray<T> {
|
||||
function parseDelimitedList<T extends Node>(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray<T> {
|
||||
const saveParsingContext = parsingContext;
|
||||
parsingContext |= 1 << kind;
|
||||
const result = <NodeArray<T>>[];
|
||||
@@ -1748,7 +1748,7 @@ namespace ts {
|
||||
// parse errors. For example, this can happen when people do things like use
|
||||
// a semicolon to delimit object literal members. Note: we'll have already
|
||||
// reported an error when we called parseExpected above.
|
||||
if (considerSemicolonAsDelimeter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) {
|
||||
if (considerSemicolonAsDelimiter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) {
|
||||
nextToken();
|
||||
}
|
||||
continue;
|
||||
@@ -2221,7 +2221,7 @@ namespace ts {
|
||||
method.name = name;
|
||||
method.questionToken = questionToken;
|
||||
|
||||
// Method signatues don't exist in expression contexts. So they have neither
|
||||
// Method signatures don't exist in expression contexts. So they have neither
|
||||
// [Yield] nor [Await]
|
||||
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method);
|
||||
parseTypeMemberSemicolon();
|
||||
@@ -2719,7 +2719,7 @@ namespace ts {
|
||||
|
||||
function isYieldExpression(): boolean {
|
||||
if (token === SyntaxKind.YieldKeyword) {
|
||||
// If we have a 'yield' keyword, and htis is a context where yield expressions are
|
||||
// If we have a 'yield' keyword, and this is a context where yield expressions are
|
||||
// allowed, then definitely parse out a yield expression.
|
||||
if (inYieldContext()) {
|
||||
return true;
|
||||
@@ -2738,7 +2738,7 @@ namespace ts {
|
||||
//
|
||||
// for now we just check if the next token is an identifier. More heuristics
|
||||
// can be added here later as necessary. We just need to make sure that we
|
||||
// don't accidently consume something legal.
|
||||
// don't accidentally consume something legal.
|
||||
return lookAhead(nextTokenIsIdentifierOrKeywordOrNumberOnSameLine);
|
||||
}
|
||||
|
||||
@@ -2767,7 +2767,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// if the next token is not on the same line as yield. or we don't have an '*' or
|
||||
// the start of an expressin, then this is just a simple "yield" expression.
|
||||
// the start of an expression, then this is just a simple "yield" expression.
|
||||
return finishNode(node);
|
||||
}
|
||||
}
|
||||
@@ -3060,7 +3060,7 @@ namespace ts {
|
||||
// Check the precedence to see if we should "take" this operator
|
||||
// - For left associative operator (all operator but **), consume the operator,
|
||||
// recursively call the function below, and parse binaryExpression as a rightOperand
|
||||
// of the caller if the new precendence of the operator is greater then or equal to the current precendence.
|
||||
// of the caller if the new precedence of the operator is greater then or equal to the current precedence.
|
||||
// For example:
|
||||
// a - b - c;
|
||||
// ^token; leftOperand = b. Return b to the caller as a rightOperand
|
||||
@@ -3069,8 +3069,8 @@ namespace ts {
|
||||
// a - b * c;
|
||||
// ^token; leftOperand = b. Return b * c to the caller as a rightOperand
|
||||
// - For right associative operator (**), consume the operator, recursively call the function
|
||||
// and parse binaryExpression as a rightOperand of the caller if the new precendence of
|
||||
// the operator is strictly grater than the current precendence
|
||||
// and parse binaryExpression as a rightOperand of the caller if the new precedence of
|
||||
// the operator is strictly grater than the current precedence
|
||||
// For example:
|
||||
// a ** b ** c;
|
||||
// ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand
|
||||
@@ -3311,7 +3311,7 @@ namespace ts {
|
||||
*/
|
||||
function isIncrementExpression(): boolean {
|
||||
// This function is called inside parseUnaryExpression to decide
|
||||
// whether to call parseSimpleUnaryExpression or call parseIncrmentExpression directly
|
||||
// whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly
|
||||
switch (token) {
|
||||
case SyntaxKind.PlusToken:
|
||||
case SyntaxKind.MinusToken:
|
||||
@@ -3799,7 +3799,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// If we have a '<', then only parse this as a arugment list if the type arguments
|
||||
// If we have a '<', then only parse this as a argument list if the type arguments
|
||||
// are complete and we have an open paren. if we don't, rewind and return nothing.
|
||||
return typeArguments && canFollowTypeArgumentsInExpression()
|
||||
? typeArguments
|
||||
@@ -3996,7 +3996,7 @@ namespace ts {
|
||||
node.multiLine = true;
|
||||
}
|
||||
|
||||
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true);
|
||||
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
return finishNode(node);
|
||||
}
|
||||
@@ -4792,8 +4792,8 @@ namespace ts {
|
||||
// off. The grammar would look something like this:
|
||||
//
|
||||
// MemberVariableDeclaration[Yield]:
|
||||
// AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initialiser_opt[In];
|
||||
// AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield];
|
||||
// AccessibilityModifier_opt PropertyName TypeAnnotation_opt Initializer_opt[In];
|
||||
// AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initializer_opt[In, ?Yield];
|
||||
//
|
||||
// The checker may still error in the static case to explicitly disallow the yield expression.
|
||||
property.initializer = modifiers && modifiers.flags & NodeFlags.Static
|
||||
@@ -5394,7 +5394,7 @@ namespace ts {
|
||||
// ImportSpecifier:
|
||||
// BindingIdentifier
|
||||
// IdentifierName as BindingIdentifier
|
||||
// ExportSpecififer:
|
||||
// ExportSpecifier:
|
||||
// IdentifierName
|
||||
// IdentifierName as IdentifierName
|
||||
let checkIdentifierIsKeyword = isKeyword(token) && !isIdentifier();
|
||||
@@ -6238,7 +6238,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Make sure we're not trying to incrementally update a source file more than once. Once
|
||||
// we do an update the original source file is considered unusbale from that point onwards.
|
||||
// we do an update the original source file is considered unusable from that point onwards.
|
||||
//
|
||||
// This is because we do incremental parsing in-place. i.e. we take nodes from the old
|
||||
// tree and give them new positions and parents. From that point on, trusting the old
|
||||
@@ -6369,7 +6369,7 @@ namespace ts {
|
||||
// We have an element that intersects the change range in some way. It may have its
|
||||
// start, or its end (or both) in the changed range. We want to adjust any part
|
||||
// that intersects such that the final tree is in a consistent state. i.e. all
|
||||
// chlidren have spans within the span of their parent, and all siblings are ordered
|
||||
// children have spans within the span of their parent, and all siblings are ordered
|
||||
// properly.
|
||||
|
||||
// We may need to update both the 'pos' and the 'end' of the element.
|
||||
@@ -6391,7 +6391,7 @@ namespace ts {
|
||||
// -------------------ZZZ-----------------
|
||||
//
|
||||
// In this case, any element that started in the 'X' range will keep its position.
|
||||
// However any element htat started after that will have their pos adjusted to be
|
||||
// However any element that started after that will have their pos adjusted to be
|
||||
// at the end of the new range. i.e. any node that started in the 'Y' range will
|
||||
// be adjusted to have their start at the end of the 'Z' range.
|
||||
//
|
||||
@@ -6416,7 +6416,7 @@ namespace ts {
|
||||
// -------------------ZZZ-----------------
|
||||
//
|
||||
// In this case, any element that ended in the 'X' range will keep its position.
|
||||
// However any element htat ended after that will have their pos adjusted to be
|
||||
// However any element that ended after that will have their pos adjusted to be
|
||||
// at the end of the new range. i.e. any node that ended in the 'Y' range will
|
||||
// be adjusted to have their end at the end of the 'Z' range.
|
||||
if (element.end >= changeRangeOldEnd) {
|
||||
@@ -6746,7 +6746,7 @@ namespace ts {
|
||||
// Position was within this node. Keep searching deeper to find the node.
|
||||
forEachChild(node, visitNode, visitArray);
|
||||
|
||||
// don't procede any futher in the search.
|
||||
// don't proceed any further in the search.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user