mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Breakpoints in enum declaration
This commit is contained in:
parent
d235caf990
commit
01d4ce25e2
@ -125,6 +125,12 @@ module ts.BreakpointResolver {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return spanInImportDeclaration(<ImportDeclaration>node);
|
||||
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return spanInEnumDeclaration(<EnumDeclaration>node);
|
||||
|
||||
case SyntaxKind.EnumMember:
|
||||
return spanInEnumMember(<EnumMember>node);
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.PostfixOperator:
|
||||
case SyntaxKind.PrefixOperator:
|
||||
@ -365,6 +371,19 @@ module ts.BreakpointResolver {
|
||||
return textSpan(importDeclaration, importDeclaration.entityName || importDeclaration.externalModuleName);
|
||||
}
|
||||
|
||||
function spanInEnumDeclaration(enumDeclaration: EnumDeclaration): TypeScript.TextSpan {
|
||||
if (enumDeclaration.members.length) {
|
||||
return spanInEnumMember(enumDeclaration.members[0]);
|
||||
}
|
||||
|
||||
// On close brace
|
||||
return spanInNode(enumDeclaration.getLastToken(sourceFile));
|
||||
}
|
||||
|
||||
function spanInEnumMember(enumMember: EnumMember) {
|
||||
return textSpan(enumMember);
|
||||
}
|
||||
|
||||
function spanInExpression(expression: Expression): TypeScript.TextSpan {
|
||||
//TODO (pick this up later) for now lets fix do-while baseline
if (node.parent.kind === SyntaxKind.DoStatement) {
|
||||
// Set span as if on while keyword
|
||||
@ -385,6 +404,7 @@ module ts.BreakpointResolver {
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.VariableStatement:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return spanInPreviousNode(node);
|
||||
|
||||
// Default to parent node
|
||||
@ -417,6 +437,7 @@ module ts.BreakpointResolver {
|
||||
function spanInCloseBraceToken(node: Node): TypeScript.TextSpan {
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.FunctionBlock:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
// Span on close brace token
|
||||
return textSpan(node);
|
||||
|
||||
|
||||
101
tests/baselines/reference/bpSpan_enums.baseline
Normal file
101
tests/baselines/reference/bpSpan_enums.baseline
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
1 >enum e {
|
||||
|
||||
~~~~~~~~~ => Pos: (0 to 8) SpanInfo: {"start":13,"length":1}
|
||||
>x
|
||||
>:=> (line 2, col 4) to (line 2, col 5)
|
||||
--------------------------------
|
||||
2 > x,
|
||||
|
||||
~~~~~~~ => Pos: (9 to 15) SpanInfo: {"start":13,"length":1}
|
||||
>x
|
||||
>:=> (line 2, col 4) to (line 2, col 5)
|
||||
--------------------------------
|
||||
3 > y,
|
||||
|
||||
~~~~~~~ => Pos: (16 to 22) SpanInfo: {"start":20,"length":1}
|
||||
>y
|
||||
>:=> (line 3, col 4) to (line 3, col 5)
|
||||
--------------------------------
|
||||
4 > x
|
||||
|
||||
~~~~~~ => Pos: (23 to 28) SpanInfo: {"start":27,"length":1}
|
||||
>x
|
||||
>:=> (line 4, col 4) to (line 4, col 5)
|
||||
--------------------------------
|
||||
5 >}
|
||||
|
||||
~~ => Pos: (29 to 30) SpanInfo: {"start":29,"length":1}
|
||||
>}
|
||||
>:=> (line 5, col 0) to (line 5, col 1)
|
||||
--------------------------------
|
||||
6 >enum e2 {
|
||||
|
||||
~~~~~~~~~~ => Pos: (31 to 40) SpanInfo: {"start":45,"length":6}
|
||||
>x = 10
|
||||
>:=> (line 7, col 4) to (line 7, col 10)
|
||||
--------------------------------
|
||||
7 > x = 10,
|
||||
|
||||
~~~~~~~~~~~~ => Pos: (41 to 52) SpanInfo: {"start":45,"length":6}
|
||||
>x = 10
|
||||
>:=> (line 7, col 4) to (line 7, col 10)
|
||||
--------------------------------
|
||||
8 > y = 10,
|
||||
|
||||
~~~~~~~~~~~~ => Pos: (53 to 64) SpanInfo: {"start":57,"length":6}
|
||||
>y = 10
|
||||
>:=> (line 8, col 4) to (line 8, col 10)
|
||||
--------------------------------
|
||||
9 > z,
|
||||
|
||||
~~~~~~~ => Pos: (65 to 71) SpanInfo: {"start":69,"length":1}
|
||||
>z
|
||||
>:=> (line 9, col 4) to (line 9, col 5)
|
||||
--------------------------------
|
||||
10 > x2
|
||||
|
||||
~~~~~~~ => Pos: (72 to 78) SpanInfo: {"start":76,"length":2}
|
||||
>x2
|
||||
>:=> (line 10, col 4) to (line 10, col 6)
|
||||
--------------------------------
|
||||
11 >}
|
||||
|
||||
~~ => Pos: (79 to 80) SpanInfo: {"start":79,"length":1}
|
||||
>}
|
||||
>:=> (line 11, col 0) to (line 11, col 1)
|
||||
--------------------------------
|
||||
12 >enum e3 {
|
||||
|
||||
~~~~~~~~~~ => Pos: (81 to 90) SpanInfo: {"start":91,"length":1}
|
||||
>}
|
||||
>:=> (line 13, col 0) to (line 13, col 1)
|
||||
--------------------------------
|
||||
13 >}
|
||||
|
||||
~~ => Pos: (91 to 92) SpanInfo: {"start":91,"length":1}
|
||||
>}
|
||||
>:=> (line 13, col 0) to (line 13, col 1)
|
||||
--------------------------------
|
||||
14 >declare enum e4 {
|
||||
|
||||
~~~~~~~~~~~~~~~~~~ => Pos: (93 to 110) SpanInfo: undefined
|
||||
--------------------------------
|
||||
15 > x,
|
||||
|
||||
~~~~~~~ => Pos: (111 to 117) SpanInfo: undefined
|
||||
--------------------------------
|
||||
16 > y,
|
||||
|
||||
~~~~~~~ => Pos: (118 to 124) SpanInfo: undefined
|
||||
--------------------------------
|
||||
17 > z,
|
||||
|
||||
~~~~~~~ => Pos: (125 to 131) SpanInfo: undefined
|
||||
--------------------------------
|
||||
18 > x2
|
||||
|
||||
~~~~~~~ => Pos: (132 to 138) SpanInfo: undefined
|
||||
--------------------------------
|
||||
19 >}
|
||||
~ => Pos: (139 to 139) SpanInfo: undefined
|
||||
@ -15,5 +15,11 @@
|
||||
////}
|
||||
////enum e3 {
|
||||
////}
|
||||
////declare enum e4 {
|
||||
//// x,
|
||||
//// y,
|
||||
//// z,
|
||||
//// x2
|
||||
////}
|
||||
|
||||
verify.baselineCurrentFileBreakpointLocations();
|
||||
Loading…
x
Reference in New Issue
Block a user