@@ -11,6 +11,17 @@ var __extends = (this && this.__extends) || (function () {
1111 d . prototype = b === null ? Object . create ( b ) : ( __ . prototype = b . prototype , new __ ( ) ) ;
1212 } ;
1313} ) ( ) ;
14+ var __assign = ( this && this . __assign ) || function ( ) {
15+ __assign = Object . assign || function ( t ) {
16+ for ( var s , i = 1 , n = arguments . length ; i < n ; i ++ ) {
17+ s = arguments [ i ] ;
18+ for ( var p in s ) if ( Object . prototype . hasOwnProperty . call ( s , p ) )
19+ t [ p ] = s [ p ] ;
20+ }
21+ return t ;
22+ } ;
23+ return __assign . apply ( this , arguments ) ;
24+ } ;
1425var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
1526 return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
1627 function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
@@ -46,14 +57,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
4657 if ( op [ 0 ] & 5 ) throw op [ 1 ] ; return { value : op [ 0 ] ? op [ 1 ] : void 0 , done : true } ;
4758 }
4859} ;
49- define ( [ "require" , "exports" ] , function ( require , exports ) {
60+ define ( [ "require" , "exports" , "./lib/emmet/expand/languageserver-types" ] , function ( require , exports , ls ) {
5061 /*---------------------------------------------------------------------------------------------
5162 * Copyright (c) Microsoft Corporation. All rights reserved.
5263 * Licensed under the MIT License. See License.txt in the project root for license information.
5364 *--------------------------------------------------------------------------------------------*/
5465 'use strict' ;
5566 Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
5667 var Uri = monaco . Uri ;
68+ var Range = monaco . Range ;
5769 // @ts -ignore
5870 var Promise = monaco . Promise ;
5971 //#region utils copied from typescript to prevent loading the entire typescriptServices ---
@@ -63,6 +75,41 @@ define(["require", "exports"], function (require, exports) {
6375 IndentStyle [ IndentStyle [ "Block" ] = 1 ] = "Block" ;
6476 IndentStyle [ IndentStyle [ "Smart" ] = 2 ] = "Smart" ;
6577 } ) ( IndentStyle || ( IndentStyle = { } ) ) ;
78+ var Priority ;
79+ ( function ( Priority ) {
80+ Priority [ Priority [ "Emmet" ] = 0 ] = "Emmet" ;
81+ Priority [ Priority [ "Platform" ] = 1 ] = "Platform" ;
82+ } ) ( Priority = exports . Priority || ( exports . Priority = { } ) ) ;
83+ function toCompletionItemKind ( kind ) {
84+ var mItemKind = monaco . languages . CompletionItemKind ;
85+ switch ( kind ) {
86+ case ls . CompletionItemKind . Text : return mItemKind . Text ;
87+ case ls . CompletionItemKind . Method : return mItemKind . Method ;
88+ case ls . CompletionItemKind . Function : return mItemKind . Function ;
89+ case ls . CompletionItemKind . Constructor : return mItemKind . Constructor ;
90+ case ls . CompletionItemKind . Field : return mItemKind . Field ;
91+ case ls . CompletionItemKind . Variable : return mItemKind . Variable ;
92+ case ls . CompletionItemKind . Class : return mItemKind . Class ;
93+ case ls . CompletionItemKind . Interface : return mItemKind . Interface ;
94+ case ls . CompletionItemKind . Module : return mItemKind . Module ;
95+ case ls . CompletionItemKind . Property : return mItemKind . Property ;
96+ case ls . CompletionItemKind . Unit : return mItemKind . Unit ;
97+ case ls . CompletionItemKind . Value : return mItemKind . Value ;
98+ case ls . CompletionItemKind . Enum : return mItemKind . Enum ;
99+ case ls . CompletionItemKind . Keyword : return mItemKind . Keyword ;
100+ case ls . CompletionItemKind . Snippet : return mItemKind . Snippet ;
101+ case ls . CompletionItemKind . Color : return mItemKind . Color ;
102+ case ls . CompletionItemKind . File : return mItemKind . File ;
103+ case ls . CompletionItemKind . Reference : return mItemKind . Reference ;
104+ }
105+ return mItemKind . Property ;
106+ }
107+ function toRange ( range ) {
108+ if ( ! range ) {
109+ return void 0 ;
110+ }
111+ return new Range ( range . start . line + 1 , range . start . character + 1 , range . end . line + 1 , range . end . character + 1 ) ;
112+ }
66113 function flattenDiagnosticMessageText ( messageText , newLine ) {
67114 if ( typeof messageText === 'string' ) {
68115 return messageText ;
@@ -225,14 +272,15 @@ define(["require", "exports"], function (require, exports) {
225272 return DiagnostcsAdapter ;
226273 } ( Adapter ) ) ;
227274 exports . DiagnostcsAdapter = DiagnostcsAdapter ;
275+ var emmetTriggerCharacters = [ '!' , '.' , '}' , ':' , '*' , '$' , ']' , '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' ] ;
228276 var SuggestAdapter = /** @class */ ( function ( _super ) {
229277 __extends ( SuggestAdapter , _super ) ;
230278 function SuggestAdapter ( ) {
231279 return _super !== null && _super . apply ( this , arguments ) || this ;
232280 }
233281 Object . defineProperty ( SuggestAdapter . prototype , "triggerCharacters" , {
234282 get : function ( ) {
235- return [ '.' ] ;
283+ return emmetTriggerCharacters . concat ( [ '.' ] ) ;
236284 } ,
237285 enumerable : true ,
238286 configurable : true
@@ -249,16 +297,47 @@ define(["require", "exports"], function (require, exports) {
249297 if ( ! info ) {
250298 return ;
251299 }
252- var suggestions = info . entries . map ( function ( entry ) {
253- return {
300+ var emmetItems = info . emmetCompletions ? info . emmetCompletions . items . map ( function ( i ) {
301+ var entry = __assign ( { } , i , { sortText : Priority . Emmet + i . label } ) ;
302+ var item = {
303+ label : entry . label ,
304+ insertText : entry . insertText ,
305+ sortText : entry . sortText ,
306+ filterText : entry . filterText ,
307+ documentation : entry . documentation ,
308+ detail : entry . detail ,
254309 uri : resource ,
255310 position : position ,
256- label : entry . name ,
257- sortText : entry . sortText ,
258- kind : SuggestAdapter . convertKind ( entry . kind ) ,
311+ kind : toCompletionItemKind ( entry . kind ) ,
259312 } ;
260- } ) ;
261- return suggestions ;
313+ if ( entry . textEdit ) {
314+ item . range = toRange ( entry . textEdit . range ) ;
315+ item . insertText = entry . textEdit . newText ;
316+ }
317+ if ( entry . insertTextFormat === ls . InsertTextFormat . Snippet ) {
318+ item . insertText = { value : item . insertText } ;
319+ }
320+ return item ;
321+ } ) : [ ] ;
322+ var suggestions ;
323+ if ( info . languageCompletions ) {
324+ suggestions = info . languageCompletions . entries . map ( function ( entry ) {
325+ return {
326+ uri : resource ,
327+ position : position ,
328+ label : entry . name ,
329+ sortText : entry . sortText ,
330+ kind : SuggestAdapter . convertKind ( entry . kind ) ,
331+ } ;
332+ } ) ;
333+ }
334+ else {
335+ suggestions = [ ] ;
336+ }
337+ return {
338+ isIncomplete : emmetItems . length !== 0 ,
339+ items : emmetItems . concat ( suggestions )
340+ } ;
262341 } ) ) ;
263342 } ;
264343 SuggestAdapter . prototype . resolveCompletionItem = function ( item , token ) {
0 commit comments