Handle multiline import declaration

Fixes #586
This commit is contained in:
Sheetal Nandi 2018-03-23 15:22:10 -07:00
Родитель 8610134389
Коммит f6c23eabdd
5 изменённых файлов: 97 добавлений и 0 удалений

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

@ -26,6 +26,7 @@ variables:
lookBehindOf: '^of|{{nonPropertyLookBehind}}of'
lookBehindTypeof: '^typeof|{{nonPropertyLookBehind}}typeof'
lookBehindCase: '^case|{{nonPropertyLookBehind}}case'
lookBehindImport: '^import|{{nonPropertyLookBehind}}import'
matchingParenthesis: (\(([^\(\)]|(\([^\(\)]*\)))*\))
matchingBraces: (\{([^\{\}]|(\{[^\{\}]*\}))*\})
matchingBrackets: (\[([^\[\]]|(\[[^\[\]]*\]))*\])
@ -865,6 +866,14 @@ repository:
'2': { name: keyword.control.import.ts }
end: (?=;|$|^)
patterns:
- include: '#comment'
- include: '#string'
- begin: (?<={{lookBehindImport}})(?!\s*["'])
end: \bfrom\b
endCaptures:
'0': { name: keyword.control.from.ts }
patterns:
- include: '#import-export-declaration'
- include: '#import-export-declaration'
export-declaration:

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

@ -2693,6 +2693,35 @@
<string>(?=;|$|^)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>begin</key>
<string>(?&lt;=^import|[^\._$[:alnum:]]import)(?!\s*["'])</string>
<key>end</key>
<string>\bfrom\b</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>keyword.control.from.ts</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#import-export-declaration</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#import-export-declaration</string>

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

@ -2697,6 +2697,35 @@
<string>(?=;|$|^)</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#string</string>
</dict>
<dict>
<key>begin</key>
<string>(?&lt;=^import|[^\._$[:alnum:]]import)(?!\s*["'])</string>
<key>end</key>
<string>\bfrom\b</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>keyword.control.from.tsx</string>
</dict>
</dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#import-export-declaration</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#import-export-declaration</string>

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

@ -0,0 +1,28 @@
original file
-----------------------------------
import a
from b;
-----------------------------------
Grammar: TypeScript.tmLanguage
-----------------------------------
>import a
^^^^^^
source.ts meta.import.ts keyword.control.import.ts
^
source.ts meta.import.ts
^
source.ts meta.import.ts variable.other.readwrite.alias.ts
^^
source.ts meta.import.ts
> from b;
^^^^
source.ts meta.import.ts
^^^^
source.ts meta.import.ts keyword.control.from.ts
^
source.ts meta.import.ts
^
source.ts meta.import.ts variable.other.readwrite.alias.ts
^
source.ts punctuation.terminator.statement.ts

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

@ -0,0 +1,2 @@
import a
from b;