mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-27 22:39:59 -05:00
Remove 'missing' syntax kind.
This commit is contained in:
@@ -483,8 +483,8 @@ module ts.formatting {
|
||||
if (!rangeOverlapsWithStartEnd(originalRange, child.pos, child.end)) {
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
if (child.kind === SyntaxKind.Missing) {
|
||||
|
||||
if (child.getFullWidth() === 0) {
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ module ts {
|
||||
}
|
||||
|
||||
private createChildren(sourceFile?: SourceFile) {
|
||||
if (this.kind > SyntaxKind.Missing) {
|
||||
if (this.kind >= SyntaxKind.FirstNode) {
|
||||
scanner.setText((sourceFile || this.getSourceFile()).text);
|
||||
var children: Node[] = [];
|
||||
var pos = this.pos;
|
||||
@@ -264,8 +264,11 @@ module ts {
|
||||
var children = this.getChildren();
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
if (child.kind < SyntaxKind.Missing) return child;
|
||||
if (child.kind > SyntaxKind.Missing) return child.getFirstToken(sourceFile);
|
||||
if (child.kind < SyntaxKind.FirstNode) {
|
||||
return child;
|
||||
}
|
||||
|
||||
return child.getFirstToken(sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,8 +276,11 @@ module ts {
|
||||
var children = this.getChildren(sourceFile);
|
||||
for (var i = children.length - 1; i >= 0; i--) {
|
||||
var child = children[i];
|
||||
if (child.kind < SyntaxKind.Missing) return child;
|
||||
if (child.kind > SyntaxKind.Missing) return child.getLastToken(sourceFile);
|
||||
if (child.kind < SyntaxKind.FirstNode) {
|
||||
return child;
|
||||
}
|
||||
|
||||
return child.getLastToken(sourceFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -758,7 +764,7 @@ module ts {
|
||||
case SyntaxKind.Method:
|
||||
var functionDeclaration = <FunctionLikeDeclaration>node;
|
||||
|
||||
if (functionDeclaration.name && functionDeclaration.name.kind !== SyntaxKind.Missing) {
|
||||
if (functionDeclaration.name && functionDeclaration.name.getFullWidth() > 0) {
|
||||
var lastDeclaration = namedDeclarations.length > 0 ?
|
||||
namedDeclarations[namedDeclarations.length - 1] :
|
||||
undefined;
|
||||
@@ -2888,7 +2894,7 @@ module ts {
|
||||
if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
var right = (<PropertyAccessExpression>location.parent).name;
|
||||
// Either the location is on the right of a property access, or on the left and the right is missing
|
||||
if (right === location || (right && right.kind === SyntaxKind.Missing)){
|
||||
if (right === location || (right && right.getFullWidth() === 0)){
|
||||
location = location.parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ module ts.SignatureHelp {
|
||||
// leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail.
|
||||
if (template.kind === SyntaxKind.TemplateExpression) {
|
||||
var lastSpan = lastOrUndefined((<TemplateExpression>template).templateSpans);
|
||||
if (lastSpan.literal.kind === SyntaxKind.Missing) {
|
||||
if (lastSpan.literal.getFullWidth() === 0) {
|
||||
applicableSpanEnd = skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,6 +393,10 @@ module ts.formatting {
|
||||
* This function is always called when position of the cursor is located after the node
|
||||
*/
|
||||
function isCompletedNode(n: Node, sourceFile: SourceFile): boolean {
|
||||
if (n.getFullWidth() === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (n.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
@@ -426,8 +430,6 @@ module ts.formatting {
|
||||
return isCompletedNode((<ExpressionStatement>n).expression, sourceFile);
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return nodeEndsWith(n, SyntaxKind.CloseBracketToken, sourceFile);
|
||||
case SyntaxKind.Missing:
|
||||
return false;
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.DefaultClause:
|
||||
// there is no such thing as terminator token for CaseClause\DefaultClause so for simplicitly always consider them non-completed
|
||||
|
||||
Reference in New Issue
Block a user