Merge pull request #293 from Microsoft/lastPropOfObjectLiteral

Handle when the last short hand property assignment of object literal ends with } on new line
This commit is contained in:
Sheetal Nandi 2016-10-10 13:45:18 -07:00 коммит произвёл GitHub
Родитель 6e4b81f40f 87f5a51a98
Коммит 3fa03f9e65
5 изменённых файлов: 155 добавлений и 3 удалений

Просмотреть файл

@ -1341,7 +1341,7 @@ repository:
patterns:
- include: '#expression'
- name: meta.object.member.ts
match: ([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\})
match: ([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)
captures:
'1': { name: variable.other.readwrite.ts }
- include: '#punctuation-comma'

Просмотреть файл

@ -3736,7 +3736,7 @@
<key>name</key>
<string>meta.object.member.ts</string>
<key>match</key>
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\})</string>
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)</string>
<key>captures</key>
<dict>
<key>1</key>

Просмотреть файл

@ -3718,7 +3718,7 @@
<key>name</key>
<string>meta.object.member.tsx</string>
<key>match</key>
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\})</string>
<string>([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)</string>
<key>captures</key>
<dict>
<key>1</key>

Просмотреть файл

@ -0,0 +1,142 @@
original file
-----------------------------------
const shellOptions: IOptions = {
filesToOpen,
filesToCreate,
filesToDiff
};
const a = {
filesToOpen: filesToOpen,
filesToCreate: filesToCreate,
filesToDiff: filesToDiff
}
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
> const shellOptions: IOptions = {
^^^^
source.ts
^^^^^
source.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.var.expr.ts
^^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts keyword.operator.type.annotation.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts entity.name.type.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.type.annotation.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts keyword.operator.assignment.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts punctuation.definition.block.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
> filesToOpen,
^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts punctuation.separator.comma.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
> filesToCreate,
^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
^^^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts punctuation.separator.comma.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
> filesToDiff
^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts variable.other.readwrite.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts
> };
^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts punctuation.definition.block.ts
^
source.ts punctuation.terminator.statement.ts
^^
source.ts
> const a = {
^^^^
source.ts
^^^^^
source.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.var.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts keyword.operator.assignment.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts punctuation.definition.block.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
> filesToOpen: filesToOpen,
^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts meta.object-literal.key.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts meta.object-literal.key.ts punctuation.separator.key-value.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts
^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts punctuation.separator.comma.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
> filesToCreate: filesToCreate,
^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
^^^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts meta.object-literal.key.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts meta.object-literal.key.ts punctuation.separator.key-value.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts
^^^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts variable.other.readwrite.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts punctuation.separator.comma.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
> filesToDiff: filesToDiff
^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts
^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts meta.object-literal.key.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts meta.object-literal.key.ts punctuation.separator.key-value.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts
^^^^^^^^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts variable.other.readwrite.ts
^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts
> }
^^^^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts meta.object.member.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.object-literal.ts punctuation.definition.block.ts

10
tests/cases/Issue292.ts Normal file
Просмотреть файл

@ -0,0 +1,10 @@
const shellOptions: IOptions = {
filesToOpen,
filesToCreate,
filesToDiff
};
const a = {
filesToOpen: filesToOpen,
filesToCreate: filesToCreate,
filesToDiff: filesToDiff
}